diff options
Diffstat (limited to 'src')
173 files changed, 2619 insertions, 3022 deletions
diff --git a/src/libs/qtcreatorcdbext/symbolgroupnode.cpp b/src/libs/qtcreatorcdbext/symbolgroupnode.cpp index f5f6edad87..631c53e2b7 100644 --- a/src/libs/qtcreatorcdbext/symbolgroupnode.cpp +++ b/src/libs/qtcreatorcdbext/symbolgroupnode.cpp @@ -762,6 +762,14 @@ static void fixValue(const std::string &type, std::wstring *value) } } + // Strip a vtable "0x13f37b7c8 module!Class::`vftable'" to a plain pointer. + if (SymbolGroupValue::isVTableType(type)) { + const std::wstring::size_type blankPos = value->find(L' ', 2); + if (blankPos != std::wstring::npos) + value->erase(blankPos, value->size() - blankPos); + return; + } + // Pointers: fix '0x00000000`00000AD class bla' ... to "0xAD", but leave // 'const char *' values as is ('0x00000000`00000AD "hallo"). if (!type.empty() && type.at(type.size() - 1) == L'*') { diff --git a/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp b/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp index 86f5386d84..8df9f90020 100644 --- a/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp +++ b/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp @@ -417,6 +417,13 @@ unsigned SymbolGroupValue::isPointerType(const std::string &t) return 0; } +// Return number of characters to strip for pointer type +bool SymbolGroupValue::isVTableType(const std::string &t) +{ + const char vtableTypeC[] = "__fptr()"; + return t.compare(0, sizeof(vtableTypeC) - 1, vtableTypeC) == 0; +} + // add pointer type 'Foo' -> 'Foo *', 'Foo *' -> 'Foo **' std::string SymbolGroupValue::pointerType(const std::string &type) { diff --git a/src/libs/qtcreatorcdbext/symbolgroupvalue.h b/src/libs/qtcreatorcdbext/symbolgroupvalue.h index d31ff7f81f..7e8c433ed1 100644 --- a/src/libs/qtcreatorcdbext/symbolgroupvalue.h +++ b/src/libs/qtcreatorcdbext/symbolgroupvalue.h @@ -113,6 +113,7 @@ public: static std::string moduleOfType(const std::string &type); // pointer type, return number of characters to strip static unsigned isPointerType(const std::string &); + static bool isVTableType(const std::string &t); // add pointer type 'Foo' -> 'Foo *', 'Foo *' -> 'Foo **' static std::string pointerType(const std::string &type); // Symbol Name/(Expression) of a pointed-to instance ('Foo' at 0x10') ==> '*(Foo *)0x10' diff --git a/src/libs/utils/fancymainwindow.cpp b/src/libs/utils/fancymainwindow.cpp index 641f9d649c..d4b31f46bd 100644 --- a/src/libs/utils/fancymainwindow.cpp +++ b/src/libs/utils/fancymainwindow.cpp @@ -32,6 +32,8 @@ #include "fancymainwindow.h" +#include "qtcassert.h" + #include <QtCore/QList> #include <QtCore/QHash> @@ -265,17 +267,28 @@ bool FancyMainWindow::isLocked() const return d->m_locked; } +static bool actionLessThan(const QAction *action1, const QAction *action2) +{ + QTC_ASSERT(action1, return true); + QTC_ASSERT(action2, return false); + return action1->text().toLower() < action2->text().toLower(); +} + QMenu *FancyMainWindow::createPopupMenu() { - QMenu *menu = new QMenu(this);; + QList<QAction *> actions; QList<QDockWidget *> dockwidgets = qFindChildren<QDockWidget *>(this); for (int i = 0; i < dockwidgets.size(); ++i) { QDockWidget *dockWidget = dockwidgets.at(i); if (dockWidget->property("managed_dockwidget").isNull() && dockWidget->parentWidget() == this) { - menu->addAction(dockwidgets.at(i)->toggleViewAction()); + actions.append(dockwidgets.at(i)->toggleViewAction()); } } + qSort(actions.begin(), actions.end(), actionLessThan); + QMenu *menu = new QMenu(this); + foreach (QAction *action, actions) + menu->addAction(action); menu->addAction(&d->m_menuSeparator1); menu->addAction(&d->m_toggleLockedAction); menu->addAction(&d->m_menuSeparator2); diff --git a/src/libs/utils/synchronousprocess.cpp b/src/libs/utils/synchronousprocess.cpp index 82a5757886..c7768a6c6f 100644 --- a/src/libs/utils/synchronousprocess.cpp +++ b/src/libs/utils/synchronousprocess.cpp @@ -130,17 +130,17 @@ QString SynchronousProcessResponse::exitMessage(const QString &binary, int timeo { switch (result) { case Finished: - return SynchronousProcess::tr("The command '%1' finished successfully.").arg(binary); + return SynchronousProcess::tr("The command '%1' finished successfully.").arg(QDir::toNativeSeparators(binary)); case FinishedError: - return SynchronousProcess::tr("The command '%1' terminated with exit code %2.").arg(binary).arg(exitCode); + return SynchronousProcess::tr("The command '%1' terminated with exit code %2.").arg(QDir::toNativeSeparators(binary)).arg(exitCode); break; case TerminatedAbnormally: - return SynchronousProcess::tr("The command '%1' terminated abnormally.").arg(binary); + return SynchronousProcess::tr("The command '%1' terminated abnormally.").arg(QDir::toNativeSeparators(binary)); case StartFailed: - return SynchronousProcess::tr("The command '%1' could not be started.").arg(binary); + return SynchronousProcess::tr("The command '%1' could not be started.").arg(QDir::toNativeSeparators(binary)); case Hang: return SynchronousProcess::tr("The command '%1' did not respond within the timeout limit (%2 ms)."). - arg(binary).arg(timeoutMS); + arg(QDir::toNativeSeparators(binary)).arg(timeoutMS); } return QString(); } diff --git a/src/libs/utils/welcomemodetreewidget.cpp b/src/libs/utils/welcomemodetreewidget.cpp deleted file mode 100644 index ee826d9c50..0000000000 --- a/src/libs/utils/welcomemodetreewidget.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "welcomemodetreewidget.h" - -#include <QtGui/QLabel> -#include <QtGui/QPixmap> -#include <QtGui/QAction> -#include <QtGui/QVBoxLayout> -#include <QtGui/QMouseEvent> -#include <QtGui/QResizeEvent> -#include <QtGui/QImage> - -enum { leftContentsMargin = 2, - topContentsMargin = 2, - bottomContentsMargin = 1, - pixmapWidth = 24 }; - -/*! - \class Utils::WelcomeModeLabel - \brief Label usable for headers of a Welcome page. -*/ - -namespace Utils { - -WelcomeModeLabel::WelcomeModeLabel(QWidget *parent) : - QLabel(parent), m_unused(0) -{ - // Bold/enlarged font slightly gray. Force color on by stylesheet as it is used - // as a child of widgets that have stylesheets. - QFont f = font(); -#ifndef Q_OS_WIN - f.setWeight(QFont::DemiBold); -#endif - f.setPointSizeF(f.pointSizeF() * 1.2); - setFont(f); - setStyleSheet(QLatin1String("color : rgb(85, 85, 85);")); - setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); -} - -WelcomeModeLabel::~WelcomeModeLabel() -{ -} - -// NewsLabel for the WelcomeModeTreeWidget: -// Shows a news article as "Bold Title!\nElided Start of article...." -// Adapts the eliding when resizing. -class NewsLabel : public QLabel { -public: - explicit NewsLabel(const QString &htmlTitle, - const QString &htmlText, - QWidget *parent = 0); - - virtual void resizeEvent(QResizeEvent *); - -private: - const QString m_title; - const QString m_text; - const int m_minWidth; - - int m_lastWidth; - int m_contentsMargin; -}; - -NewsLabel::NewsLabel(const QString &htmlTitle, - const QString &htmlText, - QWidget *parent) : - QLabel(parent), - m_title(htmlTitle), - m_text(htmlText), - m_minWidth(100), - m_lastWidth(-1) -{ - int dummy, left, right; - getContentsMargins(&left, &dummy, &right, &dummy); - m_contentsMargin = left + right; -} - -void NewsLabel::resizeEvent(QResizeEvent *e) -{ - enum { epsilon = 10 }; - QLabel::resizeEvent(e); - // Resized: Adapt to new size (if it is > m_minWidth) - const int newWidth = qMax(e->size().width() - m_contentsMargin, m_minWidth) - epsilon; - if (newWidth == m_lastWidth) - return; - m_lastWidth = newWidth; - QFont f = font(); - const QString elidedText = QFontMetrics(f).elidedText(m_text, Qt::ElideRight, newWidth); - f.setBold(true); - const QString elidedTitle = QFontMetrics(f).elidedText(m_title, Qt::ElideRight, newWidth); - QString labelText = QLatin1String("<b>"); - labelText += elidedTitle; - labelText += QLatin1String("</b><br /><font color='gray'>"); - labelText += elidedText; - labelText += QLatin1String("</font>"); - setText(labelText); -} - -// Item label of WelcomeModeTreeWidget: Horizontal widget consisting -// of arrow and clickable label. -class WelcomeModeItemWidget : public QWidget { - Q_OBJECT -public: - // Normal items - explicit WelcomeModeItemWidget(const QPixmap &pix, - const QString &text, - const QString &tooltip, - const QString &data, - QWidget *parent = 0); - // News items with title and start of article (see NewsLabel) - explicit WelcomeModeItemWidget(const QPixmap &pix, - QString htmlTitle, - QString htmlText, - const QString &tooltip, - const QString &data, - QWidget *parent = 0); - -signals: - void clicked(const QString &); - -protected: - virtual void mousePressEvent(QMouseEvent *); - -private: - static inline void initLabel(QLabel *); - - void init(const QPixmap &pix, QLabel *itemLabel, const QString &tooltip); - - const QString m_data; -}; - -WelcomeModeItemWidget::WelcomeModeItemWidget(const QPixmap &pix, - const QString &text, - const QString &tooltipText, - const QString &data, - QWidget *parent) : - QWidget(parent), - m_data(data) -{ - QLabel *label = new QLabel(text); - WelcomeModeItemWidget::initLabel(label); - init(pix, label, tooltipText); -} - -static inline void fixHtml(QString &s) -{ - s.replace(QLatin1String("’"), QString(QLatin1Char('\''))); // Quote - s.replace(QLatin1Char('\n'), QLatin1Char(' ')); -} - -WelcomeModeItemWidget::WelcomeModeItemWidget(const QPixmap &pix, - QString title, - QString text, - const QString &tooltipText, - const QString &data, - QWidget *parent) : - QWidget(parent), - m_data(data) -{ - fixHtml(text); - fixHtml(title); - QLabel *newsLabel = new NewsLabel(title, text); - WelcomeModeItemWidget::initLabel(newsLabel); - init(pix, newsLabel, tooltipText); -} - -void WelcomeModeItemWidget::initLabel(QLabel *label) -{ - label->setTextInteractionFlags(Qt::NoTextInteraction); - label->setCursor(QCursor(Qt::PointingHandCursor)); -} - -void WelcomeModeItemWidget::init(const QPixmap &pix, QLabel *itemLabel, - const QString &tooltipText) -{ - QHBoxLayout *hBoxLayout = new QHBoxLayout; - hBoxLayout->setContentsMargins(topContentsMargin, leftContentsMargin, - 0, bottomContentsMargin); - - QLabel *pxLabel = new QLabel; - QPixmap pixmap = pix; - if (layoutDirection() == Qt::RightToLeft){ - QImage image = pixmap.toImage(); - pixmap = QPixmap::fromImage(image.mirrored(1, 0)); - } - pxLabel->setPixmap(pixmap); - - pxLabel->setFixedWidth(pixmapWidth); - hBoxLayout->addWidget(pxLabel); - - hBoxLayout->addWidget(itemLabel); - if (!tooltipText.isEmpty()) { - setToolTip(tooltipText); - pxLabel->setToolTip(tooltipText); - itemLabel->setToolTip(tooltipText); - } - setLayout(hBoxLayout); -} - -void WelcomeModeItemWidget::mousePressEvent(QMouseEvent *e) -{ - e->accept(); - emit clicked(m_data); -} - -// ----------------- WelcomeModeTreeWidget -struct WelcomeModeTreeWidgetPrivate -{ - WelcomeModeTreeWidgetPrivate(); - - const QPixmap bullet; - QVBoxLayout *layout; - QVBoxLayout *itemLayout; -}; - -WelcomeModeTreeWidgetPrivate::WelcomeModeTreeWidgetPrivate() : - bullet(QLatin1String(":/welcome/images/list_bullet_arrow.png")), - layout(new QVBoxLayout), - itemLayout(new QVBoxLayout) -{ - layout->setMargin(0); -} - -/*! - \class Utils::WelcomeModeTreeWidget - \brief Show an itemized list with arrows and emits a signal on click. -*/ - -WelcomeModeTreeWidget::WelcomeModeTreeWidget(QWidget *parent) : - QWidget(parent), m_d(new WelcomeModeTreeWidgetPrivate) -{ - setLayout(m_d->layout); - m_d->layout->addLayout(m_d->itemLayout); - m_d->layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); -} - -WelcomeModeTreeWidget::~WelcomeModeTreeWidget() -{ - delete m_d; -} - -void WelcomeModeTreeWidget::addItem(const QString &label, const QString &data, const QString &toolTip) -{ - addItemWidget(new WelcomeModeItemWidget(m_d->bullet, label, toolTip, data)); -} - -void WelcomeModeTreeWidget::addNewsItem(const QString &title, - const QString &description, - const QString &link) -{ - addItemWidget(new WelcomeModeItemWidget(m_d->bullet, title, description, link, link)); -} - -void WelcomeModeTreeWidget::addItemWidget(WelcomeModeItemWidget *w) -{ - connect(w, SIGNAL(clicked(QString)), this, SIGNAL(activated(QString))); - m_d->itemLayout->addWidget(w); -} - -void WelcomeModeTreeWidget::clear() -{ - for (int i = m_d->itemLayout->count() - 1; i >= 0; i--) { - QLayoutItem *item = m_d->itemLayout->takeAt(i); - delete item->widget(); - delete item; - } -} - -} // namespace Utils - -#include "welcomemodetreewidget.moc" diff --git a/src/libs/utils/welcomemodetreewidget.h b/src/libs/utils/welcomemodetreewidget.h deleted file mode 100644 index 101e8326c9..0000000000 --- a/src/libs/utils/welcomemodetreewidget.h +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef WELCOMEMODETREEWIDGET_H -#define WELCOMEMODETREEWIDGET_H - -#include "utils_global.h" - -#include <QtGui/QTreeWidget> -#include <QtGui/QLabel> - -namespace Utils { - -struct WelcomeModeTreeWidgetPrivate; -class WelcomeModeItemWidget; - -class QTCREATOR_UTILS_EXPORT WelcomeModeLabel : public QLabel -{ - Q_OBJECT -public: - explicit WelcomeModeLabel(QWidget *parent = 0); - virtual ~WelcomeModeLabel(); - -private: - void *m_unused; -}; - -class QTCREATOR_UTILS_EXPORT WelcomeModeTreeWidget : public QWidget -{ - Q_OBJECT -public: - explicit WelcomeModeTreeWidget(QWidget *parent = 0); - virtual ~WelcomeModeTreeWidget(); - -public slots: - void addItem(const QString &label, const QString &data,const QString &toolTip = QString()); - - // Add a 'News' item as two lines of "<bold>Breaking news!</bold>\nElided Start of article...." - void addNewsItem(const QString &title, const QString &description, const QString &link); - void clear(); - -signals: - void activated(const QString &data); - -private: - void addItemWidget(WelcomeModeItemWidget *w); - - WelcomeModeTreeWidgetPrivate *m_d; -}; - -} // namespace Utils -#endif // WELCOMEMODETREEWIDGET_H diff --git a/src/plugins/analyzerbase/analyzerconstants.h b/src/plugins/analyzerbase/analyzerconstants.h index 23f15e7b80..c22b5a5e06 100644 --- a/src/plugins/analyzerbase/analyzerconstants.h +++ b/src/plugins/analyzerbase/analyzerconstants.h @@ -39,7 +39,7 @@ namespace Analyzer { -// Special values for currently used modes. +// Special values for currently used start modes. // Their meaning is interpreted by the individual tools. // FIXME: The plan is to remove this entirely from the // public interface and let the tools handle that internally. @@ -53,38 +53,28 @@ enum StartMode namespace Constants { -// modes and their priorities -const char * const MODE_ANALYZE = "Mode.Analyze"; -const int P_MODE_ANALYZE = 76; +// Mode and its priority. +const char MODE_ANALYZE[] = "Mode.Analyze"; +const int P_MODE_ANALYZE = 76; -// context -const char * const C_ANALYZEMODE = "Analyzer.AnalyzeMode"; +// Context. +const char C_ANALYZEMODE[] = "Analyzer.AnalyzeMode"; -// menu -const char * const M_DEBUG_ANALYZER = "Analyzer.Menu.StartAnalyzer"; +// Menu. +const char M_DEBUG_ANALYZER[] = "Analyzer.Menu.StartAnalyzer"; -const char * const START = "Analyzer.Start"; -const char * const STARTREMOTE = "Analyzer.StartRemote"; -const char * const STOP = "Analyzer.Stop"; +const char START[] = "Analyzer.Start"; +const char STOP[] = "Analyzer.Stop"; -const char * const G_ANALYZER_CONTROL = "Menu.Group.Analyzer.Control"; -const char * const G_ANALYZER_TOOLS = "Menu.Group.Analyzer.Tools"; -const char * const G_ANALYZER_REMOTE_TOOLS = "Menu.Group.Analyzer.RemoteTools"; +const char G_ANALYZER_CONTROL[] = "Menu.Group.Analyzer.Control"; +const char G_ANALYZER_TOOLS[] = "Menu.Group.Analyzer.Tools"; +const char G_ANALYZER_REMOTE_TOOLS[] = "Menu.Group.Analyzer.RemoteTools"; -// options dialog -const char * const ANALYZER_SETTINGS_CATEGORY = "T.Analyzer"; -const char * const ANALYZER_SETTINGS_TR_CATEGORY = - QT_TRANSLATE_NOOP("Analyzer", "Analyzer"); -const char * const ANALYZER_SETTINGS_CATEGORY_ICON = - ":/images/analyzer_category.png"; +// Manager controls. +const char ANALYZER_CONTROL_START_ICON[] = ":/images/analyzer_start_small.png"; +const char ANALYZER_CONTROL_STOP_ICON[] = ":/debugger/images/debugger_stop_small.png"; -// manager controls -const char * const ANALYZER_CONTROL_START_ICON = - ":/images/analyzer_start_small.png"; -const char * const ANALYZER_CONTROL_STOP_ICON = - ":/debugger/images/debugger_stop_small.png"; - -const char * const ANALYZERTASK_ID = "Analyzer.TaskId"; +const char ANALYZERTASK_ID[] = "Analyzer.TaskId"; } // namespace Constants } // namespace Analyzer diff --git a/src/plugins/analyzerbase/analyzermanager.cpp b/src/plugins/analyzerbase/analyzermanager.cpp index cdf4e5d167..773a09a9a5 100644 --- a/src/plugins/analyzerbase/analyzermanager.cpp +++ b/src/plugins/analyzerbase/analyzermanager.cpp @@ -328,6 +328,28 @@ void AnalyzerManagerPrivate::delayedInit() m_mode->setWidget(splitter); AnalyzerPlugin::instance()->addAutoReleasedObject(m_mode); + + // Populate Windows->Views menu with standard actions. + Core::Context analyzerContext(Constants::C_ANALYZEMODE); + ActionManager *am = ICore::instance()->actionManager(); + ActionContainer *viewsMenu = + am->actionContainer(Core::Id(Core::Constants::M_WINDOW_VIEWS)); + Command *cmd = am->registerAction(m_mainWindow->menuSeparator1(), + Core::Id("Analyzer.Views.Separator1"), analyzerContext); + cmd->setAttribute(Command::CA_Hide); + viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE); + cmd = am->registerAction(m_mainWindow->toggleLockedAction(), + Core::Id("Analyzer.Views.ToggleLocked"), analyzerContext); + cmd->setAttribute(Command::CA_Hide); + viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE); + cmd = am->registerAction(m_mainWindow->menuSeparator2(), + Core::Id("Analyzer.Views.Separator2"), analyzerContext); + cmd->setAttribute(Command::CA_Hide); + viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE); + cmd = am->registerAction(m_mainWindow->resetLayoutAction(), + Core::Id("Analyzer.Views.ResetSimple"), analyzerContext); + cmd->setAttribute(Command::CA_Hide); + viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE); } static QToolButton *toolButton(QAction *action) @@ -594,9 +616,15 @@ void AnalyzerManagerPrivate::selectSavedTool() StartMode mode = m_modeFromAction.value(action); if (tool->actionId(mode) == lastActiveAction) { selectTool(tool, mode); - break; + return; } } + // fallback to first available tool + if (!m_actions.isEmpty()) { + IAnalyzerTool *tool = m_toolFromAction.value(m_actions.first()); + StartMode mode = m_modeFromAction.value(m_actions.first()); + selectTool(tool, mode); + } } void AnalyzerManagerPrivate::selectMenuAction() @@ -705,6 +733,8 @@ void AnalyzerManagerPrivate::loadToolSettings(IAnalyzerTool *tool) settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + tool->id()); if (settings->value("ToolSettingsSaved", false).toBool()) m_mainWindow->restoreSettings(settings); + else + m_mainWindow->restoreSettings(m_defaultSettings.value(tool)); settings->endGroup(); } @@ -724,13 +754,6 @@ void AnalyzerManagerPrivate::saveToolSettings(IAnalyzerTool *tool, StartMode mod void AnalyzerManagerPrivate::updateRunActions() { - static bool previousRunning = true; - static IAnalyzerTool *previousTool = 0; - if (previousRunning == m_isRunning && previousTool == m_currentTool) - return; - previousTool = m_currentTool; - previousRunning = m_isRunning; - ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); Project *project = pe->startupProject(); @@ -775,16 +798,16 @@ AnalyzerManager::~AnalyzerManager() void AnalyzerManager::extensionsInitialized() { - if (d->m_tools.isEmpty()) + if (m_instance->d->m_tools.isEmpty()) return; - foreach (IAnalyzerTool *tool, d->m_tools) + foreach (IAnalyzerTool *tool, m_instance->d->m_tools) tool->extensionsInitialized(); } void AnalyzerManager::shutdown() { - d->saveToolSettings(d->m_currentTool, d->m_currentMode); + m_instance->d->saveToolSettings(m_instance->d->m_currentTool, m_instance->d->m_currentMode); } void AnalyzerManager::addTool(IAnalyzerTool *tool, const StartModes &modes) diff --git a/src/plugins/analyzerbase/analyzermanager.h b/src/plugins/analyzerbase/analyzermanager.h index 42700cac90..9db4e12238 100644 --- a/src/plugins/analyzerbase/analyzermanager.h +++ b/src/plugins/analyzerbase/analyzermanager.h @@ -56,16 +56,18 @@ typedef QList<StartMode> StartModes; class IAnalyzerTool; class AnalyzerManagerPrivate; + +// FIXME: Merge with AnalyzerPlugin. class ANALYZER_EXPORT AnalyzerManager : public QObject { Q_OBJECT public: - explicit AnalyzerManager(QObject *parent = 0); + explicit AnalyzerManager(QObject *parent); ~AnalyzerManager(); - void extensionsInitialized(); - void shutdown(); + static void extensionsInitialized(); + static void shutdown(); // Register a tool and initialize it. static void addTool(IAnalyzerTool *tool, const StartModes &mode); diff --git a/src/plugins/analyzerbase/analyzeroptionspage.cpp b/src/plugins/analyzerbase/analyzeroptionspage.cpp index f4c5b1498d..e853f174e3 100644 --- a/src/plugins/analyzerbase/analyzeroptionspage.cpp +++ b/src/plugins/analyzerbase/analyzeroptionspage.cpp @@ -67,17 +67,17 @@ QString AnalyzerOptionsPage::displayName() const QString AnalyzerOptionsPage::category() const { - return QLatin1String(Constants::ANALYZER_SETTINGS_CATEGORY); + return QLatin1String("T.Analyzer"); } QString AnalyzerOptionsPage::displayCategory() const { - return QCoreApplication::translate("Analyzer", Constants::ANALYZER_SETTINGS_TR_CATEGORY); + return QCoreApplication::translate("Analyzer", "Analyzer"); } QIcon AnalyzerOptionsPage::categoryIcon() const { - return QIcon(QLatin1String(Constants::ANALYZER_SETTINGS_CATEGORY_ICON)); + return QIcon(QLatin1String(":/images/analyzer_category.png")); } QWidget *AnalyzerOptionsPage::createPage(QWidget *parent) diff --git a/src/plugins/analyzerbase/analyzerplugin.cpp b/src/plugins/analyzerbase/analyzerplugin.cpp index e914130f0d..134b5ca521 100644 --- a/src/plugins/analyzerbase/analyzerplugin.cpp +++ b/src/plugins/analyzerbase/analyzerplugin.cpp @@ -56,25 +56,6 @@ using namespace Analyzer::Internal; static AnalyzerPlugin *m_instance = 0; - -//////////////////////////////////////////////////////////////////////// -// -// AnalyzerPluginPrivate -// -//////////////////////////////////////////////////////////////////////// - -class AnalyzerPlugin::AnalyzerPluginPrivate -{ -public: - AnalyzerPluginPrivate(AnalyzerPlugin *qq): - q(qq), - m_manager(0) - {} - - AnalyzerPlugin *q; - AnalyzerManager *m_manager; -}; - //////////////////////////////////////////////////////////////////////// // // AnalyzerPlugin @@ -82,14 +63,12 @@ public: //////////////////////////////////////////////////////////////////////// AnalyzerPlugin::AnalyzerPlugin() - : d(new AnalyzerPluginPrivate(this)) { m_instance = this; } AnalyzerPlugin::~AnalyzerPlugin() { - delete d; m_instance = 0; } @@ -98,7 +77,7 @@ bool AnalyzerPlugin::initialize(const QStringList &arguments, QString *errorStri Q_UNUSED(arguments) Q_UNUSED(errorString) - d->m_manager = new AnalyzerManager(this); + (void) new AnalyzerManager(this); // Task integration. ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); @@ -111,12 +90,12 @@ bool AnalyzerPlugin::initialize(const QStringList &arguments, QString *errorStri void AnalyzerPlugin::extensionsInitialized() { - d->m_manager->extensionsInitialized(); + AnalyzerManager::extensionsInitialized(); } ExtensionSystem::IPlugin::ShutdownFlag AnalyzerPlugin::aboutToShutdown() { - d->m_manager->shutdown(); + AnalyzerManager::shutdown(); return SynchronousShutdown; } diff --git a/src/plugins/analyzerbase/analyzerplugin.h b/src/plugins/analyzerbase/analyzerplugin.h index dc187de686..00bb32eb5b 100644 --- a/src/plugins/analyzerbase/analyzerplugin.h +++ b/src/plugins/analyzerbase/analyzerplugin.h @@ -54,10 +54,6 @@ public: void extensionsInitialized(); ShutdownFlag aboutToShutdown(); - -private: - class AnalyzerPluginPrivate; - AnalyzerPluginPrivate *d; }; } // namespace Internal diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp index 20913b12b5..c816a16ce1 100644 --- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp @@ -255,7 +255,7 @@ ShadowBuildPage::ShadowBuildPage(CMakeOpenProjectWizard *cmakeWizard, bool chang "Qt Creator recommends to not use the source directory for building. " "This ensures that the source directory remains clean and enables multiple builds " "with different settings.")); - fl->addWidget(label); + fl->addRow(label); m_pc = new Utils::PathChooser(this); m_pc->setBaseDirectory(m_cmakeWizard->sourceDirectory()); m_pc->setPath(m_cmakeWizard->buildDirectory()); @@ -282,6 +282,7 @@ CMakeRunPage::CMakeRunPage(CMakeOpenProjectWizard *cmakeWizard, Mode mode, const void CMakeRunPage::initWidgets() { QFormLayout *fl = new QFormLayout; + fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); setLayout(fl); // Description Label m_descriptionLabel = new QLabel(this); @@ -304,33 +305,38 @@ void CMakeRunPage::initWidgets() text += tr(" The path %1 is not a valid cmake.").arg(cmakeExecutable); } - fl->addRow(new QLabel(text, this)); + QLabel *cmakeLabel = new QLabel(text); + cmakeLabel->setWordWrap(true); + fl->addRow(cmakeLabel); // Show a field for the user to enter m_cmakeExecutable = new Utils::PathChooser(this); m_cmakeExecutable->setExpectedKind(Utils::PathChooser::ExistingCommand); - fl->addRow("cmake Executable", m_cmakeExecutable); + fl->addRow("cmake Executable:", m_cmakeExecutable); } // Run CMake Line (with arguments) m_argumentsLineEdit = new QLineEdit(this); connect(m_argumentsLineEdit,SIGNAL(returnPressed()), this, SLOT(runCMake())); + fl->addRow(tr("Arguments:"), m_argumentsLineEdit); m_generatorComboBox = new QComboBox(this); + fl->addRow(tr("Generator:"), m_generatorComboBox); m_runCMake = new QPushButton(this); m_runCMake->setText(tr("Run CMake")); connect(m_runCMake, SIGNAL(clicked()), this, SLOT(runCMake())); - QHBoxLayout *hbox = new QHBoxLayout; - hbox->addWidget(m_argumentsLineEdit); - hbox->addWidget(m_generatorComboBox); - hbox->addWidget(m_runCMake); - - fl->addRow(tr("Arguments"), hbox); + QHBoxLayout *hbox2 = new QHBoxLayout; + hbox2->addStretch(10); + hbox2->addWidget(m_runCMake); + fl->addRow(hbox2); // Bottom output window m_output = new QPlainTextEdit(this); m_output->setReadOnly(true); + // set smaller minimum size to avoid vanishing descriptions if all of the + // above is shown and the dialog not vertically resizing to fit stuff in (Mac) + m_output->setMinimumHeight(15); QFont f(TextEditor::FontSettings::defaultFixedFontFamily()); f.setStyleHint(QFont::TypeWriter); m_output->setFont(f); diff --git a/src/plugins/cpaster/pastebindotcomprotocol.cpp b/src/plugins/cpaster/pastebindotcomprotocol.cpp index 57fb4a1a8c..eea681dc46 100644 --- a/src/plugins/cpaster/pastebindotcomprotocol.cpp +++ b/src/plugins/cpaster/pastebindotcomprotocol.cpp @@ -271,11 +271,22 @@ enum ParseState WithinTableElement, WithinTableElementAnchor, ParseError }; -static inline ParseState nextOpeningState(ParseState current, const QStringRef &element) +QDebug operator<<(QDebug d, const QXmlStreamAttributes &al) { + QDebug nospace = d.nospace(); + foreach (const QXmlStreamAttribute &a, al) + nospace << a.name().toString() << '=' << a.value().toString() << ' '; + return d; +} + +static inline ParseState nextOpeningState(ParseState current, const QXmlStreamReader &reader) +{ + const QStringRef element = reader.name(); switch (current) { case OutSideTable: - if (element == QLatin1String("table")) + // Trigger on main table only. + if (element == QLatin1String("table") + && reader.attributes().value(QLatin1String("class")) == QLatin1String("maintable")) return WithinTable; return OutSideTable; case WithinTable: @@ -342,7 +353,8 @@ static inline QStringList parseLists(QIODevice *io) int tableColumn = 0; const QString hrefAttribute = QLatin1String("href"); - + //: Unknown user of paste. + const QString unknownUser = PasteBinDotComProtocol::tr("<Unknown>"); QString link; QString user; QString description; @@ -350,7 +362,7 @@ static inline QStringList parseLists(QIODevice *io) while (!reader.atEnd()) { switch(reader.readNext()) { case QXmlStreamReader::StartElement: - state = nextOpeningState(state, reader.name()); + state = nextOpeningState(state, reader); switch (state) { case WithinTableRow: tableColumn = 0; @@ -379,10 +391,11 @@ static inline QStringList parseLists(QIODevice *io) return rc; break; case WithinTable: - if (tableRow && !user.isEmpty() && !link.isEmpty() && !description.isEmpty()) { + // User can occasionally be empty. + if (tableRow && !link.isEmpty() && !description.isEmpty()) { QString entry = link; entry += QLatin1Char(' '); - entry += user; + entry += user.isEmpty() ? unknownUser : user; entry += QLatin1Char(' '); entry += description; rc.push_back(entry); diff --git a/src/plugins/cpptools/cppqtstyleindenter.cpp b/src/plugins/cpptools/cppqtstyleindenter.cpp index 413e404149..3bcbe813c2 100644 --- a/src/plugins/cpptools/cppqtstyleindenter.cpp +++ b/src/plugins/cpptools/cppqtstyleindenter.cpp @@ -50,6 +50,8 @@ using namespace CppTools; CppQtStyleIndenter::CppQtStyleIndenter() : m_cppCodeStylePreferences(0) { + // Just for safety. setCodeStylePreferences should be called when the editor the + // indenter belongs to gets initialized. m_cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStylePreferences(); } diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp index 22e82d812f..02996bfa7b 100644 --- a/src/plugins/debugger/breakwindow.cpp +++ b/src/plugins/debugger/breakwindow.cpp @@ -527,6 +527,10 @@ void BreakWindow::setModel(QAbstractItemModel *model) resizeColumnToContents(0); // Number resizeColumnToContents(3); // Line resizeColumnToContents(6); // Ignore count + if (header()) { + bool adjust = debuggerCore()->boolSetting(AlwaysAdjustBreakpointsColumnWidths); + setAlwaysResizeColumnsToContents(adjust); + } connect(model, SIGNAL(layoutChanged()), this, SLOT(expandAll())); } diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 9d2d1e3026..cd893b1e1c 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -1646,7 +1646,7 @@ static inline quint64 findClosestFunctionAddress(const QList<quint64> &addresses for (int i = 0; i < size; i++) { if (addresses.at(i) <= needle) { const quint64 offset = needle - addresses.at(i); - if (offset < offset) { + if (offset < closestOffset) { closestOffset = offset; closestIndex = i; } diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.cpp b/src/plugins/debugger/cdb/cdbparsehelpers.cpp index bade3a09a9..15ca7ee2ca 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.cpp +++ b/src/plugins/debugger/cdb/cdbparsehelpers.cpp @@ -503,26 +503,41 @@ bool parseCdbDisassemblerFunctionLine(const QString &l, return true; } -// Parse an instruction line: -// ' 21 00000001`3fcebff1 8b4030 mov eax,dword ptr [rax+30h]' -// '<source_line> <address> <raw data> <instruction> -bool parseCdbDisassemblerLine(const QString &lineIn, DisassemblerLine *dLine, uint *sourceLine) +/* Parse an instruction line, CDB 6.12: + * 0123456 + * ' 21 00000001`3fcebff1 8b4030 mov eax,dword ptr [rax+30h]' + * or CDB 6.11 (source line and address joined, 725 being the source line number): + * 0123456 + * ' 725078bb291 8bec mov ebp,esp + * '<source_line>[ ]?<address> <raw data> <instruction> */ + +bool parseCdbDisassemblerLine(const QString &line, DisassemblerLine *dLine, uint *sourceLine) { *sourceLine = 0; - if (lineIn.size() < 6) + if (line.size() < 6) return false; - // Check source line: right-padded 5 digits - const bool hasSourceLine = lineIn.at(4).isDigit(); - const QString line = lineIn.trimmed(); - int addressPos = 0; const QChar blank = QLatin1Char(' '); - // Optional source line. - if (hasSourceLine) { - const int sourceLineEnd = line.indexOf(blank); + int addressPos = 0; + // Check for joined source and address in 6.11 + const bool hasV611SourceLine = line.at(5).isDigit(); + const bool hasV612SourceLine = !hasV611SourceLine && line.at(4).isDigit(); + if (hasV611SourceLine) { + // v6.11: Fixed 5 source line columns, joined + *sourceLine = line.left(5).trimmed().toUInt(); + addressPos = 5; + } else if (hasV612SourceLine) { + // v6.12: Free format columns + const int sourceLineEnd = line.indexOf(blank, 4); if (sourceLineEnd == -1) - return false; - *sourceLine = line.left(sourceLineEnd).toUInt(); + return false; + *sourceLine = line.left(sourceLineEnd).trimmed().toUInt(); addressPos = sourceLineEnd + 1; + } else { + // Skip source line column. + const int size = line.size(); + for ( ; addressPos < size && line.at(addressPos).isSpace(); ++addressPos) ; + if (addressPos == size) + return false; } // Find positions of address/raw data/instruction const int addressEnd = line.indexOf(blank, addressPos + 1); diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index b36c4ddfbc..54dcaa0b86 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -329,6 +329,14 @@ DebuggerSettings::DebuggerSettings(QSettings *settings) item->setSettingsKey(debugModeGroup, QLatin1String("BreakOnWarning")); insertItem(BreakOnWarning, item); + item = new SavedAction(this); + item->setText(tr("Break on \"qFatal\"")); + item->setCheckable(true); + item->setDefaultValue(true); + item->setValue(true); + item->setSettingsKey(debugModeGroup, QLatin1String("BreakOnFatal")); + insertItem(BreakOnFatal, item); + // // Settings // diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 9294bb55ec..33b564c6ba 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -151,6 +151,7 @@ enum DebuggerActionCode BreakOnThrow, BreakOnCatch, BreakOnWarning, + BreakOnFatal, // Registers AlwaysAdjustRegistersColumnWidths, diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 904ced3355..799537c991 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -1177,8 +1177,6 @@ void DebuggerEngine::notifyInferiorPid(qint64 pid) return; d->m_inferiorPid = pid; if (pid) { - if (d->m_runControl) - d->m_runControl->setApplicationProcessHandle(ProcessHandle(pid)); showMessage(tr("Taking notice of pid %1").arg(pid)); if (d->m_startParameters.startMode == StartInternal || d->m_startParameters.startMode == StartExternal diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 4239efb791..f03930b740 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -2584,7 +2584,9 @@ void DebuggerPluginPrivate::extensionsInitialized() ICore *core = ICore::instance(); QTC_ASSERT(core, return); m_coreSettings = core->settings(); + m_debuggerSettings = new DebuggerSettings(m_coreSettings); + m_debuggerSettings->readSettings(); connect(core, SIGNAL(coreAboutToClose()), this, SLOT(coreShutdown())); @@ -2776,8 +2778,6 @@ void DebuggerPluginPrivate::extensionsInitialized() m_commonOptionsPage = new CommonOptionsPage(m_globalDebuggerOptions); m_plugin->addAutoReleasedObject(m_commonOptionsPage); - m_debuggerSettings->readSettings(); - // Do not fail to load the whole plugin if something goes wrong here. QString errorMessage; if (!parseArguments(m_arguments, &m_cmdLineEnabledEngines, &errorMessage)) { diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 692f2e9d94..d08a89c4ca 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -795,7 +795,7 @@ DebuggerToolTipWidget *DebuggerToolTipWidget::loadSessionDataI(QXmlStreamReader if (debugToolTips) qDebug() << "Creating tooltip " << context << " from " << creationDate << offset; DebuggerToolTipWidget *rc = 0; - if (className == "Debugger::Internal::DebuggerTreeViewToolTipWidget") + if (className == "Debugger::Internal::DebuggerToolTipWidget") rc = new DebuggerToolTipWidget; if (rc) { rc->setContext(context); diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp index 80d58ad7f2..5b5d148a5a 100644 --- a/src/plugins/debugger/disassembleragent.cpp +++ b/src/plugins/debugger/disassembleragent.cpp @@ -340,6 +340,7 @@ void DisassemblerAgent::updateLocationMarker() QTextBlock block = tc.document()->findBlockByNumber(lineNumber - 1); tc.setPosition(block.position()); plainTextEdit->setTextCursor(tc); + plainTextEdit->centerCursor(); } void DisassemblerAgent::updateBreakpointMarkers() diff --git a/src/plugins/debugger/gdb/classicgdbengine.cpp b/src/plugins/debugger/gdb/classicgdbengine.cpp index 51ee1b6be1..42f364f0f2 100644 --- a/src/plugins/debugger/gdb/classicgdbengine.cpp +++ b/src/plugins/debugger/gdb/classicgdbengine.cpp @@ -864,6 +864,8 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0) // Try automatic dereferentiation data.exp = "(*(" + data.exp + "))"; data.type = data.type + '.'; // FIXME: fragile HACK to avoid recursion + if (data.value.startsWith("0x")) + data.value = "@" + data.value; insertData(data); } else { data.setChildrenUnneeded(); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index f956c22cf8..424fe55eb5 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4913,10 +4913,13 @@ void GdbEngine::handleNamespaceExtraction(const GdbResponse &response) if (startParameters().startMode == AttachCore) { notifyInferiorSetupOk(); // No breakpoints in core files. } else { - postCommand("-break-insert -f '" + qtNamespace() + "qFatal'", - CB(handleBreakOnQFatal)); if (debuggerCore()->boolSetting(BreakOnWarning)) postCommand("-break-insert -f '" + qtNamespace() + "qWarning'"); + if (debuggerCore()->boolSetting(BreakOnFatal)) + postCommand("-break-insert -f '" + qtNamespace() + "qFatal'", + CB(handleBreakOnQFatal)); + else + notifyInferiorSetupOk(); } } diff --git a/src/plugins/debugger/gdb/gdboptionspage.cpp b/src/plugins/debugger/gdb/gdboptionspage.cpp index 28ea5b606b..20f50d21d7 100644 --- a/src/plugins/debugger/gdb/gdboptionspage.cpp +++ b/src/plugins/debugger/gdb/gdboptionspage.cpp @@ -96,6 +96,8 @@ QWidget *GdbOptionsPage::createPage(QWidget *parent) m_ui->checkBoxAdjustBreakpointLocations); m_group.insert(debuggerCore()->action(BreakOnWarning), m_ui->checkBoxBreakOnWarning); + m_group.insert(debuggerCore()->action(BreakOnFatal), + m_ui->checkBoxBreakOnFatal); m_group.insert(debuggerCore()->action(GdbWatchdogTimeout), m_ui->spinBoxGdbWatchdogTimeout); diff --git a/src/plugins/debugger/gdb/gdboptionspage.ui b/src/plugins/debugger/gdb/gdboptionspage.ui index 6fb810fca1..f2e21e1e91 100644 --- a/src/plugins/debugger/gdb/gdboptionspage.ui +++ b/src/plugins/debugger/gdb/gdboptionspage.ui @@ -130,6 +130,13 @@ on slow machines. In this case, the value should be increased.</string> </widget> </item> <item row="8" column="0" colspan="2"> + <widget class="QCheckBox" name="checkBoxBreakOnFatal"> + <property name="text"> + <string>Stop when a qFatal is issued</string> + </property> + </widget> + </item> + <item row="9" column="0" colspan="2"> <widget class="QCheckBox" name="checkBoxEnableReverseDebugging"> <property name="toolTip"> <string><html><head/><body><p>Selecting this enables reverse debugging.</p><.p><b>Note:</b>This feature is very slow and unstable on the GDB side. It exhibits unpredictable behaviour when going backwards over system calls and is very likely to destroy your debugging session.</p><body></html></string> diff --git a/src/plugins/debugger/moduleswindow.cpp b/src/plugins/debugger/moduleswindow.cpp index ee23318b78..390397f15d 100644 --- a/src/plugins/debugger/moduleswindow.cpp +++ b/src/plugins/debugger/moduleswindow.cpp @@ -215,7 +215,10 @@ void ModulesWindow::setAlwaysResizeColumnsToContents(bool on) void ModulesWindow::setModel(QAbstractItemModel *model) { QTreeView::setModel(model); - setAlwaysResizeColumnsToContents(true); + if (header()) { + bool adjust = debuggerCore()->boolSetting(AlwaysAdjustModulesColumnWidths); + setAlwaysResizeColumnsToContents(adjust); + } } } // namespace Internal diff --git a/src/plugins/debugger/qml/qmlcppengine.cpp b/src/plugins/debugger/qml/qmlcppengine.cpp index 0c5a77bb29..f3f43cfa68 100644 --- a/src/plugins/debugger/qml/qmlcppengine.cpp +++ b/src/plugins/debugger/qml/qmlcppengine.cpp @@ -39,6 +39,11 @@ #include <utils/qtcassert.h> +#include <coreplugin/icore.h> +#include <QtGui/QMainWindow> +#include <QtGui/QMessageBox> +#include <QtCore/QTimer> + namespace Debugger { namespace Internal { @@ -89,13 +94,15 @@ private: DebuggerEngine *m_cppEngine; DebuggerEngine *m_activeEngine; int m_stackBoundary; + + QMessageBox *m_msg; }; QmlCppEnginePrivate::QmlCppEnginePrivate(QmlCppEngine *parent, const DebuggerStartParameters &sp) : q(parent), m_qmlEngine(createQmlEngine(sp, q)), - m_cppEngine(0), m_activeEngine(0) + m_cppEngine(0), m_activeEngine(0), m_msg(0) { setObjectName(QLatin1String("QmlCppEnginePrivate")); } @@ -150,6 +157,7 @@ QmlCppEngine::QmlCppEngine(const DebuggerStartParameters &sp, connect(d->m_qmlEngine->stackHandler()->model(), SIGNAL(modelReset()), d.data(), SLOT(qmlStackChanged()), Qt::QueuedConnection); connect(d->m_cppEngine, SIGNAL(stackFrameCompleted()), this, SIGNAL(stackFrameCompleted())); + connect(d->m_cppEngine, SIGNAL(requestRemoteSetup()), this, SIGNAL(requestRemoteSetup())); connect(d->m_qmlEngine, SIGNAL(stackFrameCompleted()), this, SIGNAL(stackFrameCompleted())); } @@ -587,6 +595,9 @@ void QmlCppEngine::slaveEngineStateChanged } else if (state() == InferiorStopRequested) { EDEBUG("... AN INFERIOR STOPPED EXPECTEDLY"); notifyInferiorStopOk(); + } else if (otherEngine->state() == EngineRunRequested && otherEngine == d->m_qmlEngine) { + EDEBUG("... BREAKPOINT HIT IN C++ BEFORE QML STARTUP"); + QTimer::singleShot(0, this, SLOT(skipCppBreakpoint())); } else if (state() == EngineRunRequested) { EDEBUG("... AN INFERIOR FAILED STARTUP, OTHER STOPPED EXPECTEDLY"); // wait for failure notification from other engine @@ -675,6 +686,31 @@ void QmlCppEngine::showMessage(const QString &msg, int channel, int timeout) con DebuggerEngine::showMessage(msg, channel, timeout); } +void QmlCppEngine::skipCppBreakpoint() +{ + // only used to skip breakpoint in CPP when QML not ready yet + QTC_ASSERT(d->m_cppEngine->state() == InferiorStopOk, return); + QTC_ASSERT(d->m_qmlEngine->state() == EngineRunRequested, return); + + if (!d->m_msg) { + Core::ICore * const core = Core::ICore::instance(); + d->m_msg = new QMessageBox(core->mainWindow()); + } + + if (d->m_msg->isHidden()) { + d->m_msg->setIcon(QMessageBox::Warning); + d->m_msg->setWindowTitle(tr("QML/C++ Debugging")); + d->m_msg->setText(tr("Cannot stop execution before QML engine is started. Skipping breakpoint.\nSuggestions: Move the breakpoint after QmlViewer initialization or switch to C++ only debugging")); + d->m_msg->setStandardButtons(QMessageBox::Ok); + d->m_msg->setDefaultButton(QMessageBox::Ok); + d->m_msg->setModal(false); + d->m_msg->show(); + } + + d->m_cppEngine->continueInferior(); + resetLocation(); +} + DebuggerEngine *QmlCppEngine::cppEngine() const { return d->m_cppEngine; diff --git a/src/plugins/debugger/qml/qmlcppengine.h b/src/plugins/debugger/qml/qmlcppengine.h index 2f7202b398..322e4a9d44 100644 --- a/src/plugins/debugger/qml/qmlcppengine.h +++ b/src/plugins/debugger/qml/qmlcppengine.h @@ -125,6 +125,9 @@ protected: void notifyEngineRunAndInferiorRunOk(); void notifyInferiorShutdownOk(); +protected slots: + void skipCppBreakpoint(); + private: void engineStateChanged(DebuggerState newState); void setState(DebuggerState newState, bool forced = false); diff --git a/src/plugins/debugger/registerwindow.cpp b/src/plugins/debugger/registerwindow.cpp index 9407618adf..491f314bb3 100644 --- a/src/plugins/debugger/registerwindow.cpp +++ b/src/plugins/debugger/registerwindow.cpp @@ -296,6 +296,10 @@ void RegisterWindow::setModel(QAbstractItemModel *model) { QTreeView::setModel(model); setAlwaysResizeColumnsToContents(true); + if (header()) { + bool adjust = debuggerCore()->boolSetting(AlwaysAdjustRegistersColumnWidths); + setAlwaysResizeColumnsToContents(adjust); + } } void RegisterWindow::reloadRegisters() diff --git a/src/plugins/debugger/snapshotwindow.cpp b/src/plugins/debugger/snapshotwindow.cpp index 92079f91e7..6f1429611d 100644 --- a/src/plugins/debugger/snapshotwindow.cpp +++ b/src/plugins/debugger/snapshotwindow.cpp @@ -135,6 +135,16 @@ void SnapshotWindow::removeSnapshot(int i) m_snapshotHandler->at(i)->quitDebugger(); } +void SnapshotWindow::setModel(QAbstractItemModel *model) +{ + QTreeView::setModel(model); + setAlwaysResizeColumnsToContents(true); + if (header()) { + bool adjust = debuggerCore()->boolSetting(AlwaysAdjustSnapshotsColumnWidths); + setAlwaysResizeColumnsToContents(adjust); + } +} + void SnapshotWindow::resizeColumnsToContents() { for (int i = model()->columnCount(); --i >= 0; ) diff --git a/src/plugins/debugger/snapshotwindow.h b/src/plugins/debugger/snapshotwindow.h index 3b6ce709c0..f9b2a39959 100644 --- a/src/plugins/debugger/snapshotwindow.h +++ b/src/plugins/debugger/snapshotwindow.h @@ -59,6 +59,7 @@ private: void removeSnapshot(int i); void keyPressEvent(QKeyEvent *ev); void contextMenuEvent(QContextMenuEvent *ev); + void setModel(QAbstractItemModel *model); SnapshotHandler *m_snapshotHandler; }; diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp index 92e0722e7a..ef51bf71e5 100644 --- a/src/plugins/debugger/stackwindow.cpp +++ b/src/plugins/debugger/stackwindow.cpp @@ -105,6 +105,10 @@ void StackWindow::setModel(QAbstractItemModel *model) //resizeColumnsToContents(); resizeColumnToContents(0); resizeColumnToContents(3); + if (header()) { + bool adjust = debuggerCore()->boolSetting(AlwaysAdjustStackColumnWidths); + setAlwaysResizeColumnsToContents(adjust); + } } void StackWindow::contextMenuEvent(QContextMenuEvent *ev) diff --git a/src/plugins/debugger/threadswindow.cpp b/src/plugins/debugger/threadswindow.cpp index 5d70e5a71d..5d1c1de729 100644 --- a/src/plugins/debugger/threadswindow.cpp +++ b/src/plugins/debugger/threadswindow.cpp @@ -82,6 +82,10 @@ void ThreadsWindow::setModel(QAbstractItemModel *model) resizeColumnToContents(0); // Id resizeColumnToContents(4); // Line resizeColumnToContents(6); // Name + if (header()) { + bool adjust = debuggerCore()->boolSetting(AlwaysAdjustThreadsColumnWidths); + setAlwaysResizeColumnsToContents(adjust); + } } void ThreadsWindow::contextMenuEvent(QContextMenuEvent *ev) diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index 14dee8f87b..242eaf1b49 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -68,6 +68,13 @@ bool isPointerType(const QByteArray &type) return type.endsWith('*') || type.endsWith("* const"); } +bool isVTablePointer(const QByteArray &type) +{ + // FIXME: That is cdb only. + // But no user type can be named like this, so this is safe. + return type.startsWith("__fptr()"); +} + bool isCharPointerType(const QByteArray &type) { return type == "char *" || type == "const char *" || type == "char const *"; @@ -276,7 +283,7 @@ void WatchData::setAddress(const quint64 &a) void WatchData::setHexAddress(const QByteArray &a) { bool ok; - const qint64 av = a.toULongLong(&ok, 16); + const qint64 av = a.toULongLong(&ok, 0); if (ok) { address = av; } else { diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 012bd1ebfe..825eb50b19 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -296,6 +296,7 @@ QString WatchModel::displayType(const WatchData &data) const : data.displayedType; if (data.bitsize) base += QString(":%1").arg(data.bitsize); + base.remove('\''); return base; } @@ -366,14 +367,16 @@ static inline QString formattedValue(const WatchData &data, int format) return data.value; // Evil hack, covers 'unsigned' as well as quint64. if (data.type.contains('u')) - return reformatInteger(data.value.toULongLong(), format); + return reformatInteger(data.value.toULongLong(0, 0), format); return reformatInteger(data.value.toLongLong(), format); } - bool ok = false; - qulonglong integer = data.value.toULongLong(&ok, 0); - if (ok) - return reformatInteger(integer, format); + if (!isPointerType(data.type) && !isVTablePointer(data.type)) { + bool ok = false; + qulonglong integer = data.value.toULongLong(&ok, 0); + if (ok) + return reformatInteger(integer, format); + } QString result = data.value; result.replace(QLatin1Char('\n'), QLatin1String("\\n")); @@ -410,16 +413,11 @@ static inline QString formattedValue(const WatchData &data, int format) // "0x00000000`000003fd "Hallo"", or check gdb formatting of characters. static inline quint64 pointerValue(QString data) { - if (data.isEmpty() || !data.startsWith(QLatin1String("0x"))) - return 0; - data.remove(0, 2); const int blankPos = data.indexOf(QLatin1Char(' ')); if (blankPos != -1) data.truncate(blankPos); data.remove(QLatin1Char('`')); - bool ok; - const quint64 address = data.toULongLong(&ok, 16); - return ok ? address : quint64(0); + return data.toULongLong(0, 0); } // Return the type used for editing @@ -712,7 +710,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const return m_handler->m_expandedINames.contains(data.iname); case LocalsTypeFormatListRole: { - if (data.referencingAddress || data.type.endsWith('*')) + if (data.referencingAddress || isPointerType(data.type)) return QStringList() << tr("Raw pointer") << tr("Latin1 string") @@ -769,7 +767,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const } case LocalsAddressRole: - return data.coreAddress(); + return QVariant(data.coreAddress()); case LocalsReferencingAddressRole: return QVariant(data.referencingAddress); case LocalsSizeRole: @@ -845,7 +843,7 @@ Qt::ItemFlags WatchModel::flags(const QModelIndex &idx) const // source of a drag and drop operation and as a drop target. static const Qt::ItemFlags notEditable - = /* Qt::ItemIsSelectable | */ Qt::ItemIsEnabled; + = Qt::ItemIsSelectable | Qt::ItemIsEnabled; static const Qt::ItemFlags editable = notEditable | Qt::ItemIsEditable; // Disable editing if debuggee is positively running. diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index 7356f31978..04e3782b5c 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -737,7 +737,7 @@ static void setWatchDataExpression(WatchData &data, const GdbMi &mi) data.exp = mi.data(); } -static void setWatchDataAddress(WatchData &data, quint64 address , quint64 origAddress = 0) +static void setWatchDataAddress(WatchData &data, quint64 address, quint64 origAddress = 0) { if (origAddress) { // Gdb dumpers reports the dereferenced address as origAddress data.address = origAddress; diff --git a/src/plugins/debugger/watchutils.h b/src/plugins/debugger/watchutils.h index 77239dd979..360d69cf01 100644 --- a/src/plugins/debugger/watchutils.h +++ b/src/plugins/debugger/watchutils.h @@ -82,6 +82,7 @@ bool hasLetterOrNumber(const QString &exp); bool hasSideEffects(const QString &exp); bool isKeyWord(const QString &exp); bool isPointerType(const QByteArray &type); +bool isVTablePointer(const QByteArray &type); bool isCharPointerType(const QByteArray &type); bool startsWithDigit(const QString &str); QByteArray stripPointerType(QByteArray type); diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index e1e598ef25..9d6eb066ee 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -1839,8 +1839,15 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input) } else if (count() <= rightDist()) { setAnchor(); moveRight(count()); - replaceText(currentRange(), QString(count(), input.asChar())); - moveLeft(); + if (input.isReturn()) { + beginEditBlock(); + replaceText(currentRange(), QString()); + insertText(QString("\n")); + endEditBlock(); + } else { + replaceText(currentRange(), QString(count(), input.asChar())); + moveLeft(); + } setTargetColumn(); setDotCommand("%1r" + input.text(), count()); } diff --git a/src/plugins/projectexplorer/abi.cpp b/src/plugins/projectexplorer/abi.cpp index 1bf34fdd5f..df3b558a2f 100644 --- a/src/plugins/projectexplorer/abi.cpp +++ b/src/plugins/projectexplorer/abi.cpp @@ -92,6 +92,10 @@ static QList<Abi> parseCoffHeader(const QByteArray &data) arch = Abi::X86Architecture; width = 32; break; + case 0x0166: // MIPS, little endian + arch = Abi::MipsArcitecture; + width = 32; + break; case 0x0200: // ia64 arch = Abi::ItaniumArchitecture; width = 64; @@ -736,6 +740,9 @@ void ProjectExplorer::ProjectExplorerPlugin::testAbiOfBinary_data() QTest::newRow("dynamic QtCore: win msys 32bit") << QString::fromLatin1("%1/dynamic/win-mingw-32bit.dll").arg(prefix) << (QStringList() << QString::fromLatin1("x86-windows-msys-pe-32bit")); + QTest::newRow("dynamic QtCore: wince msvc2005 32bit") + << QString::fromLatin1("%1/dynamic/wince-32bit.dll").arg(prefix) + << (QStringList() << QString::fromLatin1("mips-windows-msvc2005-pe-32bit")); QTest::newRow("dynamic stdc++: mac fat") << QString::fromLatin1("%1/dynamic/mac-fat.dylib").arg(prefix) << (QStringList() << QString::fromLatin1("x86-macos-generic-mach_o-32bit") diff --git a/src/plugins/projectexplorer/abiwidget.cpp b/src/plugins/projectexplorer/abiwidget.cpp index 2be1b9801a..796b0823f5 100644 --- a/src/plugins/projectexplorer/abiwidget.cpp +++ b/src/plugins/projectexplorer/abiwidget.cpp @@ -151,6 +151,7 @@ void AbiWidget::setAbis(const QList<Abi> &abiList, const Abi ¤t) d->m_abi->addItem(tr("<custom>"), QLatin1String("custom")); d->m_abi->setCurrentIndex(0); + for (int i = 0; i < abiList.count(); ++i) { const QString abiString = abiList.at(i).toString(); d->m_abi->addItem(abiString, abiString); @@ -159,27 +160,12 @@ void AbiWidget::setAbis(const QList<Abi> &abiList, const Abi ¤t) } if (d->m_abi->currentIndex() == 0) { - if (!current.isValid() && !abiList.isEmpty()) { + if (!current.isValid() && !abiList.isEmpty()) d->m_abi->setCurrentIndex(1); // default to the first Abi if none is selected. - } else { - d->m_architectureComboBox->setCurrentIndex(static_cast<int>(current.architecture())); - d->m_osComboBox->setCurrentIndex(static_cast<int>(current.os())); - osChanged(); - for (int i = 0; i < d->m_osFlavorComboBox->count(); ++i) { - if (d->m_osFlavorComboBox->itemData(i).toInt() == current.osFlavor()) { - d->m_osFlavorComboBox->setCurrentIndex(i); - break; - } - } - d->m_binaryFormatComboBox->setCurrentIndex(static_cast<int>(current.binaryFormat())); - for (int i = 0; i < d->m_wordWidthComboBox->count(); ++i) { - if (d->m_wordWidthComboBox->itemData(i).toInt() == current.wordWidth()) { - d->m_wordWidthComboBox->setCurrentIndex(i); - break; - } - } - } + else + setCustomAbi(current); } + modeChanged(); blockSignals(false); } @@ -218,6 +204,31 @@ void AbiWidget::modeChanged() d->m_osFlavorComboBox->setEnabled(customMode); d->m_binaryFormatComboBox->setEnabled(customMode); d->m_wordWidthComboBox->setEnabled(customMode); + + if (!customMode) { + Abi current(d->m_abi->itemData(d->m_abi->currentIndex()).toString()); + setCustomAbi(current); + } +} + +void AbiWidget::setCustomAbi(const Abi ¤t) +{ + d->m_architectureComboBox->setCurrentIndex(static_cast<int>(current.architecture())); + d->m_osComboBox->setCurrentIndex(static_cast<int>(current.os())); + osChanged(); + for (int i = 0; i < d->m_osFlavorComboBox->count(); ++i) { + if (d->m_osFlavorComboBox->itemData(i).toInt() == current.osFlavor()) { + d->m_osFlavorComboBox->setCurrentIndex(i); + break; + } + } + d->m_binaryFormatComboBox->setCurrentIndex(static_cast<int>(current.binaryFormat())); + for (int i = 0; i < d->m_wordWidthComboBox->count(); ++i) { + if (d->m_wordWidthComboBox->itemData(i).toInt() == current.wordWidth()) { + d->m_wordWidthComboBox->setCurrentIndex(i); + break; + } + } } } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/abiwidget.h b/src/plugins/projectexplorer/abiwidget.h index 1b8a9350f0..2ca76e2d8d 100644 --- a/src/plugins/projectexplorer/abiwidget.h +++ b/src/plugins/projectexplorer/abiwidget.h @@ -68,6 +68,8 @@ private slots: void modeChanged(); private: + void setCustomAbi(const Abi &a); + Internal::AbiWidgetPrivate *const d; }; diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index 99b6282358..c8acfb71b5 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -69,6 +69,13 @@ static QObject *debuggerCore() return ExtensionSystem::PluginManager::instance()->getObjectByName("DebuggerCore"); } +static QString msgAttachDebuggerTooltip(const QString &handleDescription = QString()) +{ + return handleDescription.isEmpty() ? + AppOutputPane::tr("Attach debugger to this process") : + AppOutputPane::tr("Attach debugger to %1").arg(handleDescription); +} + AppOutputPane::RunControlTab::RunControlTab(RunControl *rc, Core::OutputWindow *w) : runControl(rc), window(w), asyncClosing(false) { @@ -109,7 +116,7 @@ AppOutputPane::AppOutputPane() : this, SLOT(stopRunControl())); // Attach - m_attachButton->setToolTip(tr("Attach debugger to this process")); + m_attachButton->setToolTip(msgAttachDebuggerTooltip()); m_attachButton->setEnabled(false); m_attachButton->setIcon(QIcon(ProjectExplorer::Constants::ICON_DEBUG_SMALL)); m_attachButton->setAutoRaise(true); @@ -251,6 +258,8 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc) this, SLOT(runControlStarted())); connect(rc, SIGNAL(finished()), this, SLOT(runControlFinished())); + connect(rc, SIGNAL(applicationProcessHandleChanged()), + this, SLOT(enableButtons())); connect(rc, SIGNAL(appendMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat)), this, SLOT(appendMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat))); @@ -423,33 +432,51 @@ void AppOutputPane::projectRemoved() tabChanged(m_tabWidget->currentIndex()); } -void AppOutputPane::tabChanged(int i) +void AppOutputPane::enableButtons() { - if (i == -1) { - m_stopAction->setEnabled(false); + const RunControl *rc = currentRunControl(); + const bool isRunning = rc && rc->isRunning(); + enableButtons(rc, isRunning); +} + +void AppOutputPane::enableButtons(const RunControl *rc /* = 0 */, bool isRunning /* = false */) +{ + if (rc) { + m_reRunButton->setEnabled(!isRunning); + m_reRunButton->setIcon(rc->icon()); + m_stopAction->setEnabled(isRunning); + if (isRunning && debuggerCore() && rc->applicationProcessHandle().isValid()) { + m_attachButton->setEnabled(true); + m_attachButton->setToolTip(msgAttachDebuggerTooltip(rc->applicationProcessHandle().toString())); + } else { + m_attachButton->setEnabled(false); + m_attachButton->setToolTip(msgAttachDebuggerTooltip()); + } + } else { m_reRunButton->setEnabled(false); + m_reRunButton->setIcon(QIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL))); m_attachButton->setEnabled(false); - } else { - const int index = indexOf(m_tabWidget->widget(i)); - QTC_ASSERT(index != -1, return; ) + m_attachButton->setToolTip(msgAttachDebuggerTooltip()); + m_stopAction->setEnabled(false); + } +} - RunControl *rc = m_runControlTabs.at(index).runControl; - m_stopAction->setEnabled(rc->isRunning()); - m_reRunButton->setEnabled(!rc->isRunning()); - m_reRunButton->setIcon(rc->icon()); - m_attachButton->setEnabled(debuggerCore()); +void AppOutputPane::tabChanged(int i) +{ + const int index = indexOf(m_tabWidget->widget(i)); + if (i != -1) { + const RunControl *rc = m_runControlTabs.at(index).runControl; + enableButtons(rc, rc->isRunning()); + } else { + enableButtons(); } } void AppOutputPane::runControlStarted() { RunControl *current = currentRunControl(); - if (current && current == sender()) { - m_reRunButton->setEnabled(false); - m_stopAction->setEnabled(true); - m_attachButton->setEnabled(debuggerCore()); - m_reRunButton->setIcon(current->icon()); - } + if (current && current == sender()) + enableButtons(current, true); // RunControl::isRunning() cannot be trusted in signal handler. } void AppOutputPane::runControlFinished() @@ -466,12 +493,9 @@ void AppOutputPane::runControlFinished() qDebug() << "OutputPane::runControlFinished" << senderRunControl << senderIndex << " current " << current << m_runControlTabs.size(); - if (current && current == sender()) { - m_reRunButton->setEnabled(true); - m_stopAction->setEnabled(false); - m_attachButton->setEnabled(false); - m_reRunButton->setIcon(current->icon()); - } + if (current && current == sender()) + enableButtons(current, false); // RunControl::isRunning() cannot be trusted in signal handler. + // Check for asynchronous close. Close the tab. if (m_runControlTabs.at(senderIndex).asyncClosing) closeTab(tabWidgetIndexOf(senderIndex), CloseTabNoPrompt); diff --git a/src/plugins/projectexplorer/appoutputpane.h b/src/plugins/projectexplorer/appoutputpane.h index f16c866fce..7336f23ea6 100644 --- a/src/plugins/projectexplorer/appoutputpane.h +++ b/src/plugins/projectexplorer/appoutputpane.h @@ -105,8 +105,11 @@ private slots: void aboutToUnloadSession(); void updateFromSettings(); + void enableButtons(); private: + void enableButtons(const RunControl *rc, bool isRunning); + struct RunControlTab { explicit RunControlTab(RunControl *runControl = 0, Core::OutputWindow *window = 0); diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.cpp b/src/plugins/projectexplorer/localapplicationruncontrol.cpp index dffb39f204..b1ca9cb635 100644 --- a/src/plugins/projectexplorer/localapplicationruncontrol.cpp +++ b/src/plugins/projectexplorer/localapplicationruncontrol.cpp @@ -139,6 +139,7 @@ void LocalApplicationRunControl::slotAppendMessage(const QString &err, void LocalApplicationRunControl::processExited(int exitCode) { + setApplicationProcessHandle(ProcessHandle()); QString msg = tr("%1 exited with code %2\n") .arg(QDir::toNativeSeparators(m_executable)).arg(exitCode); appendMessage(msg, Utils::NormalMessageFormat); diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index beb512dfbe..9cf2ea8948 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -55,7 +55,11 @@ #include <QtGui/QFormLayout> #include <QtGui/QDesktopServices> -static const char debuggerCommandKeyC[] = "ProjectExplorer.MsvcToolChain.Debugger"; +#define KEY_ROOT "ProjectExplorer.MsvcToolChain." +static const char debuggerCommandKeyC[] = KEY_ROOT"Debugger"; +static const char varsBatKeyC[] = KEY_ROOT"VarsBat"; +static const char varsBatArgKeyC[] = KEY_ROOT"VarsBatArg"; +static const char supportedAbiKeyC[] = KEY_ROOT"SupportedAbi"; enum { debug = 0 }; @@ -352,12 +356,38 @@ MsvcToolChain::MsvcToolChain(const QString &name, const Abi &abi, Q_ASSERT(abi.binaryFormat() == Abi::PEFormat); Q_ASSERT(abi.osFlavor() != Abi::WindowsMSysFlavor); - setId(QString::fromLatin1("%1:%2.%3.%4").arg(Constants::MSVC_TOOLCHAIN_ID).arg(m_varsBat) - .arg(m_varsBatArg).arg(m_debuggerCommand)); - + updateId(); setDisplayName(name); } +MsvcToolChain::MsvcToolChain() : + ToolChain(QLatin1String(Constants::MSVC_TOOLCHAIN_ID), false), + m_lastEnvironment(Utils::Environment::systemEnvironment()) +{ +} + +MsvcToolChain *MsvcToolChain::readFromMap(const QVariantMap &data) +{ + MsvcToolChain *tc = new MsvcToolChain; + if (tc->fromMap(data)) + return tc; + delete tc; + return 0; +} + +void MsvcToolChain::updateId() +{ + const QChar colon = QLatin1Char(':'); + QString id = QLatin1String(Constants::MSVC_TOOLCHAIN_ID); + id += colon; + id += m_varsBat; + id += colon; + id += m_varsBatArg; + id += colon; + id += m_debuggerCommand; + setId(id); +} + QString MsvcToolChain::typeName() const { return MsvcToolChainFactory::tr("MSVC"); @@ -438,6 +468,7 @@ void MsvcToolChain::setDebuggerCommand(const QString &d) if (m_debuggerCommand == d) return; m_debuggerCommand = d; + updateId(); toolChainUpdated(); } @@ -449,7 +480,12 @@ QString MsvcToolChain::debuggerCommand() const QVariantMap MsvcToolChain::toMap() const { QVariantMap data = ToolChain::toMap(); - data.insert(QLatin1String(debuggerCommandKeyC), m_debuggerCommand); + if (!m_debuggerCommand.isEmpty()) + data.insert(QLatin1String(debuggerCommandKeyC), m_debuggerCommand); + data.insert(QLatin1String(varsBatKeyC), m_varsBat); + if (!m_varsBatArg.isEmpty()) + data.insert(QLatin1String(varsBatArgKeyC), m_varsBatArg); + data.insert(QLatin1String(supportedAbiKeyC), m_abi.toString()); return data; } @@ -457,9 +493,13 @@ bool MsvcToolChain::fromMap(const QVariantMap &data) { if (!ToolChain::fromMap(data)) return false; - - m_debuggerCommand= data.value(QLatin1String(debuggerCommandKeyC)).toString(); - return true; + m_varsBat = data.value(QLatin1String(varsBatKeyC)).toString(); + m_varsBatArg = data.value(QLatin1String(varsBatArgKeyC)).toString(); + m_debuggerCommand = data.value(QLatin1String(debuggerCommandKeyC)).toString(); + const QString abiString = data.value(QLatin1String(supportedAbiKeyC)).toString(); + m_abi = Abi(abiString); + updateId(); + return !m_varsBat.isEmpty() && m_abi.isValid(); } IOutputParser *MsvcToolChain::outputParser() const @@ -523,10 +563,13 @@ void MsvcDebuggerConfigLabel::slotLinkActivated(const QString &link) // -------------------------------------------------------------------------- MsvcToolChainConfigWidget::MsvcToolChainConfigWidget(ToolChain *tc) : - ToolChainConfigWidget(tc) + ToolChainConfigWidget(tc), + m_varsBatDisplayLabel(new QLabel(this)) { QFormLayout *formLayout = new QFormLayout(this); formLayout->addRow(new QLabel(tc->displayName())); + m_varsBatDisplayLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); + formLayout->addRow(tr("Initialization:"), m_varsBatDisplayLabel); formLayout->addRow(new MsvcDebuggerConfigLabel); addDebuggerCommandControls(formLayout, QStringList(QLatin1String("-version"))); addDebuggerAutoDetection(this, SLOT(autoDetectDebugger())); @@ -545,6 +588,12 @@ void MsvcToolChainConfigWidget::setFromToolChain() { MsvcToolChain *tc = static_cast<MsvcToolChain *>(toolChain()); QTC_ASSERT(tc, return); + QString varsBatDisplay = tc->varsBat(); + if (!tc->varsBatArg().isEmpty()) { + varsBatDisplay += QLatin1Char(' '); + varsBatDisplay += tc->varsBatArg(); + } + m_varsBatDisplayLabel->setText(varsBatDisplay); setDebuggerCommand(tc->debuggerCommand()); } @@ -758,5 +807,10 @@ QString MsvcToolChain::autoDetectCdbDebugger(QStringList *checkedDirectories /* return QString(); } +bool MsvcToolChainFactory::canRestore(const QVariantMap &data) +{ + return idFromMap(data).startsWith(QLatin1String(Constants::MSVC_TOOLCHAIN_ID) + QLatin1Char(':')); +} + } // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/msvctoolchain.h b/src/plugins/projectexplorer/msvctoolchain.h index bde2695499..335e420e63 100644 --- a/src/plugins/projectexplorer/msvctoolchain.h +++ b/src/plugins/projectexplorer/msvctoolchain.h @@ -57,6 +57,8 @@ public: MsvcToolChain(const QString &name, const Abi &abi, const QString &varsBat, const QString &varsBatArg, bool autodetect = false); + static MsvcToolChain *readFromMap(const QVariantMap &data); + QString typeName() const; Abi targetAbi() const; @@ -79,9 +81,15 @@ public: bool canClone() const; ToolChain *clone() const; + QString varsBat() const { return m_varsBat; } + QString varsBatArg() const { return m_varsBatArg; } + static QString autoDetectCdbDebugger(QStringList *checkedDirectories = 0); private: + MsvcToolChain(); + void updateId(); + QString m_varsBat; // Script to setup environment QString m_varsBatArg; // Argument QString m_debuggerCommand; @@ -106,6 +114,10 @@ public: QList<ToolChain *> autoDetect(); + virtual bool canRestore(const QVariantMap &data); + virtual ToolChain *restore(const QVariantMap &data) + { return MsvcToolChain::readFromMap(data); } + ToolChainConfigWidget *configurationWidget(ToolChain *); }; @@ -146,6 +158,8 @@ private slots: private: void setFromToolChain(); + + QLabel *m_varsBatDisplayLabel; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 315817e164..15f866c2bb 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1304,12 +1304,7 @@ Project *ProjectExplorerPlugin::startupProject() const void ProjectExplorerPlugin::updateWelcomePage() { - WelcomePageData welcomePageData; - welcomePageData.sessionList = d->m_session->sessions(); - welcomePageData.activeSession = d->m_session->activeSession(); - welcomePageData.previousSession = d->m_session->lastSession(); - welcomePageData.projectList = d->m_recentProjects; - d->m_welcomePage->setWelcomePageData(welcomePageData); + d->m_welcomePage->reloadWelcomeScreenData(); } void ProjectExplorerPlugin::currentModeChanged(Core::IMode *mode, Core::IMode *oldMode) diff --git a/src/plugins/projectexplorer/projectwelcomepage.cpp b/src/plugins/projectexplorer/projectwelcomepage.cpp index e24c7a22ca..30c08caedb 100644 --- a/src/plugins/projectexplorer/projectwelcomepage.cpp +++ b/src/plugins/projectexplorer/projectwelcomepage.cpp @@ -51,7 +51,8 @@ SessionModel::SessionModel(SessionManager *manager, QObject *parent) QHash<int, QByteArray> roleNames; roleNames[Qt::DisplayRole] = "sessionName"; roleNames[DefaultSessionRole] = "defaultSession"; - roleNames[CurrentSessionRole] = "currentSession"; + roleNames[ActiveSessionRole] = "activeSession"; + roleNames[LastSessionRole] = "lastSession"; setRoleNames(roleNames); connect(manager, SIGNAL(sessionLoaded()), SLOT(resetSessions())); } @@ -63,18 +64,25 @@ int SessionModel::rowCount(const QModelIndex &) const QVariant SessionModel::data(const QModelIndex &index, int role) const { - if (role == Qt::DisplayRole || role == DefaultSessionRole || role == CurrentSessionRole) { + if (role == Qt::DisplayRole || role == DefaultSessionRole || + role == LastSessionRole || role == ActiveSessionRole) { QString sessionName = m_manager->sessions().at(index.row()); if (role == Qt::DisplayRole) return sessionName; else if (role == DefaultSessionRole) return m_manager->isDefaultSession(sessionName); - else if (role == CurrentSessionRole) - return sessionName == m_manager->currentSession(); + else if (role == LastSessionRole) + return m_manager->lastSession() == sessionName; + else if (role == ActiveSessionRole) + return m_manager->activeSession() == sessionName; } return QVariant(); } +bool SessionModel::isDefaultVirgin() const +{ + return m_manager->isDefaultVirgin(); +} void SessionModel::resetSessions() { @@ -123,7 +131,8 @@ void ProjectModel::resetProjects() /////////////////// -ProjectWelcomePage::ProjectWelcomePage() +ProjectWelcomePage::ProjectWelcomePage() : + m_sessionModel(0), m_projectModel(0) { } @@ -131,10 +140,13 @@ void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine) { static const char feedGroupName[] = "Feeds"; - QDeclarativeContext *ctx = engine->rootContext(); ProjectExplorerPlugin *pePlugin = ProjectExplorer::ProjectExplorerPlugin::instance(); - ctx->setContextProperty("sessionList", new SessionModel(pePlugin->session(), this)); - ctx->setContextProperty("projectList", new ProjectModel(pePlugin, this)); + m_sessionModel = new SessionModel(pePlugin->session(), this); + m_projectModel = new ProjectModel(pePlugin, this); + + QDeclarativeContext *ctx = engine->rootContext(); + ctx->setContextProperty("sessionList", m_sessionModel); + ctx->setContextProperty("projectList", m_projectModel); Core::MultiFeedRssModel *rssModel = new Core::MultiFeedRssModel(this); QSettings *settings = Core::ICore::instance()->settings(); if (settings->childGroups().contains(feedGroupName)) { @@ -154,9 +166,12 @@ void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine) ctx->setContextProperty("projectWelcomePage", this); } -void ProjectWelcomePage::setWelcomePageData(const WelcomePageData &welcomePageData) +void ProjectWelcomePage::reloadWelcomeScreenData() { - m_welcomePageData = welcomePageData; + if (m_sessionModel) + m_sessionModel->resetSessions(); + if (m_projectModel) + m_projectModel->resetProjects(); } } // namespace Internal diff --git a/src/plugins/projectexplorer/projectwelcomepage.h b/src/plugins/projectexplorer/projectwelcomepage.h index f63009f898..50e3ef6859 100644 --- a/src/plugins/projectexplorer/projectwelcomepage.h +++ b/src/plugins/projectexplorer/projectwelcomepage.h @@ -50,27 +50,18 @@ class SessionManager; namespace Internal { -struct WelcomePageData { - bool operator==(const WelcomePageData &rhs) const; - bool operator!=(const WelcomePageData &rhs) const; - - QString previousSession; - QString activeSession; - QStringList sessionList; - QList<QPair<QString, QString> > projectList; // pair of filename, displayname -}; - - class SessionModel : public QAbstractListModel { Q_OBJECT public: - enum { DefaultSessionRole = Qt::UserRole+1, CurrentSessionRole }; + enum { DefaultSessionRole = Qt::UserRole+1, LastSessionRole, ActiveSessionRole }; SessionModel(SessionManager* manager, QObject* parent = 0); int rowCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; + Q_SCRIPTABLE bool isDefaultVirgin() const; + public slots: void resetSessions(); @@ -108,15 +99,15 @@ public: QString title() const { return tr("Develop"); } int priority() const { return 20; } - void setWelcomePageData(const WelcomePageData &welcomePageData); + void reloadWelcomeScreenData(); signals: void requestProject(const QString &project); void requestSession(const QString &session); void manageSessions(); - private: - WelcomePageData m_welcomePageData; + SessionModel *m_sessionModel; + ProjectModel *m_projectModel; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 42bb2bc277..c9c93a0ea1 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -154,8 +154,43 @@ IRunConfigurationFactory *findRunConfigurationFactory(RunConfigurationFactoryMat \class ProjectExplorer::ProcessHandle \brief Helper class to describe a process. + Encapsulates parameters of a running process, local (PID) or remote (to be done, + address, port, etc). */ +ProcessHandle::ProcessHandle(quint64 pid) : + m_pid(pid) +{ +} + +bool ProcessHandle::isValid() const +{ + return m_pid != 0; +} + +void ProcessHandle::setPid(quint64 pid) +{ + m_pid = pid; +} + +quint64 ProcessHandle::pid() const +{ + return m_pid; +} + +QString ProcessHandle::toString() const +{ + if (m_pid) + return RunControl::tr("PID %1").arg(m_pid); + //: Invalid process handle. + return RunControl::tr("Invalid"); +} + +bool ProcessHandle::equals(const ProcessHandle &rhs) const +{ + return m_pid == rhs.m_pid; +} + /*! \class ProjectExplorer::RunConfiguration \brief Base class for a run configuration. A run configuration specifies how a @@ -506,7 +541,10 @@ ProcessHandle RunControl::applicationProcessHandle() const void RunControl::setApplicationProcessHandle(const ProcessHandle &handle) { - m_applicationProcessHandle = handle; + if (m_applicationProcessHandle != handle) { + m_applicationProcessHandle = handle; + emit applicationProcessHandleChanged(); + } } bool RunControl::promptToStop(bool *optionalPrompt) const diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 0ae9a88983..b5fb55f771 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -55,16 +55,22 @@ class Target; class PROJECTEXPLORER_EXPORT ProcessHandle { public: - explicit ProcessHandle(quint64 pid = 0) : m_pid(pid) {} + explicit ProcessHandle(quint64 pid = 0); - bool isValid() const { return m_pid != 0; } - void setPid(quint64 pid) { m_pid = pid; } - quint64 pid() const { return m_pid; } + bool isValid() const; + void setPid(quint64 pid); + quint64 pid() const; + QString toString() const; + + bool equals(const ProcessHandle &) const; private: quint64 m_pid; }; +inline bool operator==(const ProcessHandle &p1, const ProcessHandle &p2) { return p1.equals(p2); } +inline bool operator!=(const ProcessHandle &p1, const ProcessHandle &p2) { return !p1.equals(p2); } + // Documentation inside. class PROJECTEXPLORER_EXPORT RunConfiguration : public ProjectConfiguration { @@ -241,6 +247,7 @@ signals: const QString &msg, Utils::OutputFormat format); void started(); void finished(); + void applicationProcessHandleChanged(); private slots: void bringApplicationToForegroundInternal(); diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 9699943ec5..6a2929ff28 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -834,7 +834,7 @@ void SessionManager::configureEditor(Core::IEditor *editor, const QString &fileN QString SessionManager::currentSession() const { - return m_file->fileName(); + return QFileInfo(m_file->fileName()).completeBaseName(); } void SessionManager::updateWindowTitle() diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index 709dd5d394..c63689946f 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -104,6 +104,7 @@ public: void removeDependency(Project *project, Project *depProject); QString currentSession() const; + QString sessionNameToFileName(const QString &session) const; Project *startupProject() const; const QList<Project *> &projects() const; @@ -154,7 +155,6 @@ private slots: private: bool loadImpl(const QString &fileName); bool createImpl(const QString &fileName); - QString sessionNameToFileName(const QString &session) const; bool projectContainsFile(Project *p, const QString &fileName) const; bool recursiveDependencyCheck(const QString &newDep, const QString &checkDep) const; diff --git a/src/plugins/projectexplorer/sessionnodeimpl.cpp b/src/plugins/projectexplorer/sessionnodeimpl.cpp index e718bf05f3..96327f7960 100644 --- a/src/plugins/projectexplorer/sessionnodeimpl.cpp +++ b/src/plugins/projectexplorer/sessionnodeimpl.cpp @@ -37,7 +37,9 @@ namespace ProjectExplorer { namespace Internal { SessionNodeImpl::SessionNodeImpl(SessionManager *manager) - : ProjectExplorer::SessionNode(manager->currentSession(), manager) + : ProjectExplorer::SessionNode( + manager->sessionNameToFileName(manager->currentSession()), + manager) { setFileName(QLatin1String("session")); } diff --git a/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp b/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp index 0b4d5105dd..27f2d0122f 100644 --- a/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp @@ -217,21 +217,8 @@ void AbstractFormEditorTool::mouseReleaseEvent(const QList<QGraphicsItem*> & /*i } } -void AbstractFormEditorTool::mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList, QGraphicsSceneMouseEvent *event) -{ - FormEditorItem *formEditorItem = topFormEditorItem(itemList); - if (formEditorItem) { - ModelNode doubleClickNode = formEditorItem->qmlItemNode().modelNode(); - if (doubleClickNode.metaInfo().isComponent()) { - Core::EditorManager::instance()->openEditor(doubleClickNode.metaInfo().componentFileName()); - event->accept(); - } else if (checkIfNodeIsAView(doubleClickNode) && - doubleClickNode.hasNodeProperty("delegate") && - doubleClickNode.nodeProperty("delegate").modelNode().metaInfo().isComponent()) { - Core::EditorManager::instance()->openEditor(doubleClickNode.nodeProperty("delegate").modelNode().metaInfo().componentFileName()); - event->accept(); - } - } +void AbstractFormEditorTool::mouseDoubleClickEvent(const QList<QGraphicsItem*> &, QGraphicsSceneMouseEvent *) +{ } void AbstractFormEditorTool::showContextMenu(QGraphicsSceneMouseEvent *event) diff --git a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp index 38556c08cb..f2f95f52cd 100644 --- a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp @@ -379,7 +379,7 @@ void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event) createQmlItemNode(itemLibraryEntry, parentNode, event->scenePos()); } else if (event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) { Q_ASSERT(!event->mimeData()->data("application/vnd.bauhaus.libraryresource").isEmpty()); - QString imageName = QString::fromLatin1((event->mimeData()->data("application/vnd.bauhaus.libraryresource"))); + QString imageName = QString::fromUtf8((event->mimeData()->data("application/vnd.bauhaus.libraryresource"))); createQmlItemNodeFromImage(imageName, parentNode, event->scenePos()); } else Q_ASSERT(false); m_blockMove = true; @@ -404,7 +404,7 @@ void DragTool::move(QPointF scenePos) return; FormEditorItem *containerItem = calculateContainer(scenePos - QPoint(2, 2), m_movingItem.data()); - if (containerItem && + if (containerItem && m_movingItem->parentItem() && containerItem != m_movingItem->parentItem()) { m_moveManipulator.reparentTo(containerItem); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorgraphicsview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorgraphicsview.cpp index c3b6993659..43c7337cd4 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorgraphicsview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorgraphicsview.cpp @@ -83,24 +83,26 @@ void FormEditorGraphicsView::wheelEvent(QWheelEvent *event) void FormEditorGraphicsView::mouseMoveEvent(QMouseEvent *event) { - if (rect().contains(event->pos())) { - QGraphicsView::mouseMoveEvent(event); - } else { - QPoint position = event->pos(); - QPoint topLeft = rect().topLeft(); - QPoint bottomRight = rect().bottomRight(); - position.rx() = qMax(topLeft.x(), qMin(position.x(), bottomRight.x())); - position.ry() = qMax(topLeft.y(), qMin(position.y(), bottomRight.y())); - QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(event->type(), position, mapToGlobal(position), event->button(), event->buttons(), event->modifiers()); - - QGraphicsView::mouseMoveEvent(mouseEvent); - delete mouseEvent; - } - - // Keeps the feedback bubble within screen boundraries - int tx = qMin(width() - 114, qMax(16, event->pos().x() + 50)); - int ty = qMin(height() - 45, qMax(10, event->pos().y() - 70)); - m_feedbackOriginPoint = QPoint(tx, ty); + QGraphicsView::mouseMoveEvent(event); + +// if (rect().contains(event->pos())) { +// QGraphicsView::mouseMoveEvent(event); +// } else { +// QPoint position = event->pos(); +// QPoint topLeft = rect().topLeft(); +// QPoint bottomRight = rect().bottomRight(); +// position.rx() = qMax(topLeft.x(), qMin(position.x(), bottomRight.x())); +// position.ry() = qMax(topLeft.y(), qMin(position.y(), bottomRight.y())); +// QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(event->type(), position, mapToGlobal(position), event->button(), event->buttons(), event->modifiers()); + +// QGraphicsView::mouseMoveEvent(mouseEvent); +// delete mouseEvent; +// } + +// // Keeps the feedback bubble within screen boundraries +// int tx = qMin(width() - 114, qMax(16, event->pos().x() + 50)); +// int ty = qMin(height() - 45, qMax(10, event->pos().y() - 70)); +// m_feedbackOriginPoint = QPoint(tx, ty); } void FormEditorGraphicsView::keyPressEvent(QKeyEvent *event) @@ -127,21 +129,22 @@ void FormEditorGraphicsView::mousePressEvent(QMouseEvent *mouseEvent) void FormEditorGraphicsView::mouseReleaseEvent(QMouseEvent *event) { - if (rect().contains(event->pos())) { - QGraphicsView::mouseReleaseEvent(event); - } else { - QPoint position = event->pos(); - QPoint topLeft = rect().topLeft(); - QPoint bottomRight = rect().bottomRight(); - position.rx() = qMax(topLeft.x(), qMin(position.x(), bottomRight.x())); - position.ry() = qMax(topLeft.y(), qMin(position.y(), bottomRight.y())); - QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(event->type(), position, mapToGlobal(position), event->button(), event->buttons(), event->modifiers()); - - QGraphicsView::mouseReleaseEvent(mouseEvent); - delete mouseEvent; - } - - m_feedbackOriginPoint = QPoint(); + QGraphicsView::mouseReleaseEvent(event); +// if (rect().contains(event->pos())) { +// QGraphicsView::mouseReleaseEvent(event); +// } else { +// QPoint position = event->pos(); +// QPoint topLeft = rect().topLeft(); +// QPoint bottomRight = rect().bottomRight(); +// position.rx() = qMax(topLeft.x(), qMin(position.x(), bottomRight.x())); +// position.ry() = qMax(topLeft.y(), qMin(position.y(), bottomRight.y())); +// QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(event->type(), position, mapToGlobal(position), event->button(), event->buttons(), event->modifiers()); + +// QGraphicsView::mouseReleaseEvent(mouseEvent); +// delete mouseEvent; +// } + +// m_feedbackOriginPoint = QPoint(); } void FormEditorGraphicsView::leaveEvent(QEvent *event) @@ -150,162 +153,162 @@ void FormEditorGraphicsView::leaveEvent(QEvent *event) QGraphicsView::leaveEvent(event); } -static QPixmap createBubblePixmap() -{ - QPixmap pixmap(124, 48); - pixmap.fill(Qt::transparent); - QPainter pmPainter(&pixmap); - pmPainter.setRenderHint(QPainter::Antialiasing); - pmPainter.setOpacity(0.85); - pmPainter.translate(0.5, 0.5); - pmPainter.setPen(Qt::NoPen); - pmPainter.setBrush(QColor(0, 0, 0, 40)); - pmPainter.drawRoundedRect(QRect(0, 0, 124, 48), 8, 8); - QLinearGradient gradient(QPoint(0, 0), QPoint(0, 44)); - gradient.setColorAt(0.0, QColor(70, 70, 70)); - gradient.setColorAt(1.0, QColor(10, 10, 10)); - pmPainter.setBrush(gradient); - pmPainter.setPen(QColor(60, 60, 60)); - pmPainter.drawRoundedRect(QRect(2, 1, 120, 45), 5, 5); - pmPainter.setBrush(Qt::NoBrush); - pmPainter.setPen(QColor(255, 255, 255, 140)); - pmPainter.drawRoundedRect(QRect(3, 2, 118, 43), 5, 5); - pmPainter.end(); - return pixmap; -} - -void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*rect*/ ) +//static QPixmap createBubblePixmap() +//{ +// QPixmap pixmap(124, 48); +// pixmap.fill(Qt::transparent); +// QPainter pmPainter(&pixmap); +// pmPainter.setRenderHint(QPainter::Antialiasing); +// pmPainter.setOpacity(0.85); +// pmPainter.translate(0.5, 0.5); +// pmPainter.setPen(Qt::NoPen); +// pmPainter.setBrush(QColor(0, 0, 0, 40)); +// pmPainter.drawRoundedRect(QRect(0, 0, 124, 48), 8, 8); +// QLinearGradient gradient(QPoint(0, 0), QPoint(0, 44)); +// gradient.setColorAt(0.0, QColor(70, 70, 70)); +// gradient.setColorAt(1.0, QColor(10, 10, 10)); +// pmPainter.setBrush(gradient); +// pmPainter.setPen(QColor(60, 60, 60)); +// pmPainter.drawRoundedRect(QRect(2, 1, 120, 45), 5, 5); +// pmPainter.setBrush(Qt::NoBrush); +// pmPainter.setPen(QColor(255, 255, 255, 140)); +// pmPainter.drawRoundedRect(QRect(3, 2, 118, 43), 5, 5); +// pmPainter.end(); +// return pixmap; +//} + +void FormEditorGraphicsView::drawForeground(QPainter * /*painter*/, const QRectF & /*rect*/ ) { - if (!m_feedbackNode.isValid()) - return; - - if (m_feedbackOriginPoint.isNull()) - return; - - painter->save(); - painter->resetTransform(); - painter->translate(m_feedbackOriginPoint); - - QColor defaultColor(Qt::white); - QColor changeColor("#9999ff"); - - QFont font; - font.setFamily("Helvetica"); - font.setPixelSize(12); - painter->setFont(font); - - if (m_bubblePixmap.isNull()) - m_bubblePixmap = createBubblePixmap(); - painter->drawPixmap(-13, -7, m_bubblePixmap); - - if (m_beginXHasExpression) { - if(m_feedbackNode.hasBindingProperty("x")) - painter->setPen(defaultColor); - else - painter->setPen(Qt::red); - } else { - if (m_beginX != m_feedbackNode.instanceValue("x")) - painter->setPen(changeColor); - else - painter->setPen(defaultColor); - } - - painter->drawText(QPoint(8.0, 13.0), QString("x:")); - painter->drawText(QPoint(22.0, 13.0), m_feedbackNode.instanceValue("x").toString()); - - - if (m_beginYHasExpression) { - if(m_feedbackNode.hasBindingProperty("y")) - painter->setPen(defaultColor); - else - painter->setPen(Qt::red); - } else { - if (m_beginY != m_feedbackNode.instanceValue("y")) - painter->setPen(changeColor); - else - painter->setPen(defaultColor); - } - - painter->drawText(QPoint(60.0, 13.0), QString("y:")); - painter->drawText(QPoint(72.0, 13.0), m_feedbackNode.instanceValue("y").toString()); - - - if (m_beginWidthHasExpression) { - if(m_feedbackNode.hasBindingProperty("width")) - painter->setPen(defaultColor); - else - painter->setPen(Qt::red); - } else { - if (m_beginWidth != m_feedbackNode.instanceValue("width")) - painter->setPen(changeColor); - else - painter->setPen(defaultColor); - } - - painter->drawText(QPoint(8.0, 29.0), QString("w:")); - painter->drawText(QPoint(22.0, 29.0), m_feedbackNode.instanceValue("width").toString()); - - - if (m_beginHeightHasExpression) { - if(m_feedbackNode.hasBindingProperty("height")) - painter->setPen(defaultColor); - else - painter->setPen(Qt::red); - } else { - if (m_beginHeight != m_feedbackNode.instanceValue("height")) - painter->setPen(changeColor); - else - painter->setPen(defaultColor); - } - - painter->drawText(QPoint(60.0, 29.0), QString("h:")); - painter->drawText(QPoint(72.0, 29.0), m_feedbackNode.instanceValue("height").toString()); - - if (m_parentNode != m_feedbackNode.instanceParent()) { - painter->setPen(changeColor); - painter->drawText(QPoint(2.0, 39.0), QString("Parent changed")); - - } - - painter->restore(); +// if (!m_feedbackNode.isValid()) +// return; + +// if (m_feedbackOriginPoint.isNull()) +// return; + +// painter->save(); +// painter->resetTransform(); +// painter->translate(m_feedbackOriginPoint); + +// QColor defaultColor(Qt::white); +// QColor changeColor("#9999ff"); + +// QFont font; +// font.setFamily("Helvetica"); +// font.setPixelSize(12); +// painter->setFont(font); + +// if (m_bubblePixmap.isNull()) +// m_bubblePixmap = createBubblePixmap(); +// painter->drawPixmap(-13, -7, m_bubblePixmap); + +// if (m_beginXHasExpression) { +// if(m_feedbackNode.hasBindingProperty("x")) +// painter->setPen(defaultColor); +// else +// painter->setPen(Qt::red); +// } else { +// if (m_beginX != m_feedbackNode.instanceValue("x")) +// painter->setPen(changeColor); +// else +// painter->setPen(defaultColor); +// } + +// painter->drawText(QPoint(8.0, 13.0), QString("x:")); +// painter->drawText(QPoint(22.0, 13.0), m_feedbackNode.instanceValue("x").toString()); + + +// if (m_beginYHasExpression) { +// if(m_feedbackNode.hasBindingProperty("y")) +// painter->setPen(defaultColor); +// else +// painter->setPen(Qt::red); +// } else { +// if (m_beginY != m_feedbackNode.instanceValue("y")) +// painter->setPen(changeColor); +// else +// painter->setPen(defaultColor); +// } + +// painter->drawText(QPoint(60.0, 13.0), QString("y:")); +// painter->drawText(QPoint(72.0, 13.0), m_feedbackNode.instanceValue("y").toString()); + + +// if (m_beginWidthHasExpression) { +// if(m_feedbackNode.hasBindingProperty("width")) +// painter->setPen(defaultColor); +// else +// painter->setPen(Qt::red); +// } else { +// if (m_beginWidth != m_feedbackNode.instanceValue("width")) +// painter->setPen(changeColor); +// else +// painter->setPen(defaultColor); +// } + +// painter->drawText(QPoint(8.0, 29.0), QString("w:")); +// painter->drawText(QPoint(22.0, 29.0), m_feedbackNode.instanceValue("width").toString()); + + +// if (m_beginHeightHasExpression) { +// if(m_feedbackNode.hasBindingProperty("height")) +// painter->setPen(defaultColor); +// else +// painter->setPen(Qt::red); +// } else { +// if (m_beginHeight != m_feedbackNode.instanceValue("height")) +// painter->setPen(changeColor); +// else +// painter->setPen(defaultColor); +// } + +// painter->drawText(QPoint(60.0, 29.0), QString("h:")); +// painter->drawText(QPoint(72.0, 29.0), m_feedbackNode.instanceValue("height").toString()); + +// if (m_parentNode != m_feedbackNode.instanceParent()) { +// painter->setPen(changeColor); +// painter->drawText(QPoint(2.0, 39.0), QString("Parent changed")); + +// } + +// painter->restore(); } -void FormEditorGraphicsView::setFeedbackNode(const QmlItemNode &node) +void FormEditorGraphicsView::setFeedbackNode(const QmlItemNode & /*node*/) { - if (node == m_feedbackNode) - return; - - m_feedbackNode = node; - - if (m_feedbackNode.isValid()) { - m_beginX = m_feedbackNode.instanceValue("x"); - m_beginY = m_feedbackNode.instanceValue("y"); - m_beginWidth = m_feedbackNode.instanceValue("width"); - m_beginHeight = m_feedbackNode.instanceValue("height"); - m_parentNode = m_feedbackNode.instanceParent(); - m_beginLeftMargin = m_feedbackNode.instanceValue("anchors.leftMargin"); - m_beginRightMargin = m_feedbackNode.instanceValue("anchors.rightMargin"); - m_beginTopMargin = m_feedbackNode.instanceValue("anchors.topMargin"); - m_beginBottomMargin = m_feedbackNode.instanceValue("anchors.bottomMargin"); - m_beginXHasExpression = m_feedbackNode.hasBindingProperty("x"); - m_beginYHasExpression = m_feedbackNode.hasBindingProperty("y"); - m_beginWidthHasExpression = m_feedbackNode.hasBindingProperty("width"); - m_beginHeightHasExpression = m_feedbackNode.hasBindingProperty("height"); - } else { - m_beginX = QVariant(); - m_beginY = QVariant(); - m_beginWidth = QVariant(); - m_beginHeight = QVariant(); - m_parentNode = QmlObjectNode(); - m_beginLeftMargin = QVariant(); - m_beginRightMargin = QVariant(); - m_beginTopMargin = QVariant(); - m_beginBottomMargin = QVariant(); - m_beginXHasExpression = false; - m_beginYHasExpression = false; - m_beginWidthHasExpression = false; - m_beginHeightHasExpression = false; - } +// if (node == m_feedbackNode) +// return; + +// m_feedbackNode = node; + +// if (m_feedbackNode.isValid()) { +// m_beginX = m_feedbackNode.instanceValue("x"); +// m_beginY = m_feedbackNode.instanceValue("y"); +// m_beginWidth = m_feedbackNode.instanceValue("width"); +// m_beginHeight = m_feedbackNode.instanceValue("height"); +// m_parentNode = m_feedbackNode.instanceParent(); +// m_beginLeftMargin = m_feedbackNode.instanceValue("anchors.leftMargin"); +// m_beginRightMargin = m_feedbackNode.instanceValue("anchors.rightMargin"); +// m_beginTopMargin = m_feedbackNode.instanceValue("anchors.topMargin"); +// m_beginBottomMargin = m_feedbackNode.instanceValue("anchors.bottomMargin"); +// m_beginXHasExpression = m_feedbackNode.hasBindingProperty("x"); +// m_beginYHasExpression = m_feedbackNode.hasBindingProperty("y"); +// m_beginWidthHasExpression = m_feedbackNode.hasBindingProperty("width"); +// m_beginHeightHasExpression = m_feedbackNode.hasBindingProperty("height"); +// } else { +// m_beginX = QVariant(); +// m_beginY = QVariant(); +// m_beginWidth = QVariant(); +// m_beginHeight = QVariant(); +// m_parentNode = QmlObjectNode(); +// m_beginLeftMargin = QVariant(); +// m_beginRightMargin = QVariant(); +// m_beginTopMargin = QVariant(); +// m_beginBottomMargin = QVariant(); +// m_beginXHasExpression = false; +// m_beginYHasExpression = false; +// m_beginWidthHasExpression = false; +// m_beginHeightHasExpression = false; +// } } void FormEditorGraphicsView::drawBackground(QPainter *painter, const QRectF &rectangle) diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp index bedfac68d9..fd3d824a15 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp @@ -65,7 +65,8 @@ FormEditorItem::FormEditorItem(const QmlItemNode &qmlItemNode, FormEditorScene* m_qmlItemNode(qmlItemNode), m_borderWidth(1.0), m_highlightBoundingRect(false), - m_isContentVisible(true) + m_isContentVisible(true), + m_isFormEditorVisible(true) { setCacheMode(QGraphicsItem::DeviceCoordinateCache); setup(); @@ -195,6 +196,17 @@ bool FormEditorItem::isContentVisible() const return m_isContentVisible; } + +bool FormEditorItem::isFormEditorVisible() const +{ + return m_isFormEditorVisible; +} +void FormEditorItem::setFormEditorVisible(bool isVisible) +{ + m_isFormEditorVisible = isVisible; + setVisible(isVisible); +} + FormEditorItem::~FormEditorItem() { scene()->removeItemFromHash(this); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.h b/src/plugins/qmldesigner/components/formeditor/formeditoritem.h index 0232dd18a9..b3874cabf1 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.h @@ -106,6 +106,9 @@ public: void setContentVisible(bool visible); bool isContentVisible() const; + bool isFormEditorVisible() const; + void setFormEditorVisible(bool isVisible); + protected: AbstractFormEditorTool* tool() const; void paintBoundingRect(QPainter *painter) const; @@ -129,6 +132,7 @@ private: // variables double m_borderWidth; bool m_highlightBoundingRect; bool m_isContentVisible; + bool m_isFormEditorVisible; }; diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp index a2ed9a8554..08e63291d5 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp @@ -131,6 +131,38 @@ void FormEditorView::setupFormEditorItemTree(const QmlItemNode &qmlItemNode) setupFormEditorItemTree(nextNode.toQmlItemNode()); } +void FormEditorView::removeNodeFromScene(const QmlItemNode &qmlItemNode) +{ + if (qmlItemNode.isValid()) { + QList<QmlItemNode> nodeList; + nodeList.append(qmlItemNode.allSubModelNodes()); + nodeList.append(qmlItemNode); + + QList<FormEditorItem*> removedItemList; + removedItemList.append(scene()->itemsForQmlItemNodes(nodeList)); + m_currentTool->itemsAboutToRemoved(removedItemList); + + qDeleteAll(removedItemList); + } +} + +void FormEditorView::hideNodeFromScene(const QmlItemNode &qmlItemNode) +{ + if (qmlItemNode.isValid()) { + + FormEditorItem *item = m_scene->itemForQmlItemNode(qmlItemNode); + + QList<QmlItemNode> nodeList; + nodeList.append(qmlItemNode.allSubModelNodes()); + nodeList.append(qmlItemNode); + + QList<FormEditorItem*> removedItemList; + removedItemList.append(scene()->itemsForQmlItemNodes(nodeList)); + m_currentTool->itemsAboutToRemoved(removedItemList); + item->setFormEditorVisible(false); + } +} + void FormEditorView::nodeCreated(const ModelNode &createdNode) { QmlModelView::nodeCreated(createdNode); @@ -164,20 +196,7 @@ void FormEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode) { QmlItemNode qmlItemNode(removedNode); - if (qmlItemNode.isValid()) { - - FormEditorItem *item = m_scene->itemForQmlItemNode(qmlItemNode); - - QList<QmlItemNode> nodeList; - nodeList.append(qmlItemNode.allSubModelNodes()); - nodeList.append(qmlItemNode); - - QList<FormEditorItem*> removedItemList; - removedItemList.append(scene()->itemsForQmlItemNodes(nodeList)); - m_currentTool->itemsAboutToRemoved(removedItemList); - - delete item; - } + removeNodeFromScene(qmlItemNode); QmlModelView::nodeAboutToBeRemoved(removedNode); } @@ -227,8 +246,23 @@ void FormEditorView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& p QmlModelView::propertiesAboutToBeRemoved(propertyList); } + +static inline bool hasNodeSourceParent(const ModelNode &node) +{ + if (node.parentProperty().isValid() && node.parentProperty().parentModelNode().isValid()) { + ModelNode parent = node.parentProperty().parentModelNode(); + if (parent.nodeSourceType() != ModelNode::NodeWithoutSource) + return true; + return hasNodeSourceParent(parent); + } + return false; +} + void FormEditorView::nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange) { + if (hasNodeSourceParent(node)) + hideNodeFromScene(node); + QmlModelView::nodeReparented(node, newPropertyParent, oldPropertyParent, propertyChange); } @@ -435,7 +469,8 @@ void FormEditorView::auxiliaryDataChanged(const ModelNode &node, const QString & if (name == "invisible" && m_scene->hasItemForQmlItemNode(QmlItemNode(node))) { FormEditorItem *item(m_scene->itemForQmlItemNode(QmlItemNode(node))); bool isInvisible = data.toBool(); - item->setVisible(!isInvisible); + if (item->isFormEditorVisible()) + item->setVisible(!isInvisible); ModelNode newNode(node); if (isInvisible) newNode.deselectNode(); @@ -450,8 +485,6 @@ void FormEditorView::instancesCompleted(const QVector<ModelNode> &completedNodeL if (qmlItemNode.isValid() && scene()->hasItemForQmlItemNode(qmlItemNode)) { scene()->synchronizeParent(qmlItemNode); itemNodeList.append(scene()->itemForQmlItemNode(qmlItemNode)); - if (qmlItemNode.isRootModelNode()) - m_formEditorWidget->centerScene(); } } currentTool()->instancesCompleted(itemNodeList); @@ -465,8 +498,10 @@ void FormEditorView::instanceInformationsChange(const QMultiHash<ModelNode, Info QmlItemNode qmlItemNode(node); if (qmlItemNode.isValid() && scene()->hasItemForQmlItemNode(qmlItemNode)) { scene()->synchronizeTransformation(qmlItemNode); - if (qmlItemNode.isRootModelNode()) + if (qmlItemNode.isRootModelNode() && informationChangeHash.values(node).contains(Size)) { widget()->setRootItemRect(qmlItemNode.instanceBoundingRect()); + widget()->centerScene(); + } itemNodeList.append(scene()->itemForQmlItemNode(qmlItemNode)); } @@ -616,9 +651,11 @@ bool FormEditorView::isMoveToolAvailable() const return true; } -void FormEditorView::stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState) +void FormEditorView::actualStateChanged(const ModelNode &node) { - QmlModelView::stateChanged(newQmlModelState, oldQmlModelState); + QmlModelView::actualStateChanged(node); + + QmlModelState newQmlModelState(node); m_formEditorWidget->anchorToolAction()->setEnabled(newQmlModelState.isBaseState()); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.h b/src/plugins/qmldesigner/components/formeditor/formeditorview.h index b723c4bcef..f08ad2c2f6 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.h @@ -118,6 +118,8 @@ public: double spacing() const; void deActivateItemCreator(); + void actualStateChanged(const ModelNode &node); + public slots: void activateItemCreator(const QString &name); @@ -125,7 +127,6 @@ signals: void ItemCreatorDeActivated(); protected: - void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState); void reset(); protected slots: @@ -137,7 +138,8 @@ protected slots: private: //functions void setupFormEditorItemTree(const QmlItemNode &qmlItemNode); - + void removeNodeFromScene(const QmlItemNode &qmlItemNode); + void hideNodeFromScene(const QmlItemNode &qmlItemNode); private: //variables QWeakPointer<FormEditorWidget> m_formEditorWidget; diff --git a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp index 91926dc5df..ce855211c2 100644 --- a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp +++ b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp @@ -88,6 +88,7 @@ void MoveManipulator::setItems(const QList<FormEditorItem*> &itemList) } } + void MoveManipulator::synchronizeParent(const QList<FormEditorItem*> &itemList, const ModelNode &parentNode) { bool snapperUpdated = false; @@ -114,7 +115,6 @@ void MoveManipulator::synchronizeInstanceParent(const QList<FormEditorItem*> &it { if (m_view->model() && !m_itemList.isEmpty()) synchronizeParent(itemList, m_itemList.first()->qmlItemNode().instanceParent()); - } void MoveManipulator::updateHashes() diff --git a/src/plugins/qmldesigner/components/formeditor/movemanipulator.h b/src/plugins/qmldesigner/components/formeditor/movemanipulator.h index 671feef038..685bc1504e 100644 --- a/src/plugins/qmldesigner/components/formeditor/movemanipulator.h +++ b/src/plugins/qmldesigner/components/formeditor/movemanipulator.h @@ -71,6 +71,7 @@ public: void setItem(FormEditorItem* item); void synchronizeInstanceParent(const QList<FormEditorItem*> &itemList); void synchronizeParent(const QList<FormEditorItem*> &itemList, const ModelNode &parentNode); + void begin(const QPointF& beginPoint); void update(const QPointF& updatePoint, Snapping useSnapping, State stateToBeManipulated = UseActualState); void reparentTo(FormEditorItem *newParent); diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp index df58e0cda4..214a6c67ac 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp @@ -201,7 +201,9 @@ QWidget *DesignDocumentController::centralWidget() const QString DesignDocumentController::pathToQt() const { QtSupport::BaseQtVersion *activeQtVersion = QtSupport::QtVersionManager::instance()->version(m_d->qt_versionId); - if (activeQtVersion && (activeQtVersion->qtVersion().majorVersion > 3) && (activeQtVersion->supportsTargetId(Qt4ProjectManager::Constants::QT_SIMULATOR_TARGET_ID) || activeQtVersion->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID))) + if (activeQtVersion && (activeQtVersion->qtVersion().majorVersion > 3) + && (activeQtVersion->supportsTargetId(Qt4ProjectManager::Constants::QT_SIMULATOR_TARGET_ID) + || activeQtVersion->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID))) return activeQtVersion->versionInfo().value("QT_INSTALL_DATA"); return QString(); } diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.cpp index 9311e097fd..77a69272d7 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarycomponents.cpp @@ -129,7 +129,7 @@ void ItemLibraryTreeView::startDrag(Qt::DropActions /* supportedActions */) drag->setPreview(pixmap); drag->setPixmap(QIcon(pixmap).pixmap(128, 128)); QMimeData *mimeData = new QMimeData; - mimeData->setData("application/vnd.bauhaus.libraryresource", fileInfo.absoluteFilePath().toLatin1()); + mimeData->setData("application/vnd.bauhaus.libraryresource", fileInfo.absoluteFilePath().toUtf8()); drag->setMimeData(mimeData); drag->exec(); } diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp index d494e90878..7e7fad921c 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp @@ -933,9 +933,11 @@ QWidget *PropertyEditor::widget() return m_stackedWidget; } -void PropertyEditor::stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState) + +void PropertyEditor::actualStateChanged(const ModelNode &node) { - QmlModelView::stateChanged(newQmlModelState, oldQmlModelState); + QmlModelView::actualStateChanged(node); + QmlModelState newQmlModelState(node); Q_ASSERT(newQmlModelState.isValid()); if (debug) qDebug() << Q_FUNC_INFO << newQmlModelState.name(); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h index d626b21246..02a97954d2 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h @@ -111,12 +111,12 @@ public: void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList); void resetView(); + void actualStateChanged(const ModelNode &node); protected: void timerEvent(QTimerEvent *event); void otherPropertyChanged(const QmlObjectNode &, const QString &propertyName); void transformChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName); - void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState); void setupPane(const QString &typeName); void setValue(const QmlObjectNode &fxObjectNode, const QString &name, const QVariant &value); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index e4cde53158..277eb33189 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -308,14 +308,16 @@ void StatesEditorView::nodeInstancePropertyChanged(const ModelNode &node, const QmlModelView::nodeInstancePropertyChanged(node, propertyName); } -void StatesEditorView::stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState) +void StatesEditorView::actualStateChanged(const ModelNode &node) { + QmlModelState newQmlModelState(node); + if (newQmlModelState.isBaseState()) { m_statesEditorWidget->setCurrentStateInternalId(0); } else { m_statesEditorWidget->setCurrentStateInternalId(newQmlModelState.modelNode().internalId()); } - QmlModelView::stateChanged(newQmlModelState, oldQmlModelState); + QmlModelView::actualStateChanged(node); } void StatesEditorView::transformChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName) diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h index 3bfc7bb75c..89cd210752 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h @@ -67,7 +67,7 @@ public: // QmlModelView - void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState); + void actualStateChanged(const ModelNode &node); void transformChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName); void parentChanged(const QmlObjectNode &qmlObjectNode); void otherPropertyChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName); diff --git a/src/plugins/qmldesigner/designercore/include/abstractview.h b/src/plugins/qmldesigner/designercore/include/abstractview.h index 45b2a064d6..27c2b06af3 100644 --- a/src/plugins/qmldesigner/designercore/include/abstractview.h +++ b/src/plugins/qmldesigner/designercore/include/abstractview.h @@ -122,7 +122,6 @@ public: void emitRewriterBeginTransaction(); void emitRewriterEndTransaction(); void emitInstanceToken(const QString &token, int number, const QVector<ModelNode> &nodeVector); - void emitActualStateChanged(const ModelNode &node); void sendTokenToInstances(const QString &token, int number, const QVector<ModelNode> &nodeVector); @@ -178,6 +177,9 @@ public: NodeInstanceView *nodeInstanceView() const; RewriterView *rewriterView() const; + void setAcutalStateNode(const ModelNode &node); + ModelNode actualStateNode() const; + void resetView(); protected: diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h index 053da698e2..e4b1ba6e8b 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h +++ b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h @@ -130,8 +130,6 @@ public: NodeInstance activeStateInstance() const; - void activateState(const NodeInstance &instance); - void activateBaseState(); void valuesChanged(const ValuesChangedCommand &command); void pixmapChanged(const PixmapChangedCommand &command); @@ -151,6 +149,9 @@ signals: void qmlPuppetCrashed(); private: // functions + void activateState(const NodeInstance &instance); + void activateBaseState(); + NodeInstance rootNodeInstance() const; NodeInstance loadNode(const ModelNode &node); diff --git a/src/plugins/qmldesigner/designercore/include/qmlmodelview.h b/src/plugins/qmldesigner/designercore/include/qmlmodelview.h index d77bfbb6cb..ab36aa7211 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlmodelview.h +++ b/src/plugins/qmldesigner/designercore/include/qmlmodelview.h @@ -131,7 +131,6 @@ protected: virtual void transformChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName) ; virtual void parentChanged(const QmlObjectNode &qmlObjectNode); virtual void otherPropertyChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName); - virtual void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState); void activateState(const QmlModelState &state); diff --git a/src/plugins/qmldesigner/designercore/include/qmlstate.h b/src/plugins/qmldesigner/designercore/include/qmlstate.h index 897fa61ebf..ea8226ec9e 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlstate.h +++ b/src/plugins/qmldesigner/designercore/include/qmlstate.h @@ -77,8 +77,6 @@ protected: void addChangeSetIfNotExists(const ModelNode &node); static QmlModelState createBaseState(const QmlModelView *view); -private: - bool m_isBaseState; }; } //QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp index 8c8f1bef42..2bf1bed028 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp @@ -77,11 +77,11 @@ namespace QmlDesigner { -static bool hasQtQuick1(NodeInstanceView *nodeInstanceView) +static bool hasQtQuick2(NodeInstanceView *nodeInstanceView) { if (nodeInstanceView && nodeInstanceView->model()) { foreach (const Import &import ,nodeInstanceView->model()->imports()) { - if (import.url() == "QtQuick" && import.version().toDouble() < 2.0) + if (import.url() == "QtQuick" && import.version().toDouble() >= 2.0) return true; } } @@ -436,10 +436,10 @@ void NodeInstanceServerProxy::readThirdDataStream() QString NodeInstanceServerProxy::qmlPuppetApplicationName() const { QString appName; - if (hasQtQuick1(m_nodeInstanceView.data())) { - appName = QLatin1String("qmlpuppet"); - } else { + if (hasQtQuick2(m_nodeInstanceView.data())) { appName = QLatin1String("qml2puppet"); + } else { + appName = QLatin1String("qmlpuppet"); } #ifdef Q_OS_WIN appName += QLatin1String(".exe"); diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index b21add18e2..241663e708 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -172,6 +172,13 @@ void NodeInstanceView::modelAttached(Model *model) if (!isSkippedRootNode(rootModelNode())) nodeInstanceServer()->createScene(createCreateSceneCommand()); + + ModelNode stateNode = actualStateNode(); + if (stateNode.isValid() && stateNode.metaInfo().isSubclassOf("QtQuick.State", 1, 0)) { + NodeInstance newStateInstance = instanceForNode(stateNode); + activateState(newStateInstance); + } + } void NodeInstanceView::modelAboutToBeDetached(Model * model) @@ -210,6 +217,12 @@ void NodeInstanceView::restartProcess() if (!isSkippedRootNode(rootModelNode())) nodeInstanceServer()->createScene(createCreateSceneCommand()); + + ModelNode stateNode = actualStateNode(); + if (stateNode.isValid() && stateNode.metaInfo().isSubclassOf("QtQuick.State", 1, 0)) { + NodeInstance newStateInstance = instanceForNode(stateNode); + activateState(newStateInstance); + } } } @@ -539,8 +552,15 @@ void NodeInstanceView::rewriterEndTransaction() } -void NodeInstanceView::actualStateChanged(const ModelNode &/*node*/) +void NodeInstanceView::actualStateChanged(const ModelNode &node) { + NodeInstance newStateInstance = instanceForNode(node); + + if (newStateInstance.isValid() && node.metaInfo().isSubclassOf("QtQuick.State", 1, 0)) { + nodeInstanceView()->activateState(newStateInstance); + } else { + nodeInstanceView()->activateBaseState(); + } } @@ -693,16 +713,11 @@ NodeInstance NodeInstanceView::loadNode(const ModelNode &node) void NodeInstanceView::activateState(const NodeInstance &instance) { nodeInstanceServer()->changeState(ChangeStateCommand(instance.instanceId())); -// activateBaseState(); -// NodeInstance stateInstance(instance); -// stateInstance.activateState(); } void NodeInstanceView::activateBaseState() { nodeInstanceServer()->changeState(ChangeStateCommand(-1)); -// if (activeStateInstance().isValid()) -// activeStateInstance().deactivateState(); } void NodeInstanceView::removeRecursiveChildRelationship(const ModelNode &removedNode) @@ -1103,8 +1118,10 @@ QImage NodeInstanceView::statePreviewImage(const ModelNode &stateNode) const void NodeInstanceView::setPathToQt(const QString &pathToQt) { - m_pathToQt = pathToQt; - restartProcess(); + if (m_pathToQt != pathToQt) { + m_pathToQt = pathToQt; + restartProcess(); + } } void NodeInstanceView::statePreviewImagesChanged(const StatePreviewImageChangedCommand &command) diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index db2467886c..64cb00d08c 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -365,6 +365,7 @@ private: QString lookupName() const; QStringList lookupNameComponent() const; const QmlJS::Interpreter::QmlObjectValue *getNearestQmlObjectValue() const; + QString fullQualifiedImportAliasType() const; QString m_qualfiedTypeName; int m_majorVersion; @@ -486,7 +487,16 @@ const QmlJS::Interpreter::QmlObjectValue *NodeMetaInfoPrivate::getQmlObjectValue const QString package = getUrlFromType(m_qualfiedTypeName); const QString type = m_qualfiedTypeName.split('.').last(); + LanguageUtils::ComponentVersion version(9999, 9999); + //get the correct version + Document::Ptr doc = lookupContext()->document(); + const Interpreter::Context *context = lookupContext()->context(); + Interpreter::ImportInfo importInfo = context->imports(doc.data())->info(fullQualifiedImportAliasType(), context); + + if (importInfo.isValid()) + version = importInfo.version(); + QList<Interpreter::QmlObjectValue *> qmlObjectValues = lookupContext()->valueOwner()->cppQmlTypes().typesForImport(package, version); const Interpreter::QmlObjectValue *qmlValue = 0; foreach (Interpreter::QmlObjectValue *value, qmlObjectValues) { @@ -832,14 +842,11 @@ QString NodeMetaInfoPrivate::lookupName() const QStringList NodeMetaInfoPrivate::lookupNameComponent() const { - if (m_model && m_model->rewriterView()) { - QString tempString = model()->rewriterView()->convertTypeToImportAlias(m_qualfiedTypeName); - + QString tempString = fullQualifiedImportAliasType(); return tempString.split('.'); - } - return QStringList(); } + bool NodeMetaInfoPrivate::isValid() const { return m_isValid && lookupContext() && document(); @@ -890,6 +897,13 @@ const QmlJS::Interpreter::QmlObjectValue *NodeMetaInfoPrivate::getNearestQmlObje return getQmlObjectValue(); } +QString NodeMetaInfoPrivate::fullQualifiedImportAliasType() const +{ + if (m_model && m_model->rewriterView()) + return model()->rewriterView()->convertTypeToImportAlias(m_qualfiedTypeName); + return m_qualfiedTypeName; +} + } //namespace Internal NodeMetaInfo::NodeMetaInfo() : m_privateData(new Internal::NodeMetaInfoPrivate()) diff --git a/src/plugins/qmldesigner/designercore/model/abstractview.cpp b/src/plugins/qmldesigner/designercore/model/abstractview.cpp index b8f589b669..3b287d32b4 100644 --- a/src/plugins/qmldesigner/designercore/model/abstractview.cpp +++ b/src/plugins/qmldesigner/designercore/model/abstractview.cpp @@ -447,8 +447,9 @@ void AbstractView::emitRewriterEndTransaction() model()->m_d->notifyRewriterEndTransaction(); } -void AbstractView::emitActualStateChanged(const ModelNode &node) +void AbstractView::setAcutalStateNode(const ModelNode &node) { + Internal::WriteLocker locker(m_model.data()); if (model()) model()->m_d->notifyActualStateChanged(node); } @@ -460,4 +461,12 @@ void AbstractView::changeRootNodeType(const QString &type, int majorVersion, int m_model.data()->m_d->changeRootNodeType(type, majorVersion, minorVersion); } +ModelNode AbstractView::actualStateNode() const +{ + if (model()) + return ModelNode(m_model.data()->m_d->actualStateNode(), m_model.data(), const_cast<AbstractView*>(this)); + + return ModelNode(); +} + } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/model/model.cpp b/src/plugins/qmldesigner/designercore/model/model.cpp index 938026c3f9..72e8585f7d 100644 --- a/src/plugins/qmldesigner/designercore/model/model.cpp +++ b/src/plugins/qmldesigner/designercore/model/model.cpp @@ -605,6 +605,8 @@ void ModelPrivate::notifyActualStateChanged(const ModelNode &node) bool resetModel = false; QString description; + m_acutalStateNode = node.internalNode(); + try { if (rewriterView()) rewriterView()->actualStateChanged(ModelNode(node.internalNode(), model(), rewriterView())); @@ -1638,6 +1640,11 @@ bool ModelPrivate::isWriteLocked() const return m_writeLock; } +InternalNode::Pointer ModelPrivate::actualStateNode() const +{ + return m_acutalStateNode; +} + WriteLocker::WriteLocker(ModelPrivate *model) : m_model(model) diff --git a/src/plugins/qmldesigner/designercore/model/model_p.h b/src/plugins/qmldesigner/designercore/model/model_p.h index bc6ff14564..c0f49cc427 100644 --- a/src/plugins/qmldesigner/designercore/model/model_p.h +++ b/src/plugins/qmldesigner/designercore/model/model_p.h @@ -218,6 +218,8 @@ public: void setNodeInstanceView(NodeInstanceView *nodeInstanceView); NodeInstanceView *nodeInstanceView() const; + InternalNodePointer actualStateNode() const; + private: //functions void removePropertyWithoutNotification(const InternalPropertyPointer &property); void removeAllSubNodes(const InternalNodePointer &node); @@ -237,6 +239,8 @@ private: QHash<QString,InternalNodePointer> m_idNodeHash; QHash<qint32, InternalNodePointer> m_internalIdNodeHash; QSet<InternalNodePointer> m_nodeSet; + InternalNodePointer m_acutalStateNode; + InternalNodePointer m_rootInternalNode; diff --git a/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp b/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp index ceec3fbd21..01b5215905 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp @@ -63,12 +63,12 @@ void QmlModelView::setCurrentState(const QmlModelState &state) if (!state.isValid()) return; - emitActualStateChanged(state.modelNode()); + setAcutalStateNode(state.modelNode()); } QmlModelState QmlModelView::currentState() const { - return m_state; + return QmlModelState(actualStateNode()); } QmlModelState QmlModelView::baseState() const @@ -226,11 +226,14 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE inputModel->attachView(rewriterView.data()); if (rewriterView->errors().isEmpty() && rewriterView->rootModelNode().isValid()) { - rewriterView->rootModelNode().variantProperty("x") = propertyPairList.first().second; - rewriterView->rootModelNode().variantProperty("y") = propertyPairList.at(1).second; + ModelNode rootModelNode = rewriterView->rootModelNode(); + inputModel->detachView(rewriterView.data()); + + rootModelNode.variantProperty("x") = propertyPairList.first().second; + rootModelNode.variantProperty("y") = propertyPairList.at(1).second; ModelMerger merger(this); - newNode = merger.insertModel(rewriterView->rootModelNode()); + newNode = merger.insertModel(rootModelNode); } } @@ -331,14 +334,10 @@ bool QmlModelView::hasInstanceForModelNode(const ModelNode &modelNode) void QmlModelView::modelAttached(Model *model) { AbstractView::modelAttached(model); - m_state = QmlModelState(); - m_state = baseState(); - Q_ASSERT(m_state.isBaseState()); } void QmlModelView::modelAboutToBeDetached(Model *model) { - m_state = QmlModelState(); AbstractView::modelAboutToBeDetached(model); } @@ -441,20 +440,8 @@ void QmlModelView::rewriterEndTransaction() } -void QmlModelView::actualStateChanged(const ModelNode &node) +void QmlModelView::actualStateChanged(const ModelNode & /*node*/) { - QmlModelState newState(node); - QmlModelState oldState = currentState(); - - if (!newState.isValid()) - newState = baseState(); - - activateState(newState); - - m_state = newState; - - if (newState != oldState) - stateChanged(newState, oldState); } @@ -473,28 +460,6 @@ void QmlModelView::nodeInstancePropertyChanged(const ModelNode &node, const QStr otherPropertyChanged(qmlObjectNode, propertyName); } -void QmlModelView::activateState(const QmlModelState &state) -{ - if (!state.isValid()) - return; - - if (m_state == state) - return; - - m_state = state; //This is hacky. m_state should be controlled by the instances - //### todo: If the state thumbnail code gets refactored. - // this is not necessary anymore. - - - NodeInstance newStateInstance = instanceForModelNode(state.modelNode()); - - if (state.isBaseState()) { - nodeInstanceView()->activateBaseState(); - } else { - nodeInstanceView()->activateState(newStateInstance); - } -} - void QmlModelView::transformChanged(const QmlObjectNode &/*qmlObjectNode*/, const QString &/*propertyName*/) { } @@ -507,8 +472,5 @@ void QmlModelView::otherPropertyChanged(const QmlObjectNode &/*qmlObjectNode*/, { } -void QmlModelView::stateChanged(const QmlModelState &/*newQmlModelState*/, const QmlModelState &/*oldQmlModelState*/) -{ -} } //QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/model/qmlstate.cpp b/src/plugins/qmldesigner/designercore/model/qmlstate.cpp index 51d79cdd02..94e0ca22e8 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlstate.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlstate.cpp @@ -42,14 +42,12 @@ namespace QmlDesigner { QmlModelState::QmlModelState() - : QmlModelNodeFacade(), - m_isBaseState(false) + : QmlModelNodeFacade() { } QmlModelState::QmlModelState(const ModelNode &modelNode) - : QmlModelNodeFacade(modelNode), - m_isBaseState(false) + : QmlModelNodeFacade(modelNode) { } @@ -268,7 +266,7 @@ void QmlModelState::destroy() bool QmlModelState::isBaseState() const { - return m_isBaseState && modelNode().isRootNode(); + return !modelNode().isValid() || modelNode().isRootNode(); } QmlModelState QmlModelState::duplicate(const QString &name) const @@ -308,7 +306,7 @@ QmlModelStateGroup QmlModelState::stateGroup() const QmlModelState QmlModelState::createBaseState(const QmlModelView *view) { QmlModelState fxState(view->rootModelNode()); - fxState.m_isBaseState = true; + return fxState; } diff --git a/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp b/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp index c3ef3ebb48..6f7f70d488 100644 --- a/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp @@ -116,6 +116,7 @@ QString QmlTextGenerator::toQml(const AbstractProperty &property, int indentDept return QString(QLatin1String("\"%1\"")).arg(properColorName(value.value<QColor>())); case QVariant::Double: + return QString::number(value.toDouble(), 'g', 3); case QVariant::Int: case QVariant::LongLong: case QVariant::UInt: diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index 6001b0655c..d858fbd570 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -643,10 +643,24 @@ private: using namespace QmlDesigner; using namespace QmlDesigner::Internal; + +static inline bool smartVeryFuzzyCompare(QVariant value1, QVariant value2) +{ //we ignore slight changes on doubles and only check three digits + if ((value1.type() == QVariant::Double) && (value2.type() == QVariant::Double)) { + int a = value1.toDouble() * 1000; + int b = value2.toDouble() * 1000; + + if (qFuzzyCompare((qreal(a) / 1000), (qreal(b) / 1000))) { + return true; + } + } + return false; +} + static inline bool equals(const QVariant &a, const QVariant &b) { if (a.type() == QVariant::Double && b.type() == QVariant::Double) - return qFuzzyCompare(a.toDouble(), b.toDouble()); + return smartVeryFuzzyCompare(a.toDouble(), b.toDouble()); else return a == b; } @@ -750,6 +764,11 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH setupImports(doc, differenceHandler); + if (m_rewriterView->model()->imports().isEmpty()) { + const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::DiagnosticMessage::Error, AST::SourceLocation(0, 0, 0, 0), QCoreApplication::translate("QmlDesigner::TextToModelMerger error message", "No import statements found")); + errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName()))); + } + if (view()->checkSemanticErrors()) { Check check(doc, m_lookupContext->context()); check.setOptions(check.options() & ~Check::ErrCheckTypeErrors); diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp index a22e6e4676..9e43831f8c 100644 --- a/src/plugins/qmldesigner/designmodewidget.cpp +++ b/src/plugins/qmldesigner/designmodewidget.cpp @@ -557,6 +557,7 @@ void DesignModeWidget::setAutoSynchronization(bool sync) m_currentDesignDocumentController->loadMaster(m_currentTextEdit.data()); } else { m_currentDesignDocumentController->loadCurrentModel(); + m_componentView->resetView(); } QList<RewriterView::Error> errors = m_currentDesignDocumentController->qmlErrors(); diff --git a/src/plugins/qmldesigner/qtquickplugin/source/textedit.qml b/src/plugins/qmldesigner/qtquickplugin/source/textedit.qml index 87254f21c4..dc828f3114 100644 --- a/src/plugins/qmldesigner/qtquickplugin/source/textedit.qml +++ b/src/plugins/qmldesigner/qtquickplugin/source/textedit.qml @@ -32,7 +32,7 @@ import QtQuick 1.0 -Text { +TextEdit { width: 80 height: 20 text: qsTr("text edit") diff --git a/src/plugins/qmldesigner/qtquickplugin/source/textinput.qml b/src/plugins/qmldesigner/qtquickplugin/source/textinput.qml index 423e599993..6189edf942 100644 --- a/src/plugins/qmldesigner/qtquickplugin/source/textinput.qml +++ b/src/plugins/qmldesigner/qtquickplugin/source/textinput.qml @@ -32,7 +32,7 @@ import QtQuick 1.0 -Text { +TextInput { width: 80 height: 20 text: qsTr("text") diff --git a/src/plugins/qmljseditor/quicktoolbar.cpp b/src/plugins/qmljseditor/quicktoolbar.cpp index 50b8b553e4..6ca0e5150c 100644 --- a/src/plugins/qmljseditor/quicktoolbar.cpp +++ b/src/plugins/qmljseditor/quicktoolbar.cpp @@ -92,7 +92,10 @@ static inline const Interpreter::ObjectValue * getPropertyChangesTarget(Node *no return 0; } -QuickToolBar::QuickToolBar(QObject *parent) : ::QmlJS::IContextPane(parent), m_blockWriting(false) +QuickToolBar::QuickToolBar(QObject *parent) + : ::QmlJS::IContextPane(parent) + , m_editor(0) + , m_blockWriting(false) { m_node = 0; contextWidget(); diff --git a/src/plugins/qmljsinspector/qmljspropertyinspector.cpp b/src/plugins/qmljsinspector/qmljspropertyinspector.cpp index d4996f7c4c..67eb547f64 100644 --- a/src/plugins/qmljsinspector/qmljspropertyinspector.cpp +++ b/src/plugins/qmljsinspector/qmljspropertyinspector.cpp @@ -187,6 +187,30 @@ void ExpressionEdit::accept() // color chooser // ************************************************************************* +inline QString extendedNameFromColor(QColor color) +{ + int alphaValue = color.alpha(); + if (alphaValue < 255) + return QLatin1String("#") + QString("%1").arg(alphaValue, 2, 16, QChar('0')) + color.name().right(6) ; + else + return color.name(); +} + +inline QString extendedNameFromColor(QVariant color) { + return extendedNameFromColor(QColor(color.value<QColor>())); +} + +inline QColor colorFromExtendedName(QString name) { + QRegExp validator("#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})"); + if (validator.exactMatch(name)) { + return QColor(validator.cap(2).toInt(0,16), + validator.cap(3).toInt(0,16), + validator.cap(4).toInt(0,16), + validator.cap(1).toInt(0,16)); + } + return QColor(name); +} + ColorChooserDialog::ColorChooserDialog(const QString &title, QDialog *parent) : QDialog(parent) { @@ -303,9 +327,13 @@ void QmlJSPropertyInspector::propertyValueChanged(int debugId, const QByteArray for (int i = 0; i < m_model.rowCount(); i++) { if (m_model.data(m_model.index(i, 0), Qt::DisplayRole).toString() == propertyNameS && m_model.data(m_model.index(i, 0), Qt::UserRole).toInt() == debugId) { - QVariant oldData = m_model.data(m_model.index(i, 1), Qt::DisplayRole); - m_model.setData(m_model.index(i, 1), propertyValue.toString(), Qt::DisplayRole); - if (oldData != propertyValue) { + QString oldData = m_model.data(m_model.index(i, 1), Qt::DisplayRole).toString(); + QString newData = propertyValue.toString(); + if (QString(propertyValue.typeName()) == "QColor") + newData = extendedNameFromColor(propertyValue); + if (oldData != newData) { + m_model.setData(m_model.index(i, 1), newData, Qt::DisplayRole); + m_model.item(i, 1)->setToolTip(newData); m_model.item(i, 0)->setForeground(QBrush(Qt::red)); m_model.item(i, 1)->setForeground(QBrush(Qt::red)); m_model.item(i, 2)->setForeground(QBrush(Qt::red)); @@ -349,11 +377,16 @@ void QmlJSPropertyInspector::buildPropertyTree(const QDeclarativeDebugObjectRefe foreach (const QDeclarativeDebugPropertyReference &prop, obj.properties()) { QString propertyName = prop.name(); + QString propertyValue = prop.value().toString(); - if (cleanPropertyValue(prop.value().toString()).isEmpty()) + if (cleanPropertyValue(propertyValue).isEmpty()) continue; - addRow(propertyName, prop.value().toString(), prop.valueTypeName(), obj.debugId(), prop.hasNotifySignal()); + if (prop.valueTypeName() == "QColor") { + propertyValue = extendedNameFromColor(prop.value()); + } + + addRow(propertyName, propertyValue, prop.valueTypeName(), obj.debugId(), prop.hasNotifySignal()); } m_model.setHeaderData(0,Qt::Horizontal,QVariant("name")); @@ -403,12 +436,14 @@ void QmlJSPropertyInspector::addRow(const QString &name,const QString &value, co void QmlJSPropertyInspector::setColorIcon(int row) { QStandardItem *item = m_model.itemFromIndex(m_model.index(row, 1)); - QColor color = QColor(item->data(Qt::DisplayRole).toString()); + QColor color = colorFromExtendedName(item->data(Qt::DisplayRole).toString()); int recomendedLength = viewOptions().decorationSize.height() - 2; QPixmap colorpix(recomendedLength, recomendedLength); QPainter p(&colorpix); + if (color.alpha() != 255) + p.fillRect(1,1, recomendedLength -2, recomendedLength - 2, Qt::white); p.fillRect(1, 1, recomendedLength - 2, recomendedLength - 2, color); p.setPen(Qt::black); p.drawRect(0, 0, recomendedLength - 1, recomendedLength - 1); diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp b/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp index ddaa3d4d95..d9ac4a2ce9 100644 --- a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp +++ b/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp @@ -941,6 +941,8 @@ void Context2D::beginPainting() return; if (m_pixmap.width() != m_width || m_pixmap.height() != m_height) { + if (m_painter.isActive()) + m_painter.end(); m_pixmap = QPixmap(m_width, m_height); m_pixmap.fill(parent()->property("color").value<QColor>()); } diff --git a/src/plugins/qmlprofiler/qml/MainView.js b/src/plugins/qmlprofiler/qml/MainView.js index bd4752d071..128ea396a3 100644 --- a/src/plugins/qmlprofiler/qml/MainView.js +++ b/src/plugins/qmlprofiler/qml/MainView.js @@ -6,26 +6,25 @@ ** ** Contact: Nokia Corporation (info@qt.nokia.com) ** -** No Commercial Usage -** -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. ** ** GNU Lesser General Public License Usage ** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** ** If you have questions regarding the use of this file, please contact ** Nokia at info@qt.nokia.com. ** @@ -33,12 +32,9 @@ .pragma library -var values = [ ]; //events var ranges = [ ]; -var frameFps = [ ]; var xmargin = 0; var ymargin = 0; -var drawFpsGraph = false; var nestingDepth = []; var names = [ "Painting", "Compiling", "Creating", "Binding", "Handling Signal"] @@ -49,26 +45,12 @@ var xRayColors = [ "#6699CCB3", "#6699CCCC", "#6699B3CC", "#669999CC", "#66CC99B function reset() { - values = []; ranges = []; - frameFps = []; xmargin = 0; ymargin = 0; nestingDepth = []; } -function calcFps() -{ - if (drawFpsGraph) { - if (values.length) - frameFps = new Array(values.length - 1); - for (var i = 0; i < values.length - 1; ++i) { - var frameTime = (values[i + 1] - values[i]) / 1000000; - frameFps[i] = 1000 / frameTime; - } - } -} - //draw background of the graph function drawGraph(canvas, ctxt, region) { @@ -83,7 +65,7 @@ function drawGraph(canvas, ctxt, region) //draw the actual data to be graphed function drawData(canvas, ctxt, region) { - if (values.length == 0 && ranges.length == 0) + if (ranges.length == 0) return; var width = canvas.canvasSize.width - xmargin; @@ -115,24 +97,6 @@ function drawData(canvas, ctxt, region) highest[ranges[ii].type] = xx+size; } } - - if (drawFpsGraph) { - //draw fps overlay - var heightScale = height / 60; - ctxt.beginPath(); - ctxt.moveTo(0,0); - for (var i = 1; i < values.length; ++i) { - var xx = (values[i] - ranges[0].start) * spacing + xmargin; - ctxt.lineTo(xx, height - frameFps[i-1]*heightScale) - } - ctxt.lineTo(width, 0); - ctxt.closePath(); - var grad = ctxt.createLinearGradient(0, 0, 0, canvas.canvasSize.height); - grad.addColorStop(0, "rgba(255,128,128,.5)"); - grad.addColorStop(1, "rgba(255,0,0,.5)"); - ctxt.fillStyle = grad; - ctxt.fill(); - } } function plot(canvas, ctxt, region) @@ -143,7 +107,7 @@ function plot(canvas, ctxt, region) function xScale(canvas) { - if (values.length === 0 && ranges.length === 0) + if (ranges.length === 0) return; var width = canvas.canvasSize.width - xmargin; diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index b66c73396b..8664ed5b7f 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -38,6 +38,7 @@ Rectangle { id: root property bool dataAvailable: false; + property int eventCount: 0; // move the cursor in the editor signal updateCursorPosition @@ -53,6 +54,7 @@ Rectangle { Plotter.reset(); view.clearData(); root.dataAvailable = false; + root.eventCount = 0; rangeMover.x = 2 rangeMover.opacity = 0 } @@ -128,14 +130,6 @@ Rectangle { //handle debug data coming from C++ Connections { target: connection - onEvent: { - if (root.dataAvailable) { - root.clearData(); - } - - if (!root.dataAvailable && event === 0) //### only handle paint event - Plotter.values.push(time); - } onRange: { if (root.dataAvailable) { @@ -151,19 +145,22 @@ Rectangle { Plotter.ranges.push( { type: type, start: startTime, duration: length, label: data, fileName: fileName, line: line, nestingLevel: nestingInType, nestingDepth: Plotter.nestingDepth[type] } ); if (nestingInType == 1) Plotter.nestingDepth[type] = 1; + root.eventCount = Plotter.ranges.length; + } } onComplete: { root.dataAvailable = true; - Plotter.calcFps(); - view.visible = true; - view.setRanges(Plotter.ranges); - view.updateTimeline(); - canvas.requestPaint(); - rangeMover.x = 1 //### hack to get view to display things immediately - rangeMover.x = 0 - rangeMover.opacity = 1 + if (Plotter.ranges.length > 0) { + view.visible = true; + view.setRanges(Plotter.ranges); + view.updateTimeline(); + canvas.requestPaint(); + rangeMover.x = 1 //### hack to get view to display things immediately + rangeMover.x = 0 + rangeMover.opacity = 1 + } } onClear: { @@ -500,4 +497,8 @@ Rectangle { height: flick.height + labels.y visible: false } + + StatusDisplay { + anchors.centerIn: flick + } } diff --git a/src/plugins/qmlprofiler/qml/StatusDisplay.qml b/src/plugins/qmlprofiler/qml/StatusDisplay.qml new file mode 100644 index 0000000000..4653450f92 --- /dev/null +++ b/src/plugins/qmlprofiler/qml/StatusDisplay.qml @@ -0,0 +1,106 @@ +import QtQuick 1.0 +import "MainView.js" as Plotter + +Rectangle { + id: statusDisplay + + property real percentage : 0 + property int eventCount: root.eventCount + onEventCountChanged: { + if (state=="loading" && eventCount > 0 && root.elapsedTime > 0) { + percentage = Math.min(1.0, + (Plotter.ranges[Plotter.ranges.length-1].start - Plotter.ranges[0].start) / root.elapsedTime * 1e-9 ); + } + } + + width: 200 + height: displayColumn.height + 20 + + visible: false; + + color: "#CCD0CC" + border.width: 1 + border.color: "#AAAEAA"; + radius: 4 + + Column { + id: displayColumn + y: 10 + spacing: 5 + Text { + id: statusText + width: statusDisplay.width + horizontalAlignment: "AlignHCenter" + y: 10 + } + + Rectangle { + id: progressBar + + visible: false + + width: statusDisplay.width - 20 + height: 20 + x: 10 + color: "transparent" + border.width: 1 + border.color: "#AAAEAA" + Rectangle { + x: 1 + y: 1 + width: (parent.width-1) * statusDisplay.percentage + color: Qt.rgba(0.37 + 0.2*(1 - statusDisplay.percentage), 0.58, 0.37, 1); + height: parent.height-1 + } + } + } + + states: [ + // no data available + State { + when: (root.eventCount == 0) && !connection.recording; + PropertyChanges { + target: statusDisplay + visible: true + } + + PropertyChanges { + target: statusText + text: qsTr("No QML events recorded"); + } + }, + // running app + State { + when: connection.recording; + PropertyChanges { + target: statusDisplay + visible: true + } + + PropertyChanges { + target: statusText + text: qsTr("Profiling application"); + } + }, + // loading data + State { + name: "loading" + when: (!root.dataAvailable) && (root.eventCount > 0); + PropertyChanges { + target: statusDisplay + visible: true + } + + PropertyChanges { + target: statusText + text: qsTr("Loading data"); + } + + PropertyChanges { + target: progressBar + visible: true + } + } + ] + +} diff --git a/src/plugins/qmlprofiler/qml/TimeDisplay.qml b/src/plugins/qmlprofiler/qml/TimeDisplay.qml index 24dd47d8cf..3b5c67852c 100644 --- a/src/plugins/qmlprofiler/qml/TimeDisplay.qml +++ b/src/plugins/qmlprofiler/qml/TimeDisplay.qml @@ -103,7 +103,7 @@ TiledCanvas { } function drawBackgroundBars( ctxt, region ) { - var barHeight = labels.height / labels.rowCount; + var barHeight = Math.round(labels.height / labels.rowCount); var originY = labels.y for (var i=0; i<labels.rowCount; i++) { ctxt.fillStyle = i%2 ? "#f3f3f3" : "white" diff --git a/src/plugins/qmlprofiler/qml/qml.qrc b/src/plugins/qmlprofiler/qml/qml.qrc index acb92c1d77..f830de9ef8 100644 --- a/src/plugins/qmlprofiler/qml/qml.qrc +++ b/src/plugins/qmlprofiler/qml/qml.qrc @@ -15,5 +15,6 @@ <file>magnifier-plus.png</file> <file>recordOff.png</file> <file>recordOn.png</file> + <file>StatusDisplay.qml</file> </qresource> </RCC> diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro index 69ed6b3c45..300d910c74 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.pro +++ b/src/plugins/qmlprofiler/qmlprofiler.pro @@ -59,7 +59,8 @@ OTHER_FILES += \ qml/RangeDetails.qml \ qml/RangeMover.qml \ qml/MainView.js \ - qml/TimeDisplay.qml + qml/TimeDisplay.qml \ + qml/StatusDisplay.qml FORMS += \ qmlprofilerattachdialog.ui diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.cpp b/src/plugins/qmlprofiler/qmlprofilerengine.cpp index 27f34056ff..829f26ea5d 100644 --- a/src/plugins/qmlprofiler/qmlprofilerengine.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerengine.cpp @@ -173,6 +173,19 @@ void QmlProfilerEngine::stop() void QmlProfilerEngine::stopped() { + // user feedback + if (d->m_running && d->m_fetchingData) { + Core::ICore * const core = Core::ICore::instance(); + QMessageBox *killedWarning = new QMessageBox(core->mainWindow()); + killedWarning->setIcon(QMessageBox::Warning); + killedWarning->setWindowTitle(tr("QML Profiler")); + killedWarning->setText(tr("Application finished before loading profiled data.\n Please use the stop button instead.")); + killedWarning->setStandardButtons(QMessageBox::Ok); + killedWarning->setDefaultButton(QMessageBox::Ok); + killedWarning->setModal(false); + killedWarning->show(); + } + d->m_running = false; AnalyzerManager::stopTool(); // FIXME: Needed? emit finished(); @@ -265,7 +278,7 @@ void QmlProfilerEngine::wrongSetupMessageBoxFinished(int button) { if (button == QMessageBox::Help) { Core::HelpManager *helpManager = Core::HelpManager::instance(); - helpManager->handleHelpRequest("creator-qml-performance-monitor.html"); + helpManager->handleHelpRequest("qthelp://com.nokia.qtcreator/doc/creator-qml-performance-monitor.html"); } } diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.cpp b/src/plugins/qmlprofiler/qmlprofilereventview.cpp index dc75dd5cb8..b185616888 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilereventview.cpp @@ -125,11 +125,16 @@ void QmlProfilerEventStatistics::clear() d->m_rootHash.clear(); } -QList <QmlEventData *> QmlProfilerEventStatistics::getEventList() +QList <QmlEventData *> QmlProfilerEventStatistics::getEventList() const { return d->m_rootHash.values(); } +int QmlProfilerEventStatistics::eventCount() const +{ + return d->m_rootHash.size(); +} + void QmlProfilerEventStatistics::addRangedEvent(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line) { diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.h b/src/plugins/qmlprofiler/qmlprofilereventview.h index eac510a9e2..857c5058ae 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.h +++ b/src/plugins/qmlprofiler/qmlprofilereventview.h @@ -85,7 +85,8 @@ public: explicit QmlProfilerEventStatistics(QObject *parent = 0); ~QmlProfilerEventStatistics(); - QmlEventList getEventList(); + QmlEventList getEventList() const; + int eventCount() const; signals: void dataReady(); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index fd004b7ae0..a72872bce0 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -76,6 +76,7 @@ #include <QtGui/QTabWidget> #include <QtGui/QToolButton> #include <QtGui/QMessageBox> +#include <QtGui/QDockWidget> using namespace Analyzer; using namespace QmlProfiler::Internal; @@ -216,6 +217,7 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp connect(engine, SIGNAL(processRunning(int)), this, SLOT(connectClient(int))); connect(engine, SIGNAL(finished()), this, SLOT(disconnectClient())); + connect(engine, SIGNAL(finished()), this, SLOT(correctTimer())); connect(engine, SIGNAL(stopRecording()), this, SLOT(stopRecording())); connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(dataReceived())); connect(this, SIGNAL(connectionFailed()), engine, SLOT(finishProcess())); @@ -295,6 +297,11 @@ QWidget *QmlProfilerTool::createWidgets() QDockWidget *callerDock = AnalyzerManager::createDockWidget (this, tr("Callers"), d->m_callerView, Qt::BottomDockWidgetArea); + eventsDock->show(); + timelineDock->show(); + calleeDock->show(); + callerDock->show(); + mw->splitDockWidget(mw->toolBarDockWidget(), eventsDock, Qt::Vertical); mw->tabifyDockWidget(eventsDock, timelineDock); mw->tabifyDockWidget(timelineDock, calleeDock); @@ -329,8 +336,9 @@ QWidget *QmlProfilerTool::createWidgets() palette.setColor(QPalette::WindowText, Qt::white); timeLabel->setPalette(palette); timeLabel->setIndent(10); - + connect(d->m_traceWindow, SIGNAL(viewUpdated()), this, SLOT(correctTimer())); connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString))); + correctTimer(); layout->addWidget(timeLabel); toolbarWidget->setLayout(layout); @@ -426,6 +434,11 @@ void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber) } } +void QmlProfilerTool::correctTimer() { + if (d->m_statistics->eventCount() == 0) + updateTimer(0); +} + void QmlProfilerTool::updateTimer(qreal elapsedSeconds) { QString timeString = QString::number(elapsedSeconds,'f',1); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index c4520d5a65..490bbd2650 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -72,6 +72,7 @@ public slots: void gotoSourceLocation(const QString &fileUrl, int lineNumber); void updateTimer(qreal elapsedSeconds); + void correctTimer(); void clearDisplay(); diff --git a/src/plugins/qmlprofiler/timelineview.cpp b/src/plugins/qmlprofiler/timelineview.cpp index 79afcf2cc2..930672a847 100644 --- a/src/plugins/qmlprofiler/timelineview.cpp +++ b/src/plugins/qmlprofiler/timelineview.cpp @@ -184,7 +184,7 @@ void TimelineView::updateTimeline(bool updateStartX) // Show items int z = 0; - for (int i = maxsample-1; i >= minsample; --i) { + for (int i = maxsample; i >= minsample; --i) { QDeclarativeItem *item = 0; item = m_items.value(i); bool creating = false; diff --git a/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.cpp b/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.cpp index bb2dca563d..6e97e7b7fc 100644 --- a/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.cpp @@ -175,6 +175,11 @@ QList<BuildConfigurationInfo> Qt4SymbianTargetFactory::availableBuildConfigurati return tmp; } +bool Qt4SymbianTargetFactory::selectByDefault(const QString &id) const +{ + return id != QLatin1String(Constants::S60_EMULATOR_TARGET_ID); +} + QSet<QString> Qt4SymbianTargetFactory::targetFeatures(const QString & /*id*/) const { QSet<QString> features; diff --git a/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.h b/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.h index 92617456a3..2f5723bfc8 100644 --- a/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.h +++ b/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.h @@ -61,6 +61,7 @@ public: QList<ProjectExplorer::Task> reportIssues(const QString &proFile); QList<BuildConfigurationInfo> availableBuildConfigurations(const QString &id, const QString &proFilePath, const QtSupport::QtVersionNumber &minimumQtVersion); + bool selectByDefault(const QString &id) const; QSet<QString> targetFeatures(const QString &id) const; }; diff --git a/src/plugins/qt4projectmanager/qt-s60/symbianqtversion.cpp b/src/plugins/qt4projectmanager/qt-s60/symbianqtversion.cpp index 0f3fd9759c..02d568e572 100644 --- a/src/plugins/qt4projectmanager/qt-s60/symbianqtversion.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/symbianqtversion.cpp @@ -117,6 +117,11 @@ bool SymbianQtVersion::toolChainAvailable(const QString &id) const if (!isValid()) return false; if (id == QLatin1String(Constants::S60_EMULATOR_TARGET_ID)) { +#ifndef Q_OS_WIN + return false; +#endif + if (!QFileInfo(systemRoot() + QLatin1String("/Epoc32/release/winscw/udeb/epoc.exe")).exists()) + return false; QList<ProjectExplorer::ToolChain *> tcList = ProjectExplorer::ToolChainManager::instance()->toolChains(); foreach (ProjectExplorer::ToolChain *tc, tcList) { diff --git a/src/plugins/qt4projectmanager/qt4basetargetfactory.h b/src/plugins/qt4projectmanager/qt4basetargetfactory.h index 5a0301e768..633613854b 100644 --- a/src/plugins/qt4projectmanager/qt4basetargetfactory.h +++ b/src/plugins/qt4projectmanager/qt4basetargetfactory.h @@ -76,6 +76,7 @@ public: virtual QIcon iconForId(const QString &id) const = 0; virtual QSet<QString> targetFeatures(const QString &id) const = 0; + virtual bool selectByDefault(const QString &id) const; virtual ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id) = 0; virtual ProjectExplorer::Target *create(ProjectExplorer::Project *parent, const QString &id, const QList<BuildConfigurationInfo> &infos) = 0; diff --git a/src/plugins/qt4projectmanager/qt4target.cpp b/src/plugins/qt4projectmanager/qt4target.cpp index 28d523a3bc..2ec2103cc6 100644 --- a/src/plugins/qt4projectmanager/qt4target.cpp +++ b/src/plugins/qt4projectmanager/qt4target.cpp @@ -213,6 +213,12 @@ QList<ProjectExplorer::Task> Qt4BaseTargetFactory::reportIssues(const QString &p return QList<ProjectExplorer::Task>(); } +bool Qt4BaseTargetFactory::selectByDefault(const QString &id) const +{ + Q_UNUSED(id); + return true; +} + // ------------------------------------------------------------------------- // Qt4BaseTarget // ------------------------------------------------------------------------- diff --git a/src/plugins/qt4projectmanager/wizards/abstractmobileapp.cpp b/src/plugins/qt4projectmanager/wizards/abstractmobileapp.cpp index acac67cacb..1c78e43bce 100644 --- a/src/plugins/qt4projectmanager/wizards/abstractmobileapp.cpp +++ b/src/plugins/qt4projectmanager/wizards/abstractmobileapp.cpp @@ -59,7 +59,7 @@ const QString AbstractMobileApp::ProFileComment(QLatin1String("#")); const QString AbstractMobileApp::DeploymentPriFileName(QLatin1String("deployment.pri")); const QString AbstractMobileApp::FileChecksum(QLatin1String("checksum")); const QString AbstractMobileApp::FileStubVersion(QLatin1String("version")); -const int AbstractMobileApp::StubVersion = 5; +const int AbstractMobileApp::StubVersion = 6; AbstractMobileApp::AbstractMobileApp() : m_orientation(ScreenOrientationAuto) diff --git a/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp b/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp index ffdd150d38..9c15946f28 100644 --- a/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp +++ b/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp @@ -136,7 +136,8 @@ void TargetSetupPage::setupWidgets() selectTarget = !infos.isEmpty(); } else { if (!m_preferredFeatures.isEmpty()) { - selectTarget = factory->targetFeatures(id).contains(m_preferredFeatures); + selectTarget = factory->targetFeatures(id).contains(m_preferredFeatures) + && factory->selectByDefault(id); } } widget->setTargetSelected(selectTarget); diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 03a84f504b..191b7d4259 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -92,7 +92,7 @@ QList<ExampleItem> ExamplesListModel::parseExamples(QXmlStreamReader* reader, co item.imageUrl = attributes.value(QLatin1String("imagePath")).toString(); item.docUrl = attributes.value(QLatin1String("docUrl")).toString(); } else if (reader->name() == QLatin1String("fileToOpen")) { - item.filesToOpen.append(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement)); + item.filesToOpen.append(projectsOffset + '/' + reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement)); } else if (reader->name() == QLatin1String("description")) { item.description = reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement); } else if (reader->name() == QLatin1String("tags")) { @@ -132,7 +132,7 @@ QList<ExampleItem> ExamplesListModel::parseDemos(QXmlStreamReader* reader, const item.imageUrl = attributes.value(QLatin1String("imageUrl")).toString(); item.docUrl = attributes.value(QLatin1String("docUrl")).toString(); } else if (reader->name() == QLatin1String("fileToOpen")) { - item.filesToOpen.append(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement)); + item.filesToOpen.append(projectsOffset + '/' + reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement)); } else if (reader->name() == QLatin1String("description")) { item.description = reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement); } else if (reader->name() == QLatin1String("tags")) { @@ -171,7 +171,7 @@ QList<ExampleItem> ExamplesListModel::parseTutorials(QXmlStreamReader* reader, c item.imageUrl = attributes.value(QLatin1String("imageUrl")).toString(); item.docUrl = attributes.value(QLatin1String("docUrl")).toString(); } else if (reader->name() == QLatin1String("fileToOpen")) { - item.filesToOpen.append(reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement)); + item.filesToOpen.append(projectsOffset + '/' + reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement)); } else if (reader->name() == QLatin1String("description")) { item.description = reader->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement); } else if (reader->name() == QLatin1String("tags")) { @@ -192,7 +192,7 @@ QList<ExampleItem> ExamplesListModel::parseTutorials(QXmlStreamReader* reader, c return tutorials; } -void ExamplesListModel::readNewsItems(const QString &examplesPath, const QString &demosPath, const QString & /* sourcePath */) +void ExamplesListModel::readNewsItems(const QString &examplesPath, const QString &demosPath, const QString & sourcePath) { clear(); foreach (const QString exampleSource, exampleSources()) { @@ -207,9 +207,18 @@ void ExamplesListModel::readNewsItems(const QString &examplesPath, const QString QDir examplesDir(offsetPath); QDir demosDir(offsetPath); if (offsetPath.startsWith(Core::ICore::instance()->resourcePath())) { - // Try to get dir from first Qt Version - examplesDir = examplesPath; - demosDir = demosPath; + // Try to get dir from first Qt Version, based on the Qt source directory + // at first, since examplesPath / demosPath points at the build directory + QString sourceBasedExamplesPath = sourcePath + QLatin1String("/examples"); + QString sourceBasedDemosPath = sourcePath + QLatin1String("/demos"); + examplesDir = sourceBasedExamplesPath; + demosDir = sourceBasedDemosPath; + // SDK case, folders might be called sth else (e.g. 'Examples' with uppercase E) + // but examplesPath / demosPath is correct + if (!examplesDir.exists() || !demosDir.exists()) { + examplesDir = examplesPath; + demosDir = demosPath; + } } QXmlStreamReader reader(&exampleFile); @@ -350,7 +359,7 @@ void ExamplesListModel::helpInitialized() disconnect(this, SLOT(cacheExamplesPath(QString, QString, QString))); connect(QtVersionManager::instance(), SIGNAL(updateExamples(QString,QString,QString)), SLOT(readNewsItems(QString,QString,QString))); - readNewsItems(m_cache.examplesPath, m_cache.demosPath, m_cache.examplesPath); + readNewsItems(m_cache.examplesPath, m_cache.demosPath, m_cache.sourcePath); } diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp index 37f91240e0..eb225a2501 100644 --- a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp +++ b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp @@ -34,6 +34,9 @@ #include "exampleslistmodel.h" +#include <utils/pathchooser.h> +#include <utils/fileutils.h> + #include <coreplugin/coreplugin.h> #include <coreplugin/helpmanager.h> #include <projectexplorer/projectexplorer.h> @@ -49,6 +52,8 @@ namespace QtSupport { namespace Internal { +const char *C_FALLBACK_ROOT = "ProjectsFallbackRoot"; + class HelpImageProvider : public QDeclarativeImageProvider { public: @@ -79,7 +84,7 @@ GettingStartedWelcomePage::GettingStartedWelcomePage() void GettingStartedWelcomePage::facilitateQml(QDeclarativeEngine *engine) { m_engine = engine; - m_engine->addImageProvider("helpimage", new HelpImageProvider); + m_engine->addImageProvider(QLatin1String("helpimage"), new HelpImageProvider); m_examplesModel = new ExamplesListModel(this); connect (m_examplesModel, SIGNAL(tagsUpdated()), SLOT(updateTagsModel())); ExamplesListModelFilter *proxy = new ExamplesListModelFilter(this); @@ -89,8 +94,8 @@ void GettingStartedWelcomePage::facilitateQml(QDeclarativeEngine *engine) proxy->setFilterCaseSensitivity(Qt::CaseInsensitive); QDeclarativeContext *rootContenxt = m_engine->rootContext(); - rootContenxt->setContextProperty("examplesModel", proxy); - rootContenxt->setContextProperty("gettingStarted", this); + rootContenxt->setContextProperty(QLatin1String("examplesModel"), proxy); + rootContenxt->setContextProperty(QLatin1String("gettingStarted"), this); } void GettingStartedWelcomePage::openSplitHelp(const QUrl &help) @@ -103,19 +108,94 @@ QStringList GettingStartedWelcomePage::tagList() const return m_examplesModel->tags(); } +QString GettingStartedWelcomePage::copyToAlternativeLocation(const QFileInfo& proFileInfo, QStringList &filesToOpen) +{ + const QString projectDir = proFileInfo.canonicalPath(); + QDialog d(Core::ICore::instance()->mainWindow()); + QGridLayout *lay = new QGridLayout(&d); + QLabel *descrLbl = new QLabel; + d.setWindowTitle(tr("Copy Project to writable Location?")); + descrLbl->setTextFormat(Qt::RichText); + descrLbl->setWordWrap(true); + descrLbl->setText(tr("<p>The project you are about to open is located in the " + "write-protected location:</p><blockquote>%1</blockquote>" + "<p>Please select a writable location below and click \"Copy Project and Open\" " + "to open a modifiable copy of the project or click \"Keep Project and Open\" " + "to open the project in location.</p><p><b>Note:</b> You will not " + "be able to alter or compile your project in the current location.</p>") + .arg(QDir::toNativeSeparators(projectDir))); + lay->addWidget(descrLbl, 0, 0, 1, 2); + QLabel *txt = new QLabel(tr("&Location:")); + Utils::PathChooser *chooser = new Utils::PathChooser; + txt->setBuddy(chooser); + chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory); + QSettings *settings = Core::ICore::instance()->settings(); + chooser->setPath(settings->value( + QString::fromLatin1(C_FALLBACK_ROOT), QDir::homePath()).toString()); + lay->addWidget(txt, 1, 0); + lay->addWidget(chooser, 1, 1); + QDialogButtonBox *bb = new QDialogButtonBox; + connect(bb, SIGNAL(accepted()), &d, SLOT(accept())); + connect(bb, SIGNAL(rejected()), &d, SLOT(reject())); + QPushButton *copyBtn = bb->addButton(tr("&Copy Project and Open"), QDialogButtonBox::AcceptRole); + copyBtn->setDefault(true); + bb->addButton(tr("&Keep Project and Open"), QDialogButtonBox::RejectRole); + lay->addWidget(bb, 2, 0, 1, 2); + connect(chooser, SIGNAL(validChanged(bool)), copyBtn, SLOT(setEnabled(bool))); + if (d.exec() == QDialog::Accepted) { + QString exampleDirName = proFileInfo.dir().dirName(); + QString destBaseDir = chooser->path(); + settings->setValue(QString::fromLatin1(C_FALLBACK_ROOT), destBaseDir); + QDir toDirWithExamplesDir(destBaseDir); + if (toDirWithExamplesDir.cd(exampleDirName)) { + toDirWithExamplesDir.cdUp(); // step out, just to not be in the way + QMessageBox::warning(Core::ICore::instance()->mainWindow(), tr("Cannot Use Location"), + tr("The specified location already exists. " + "Please specify a valid location."), + QMessageBox::Ok, QMessageBox::NoButton); + return QString(); + } else { + QString error; + QString targetDir = destBaseDir + '/' + exampleDirName; + if (Utils::FileUtils::copyRecursively(projectDir, targetDir, &error)) { + // set vars to new location + QStringList::Iterator it; + for (it = filesToOpen.begin(); it != filesToOpen.end(); ++it) + it->replace(projectDir, targetDir); + + return targetDir+ '/' + proFileInfo.fileName(); + } else { + QMessageBox::warning(Core::ICore::instance()->mainWindow(), tr("Cannot Copy Project"), error); + } + + } + } + return QString(); + +} + void GettingStartedWelcomePage::openProject(const QString &projectFile, const QStringList &additionalFilesToOpen, const QUrl &help) { - qDebug() << projectFile << additionalFilesToOpen << help; + QString proFile = projectFile; + if (proFile.isEmpty()) + return; + + QStringList filesToOpen = additionalFilesToOpen; + QFileInfo proFileInfo(proFile); + // If the Qt is a distro Qt on Linux, it will not be writable, hence compilation will fail + if (!proFileInfo.isWritable()) + proFile = copyToAlternativeLocation(proFileInfo, filesToOpen); + // don't try to load help and files if loading the help request is being cancelled - if (ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(projectFile)) { - Core::ICore::instance()->openFiles(additionalFilesToOpen); + if (!proFile.isEmpty() && ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFile)) { + Core::ICore::instance()->openFiles(filesToOpen); Core::ICore::instance()->helpManager()->handleHelpRequest(help.toString()+QLatin1String("?view=split")); } } void GettingStartedWelcomePage::updateTagsModel() { - m_engine->rootContext()->setContextProperty("tagsList", m_examplesModel->tags()); + m_engine->rootContext()->setContextProperty(QLatin1String("tagsList"), m_examplesModel->tags()); emit tagsUpdated(); } diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.h b/src/plugins/qtsupport/gettingstartedwelcomepage.h index b67d62c5c9..ebe2318f9f 100644 --- a/src/plugins/qtsupport/gettingstartedwelcomepage.h +++ b/src/plugins/qtsupport/gettingstartedwelcomepage.h @@ -41,6 +41,7 @@ QT_BEGIN_NAMESPACE class QDeclarativeEngine; +class QFileInfo; QT_END_NAMESPACE namespace QtSupport { @@ -71,6 +72,7 @@ public slots: void updateTagsModel(); private: + QString copyToAlternativeLocation(const QFileInfo &fileInfo, QStringList &filesToOpen); ExamplesListModel *m_examplesModel; QDeclarativeEngine *m_engine; }; diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp index 40febd9410..5a3c5997d9 100644 --- a/src/plugins/qtsupport/qtoptionspage.cpp +++ b/src/plugins/qtsupport/qtoptionspage.cpp @@ -486,7 +486,7 @@ void QtOptionsPageWidget::showDebuggingBuildLog(const QTreeWidgetItem *currentIt const int currentItemIndex = indexForTreeItem(currentItem); if (currentItemIndex < 0) return; - BuildLogDialog *dialog = new BuildLogDialog(this); + BuildLogDialog *dialog = new BuildLogDialog(this->window()); dialog->setWindowTitle(tr("Debugging Helper Build Log for '%1'").arg(currentItem->text(0))); dialog->setText(currentItem->data(0, BuildLogRole).toString()); dialog->show(); diff --git a/src/plugins/qtsupport/qtsupport_dependencies.pri b/src/plugins/qtsupport/qtsupport_dependencies.pri index 7f68594566..e80b878076 100644 --- a/src/plugins/qtsupport/qtsupport_dependencies.pri +++ b/src/plugins/qtsupport/qtsupport_dependencies.pri @@ -1,2 +1,3 @@ include(../../plugins/projectexplorer/projectexplorer.pri) include(../../libs/qmljs/qmljs.pri) +include(../../libs/utils/utils.pri) diff --git a/src/plugins/remotelinux/deployablefilesperprofile.cpp b/src/plugins/remotelinux/deployablefilesperprofile.cpp index f571117fe9..396357d745 100644 --- a/src/plugins/remotelinux/deployablefilesperprofile.cpp +++ b/src/plugins/remotelinux/deployablefilesperprofile.cpp @@ -263,7 +263,7 @@ bool DeployableFilesPerProFile::addDesktopFile() } const QtSupport::BaseQtVersion * const version = qtVersion(); - QTC_ASSERT(version, return false); + QTC_ASSERT(version && version->isValid(), return false); QString remoteDir = QLatin1String("/usr/share/applications"); if (MaemoGlobal::osType(version->qmakeCommand()) == LinuxDeviceConfiguration::Maemo5OsType) remoteDir += QLatin1String("/hildon"); @@ -339,9 +339,15 @@ const QtSupport::BaseQtVersion *DeployableFilesPerProFile::qtVersion() const QString DeployableFilesPerProFile::proFileScope() const { const QtSupport::BaseQtVersion *const qv = qtVersion(); - QTC_ASSERT(qv, return QString()); - return QLatin1String(MaemoGlobal::osType(qv->qmakeCommand()) == LinuxDeviceConfiguration::Maemo5OsType - ? "maemo5" : "unix:!symbian:!maemo5"); + QTC_ASSERT(qv && qv->isValid(), return QString()); + const QString osType = MaemoGlobal::osType(qv->qmakeCommand()); + if (osType == LinuxDeviceConfiguration::Maemo5OsType) + return QLatin1String("maemo5"); + if (osType == LinuxDeviceConfiguration::HarmattanOsType) + return QLatin1String("contains(MEEGO_EDITION,harmattan)"); + if (osType == LinuxDeviceConfiguration::MeeGoOsType) + return QLatin1String("!isEmpty(MEEGO_VERSION_MAJOR):!contains(MEEGO_EDITION,harmattan)"); + return QLatin1String("unix:!symbian:!maemo5:isEmpty(MEEGO_VERSION_MAJOR)"); } QString DeployableFilesPerProFile::installPrefix() const @@ -352,7 +358,7 @@ QString DeployableFilesPerProFile::installPrefix() const QString DeployableFilesPerProFile::remoteIconDir() const { const QtSupport::BaseQtVersion *const qv = qtVersion(); - QTC_ASSERT(qv, return QString()); + QTC_ASSERT(qv && qv->isValid(), return QString()); return QString::fromLocal8Bit("/usr/share/icons/hicolor/%1x%1/apps") .arg(MaemoGlobal::applicationIconSize(MaemoGlobal::osType(qv->qmakeCommand()))); } diff --git a/src/plugins/remotelinux/deploymentinfo.cpp b/src/plugins/remotelinux/deploymentinfo.cpp index 90bd032d49..23b23f5b6e 100644 --- a/src/plugins/remotelinux/deploymentinfo.cpp +++ b/src/plugins/remotelinux/deploymentinfo.cpp @@ -71,6 +71,13 @@ void DeploymentInfo::createModels() { if (m_target->project()->activeTarget() != m_target) return; + if (!m_target->activeBuildConfiguration() || !m_target->activeBuildConfiguration()->qtVersion() + || !m_target->activeBuildConfiguration()->qtVersion()->isValid()) { + beginResetModel(); + m_listModels.clear(); + endResetModel(); + return; + } const Qt4ProFileNode *const rootNode = m_target->qt4Project()->rootProjectNode(); if (!rootNode || rootNode->parseInProgress()) // Can be null right after project creation by wizard. diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp index 51102702bf..9876010ca4 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp @@ -80,7 +80,7 @@ bool GenericLinuxDeviceConfigurationWizardSetupPage::isComplete() const { return !configurationName().isEmpty() && !hostName().isEmpty() && !userName().isEmpty() && (authenticationType() == SshConnectionParameters::AuthenticationByPassword - || !m_d->ui.privateKeyPathChooser->isValid()); + || m_d->ui.privateKeyPathChooser->isValid()); } QString GenericLinuxDeviceConfigurationWizardSetupPage::configurationName() const diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardsetuppage.ui b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardsetuppage.ui index c2638dc9ce..59c98b15d2 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardsetuppage.ui +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardsetuppage.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>542</width> - <height>201</height> + <width>564</width> + <height>207</height> </rect> </property> <property name="windowTitle"> @@ -71,7 +71,7 @@ <item row="2" column="0"> <widget class="QLabel" name="userNameLabel"> <property name="text"> - <string>User name:</string> + <string>The user name to log into the device:</string> </property> </widget> </item> @@ -98,7 +98,7 @@ <item row="3" column="0"> <widget class="QLabel" name="label"> <property name="text"> - <string>Authentication type:</string> + <string>The authentication type:</string> </property> </widget> </item> @@ -136,7 +136,7 @@ <item row="4" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> - <string>Password:</string> + <string>The user's password:</string> </property> </widget> </item> @@ -167,7 +167,7 @@ <item row="5" column="0"> <widget class="QLabel" name="label_3"> <property name="text"> - <string>Private key:</string> + <string>The file containing the user's private key:</string> </property> </widget> </item> diff --git a/src/plugins/remotelinux/linuxdevicefactoryselectiondialog.ui b/src/plugins/remotelinux/linuxdevicefactoryselectiondialog.ui index b3b2490cf1..bb394e4f67 100644 --- a/src/plugins/remotelinux/linuxdevicefactoryselectiondialog.ui +++ b/src/plugins/remotelinux/linuxdevicefactoryselectiondialog.ui @@ -17,12 +17,15 @@ <item> <widget class="QLabel" name="label"> <property name="text"> - <string>Available wizards:</string> + <string>Available device types:</string> </property> </widget> </item> <item> <widget class="QListWidget" name="listWidget"> + <property name="selectionBehavior"> + <enum>QAbstractItemView::SelectRows</enum> + </property> <property name="resizeMode"> <enum>QListView::Adjust</enum> </property> @@ -30,7 +33,7 @@ <bool>true</bool> </property> <property name="wordWrap"> - <bool>true</bool> + <bool>false</bool> </property> </widget> </item> diff --git a/src/plugins/remotelinux/maemodeviceconfigwizard.cpp b/src/plugins/remotelinux/maemodeviceconfigwizard.cpp index 969515a75c..4ee65e3ab2 100644 --- a/src/plugins/remotelinux/maemodeviceconfigwizard.cpp +++ b/src/plugins/remotelinux/maemodeviceconfigwizard.cpp @@ -32,7 +32,6 @@ #include "maemodeviceconfigwizard.h" #include "ui_maemodeviceconfigwizardkeycreationpage.h" #include "ui_maemodeviceconfigwizardkeydeploymentpage.h" -#include "ui_maemodeviceconfigwizardlogindatapage.h" #include "ui_maemodeviceconfigwizardpreviouskeysetupcheckpage.h" #include "ui_maemodeviceconfigwizardreusekeyscheckpage.h" #include "ui_maemodeviceconfigwizardstartpage.h" @@ -86,8 +85,8 @@ struct WizardData }; enum PageId { - StartPageId, LoginDataPageId, PreviousKeySetupCheckPageId, - ReuseKeysCheckPageId, KeyCreationPageId, KeyDeploymentPageId, FinalPageId + StartPageId, PreviousKeySetupCheckPageId, ReuseKeysCheckPageId, KeyCreationPageId, + KeyDeploymentPageId, FinalPageId }; class MaemoDeviceConfigWizardStartPage : public QWizardPage @@ -174,67 +173,6 @@ private: const QScopedPointer<Ui::MaemoDeviceConfigWizardStartPage> m_ui; }; -class MaemoDeviceConfigWizardLoginDataPage : public QWizardPage -{ - Q_OBJECT - -public: - MaemoDeviceConfigWizardLoginDataPage(WizardData &wizardData, QWidget *parent) - : QWizardPage(parent), - m_ui(new Ui::MaemoDeviceConfigWizardLoginDataPage), - m_wizardData(wizardData) - { - m_ui->setupUi(this); - setTitle(tr("Login Data")); - m_ui->privateKeyPathChooser->setExpectedKind(PathChooser::File); - setSubTitle(QLatin1String(" ")); // For Qt bug (background color) - connect(m_ui->userNameLineEdit, SIGNAL(textChanged(QString)), - SIGNAL(completeChanged())); - connect(m_ui->privateKeyPathChooser, SIGNAL(validChanged()), - SIGNAL(completeChanged())); - connect(m_ui->passwordButton, SIGNAL(toggled(bool)), - SLOT(handleAuthTypeChanged())); - } - - virtual bool isComplete() const - { - return !userName().isEmpty() - && (authType() == SshConnectionParameters::AuthenticationByPassword - || m_ui->privateKeyPathChooser->isValid()); - } - - virtual void initializePage() - { - m_ui->userNameLineEdit->setText(defaultUser(m_wizardData.osType)); - m_ui->passwordButton->setChecked(true); - m_ui->passwordLineEdit->clear(); - m_ui->privateKeyPathChooser->setPath(LinuxDeviceConfiguration::defaultPrivateKeyFilePath()); - handleAuthTypeChanged(); - } - - SshConnectionParameters::AuthenticationType authType() const - { - return m_ui->passwordButton->isChecked() - ? SshConnectionParameters::AuthenticationByPassword - : SshConnectionParameters::AuthenticationByKey; - } - - QString userName() const { return m_ui->userNameLineEdit->text().trimmed(); } - QString password() const { return m_ui->passwordLineEdit->text(); } - QString privateKeyFilePath() const { return m_ui->privateKeyPathChooser->path(); } - -private: - Q_SLOT void handleAuthTypeChanged() - { - m_ui->passwordLineEdit->setEnabled(authType() == SshConnectionParameters::AuthenticationByPassword); - m_ui->privateKeyPathChooser->setEnabled(authType() == SshConnectionParameters::AuthenticationByKey); - emit completeChanged(); - } - - const QScopedPointer<Ui::MaemoDeviceConfigWizardLoginDataPage> m_ui; - const WizardData &m_wizardData; -}; - class MaemoDeviceConfigWizardPreviousKeySetupCheckPage : public QWizardPage { Q_OBJECT @@ -578,7 +516,6 @@ struct MaemoDeviceConfigWizardPrivate { MaemoDeviceConfigWizardPrivate(QWidget *parent) : startPage(parent), - loginDataPage(wizardData, parent), previousKeySetupPage(parent), reuseKeysCheckPage(parent), keyCreationPage(parent), @@ -589,7 +526,6 @@ struct MaemoDeviceConfigWizardPrivate WizardData wizardData; MaemoDeviceConfigWizardStartPage startPage; - MaemoDeviceConfigWizardLoginDataPage loginDataPage; MaemoDeviceConfigWizardPreviousKeySetupCheckPage previousKeySetupPage; MaemoDeviceConfigWizardReuseKeysCheckPage reuseKeysCheckPage; MaemoDeviceConfigWizardKeyCreationPage keyCreationPage; @@ -603,7 +539,6 @@ MaemoDeviceConfigWizard::MaemoDeviceConfigWizard(QWidget *parent) { setWindowTitle(tr("New Device Configuration Setup")); setPage(StartPageId, &d->startPage); - setPage(LoginDataPageId, &d->loginDataPage); setPage(PreviousKeySetupCheckPageId, &d->previousKeySetupPage); setPage(ReuseKeysCheckPageId, &d->reuseKeysCheckPage); setPage(KeyCreationPageId, &d->keyCreationPage); @@ -658,14 +593,6 @@ int MaemoDeviceConfigWizard::nextId() const if (d->wizardData.deviceType == LinuxDeviceConfiguration::Emulator) return FinalPageId; return PreviousKeySetupCheckPageId; - case LoginDataPageId: - d->wizardData.userName = d->loginDataPage.userName(); - d->wizardData.authType = d->loginDataPage.authType(); - if (d->wizardData.authType == SshConnectionParameters::AuthenticationByPassword) - d->wizardData.password = d->loginDataPage.password(); - else - d->wizardData.privateKeyFilePath = d->loginDataPage.privateKeyFilePath(); - return FinalPageId; case PreviousKeySetupCheckPageId: if (d->previousKeySetupPage.keyBasedLoginWasSetup()) { d->wizardData.privateKeyFilePath diff --git a/src/plugins/remotelinux/maemodeviceconfigwizardlogindatapage.ui b/src/plugins/remotelinux/maemodeviceconfigwizardlogindatapage.ui deleted file mode 100644 index c36cf115b4..0000000000 --- a/src/plugins/remotelinux/maemodeviceconfigwizardlogindatapage.ui +++ /dev/null @@ -1,156 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>MaemoDeviceConfigWizardLoginDataPage</class> - <widget class="QWizardPage" name="MaemoDeviceConfigWizardLoginDataPage"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>423</width> - <height>127</height> - </rect> - </property> - <property name="windowTitle"> - <string>WizardPage</string> - </property> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="userNameLabel"> - <property name="text"> - <string>User name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLineEdit" name="userNameLineEdit"/> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Authentication type:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QRadioButton" name="passwordButton"> - <property name="text"> - <string>Password</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="radioButton"> - <property name="text"> - <string>Key</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Password:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLineEdit" name="passwordLineEdit"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Private key:</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="Utils::PathChooser" name="privateKeyPathChooser"/> - </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - <slots> - <signal>editingFinished()</signal> - <signal>browsingFinished()</signal> - </slots> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/remotelinux/maemodeviceconfigwizardstartpage.ui b/src/plugins/remotelinux/maemodeviceconfigwizardstartpage.ui index 062a89c4d1..4df4e3f850 100644 --- a/src/plugins/remotelinux/maemodeviceconfigwizardstartpage.ui +++ b/src/plugins/remotelinux/maemodeviceconfigwizardstartpage.ui @@ -102,7 +102,7 @@ <item row="4" column="0"> <widget class="QLabel" name="sshPortLabel"> <property name="text"> - <string>The SSH port:</string> + <string>The SSH server port:</string> </property> </widget> </item> diff --git a/src/plugins/remotelinux/maemoqemumanager.cpp b/src/plugins/remotelinux/maemoqemumanager.cpp index 862f55a240..4ec9bce9a4 100644 --- a/src/plugins/remotelinux/maemoqemumanager.cpp +++ b/src/plugins/remotelinux/maemoqemumanager.cpp @@ -87,9 +87,9 @@ MaemoQemuManager::MaemoQemuManager(QObject *parent) m_qemuStarterIcon.addFile(":/qt-maemo/images/qemu-stop.png", iconSize, QIcon::Normal, QIcon::On); - m_qemuAction = new QAction("Maemo Emulator", this); + m_qemuAction = new QAction("MeeGo Emulator", this); m_qemuAction->setIcon(m_qemuStarterIcon.pixmap(iconSize)); - m_qemuAction->setToolTip(tr("Start Maemo Emulator")); + m_qemuAction->setToolTip(tr("Start MeeGo Emulator")); connect(m_qemuAction, SIGNAL(triggered()), this, SLOT(startRuntime())); Core::ICore *core = Core::ICore::instance(); @@ -512,10 +512,10 @@ void MaemoQemuManager::updateStarterIcon(bool running) QString toolTip; if (running) { state = QIcon::On; - toolTip = tr("Stop Maemo Emulator"); + toolTip = tr("Stop MeeGo Emulator"); } else { state = QIcon::Off; - toolTip = tr("Start Maemo Emulator"); + toolTip = tr("Start MeeGo Emulator"); } m_qemuAction->setToolTip(toolTip); diff --git a/src/plugins/remotelinux/maemosettingspages.cpp b/src/plugins/remotelinux/maemosettingspages.cpp index b1380ff8ad..e22c78b295 100644 --- a/src/plugins/remotelinux/maemosettingspages.cpp +++ b/src/plugins/remotelinux/maemosettingspages.cpp @@ -181,7 +181,7 @@ QString MaemoQemuSettingsPage::id() const QString MaemoQemuSettingsPage::displayName() const { - return tr("Maemo Qemu Settings"); + return tr("MeeGo Qemu Settings"); } QString MaemoQemuSettingsPage::category() const diff --git a/src/plugins/remotelinux/qt4maemotarget.cpp b/src/plugins/remotelinux/qt4maemotarget.cpp index 92a675c7e8..3f836dac2c 100644 --- a/src/plugins/remotelinux/qt4maemotarget.cpp +++ b/src/plugins/remotelinux/qt4maemotarget.cpp @@ -321,7 +321,7 @@ AbstractQt4MaemoTarget::ActionStatus AbstractQt4MaemoTarget::createTemplates() QDir projectDir(project()->projectDirectory()); if (!projectDir.exists(PackagingDirName) && !projectDir.mkdir(PackagingDirName)) { - raiseError(tr("Error creating Maemo packaging directory '%1'.") + raiseError(tr("Error creating packaging directory '%1'.") .arg(PackagingDirName)); return ActionFailed; } @@ -331,15 +331,20 @@ AbstractQt4MaemoTarget::ActionStatus AbstractQt4MaemoTarget::createTemplates() return ActionFailed; if (actionStatus == ActionSuccessful) { const QStringList &files = packagingFilePaths(); - QMessageBox::StandardButton button - = QMessageBox::question(Core::ICore::instance()->mainWindow(), - tr("Add Packaging Files to Project"), - tr("Qt Creator has set up the following files to enable " - "packaging:\n %1\nDo you want to add them to the project?") - .arg(files.join(QLatin1String("\n "))), - QMessageBox::Yes | QMessageBox::No); - if (button == QMessageBox::Yes) - ProjectExplorer::ProjectExplorerPlugin::instance()->addExistingFiles(project()->rootProjectNode(), files); + if (!files.isEmpty()) { + const QString list = QLatin1String("<ul><li>") + + files.join(QLatin1String("</li><li>")) + QLatin1String("</li></ul>"); + QMessageBox::StandardButton button + = QMessageBox::question(Core::ICore::instance()->mainWindow(), + tr("Add Packaging Files to Project"), + tr("<html>Qt Creator has set up the following files to enable " + "packaging:\n %1\nDo you want to add them to the project?</html>") + .arg(list), QMessageBox::Yes | QMessageBox::No); + if (button == QMessageBox::Yes) { + ProjectExplorer::ProjectExplorerPlugin::instance() + ->addExistingFiles(project()->rootProjectNode(), files); + } + } } return actionStatus; } @@ -365,7 +370,7 @@ bool AbstractQt4MaemoTarget::initPackagingSettingsFromOtherTarget() void AbstractQt4MaemoTarget::raiseError(const QString &reason) { - QMessageBox::critical(0, tr("Error creating Maemo templates"), reason); + QMessageBox::critical(0, tr("Error creating MeeGo templates"), reason); } AbstractDebBasedQt4MaemoTarget::AbstractDebBasedQt4MaemoTarget(Qt4Project *parent, diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro index f6b668216f..efce567916 100644 --- a/src/plugins/remotelinux/remotelinux.pro +++ b/src/plugins/remotelinux/remotelinux.pro @@ -192,7 +192,6 @@ FORMS += \ maemodeviceconfigwizardkeycreationpage.ui \ maemodeviceconfigwizardkeydeploymentpage.ui \ maemodeployconfigurationwidget.ui \ - maemodeviceconfigwizardlogindatapage.ui \ linuxdevicefactoryselectiondialog.ui \ genericlinuxdeviceconfigurationwizardsetuppage.ui diff --git a/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp b/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp index f758c27bc9..f1cb9d383b 100644 --- a/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp +++ b/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp @@ -41,8 +41,6 @@ #include <utils/ssh/sshconnectionmanager.h> #include <utils/ssh/sshremoteprocess.h> -#include <QtCore/QFileInfo> - #include <limits> #define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state) @@ -65,7 +63,12 @@ RemoteLinuxApplicationRunner::RemoteLinuxApplicationRunner(QObject *parent, m_stopRequested(false), m_state(Inactive) { - m_procsToKill << QFileInfo(m_remoteExecutable).fileName(); + // Prevent pkill from matching our own pkill call. + QString pkillArg = m_remoteExecutable; + const int lastPos = pkillArg.count() - 1; + pkillArg.replace(lastPos, 1, QLatin1Char('[') + pkillArg.at(lastPos) + QLatin1Char(']')); + m_procsToKill << pkillArg; + connect(m_portsGatherer, SIGNAL(error(QString)), SLOT(handlePortsGathererError(QString))); connect(m_portsGatherer, SIGNAL(portListReady()), SLOT(handleUsedPortsAvailable())); } @@ -169,8 +172,13 @@ void RemoteLinuxApplicationRunner::cleanup() emit reportProgress(tr("Killing remote process(es)...")); - // pkill behaves differently on Fremantle and Harmattan. - const char *const killTemplate = "pkill -%2 '^%1$'; pkill -%2 '/%1$';"; + // Fremantle's busybox configuration is strange. + const char *killTemplate; + if (m_devConfig->osType() == LinuxDeviceConfiguration::Maemo5OsType) + killTemplate = "pkill -f -%2 %1;"; + else + killTemplate = "pkill -%2 -f %1;"; + QString niceKill; QString brutalKill; foreach (const QString &proc, m_procsToKill) { @@ -209,6 +217,7 @@ void RemoteLinuxApplicationRunner::handleCleanupFinished(int exitStatus) if (exitStatus != SshRemoteProcess::ExitedNormally) { emitError(tr("Initial cleanup failed: %1").arg(m_cleaner->errorString())); + emit remoteProcessFinished(InvalidExitCode); return; } diff --git a/src/plugins/remotelinux/remotelinuxruncontrol.cpp b/src/plugins/remotelinux/remotelinuxruncontrol.cpp index 0b9ed277e2..67dd6c3d00 100644 --- a/src/plugins/remotelinux/remotelinuxruncontrol.cpp +++ b/src/plugins/remotelinux/remotelinuxruncontrol.cpp @@ -79,7 +79,7 @@ void AbstractRemoteLinuxRunControl::start() RunControl::StopResult AbstractRemoteLinuxRunControl::stop() { runner()->stop(); - return StoppedSynchronously; + return AsynchronousStop; } void AbstractRemoteLinuxRunControl::handleSshError(const QString &error) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 1401ab7450..a14afe3254 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -51,6 +51,7 @@ #include "codeassistant.h" #include "defaultassistinterface.h" #include "convenience.h" +#include "texteditorsettings.h" #include <aggregation/aggregate.h> #include <coreplugin/actionmanager/actionmanager.h> @@ -4335,12 +4336,16 @@ void BaseTextEditorWidget::setTabPreferences(TabPreferences *tabPreferences) { if (d->m_tabPreferences) { disconnect(d->m_tabPreferences, SIGNAL(currentSettingsChanged(TextEditor::TabSettings)), - this, SLOT(setTabSettings(TextEditor::TabSettings))); + this, SLOT(setTabSettings(TextEditor::TabSettings))); + disconnect(d->m_tabPreferences, SIGNAL(destroyed()), + this, SLOT(onTabPreferencesDestroyed())); } d->m_tabPreferences = tabPreferences; if (d->m_tabPreferences) { connect(d->m_tabPreferences, SIGNAL(currentSettingsChanged(TextEditor::TabSettings)), this, SLOT(setTabSettings(TextEditor::TabSettings))); + connect(d->m_tabPreferences, SIGNAL(destroyed()), + this, SLOT(onTabPreferencesDestroyed())); setTabSettings(d->m_tabPreferences->currentSettings()); } } @@ -4351,15 +4356,37 @@ void BaseTextEditorWidget::setCodeStylePreferences(IFallbackPreferences *prefere if (d->m_codeStylePreferences) { disconnect(d->m_codeStylePreferences, SIGNAL(currentValueChanged(QVariant)), this, SLOT(slotCodeStyleSettingsChanged(QVariant))); + disconnect(d->m_codeStylePreferences, SIGNAL(destroyed()), + this, SLOT(onCodeStylePreferencesDestroyed())); } d->m_codeStylePreferences = preferences; if (d->m_codeStylePreferences) { connect(d->m_codeStylePreferences, SIGNAL(currentValueChanged(QVariant)), this, SLOT(slotCodeStyleSettingsChanged(QVariant))); + connect(d->m_codeStylePreferences, SIGNAL(destroyed()), + this, SLOT(onCodeStylePreferencesDestroyed())); slotCodeStyleSettingsChanged(d->m_codeStylePreferences->currentValue()); } } +void BaseTextEditorWidget::onTabPreferencesDestroyed() +{ + if (sender() != d->m_tabPreferences) + return; + // avoid failing disconnects, m_tabPreferences has already been reduced to QObject + d->m_tabPreferences = 0; + setTabPreferences(TextEditorSettings::instance()->tabPreferences(languageSettingsId())); +} + +void BaseTextEditorWidget::onCodeStylePreferencesDestroyed() +{ + if (sender() != d->m_codeStylePreferences) + return; + // avoid failing disconnects, m_codeStylePreferences has already been reduced to QObject + d->m_codeStylePreferences = 0; + setCodeStylePreferences(TextEditorSettings::instance()->codeStylePreferences(languageSettingsId())); +} + void BaseTextEditorWidget::slotCodeStyleSettingsChanged(const QVariant &) { diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index e7915545d6..ab64861b30 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -355,6 +355,8 @@ private slots: bool inFindScope(const QTextCursor &cursor); bool inFindScope(int selectionStart, int selectionEnd); void inSnippetMode(bool *active); + void onTabPreferencesDestroyed(); + void onCodeStylePreferencesDestroyed(); private: Internal::BaseTextEditorPrivate *d; diff --git a/src/plugins/valgrind/callgrindconfigwidget.cpp b/src/plugins/valgrind/callgrindconfigwidget.cpp deleted file mode 100644 index 280fd4353d..0000000000 --- a/src/plugins/valgrind/callgrindconfigwidget.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "callgrindconfigwidget.h" - -#include "ui_callgrindconfigwidget.h" - -#include "callgrindsettings.h" - -using namespace Valgrind::Internal; - -CallgrindConfigWidget::CallgrindConfigWidget(AbstractCallgrindSettings *settings, QWidget *parent) - : QWidget(parent) - , m_ui(new Ui::CallgrindConfigWidget) - , m_settings(settings) -{ - m_ui->setupUi(this); - - m_ui->enableCacheSim->setChecked(m_settings->enableCacheSim()); - connect(m_ui->enableCacheSim, SIGNAL(toggled(bool)), - m_settings, SLOT(setEnableCacheSim(bool))); - connect(m_settings, SIGNAL(enableCacheSimChanged(bool)), - m_ui->enableCacheSim, SLOT(setChecked(bool))); - - m_ui->enableBranchSim->setChecked(m_settings->enableBranchSim()); - connect(m_ui->enableBranchSim, SIGNAL(toggled(bool)), - m_settings, SLOT(setEnableBranchSim(bool))); - connect(m_settings, SIGNAL(enableBranchSimChanged(bool)), - m_ui->enableBranchSim, SLOT(setChecked(bool))); - - m_ui->collectSystime->setChecked(m_settings->collectSystime()); - connect(m_ui->collectSystime, SIGNAL(toggled(bool)), - m_settings, SLOT(setCollectSystime(bool))); - connect(m_settings, SIGNAL(collectSystimeChanged(bool)), - m_ui->collectSystime, SLOT(setChecked(bool))); - - m_ui->collectBusEvents->setChecked(m_settings->collectBusEvents()); - connect(m_ui->collectBusEvents, SIGNAL(toggled(bool)), - m_settings, SLOT(setCollectBusEvents(bool))); - connect(m_settings, SIGNAL(collectBusEventsChanged(bool)), - m_ui->collectBusEvents, SLOT(setChecked(bool))); - - m_ui->enableEventToolTips->setChecked(m_settings->enableEventToolTips()); - connect(m_ui->enableEventToolTips, SIGNAL(toggled(bool)), - m_settings, SLOT(setEnableEventToolTips(bool))); - connect(m_settings, SIGNAL(enableEventToolTipsChanged(bool)), - m_ui->enableEventToolTips, SLOT(setChecked(bool))); - - m_ui->minimumInclusiveCostRatio->setValue(m_settings->minimumInclusiveCostRatio()); - connect(m_ui->minimumInclusiveCostRatio, SIGNAL(valueChanged(double)), - m_settings, SLOT(setMinimumInclusiveCostRatio(double))); - connect(m_settings, SIGNAL(minimumInclusiveCostRatioChanged(double)), - m_ui->minimumInclusiveCostRatio, SLOT(setValue(double))); - - m_ui->visualisationMinimumInclusiveCostRatio->setValue(m_settings->visualisationMinimumInclusiveCostRatio()); - connect(m_ui->visualisationMinimumInclusiveCostRatio, SIGNAL(valueChanged(double)), - m_settings, SLOT(setVisualisationMinimumInclusiveCostRatio(double))); - connect(m_settings, SIGNAL(visualisationMinimumInclusiveCostRatioChanged(double)), - m_ui->visualisationMinimumInclusiveCostRatio, SLOT(setValue(double))); -} - -CallgrindConfigWidget::~CallgrindConfigWidget() -{ - delete m_ui; -} diff --git a/src/plugins/valgrind/callgrindconfigwidget.h b/src/plugins/valgrind/callgrindconfigwidget.h deleted file mode 100644 index b76495f7f2..0000000000 --- a/src/plugins/valgrind/callgrindconfigwidget.h +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef ANALYZER_INTERNAL_CALLGRINDCONFIGWIDGET_H -#define ANALYZER_INTERNAL_CALLGRINDCONFIGWIDGET_H - -#include <QtGui/QWidget> - -namespace Valgrind { -namespace Internal { - -namespace Ui { -class CallgrindConfigWidget; -} - -class AbstractCallgrindSettings; - -class CallgrindConfigWidget : public QWidget -{ -public: - CallgrindConfigWidget(AbstractCallgrindSettings *settings, QWidget *parent); - virtual ~CallgrindConfigWidget(); - -private: - Ui::CallgrindConfigWidget *m_ui; - AbstractCallgrindSettings *m_settings; -}; - -} // namespace Internal -} // namespace Valgrind - -#endif // ANALYZER_INTERNAL_CALLGRINDCONFIGWIDGET_H diff --git a/src/plugins/valgrind/callgrindconfigwidget.ui b/src/plugins/valgrind/callgrindconfigwidget.ui deleted file mode 100644 index 877c88a525..0000000000 --- a/src/plugins/valgrind/callgrindconfigwidget.ui +++ /dev/null @@ -1,166 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Valgrind::Internal::CallgrindConfigWidget</class> - <widget class="QWidget" name="Valgrind::Internal::CallgrindConfigWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>494</width> - <height>565</height> - </rect> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="2"> - <widget class="QGroupBox" name="memcheckOptions"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Profiling Options</string> - </property> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="minimumInclusiveCostRatioLabel"> - <property name="toolTip"> - <string>Limits the amount of results the profiler gives you. A lower limit will likely increase performance.</string> - </property> - <property name="text"> - <string>Result view: Show events with inclusive costs higher than:</string> - </property> - <property name="buddy"> - <cstring>minimumInclusiveCostRatio</cstring> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QDoubleSpinBox" name="minimumInclusiveCostRatio"> - <property name="suffix"> - <string>%</string> - </property> - <property name="decimals"> - <number>2</number> - </property> - <property name="maximum"> - <double>10.000000000000000</double> - </property> - <property name="singleStep"> - <double>0.100000000000000</double> - </property> - </widget> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QGroupBox" name="enableEventToolTips"> - <property name="title"> - <string>Show additional information for events in tooltips</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <widget class="QCheckBox" name="enableCacheSim"> - <property name="toolTip"> - <string><html><head/><body> -<p>Does full cache simulation.</p> -<p>By default, only instruction read accesses will be counted ("Ir").</p> -<p> -With cache simulation, further event counters are enabled: -<ul><li>Cache misses on instruction reads ("I1mr"/"I2mr")</li> -<li>Data read accesses ("Dr") and related cache misses ("D1mr"/"D2mr")</li> -<li>Data write accesses ("Dw") and related cache misses ("D1mw"/"D2mw")</li></ul> -</p> - -</body></html></string> - </property> - <property name="text"> - <string>Enable cache simulation</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="enableBranchSim"> - <property name="toolTip"> - <string><html><head/><body> -<p>Do branch prediction simulation.</p> -<p>Further event counters are enabled: </p> -<ul><li>Number of executed conditional branches and related predictor misses ( -"Bc"/"Bcm")</li> -<li>Executed indirect jumps and related misses of the jump address predictor ( -"Bi"/"Bim")</li></ul></body></html></string> - </property> - <property name="text"> - <string>Enable branch prediction simulation</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QCheckBox" name="collectSystime"> - <property name="toolTip"> - <string>Collect information for system call times.</string> - </property> - <property name="text"> - <string>Collect system call time</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QCheckBox" name="collectBusEvents"> - <property name="toolTip"> - <string>Collect the number of global bus events that are executed. The event type "Ge" is used for these events.</string> - </property> - <property name="text"> - <string>Collect global bus events</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="visualisationMinimumInclusiveCostRatioLabel"> - <property name="text"> - <string>Visualisation: Show events with inclusive costs higher than:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QDoubleSpinBox" name="visualisationMinimumInclusiveCostRatio"> - <property name="prefix"> - <string/> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <double>0.000000000000000</double> - </property> - <property name="maximum"> - <double>50.000000000000000</double> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/valgrind/callgrindengine.cpp b/src/plugins/valgrind/callgrindengine.cpp index 988c709329..72ead6e350 100644 --- a/src/plugins/valgrind/callgrindengine.cpp +++ b/src/plugins/valgrind/callgrindengine.cpp @@ -32,7 +32,7 @@ #include "callgrindengine.h" -#include "callgrindsettings.h" +#include "valgrindsettings.h" #include <valgrind/callgrind/callgrindcontroller.h> #include <valgrind/callgrind/callgrindparser.h> @@ -67,7 +67,7 @@ QStringList CallgrindEngine::toolArguments() const { QStringList arguments; - AbstractCallgrindSettings *callgrindSettings = m_settings->subConfig<AbstractCallgrindSettings>(); + ValgrindBaseSettings *callgrindSettings = m_settings->subConfig<ValgrindBaseSettings>(); QTC_ASSERT(callgrindSettings, return arguments); if (callgrindSettings->enableCacheSim()) diff --git a/src/plugins/valgrind/callgrindsettings.cpp b/src/plugins/valgrind/callgrindsettings.cpp deleted file mode 100644 index 58505cebdb..0000000000 --- a/src/plugins/valgrind/callgrindsettings.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "callgrindsettings.h" - -#include "callgrindconfigwidget.h" - -#include <QtCore/QDebug> - -using namespace Analyzer; - -static const char callgrindEnableCacheSimC[] = "Analyzer.Valgrind.Callgrind.EnableCacheSim"; -static const char callgrindEnableBranchSimC[] = "Analyzer.Valgrind.Callgrind.EnableBranchSim"; -static const char callgrindCollectSystimeC[] = "Analyzer.Valgrind.Callgrind.CollectSystime"; -static const char callgrindCollectBusEventsC[] = "Analyzer.Valgrind.Callgrind.CollectBusEvents"; -static const char callgrindEnableEventToolTipsC[] = "Analyzer.Valgrind.Callgrind.EnableEventToolTips"; -static const char callgrindMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.MinimumCostRatio"; -static const char callgrindVisualisationMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio"; - -static const char callgrindCycleDetectionC[] = "Analyzer.Valgrind.Callgrind.CycleDetection"; -static const char callgrindCostFormatC[] = "Analyzer.Valgrind.Callgrind.CostFormat"; - -namespace Valgrind { -namespace Internal { - -void AbstractCallgrindSettings::setEnableCacheSim(bool enable) -{ - if (m_enableCacheSim == enable) - return; - - m_enableCacheSim = enable; - emit enableCacheSimChanged(enable); -} - -void AbstractCallgrindSettings::setEnableBranchSim(bool enable) -{ - if (m_enableBranchSim == enable) - return; - - m_enableBranchSim = enable; - emit enableBranchSimChanged(enable); -} - -void AbstractCallgrindSettings::setCollectSystime(bool collect) -{ - if (m_collectSystime == collect) - return; - - m_collectSystime = collect; - emit collectSystimeChanged(collect); -} - -void AbstractCallgrindSettings::setCollectBusEvents(bool collect) -{ - if (m_collectBusEvents == collect) - return; - - m_collectBusEvents = collect; - emit collectBusEventsChanged(collect); -} - -void AbstractCallgrindSettings::setEnableEventToolTips(bool enable) -{ - if (m_enableEventToolTips == enable) - return; - - m_enableEventToolTips = enable; - emit enableEventToolTipsChanged(enable); -} - -void AbstractCallgrindSettings::setMinimumInclusiveCostRatio( - double minimumInclusiveCostRatio) -{ - if (m_minimumInclusiveCostRatio == minimumInclusiveCostRatio) - return; - - m_minimumInclusiveCostRatio = qBound(0.0, minimumInclusiveCostRatio, 100.0); - emit minimumInclusiveCostRatioChanged(minimumInclusiveCostRatio); -} - -void AbstractCallgrindSettings::setVisualisationMinimumInclusiveCostRatio( - double minimumInclusiveCostRatio) -{ - if (m_visualisationMinimumInclusiveCostRatio == minimumInclusiveCostRatio) - return; - - m_visualisationMinimumInclusiveCostRatio = qBound(0.0, minimumInclusiveCostRatio, 100.0); - emit visualisationMinimumInclusiveCostRatioChanged(minimumInclusiveCostRatio); -} - -QVariantMap AbstractCallgrindSettings::defaults() const -{ - QVariantMap map; - map.insert(QLatin1String(callgrindEnableCacheSimC), false); - map.insert(QLatin1String(callgrindEnableBranchSimC), false); - map.insert(QLatin1String(callgrindCollectSystimeC), false); - map.insert(QLatin1String(callgrindCollectBusEventsC), false); - map.insert(QLatin1String(callgrindEnableEventToolTipsC), true); - map.insert(QLatin1String(callgrindMinimumCostRatioC), 0.01); - map.insert(QLatin1String(callgrindVisualisationMinimumCostRatioC), 10.0); - return map; -} - -bool AbstractCallgrindSettings::fromMap(const QVariantMap &map) -{ - setIfPresent(map, QLatin1String(callgrindEnableCacheSimC), &m_enableCacheSim); - setIfPresent(map, QLatin1String(callgrindEnableBranchSimC), &m_enableBranchSim); - setIfPresent(map, QLatin1String(callgrindCollectSystimeC), &m_collectSystime); - setIfPresent(map, QLatin1String(callgrindCollectBusEventsC), &m_collectBusEvents); - setIfPresent(map, QLatin1String(callgrindEnableEventToolTipsC), &m_enableEventToolTips); - setIfPresent(map, QLatin1String(callgrindMinimumCostRatioC), &m_minimumInclusiveCostRatio); - setIfPresent(map, QLatin1String(callgrindVisualisationMinimumCostRatioC), - &m_visualisationMinimumInclusiveCostRatio); - return true; -} - -QVariantMap AbstractCallgrindSettings::toMap() const -{ - QVariantMap map; - map.insert(QLatin1String(callgrindEnableCacheSimC), m_enableCacheSim); - map.insert(QLatin1String(callgrindEnableBranchSimC), m_enableBranchSim); - map.insert(QLatin1String(callgrindCollectSystimeC), m_collectSystime); - map.insert(QLatin1String(callgrindCollectBusEventsC), m_collectBusEvents); - map.insert(QLatin1String(callgrindEnableEventToolTipsC), m_enableEventToolTips); - map.insert(QLatin1String(callgrindMinimumCostRatioC), m_minimumInclusiveCostRatio); - map.insert(QLatin1String(callgrindVisualisationMinimumCostRatioC), - m_visualisationMinimumInclusiveCostRatio); - return map; -} - -QString AbstractCallgrindSettings::id() const -{ - return QLatin1String("Analyzer.Valgrind.Settings.Callgrind"); -} - -QString AbstractCallgrindSettings::displayName() const -{ - return tr("Profiling"); -} - -QWidget *AbstractCallgrindSettings::createConfigWidget(QWidget *parent) -{ - return new CallgrindConfigWidget(this, parent); -} - - -QVariantMap CallgrindGlobalSettings::defaults() const -{ - QVariantMap map = AbstractCallgrindSettings::defaults(); - map.insert(QLatin1String(callgrindCostFormatC), CostDelegate::FormatRelative); - map.insert(QLatin1String(callgrindCycleDetectionC), true); - return map; -} - -bool CallgrindGlobalSettings::fromMap(const QVariantMap &map) -{ - AbstractCallgrindSettings::fromMap(map); - // special code as the default one does not cope with the enum properly - if (map.contains(QLatin1String(callgrindCostFormatC))) { - m_costFormat = static_cast<CostDelegate::CostFormat>(map.value(QLatin1String(callgrindCostFormatC)).toInt()); - } - setIfPresent(map, QLatin1String(callgrindCycleDetectionC), &m_detectCycles); - return true; -} - -QVariantMap CallgrindGlobalSettings::toMap() const -{ - QVariantMap map = AbstractCallgrindSettings::toMap(); - map.insert(QLatin1String(callgrindCostFormatC), m_costFormat); - map.insert(QLatin1String(callgrindCycleDetectionC), m_detectCycles); - return map; -} - -CostDelegate::CostFormat CallgrindGlobalSettings::costFormat() const -{ - return m_costFormat; -} - -void CallgrindGlobalSettings::setCostFormat(CostDelegate::CostFormat format) -{ - m_costFormat = format; - AnalyzerGlobalSettings::instance()->writeSettings(); -} - -bool CallgrindGlobalSettings::detectCycles() const -{ - return m_detectCycles; -} - -void CallgrindGlobalSettings::setDetectCycles(bool detect) -{ - m_detectCycles = detect; - AnalyzerGlobalSettings::instance()->writeSettings(); -} - -} // namespace Internal -} // namespace Valgrind diff --git a/src/plugins/valgrind/callgrindsettings.h b/src/plugins/valgrind/callgrindsettings.h deleted file mode 100644 index 1a81bf8712..0000000000 --- a/src/plugins/valgrind/callgrindsettings.h +++ /dev/null @@ -1,153 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef ANALYZER_INTERNAL_CALLGRINDSETTINGS_H -#define ANALYZER_INTERNAL_CALLGRINDSETTINGS_H - -#include "callgrindcostdelegate.h" - -#include <analyzerbase/analyzersettings.h> - -#include <QtCore/QString> - -namespace Valgrind { -namespace Internal { - -/** - * Generic callgrind settings - */ -class AbstractCallgrindSettings : public Analyzer::AbstractAnalyzerSubConfig -{ - Q_OBJECT - -public: - AbstractCallgrindSettings() {} - - bool enableCacheSim() const { return m_enableCacheSim; } - bool enableBranchSim() const { return m_enableBranchSim; } - bool collectSystime() const { return m_collectSystime; } - bool collectBusEvents() const { return m_collectBusEvents; } - bool enableEventToolTips() const { return m_enableEventToolTips; } - - /// \return Minimum cost ratio, range [0.0..100.0] - double minimumInclusiveCostRatio() const { return m_minimumInclusiveCostRatio; } - - /// \return Minimum cost ratio, range [0.0..100.0] - double visualisationMinimumInclusiveCostRatio() const { return m_visualisationMinimumInclusiveCostRatio; } - - // abstract virtual methods from base class - virtual bool fromMap(const QVariantMap &map); - - virtual QVariantMap defaults() const; - - virtual QString id() const; - virtual QString displayName() const; - virtual QWidget *createConfigWidget(QWidget *parent); - -public slots: - void setEnableCacheSim(bool enable); - void setEnableBranchSim(bool enable); - void setCollectSystime(bool collect); - void setCollectBusEvents(bool collect); - void setEnableEventToolTips(bool enable); - - /// \param minimumInclusiveCostRatio Minimum inclusive cost ratio, valid values are [0.0..100.0] - void setMinimumInclusiveCostRatio(double minimumInclusiveCostRatio); - - /// \param minimumInclusiveCostRatio Minimum inclusive cost ratio, valid values are [0.0..100.0] - void setVisualisationMinimumInclusiveCostRatio(double minimumInclusiveCostRatio); - -signals: - void enableCacheSimChanged(bool); - void enableBranchSimChanged(bool); - void collectSystimeChanged(bool); - void collectBusEventsChanged(bool); - void enableEventToolTipsChanged(bool); - void minimumInclusiveCostRatioChanged(double); - void visualisationMinimumInclusiveCostRatioChanged(double); - -protected: - virtual QVariantMap toMap() const; - -private: - bool m_enableCacheSim; - bool m_collectSystime; - bool m_collectBusEvents; - bool m_enableBranchSim; - bool m_enableEventToolTips; - double m_minimumInclusiveCostRatio; - double m_visualisationMinimumInclusiveCostRatio; -}; - -/** - * Global callgrind settings - */ -class CallgrindGlobalSettings : public AbstractCallgrindSettings -{ - Q_OBJECT - -public: - CallgrindGlobalSettings() {} - - virtual bool fromMap(const QVariantMap &map); - virtual QVariantMap defaults() const; - - CostDelegate::CostFormat costFormat() const; - bool detectCycles() const; - -public slots: - void setCostFormat(Valgrind::Internal::CostDelegate::CostFormat format); - void setDetectCycles(bool detect); - -protected: - virtual QVariantMap toMap() const; - -private: - CostDelegate::CostFormat m_costFormat; - bool m_detectCycles; -}; - -/** - * Per-project callgrind settings, saves a diff to the global suppression files list - */ -class CallgrindProjectSettings : public AbstractCallgrindSettings -{ - Q_OBJECT - -public: - CallgrindProjectSettings() {} -}; - -} // namespace Internal -} // namespace Valgrind - -#endif // ANALYZER_INTERNAL_CALLGRINDSETTINGS_H diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index d89632d6c7..d823560246 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -35,7 +35,6 @@ #include "callgrindcostdelegate.h" #include "callgrindcostview.h" #include "callgrindengine.h" -#include "callgrindsettings.h" #include "callgrindtextmark.h" #include "callgrindvisualisation.h" @@ -48,6 +47,7 @@ #include <valgrind/callgrind/callgrindproxymodel.h> #include <valgrind/callgrind/callgrindstackbrowser.h> #include <valgrind/valgrindplugin.h> +#include <valgrind/valgrindsettings.h> #include <analyzerbase/analyzermanager.h> #include <analyzerbase/analyzersettings.h> @@ -210,7 +210,7 @@ public: QAction *m_showCostsOfFunctionAction; QString m_toggleCollectFunction; - CallgrindGlobalSettings *m_settings; // Not owned + ValgrindGlobalSettings *m_settings; // Not owned }; @@ -249,7 +249,7 @@ CallgrindToolPrivate::CallgrindToolPrivate(CallgrindTool *parent) m_proxyModel->setFilterKeyColumn(DataModel::NameColumn); m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); - m_settings = AnalyzerGlobalSettings::instance()->subConfig<CallgrindGlobalSettings>(); + m_settings = AnalyzerGlobalSettings::instance()->subConfig<ValgrindGlobalSettings>(); connect(m_stackBrowser, SIGNAL(currentChanged()), SLOT(stackBrowserChanged())); connect(m_updateTimer, SIGNAL(timeout()), SLOT(updateFilterString())); @@ -520,7 +520,7 @@ QByteArray CallgrindTool::id() const QString CallgrindTool::displayName() const { - return tr("Valgrind Function Profile"); + return tr("Valgrind Function Profiler"); } QString CallgrindTool::description() const @@ -598,7 +598,7 @@ IAnalyzerEngine *CallgrindToolPrivate::createEngine(const AnalyzerStartParameter // apply project settings AnalyzerProjectSettings *analyzerSettings = runConfiguration->extraAspect<AnalyzerProjectSettings>(); - CallgrindProjectSettings *settings = analyzerSettings->subConfig<CallgrindProjectSettings>(); + ValgrindProjectSettings *settings = analyzerSettings->subConfig<ValgrindProjectSettings>(); QTC_ASSERT(settings, return engine) QTC_ASSERT(m_visualisation, return engine); diff --git a/src/plugins/valgrind/memcheck.pro b/src/plugins/valgrind/memcheck.pro deleted file mode 100644 index e6843ed307..0000000000 --- a/src/plugins/valgrind/memcheck.pro +++ /dev/null @@ -1,32 +0,0 @@ -TEMPLATE = lib -TARGET = Memcheck - -DEFINES += MEMCHECK_LIBRARY - -include(../../qtcreatorplugin.pri) -include(memcheck_dependencies.pri) - -# Memcheck files - -HEADERS += \ - memcheckplugin.h \ - memcheck_global.h \ - memchecktool.h \ - memcheckengine.h \ - memcheckerrorview.h \ - memchecksettings.h \ - memcheckconfigwidget.h \ - suppressiondialog.h - -SOURCES += \ - memcheckplugin.cpp \ - memchecktool.cpp \ - memcheckengine.cpp \ - memcheckerrorview.cpp \ - memchecksettings.cpp \ - memcheckconfigwidget.cpp \ - suppressiondialog.cpp - -FORMS += \ - suppressiondialog.ui \ - memcheckconfigwidget.ui \ diff --git a/src/plugins/valgrind/memcheckconfigwidget.cpp b/src/plugins/valgrind/memcheckconfigwidget.cpp deleted file mode 100644 index d573178764..0000000000 --- a/src/plugins/valgrind/memcheckconfigwidget.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator Instrumentation Tools -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Author: Milian Wolff, KDAB (milian.wolff@kdab.com) -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "memcheckconfigwidget.h" - -#include "ui_memcheckconfigwidget.h" - -#include "memchecksettings.h" - -#include <utils/qtcassert.h> - -#include <QtGui/QStandardItemModel> -#include <QtGui/QFileDialog> -#include <QtCore/QDebug> - -namespace Valgrind { -namespace Internal { - -MemcheckConfigWidget::MemcheckConfigWidget(AbstractMemcheckSettings *settings, QWidget *parent) - : QWidget(parent), - m_settings(settings), - m_model(new QStandardItemModel(this)), - m_ui(new Ui::MemcheckConfigWidget) -{ - m_ui->setupUi(this); - - m_ui->suppressionList->setModel(m_model); - m_ui->suppressionList->setSelectionMode(QAbstractItemView::MultiSelection); - - connect(m_ui->addSuppression, SIGNAL(clicked()), - this, SLOT(slotAddSuppression())); - connect(m_ui->removeSuppression, SIGNAL(clicked()), - this, SLOT(slotRemoveSuppression())); - - m_ui->numCallers->setValue(m_settings->numCallers()); - connect(m_ui->numCallers, SIGNAL(valueChanged(int)), m_settings, SLOT(setNumCallers(int))); - connect(m_settings, SIGNAL(numCallersChanged(int)), m_ui->numCallers, SLOT(setValue(int))); - - m_ui->trackOrigins->setChecked(m_settings->trackOrigins()); - connect(m_ui->trackOrigins, SIGNAL(toggled(bool)), m_settings, SLOT(setTrackOrigins(bool))); - connect(m_settings, SIGNAL(trackOriginsChanged(bool)), m_ui->trackOrigins, SLOT(setChecked(bool))); - - connect(m_settings, SIGNAL(suppressionFilesRemoved(QStringList)), - this, SLOT(slotSuppressionsRemoved(QStringList))); - connect(m_settings, SIGNAL(suppressionFilesAdded(QStringList)), - this, SLOT(slotSuppressionsAdded(QStringList))); - - m_model->clear(); - foreach (const QString &file, m_settings->suppressionFiles()) - m_model->appendRow(new QStandardItem(file)); - - connect(m_ui->suppressionList->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(slotSuppressionSelectionChanged())); - slotSuppressionSelectionChanged(); -} - -MemcheckConfigWidget::~MemcheckConfigWidget() -{ - delete m_ui; -} - -void MemcheckConfigWidget::slotAddSuppression() -{ - QFileDialog dialog; - dialog.setNameFilter(tr("Valgrind Suppression File (*.supp);;All Files (*)")); - dialog.setAcceptMode(QFileDialog::AcceptOpen); - dialog.setFileMode(QFileDialog::ExistingFiles); - MemcheckGlobalSettings *conf = Analyzer::AnalyzerGlobalSettings::instance()->subConfig<MemcheckGlobalSettings>(); - QTC_ASSERT(conf, return); - dialog.setDirectory(conf->lastSuppressionDialogDirectory()); - dialog.setHistory(conf->lastSuppressionDialogHistory()); - - if (dialog.exec() == QDialog::Accepted) { - foreach (const QString &file, dialog.selectedFiles()) - m_model->appendRow(new QStandardItem(file)); - - m_settings->addSuppressionFiles(dialog.selectedFiles()); - } - - conf->setLastSuppressionDialogDirectory(dialog.directory().absolutePath()); - conf->setLastSuppressionDialogHistory(dialog.history()); -} - -void MemcheckConfigWidget::slotSuppressionsAdded(const QStringList &files) -{ - QStringList filesToAdd = files; - for (int i = 0, c = m_model->rowCount(); i < c; ++i) - filesToAdd.removeAll(m_model->item(i)->text()); - - foreach (const QString &file, filesToAdd) - m_model->appendRow(new QStandardItem(file)); -} - -bool sortReverse(int l, int r) -{ - return l > r; -} - -void MemcheckConfigWidget::slotRemoveSuppression() -{ - // remove from end so no rows get invalidated - QList<int> rows; - - QStringList removed; - foreach (const QModelIndex &index, m_ui->suppressionList->selectionModel()->selectedIndexes()) { - rows << index.row(); - removed << index.data().toString(); - } - - qSort(rows.begin(), rows.end(), sortReverse); - - foreach (int row, rows) - m_model->removeRow(row); - - m_settings->removeSuppressionFiles(removed); -} - -void MemcheckConfigWidget::slotSuppressionsRemoved(const QStringList &files) -{ - for (int i = 0; i < m_model->rowCount(); ++i) { - if (files.contains(m_model->item(i)->text())) { - m_model->removeRow(i); - --i; - } - } -} - -void MemcheckConfigWidget::setSuppressions(const QStringList &files) -{ - m_model->clear(); - foreach (const QString &file, files) - m_model->appendRow(new QStandardItem(file)); -} - -QStringList MemcheckConfigWidget::suppressions() const -{ - QStringList ret; - - for (int i = 0; i < m_model->rowCount(); ++i) - ret << m_model->item(i)->text(); - - return ret; -} - -void MemcheckConfigWidget::slotSuppressionSelectionChanged() -{ - m_ui->removeSuppression->setEnabled(m_ui->suppressionList->selectionModel()->hasSelection()); -} - -} // namespace Internal -} // namespace Valgrind diff --git a/src/plugins/valgrind/memcheckconfigwidget.h b/src/plugins/valgrind/memcheckconfigwidget.h deleted file mode 100644 index e3d806d75a..0000000000 --- a/src/plugins/valgrind/memcheckconfigwidget.h +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator Instrumentation Tools -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Author: Milian Wolff, KDAB (milian.wolff@kdab.com) -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef ANALYZER_INTERNAL_MEMCHECKCONFIGWIDGET_H -#define ANALYZER_INTERNAL_MEMCHECKCONFIGWIDGET_H - -#include <QtGui/QWidget> - -QT_BEGIN_NAMESPACE -class QStandardItemModel; -QT_END_NAMESPACE - -namespace Valgrind { -namespace Internal { - -namespace Ui { -class MemcheckConfigWidget; -} - -class AbstractMemcheckSettings; - -class MemcheckConfigWidget : public QWidget -{ - Q_OBJECT - -public: - MemcheckConfigWidget(AbstractMemcheckSettings *settings, QWidget *parent); - virtual ~MemcheckConfigWidget(); - - void setSuppressions(const QStringList &files); - QStringList suppressions() const; - -public Q_SLOTS: - void slotAddSuppression(); - void slotRemoveSuppression(); - void slotSuppressionsRemoved(const QStringList &files); - void slotSuppressionsAdded(const QStringList &files); - void slotSuppressionSelectionChanged(); - -private: - AbstractMemcheckSettings *m_settings; - QStandardItemModel *m_model; - Ui::MemcheckConfigWidget *m_ui; -}; - -} // namespace Internal -} // namespace Valgrind - -#endif // ANALYZER_INTERNAL_MEMCHECKCONFIGWIDGET_H diff --git a/src/plugins/valgrind/memcheckconfigwidget.ui b/src/plugins/valgrind/memcheckconfigwidget.ui deleted file mode 100644 index 1763dbfbfb..0000000000 --- a/src/plugins/valgrind/memcheckconfigwidget.ui +++ /dev/null @@ -1,130 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Valgrind::Internal::MemcheckConfigWidget</class> - <widget class="QWidget" name="Valgrind::Internal::MemcheckConfigWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>416</width> - <height>565</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="memcheckOptions"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Memory Analysis Options</string> - </property> - <layout class="QFormLayout" name="formLayout_4"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::ExpandingFieldsGrow</enum> - </property> - <item row="2" column="0"> - <widget class="QLabel" name="numCallersLabel"> - <property name="text"> - <string>Backtrace frame count:</string> - </property> - <property name="buddy"> - <cstring>numCallers</cstring> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Suppression files:</string> - </property> - <property name="buddy"> - <cstring>suppressionList</cstring> - </property> - </widget> - </item> - <item row="4" column="0" colspan="2"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QListView" name="suppressionList"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,1"> - <property name="sizeConstraint"> - <enum>QLayout::SetMinimumSize</enum> - </property> - <item> - <widget class="QPushButton" name="addSuppression"> - <property name="text"> - <string>Add...</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeSuppression"> - <property name="text"> - <string>Remove</string> - </property> - <property name="flat"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </item> - <item row="2" column="1"> - <widget class="QSpinBox" name="numCallers"> - <property name="minimum"> - <number>5</number> - </property> - <property name="maximum"> - <number>50</number> - </property> - <property name="value"> - <number>12</number> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QCheckBox" name="trackOrigins"> - <property name="text"> - <string>Track origins of uninitialized memory</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/valgrind/memcheckengine.cpp b/src/plugins/valgrind/memcheckengine.cpp index 19f20b8c00..863d6c885d 100644 --- a/src/plugins/valgrind/memcheckengine.cpp +++ b/src/plugins/valgrind/memcheckengine.cpp @@ -34,7 +34,7 @@ #include "memcheckengine.h" -#include "memchecksettings.h" +#include "valgrindsettings.h" #include <analyzerbase/analyzersettings.h> @@ -96,7 +96,7 @@ QStringList MemcheckEngine::toolArguments() const QStringList arguments; arguments << QLatin1String("--gen-suppressions=all"); - AbstractMemcheckSettings *memcheckSettings = m_settings->subConfig<AbstractMemcheckSettings>(); + ValgrindBaseSettings *memcheckSettings = m_settings->subConfig<ValgrindBaseSettings>(); QTC_ASSERT(memcheckSettings, return arguments); if (memcheckSettings->trackOrigins()) @@ -111,7 +111,7 @@ QStringList MemcheckEngine::toolArguments() const QStringList MemcheckEngine::suppressionFiles() const { - return m_settings->subConfig<AbstractMemcheckSettings>()->suppressionFiles(); + return m_settings->subConfig<ValgrindBaseSettings>()->suppressionFiles(); } void MemcheckEngine::status(const Status &status) diff --git a/src/plugins/valgrind/memcheckerrorview.cpp b/src/plugins/valgrind/memcheckerrorview.cpp index f044a7850b..31fcd884fa 100644 --- a/src/plugins/valgrind/memcheckerrorview.cpp +++ b/src/plugins/valgrind/memcheckerrorview.cpp @@ -509,11 +509,13 @@ void MemcheckErrorView::suppressError() void MemcheckErrorView::goNext() { + QTC_ASSERT(rowCount(), return); setCurrentRow((currentRow() + 1) % rowCount()); } void MemcheckErrorView::goBack() { + QTC_ASSERT(rowCount(), return); const int prevRow = currentRow() - 1; setCurrentRow(prevRow >= 0 ? prevRow : rowCount() - 1); } diff --git a/src/plugins/valgrind/memchecksettings.cpp b/src/plugins/valgrind/memchecksettings.cpp deleted file mode 100644 index 664f59973b..0000000000 --- a/src/plugins/valgrind/memchecksettings.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Author: Milian Wolff, KDAB (milian.wolff@kdab.com) -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#include "memchecksettings.h" -#include "memcheckconfigwidget.h" - -#include <valgrind/xmlprotocol/error.h> - -#include <utils/qtcassert.h> - -using namespace Analyzer; - -static const char numCallersC[] = "Analyzer.Valgrind.NumCallers"; -static const char trackOriginsC[] = "Analyzer.Valgrind.TrackOrigins"; -static const char suppressionFilesC[] = "Analyzer.Valgrind.SupressionFiles"; -static const char removedSuppressionFilesC[] = "Analyzer.Valgrind.RemovedSuppressionFiles"; -static const char addedSuppressionFilesC[] = "Analyzer.Valgrind.AddedSuppressionFiles"; -static const char filterExternalIssuesC[] = "Analyzer.Valgrind.FilterExternalIssues"; -static const char visibleErrorKindsC[] = "Analyzer.Valgrind.VisibleErrorKinds"; - -static const char lastSuppressionDirectoryC[] = "Analyzer.Valgrind.LastSuppressionDirectory"; -static const char lastSuppressionHistoryC[] = "Analyzer.Valgrind.LastSuppressionHistory"; - -namespace Valgrind { -namespace Internal { - -QVariantMap AbstractMemcheckSettings::defaults() const -{ - QVariantMap map; - map.insert(QLatin1String(numCallersC), 25); - map.insert(QLatin1String(trackOriginsC), true); - map.insert(QLatin1String(filterExternalIssuesC), true); - - QVariantList defaultErrorKinds; - for (int i = 0; i < Valgrind::XmlProtocol::MemcheckErrorKindCount; ++i) - defaultErrorKinds << i; - map.insert(QLatin1String(visibleErrorKindsC), defaultErrorKinds); - - return map; -} - -bool AbstractMemcheckSettings::fromMap(const QVariantMap &map) -{ - setIfPresent(map, QLatin1String(numCallersC), &m_numCallers); - setIfPresent(map, QLatin1String(trackOriginsC), &m_trackOrigins); - setIfPresent(map, QLatin1String(filterExternalIssuesC), &m_filterExternalIssues); - - // if we get more of these try a template specialization of setIfPresent for lists... - if (map.contains(QLatin1String(visibleErrorKindsC))) { - m_visibleErrorKinds.clear(); - foreach (const QVariant &val, map.value(QLatin1String(visibleErrorKindsC)).toList()) - m_visibleErrorKinds << val.toInt(); - } - - return true; -} - -QVariantMap AbstractMemcheckSettings::toMap() const -{ - QVariantMap map; - map.insert(QLatin1String(numCallersC), m_numCallers); - map.insert(QLatin1String(trackOriginsC), m_trackOrigins); - map.insert(QLatin1String(filterExternalIssuesC), m_filterExternalIssues); - - QVariantList errorKinds; - foreach (int i, m_visibleErrorKinds) - errorKinds << i; - map.insert(QLatin1String(visibleErrorKindsC), errorKinds); - - return map; -} - -void AbstractMemcheckSettings::setNumCallers(int numCallers) -{ - if (m_numCallers != numCallers) { - m_numCallers = numCallers; - emit numCallersChanged(numCallers); - } -} - -void AbstractMemcheckSettings::setTrackOrigins(bool trackOrigins) -{ - if (m_trackOrigins != trackOrigins) { - m_trackOrigins = trackOrigins; - emit trackOriginsChanged(trackOrigins); - } -} - -void AbstractMemcheckSettings::setFilterExternalIssues(bool filterExternalIssues) -{ - if (m_filterExternalIssues != filterExternalIssues) { - m_filterExternalIssues = filterExternalIssues; - emit filterExternalIssuesChanged(filterExternalIssues); - } -} - -void AbstractMemcheckSettings::setVisibleErrorKinds(const QList<int> &visibleErrorKinds) -{ - if (m_visibleErrorKinds != visibleErrorKinds) { - m_visibleErrorKinds = visibleErrorKinds; - emit visibleErrorKindsChanged(visibleErrorKinds); - } -} - -QString AbstractMemcheckSettings::id() const -{ - return "Analyzer.Valgrind.Settings.Memcheck"; -} - -QString AbstractMemcheckSettings::displayName() const -{ - return tr("Memory Analysis"); -} - -QWidget *AbstractMemcheckSettings::createConfigWidget(QWidget *parent) -{ - return new MemcheckConfigWidget(this, parent); -} - -QStringList MemcheckGlobalSettings::suppressionFiles() const -{ - return m_suppressionFiles; -} - -void MemcheckGlobalSettings::addSuppressionFiles(const QStringList &suppressions) -{ - foreach (const QString &s, suppressions) - if (!m_suppressionFiles.contains(s)) - m_suppressionFiles.append(s); -} - -void MemcheckGlobalSettings::removeSuppressionFiles(const QStringList &suppressions) -{ - foreach (const QString &s, suppressions) - m_suppressionFiles.removeAll(s); -} - -QString MemcheckGlobalSettings::lastSuppressionDialogDirectory() const -{ - return m_lastSuppressionDirectory; -} - -void MemcheckGlobalSettings::setLastSuppressionDialogDirectory(const QString &directory) -{ - m_lastSuppressionDirectory = directory; -} - -QStringList MemcheckGlobalSettings::lastSuppressionDialogHistory() const -{ - return m_lastSuppressionHistory; -} - -void MemcheckGlobalSettings::setLastSuppressionDialogHistory(const QStringList &history) -{ - m_lastSuppressionHistory = history; -} - -QVariantMap MemcheckGlobalSettings::defaults() const -{ - QVariantMap ret = AbstractMemcheckSettings::defaults(); - ret.insert(suppressionFilesC, QStringList()); - ret.insert(lastSuppressionDirectoryC, QString()); - ret.insert(lastSuppressionHistoryC, QStringList()); - return ret; -} - -bool MemcheckGlobalSettings::fromMap(const QVariantMap &map) -{ - AbstractMemcheckSettings::fromMap(map); - m_suppressionFiles = map.value(suppressionFilesC).toStringList(); - m_lastSuppressionDirectory = map.value(lastSuppressionDirectoryC).toString(); - m_lastSuppressionHistory = map.value(lastSuppressionHistoryC).toStringList(); - return true; -} - -QVariantMap MemcheckGlobalSettings::toMap() const -{ - QVariantMap map = AbstractMemcheckSettings::toMap(); - map.insert(suppressionFilesC, m_suppressionFiles); - map.insert(lastSuppressionDirectoryC, m_lastSuppressionDirectory); - map.insert(lastSuppressionHistoryC, m_lastSuppressionHistory); - return map; -} - -MemcheckGlobalSettings *globalMemcheckSettings() -{ - MemcheckGlobalSettings *ret = AnalyzerGlobalSettings::instance()->subConfig<MemcheckGlobalSettings>(); - QTC_ASSERT(ret, return 0); - return ret; -} - - -QVariantMap MemcheckProjectSettings::defaults() const -{ - QVariantMap ret = AbstractMemcheckSettings::defaults(); - ret.insert(addedSuppressionFilesC, QStringList()); - ret.insert(removedSuppressionFilesC, QStringList()); - return ret; -} - -bool MemcheckProjectSettings::fromMap(const QVariantMap &map) -{ - AbstractMemcheckSettings::fromMap(map); - setIfPresent(map, addedSuppressionFilesC, &m_addedSuppressionFiles); - setIfPresent(map, removedSuppressionFilesC, &m_disabledGlobalSuppressionFiles); - return true; -} - -QVariantMap MemcheckProjectSettings::toMap() const -{ - QVariantMap map = AbstractMemcheckSettings::toMap(); - map.insert(addedSuppressionFilesC, m_addedSuppressionFiles); - map.insert(removedSuppressionFilesC, m_disabledGlobalSuppressionFiles); - return map; -} - -void MemcheckProjectSettings::addSuppressionFiles(const QStringList &suppressions) -{ - QStringList globalSuppressions = globalMemcheckSettings()->suppressionFiles(); - foreach (const QString &s, suppressions) { - if (m_addedSuppressionFiles.contains(s)) - continue; - m_disabledGlobalSuppressionFiles.removeAll(s); - if (!globalSuppressions.contains(s)) - m_addedSuppressionFiles.append(s); - } -} - -void MemcheckProjectSettings::removeSuppressionFiles(const QStringList &suppressions) -{ - QStringList globalSuppressions = globalMemcheckSettings()->suppressionFiles(); - foreach (const QString &s, suppressions) { - m_addedSuppressionFiles.removeAll(s); - if (globalSuppressions.contains(s)) - m_disabledGlobalSuppressionFiles.append(s); - } -} - -QStringList MemcheckProjectSettings::suppressionFiles() const -{ - QStringList ret = globalMemcheckSettings()->suppressionFiles(); - foreach (const QString &s, m_disabledGlobalSuppressionFiles) - ret.removeAll(s); - ret.append(m_addedSuppressionFiles); - return ret; -} - -} // namespace Internal -} // namespace Valgrind diff --git a/src/plugins/valgrind/memchecksettings.h b/src/plugins/valgrind/memchecksettings.h deleted file mode 100644 index 7d4a2f3f79..0000000000 --- a/src/plugins/valgrind/memchecksettings.h +++ /dev/null @@ -1,152 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Author: Milian Wolff, KDAB (milian.wolff@kdab.com) -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ - -#ifndef ANALYZER_INTERNAL_MEMCHECKSETTINGS_H -#define ANALYZER_INTERNAL_MEMCHECKSETTINGS_H - -#include <analyzerbase/analyzersettings.h> - -namespace Valgrind { -namespace Internal { - -/** - * Generic memcheck settings - */ -class AbstractMemcheckSettings : public Analyzer::AbstractAnalyzerSubConfig -{ - Q_OBJECT - -public: - AbstractMemcheckSettings() {} - - virtual bool fromMap(const QVariantMap &map); - - int numCallers() const { return m_numCallers; } - bool trackOrigins() const { return m_trackOrigins; } - bool filterExternalIssues() const { return m_filterExternalIssues; } - QList<int> visibleErrorKinds() const { return m_visibleErrorKinds; } - - virtual QStringList suppressionFiles() const = 0; - virtual void addSuppressionFiles(const QStringList &) = 0; - virtual void removeSuppressionFiles(const QStringList &) = 0; - - virtual QVariantMap defaults() const; - - virtual QString id() const; - virtual QString displayName() const; - virtual QWidget *createConfigWidget(QWidget *parent); - -public slots: - void setNumCallers(int); - void setTrackOrigins(bool); - void setFilterExternalIssues(bool); - void setVisibleErrorKinds(const QList<int> &); - -signals: - void numCallersChanged(int); - void trackOriginsChanged(bool); - void filterExternalIssuesChanged(bool); - void visibleErrorKindsChanged(const QList<int> &); - void suppressionFilesRemoved(const QStringList &); - void suppressionFilesAdded(const QStringList &); - -protected: - virtual QVariantMap toMap() const; - - int m_numCallers; - bool m_trackOrigins; - bool m_filterExternalIssues; - QList<int> m_visibleErrorKinds; -}; - -/** - * Global memcheck settings - */ -class MemcheckGlobalSettings : public AbstractMemcheckSettings -{ -public: - MemcheckGlobalSettings() {} - - QStringList suppressionFiles() const; - // in the global settings we change the internal list directly - void addSuppressionFiles(const QStringList &); - void removeSuppressionFiles(const QStringList &); - - QVariantMap toMap() const; - QVariantMap defaults() const; - - // internal settings which don't require any UI - void setLastSuppressionDialogDirectory(const QString &directory); - QString lastSuppressionDialogDirectory() const; - - void setLastSuppressionDialogHistory(const QStringList &history); - QStringList lastSuppressionDialogHistory() const; - -protected: - bool fromMap(const QVariantMap &map); - -private: - QStringList m_suppressionFiles; - QString m_lastSuppressionDirectory; - QStringList m_lastSuppressionHistory; -}; - -/** - * Per-project memcheck settings, saves a diff to the global suppression files list - */ -class MemcheckProjectSettings : public AbstractMemcheckSettings -{ -public: - MemcheckProjectSettings() {} - - QStringList suppressionFiles() const; - // in the project-specific settings we store a diff to the global list - void addSuppressionFiles(const QStringList &suppressions); - void removeSuppressionFiles(const QStringList &suppressions); - - QVariantMap toMap() const; - QVariantMap defaults() const; - -protected: - bool fromMap(const QVariantMap &map); - -private: - QStringList m_disabledGlobalSuppressionFiles; - QStringList m_addedSuppressionFiles; -}; - -} // namespace Internal -} // namespace Valgrind - -#endif // ANALYZER_INTERNAL_MEMCHECKSETTINGS_H diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 9c2e89a817..0983d2f5e2 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -35,7 +35,6 @@ #include "memchecktool.h" #include "memcheckengine.h" #include "memcheckerrorview.h" -#include "memchecksettings.h" #include "valgrindsettings.h" #include "valgrindplugin.h" @@ -260,7 +259,7 @@ void MemcheckTool::maybeActiveRunConfigurationChanged() connect(m_settings, SIGNAL(destroyed(QObject *)), SLOT(settingsDestroyed(QObject *))); - AbstractMemcheckSettings *memcheckSettings = m_settings->subConfig<AbstractMemcheckSettings>(); + ValgrindBaseSettings *memcheckSettings = m_settings->subConfig<ValgrindBaseSettings>(); QTC_ASSERT(memcheckSettings, return); foreach (QAction *action, m_errorFilterActions) { @@ -288,12 +287,12 @@ void MemcheckTool::maybeActiveRunConfigurationChanged() QByteArray MemcheckTool::id() const { - return "MemcheckLocal"; + return "Memcheck"; } QString MemcheckTool::displayName() const { - return tr("Valgrind Analyze Memory"); + return tr("Valgrind Memory Analyzer"); } QString MemcheckTool::description() const @@ -380,6 +379,7 @@ QWidget *MemcheckTool::createWidgets() QDockWidget *errorDock = AnalyzerManager::createDockWidget (this, tr("Memory Issues"), m_errorView, Qt::BottomDockWidgetArea); + errorDock->show(); mw->splitDockWidget(mw->toolBarDockWidget(), errorDock, Qt::Vertical); connect(ProjectExplorer::ProjectExplorerPlugin::instance(), @@ -523,7 +523,7 @@ void MemcheckTool::updateErrorFilter() QTC_ASSERT(m_errorView, return); QTC_ASSERT(m_settings, return); - AbstractMemcheckSettings *memcheckSettings = m_settings->subConfig<AbstractMemcheckSettings>(); + ValgrindBaseSettings *memcheckSettings = m_settings->subConfig<ValgrindBaseSettings>(); QTC_ASSERT(memcheckSettings, return); memcheckSettings->setFilterExternalIssues(!m_filterProjectAction->isChecked()); @@ -544,8 +544,8 @@ void MemcheckTool::updateErrorFilter() void MemcheckTool::finished() { const int n = m_errorModel->rowCount(); - m_goBack->setEnabled(n > 0); - m_goNext->setEnabled(n > 0); + m_goBack->setEnabled(n > 1); + m_goNext->setEnabled(n > 1); const QString msg = AnalyzerManager::msgToolFinished(displayName(), n); AnalyzerManager::showStatusMessage(msg); } diff --git a/src/plugins/valgrind/suppressiondialog.cpp b/src/plugins/valgrind/suppressiondialog.cpp index 735fa5bf8d..e5e3470534 100644 --- a/src/plugins/valgrind/suppressiondialog.cpp +++ b/src/plugins/valgrind/suppressiondialog.cpp @@ -36,7 +36,7 @@ #include "ui_suppressiondialog.h" #include "memcheckerrorview.h" -#include "memchecksettings.h" +#include "valgrindsettings.h" #include "xmlprotocol/suppression.h" #include "xmlprotocol/errorlistmodel.h" @@ -199,7 +199,7 @@ void SuppressionDialog::accept() } } - m_settings->subConfig<AbstractMemcheckSettings>()->addSuppressionFiles(QStringList(path)); + m_settings->subConfig<ValgrindBaseSettings>()->addSuppressionFiles(QStringList(path)); QModelIndexList indices = m_view->selectionModel()->selectedRows(); qSort(indices.begin(), indices.end(), sortIndizesReverse); diff --git a/src/plugins/valgrind/valgrind.pro b/src/plugins/valgrind/valgrind.pro index 1be71c77b3..adddcc0f28 100644 --- a/src/plugins/valgrind/valgrind.pro +++ b/src/plugins/valgrind/valgrind.pro @@ -17,13 +17,10 @@ HEADERS += \ valgrindsettings.h \ valgrindrunner.h \ valgrindprocess.h \ - \ - callgrindconfigwidget.h \ callgrindcostdelegate.h \ callgrindcostview.h \ callgrindhelper.h \ callgrindnamedelegate.h \ - callgrindsettings.h \ callgrindtool.h \ callgrindvisualisation.h \ callgrindengine.h \ @@ -33,8 +30,6 @@ HEADERS += \ memchecktool.h \ memcheckengine.h \ memcheckerrorview.h \ - memchecksettings.h \ - memcheckconfigwidget.h \ suppressiondialog.h SOURCES += \ @@ -45,12 +40,10 @@ SOURCES += \ valgrindrunner.cpp \ valgrindprocess.cpp \ \ - callgrindconfigwidget.cpp \ callgrindcostdelegate.cpp \ callgrindcostview.cpp \ callgrindhelper.cpp \ callgrindnamedelegate.cpp \ - callgrindsettings.cpp \ callgrindtool.cpp \ callgrindvisualisation.cpp \ callgrindengine.cpp \ @@ -59,13 +52,9 @@ SOURCES += \ memchecktool.cpp \ memcheckengine.cpp \ memcheckerrorview.cpp \ - memchecksettings.cpp \ - memcheckconfigwidget.cpp \ suppressiondialog.cpp FORMS += \ valgrindconfigwidget.ui \ - callgrindconfigwidget.ui \ - suppressiondialog.ui \ - memcheckconfigwidget.ui + suppressiondialog.ui diff --git a/src/plugins/valgrind/valgrindconfigwidget.cpp b/src/plugins/valgrind/valgrindconfigwidget.cpp index c03775c7cf..337b786c83 100644 --- a/src/plugins/valgrind/valgrindconfigwidget.cpp +++ b/src/plugins/valgrind/valgrindconfigwidget.cpp @@ -33,16 +33,22 @@ **************************************************************************/ #include "valgrindconfigwidget.h" +#include "valgrindsettings.h" #include "ui_valgrindconfigwidget.h" -#include "valgrindsettings.h" +#include <utils/qtcassert.h> #include <QtCore/QDebug> -using namespace Valgrind::Internal; +#include <QtGui/QStandardItemModel> +#include <QtGui/QFileDialog> -ValgrindConfigWidget::ValgrindConfigWidget(ValgrindSettings *settings, QWidget *parent) +namespace Valgrind { +namespace Internal { + +ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings, + QWidget *parent, bool global) : QWidget(parent), m_settings(settings), m_ui(new Ui::ValgrindConfigWidget) @@ -53,11 +59,203 @@ ValgrindConfigWidget::ValgrindConfigWidget(ValgrindSettings *settings, QWidget * m_ui->valgrindExeChooser->setPromptDialogTitle(tr("Valgrind Command")); m_ui->valgrindExeChooser->setPath(m_settings->valgrindExecutable()); - connect(m_ui->valgrindExeChooser, SIGNAL(changed(QString)), m_settings, SLOT(setValgrindExecutable(QString))); - connect(m_settings, SIGNAL(valgrindExecutableChanged(QString)), m_ui->valgrindExeChooser, SLOT(setPath(QString))); + connect(m_ui->valgrindExeChooser, SIGNAL(changed(QString)), + m_settings, SLOT(setValgrindExecutable(QString))); + connect(m_settings, SIGNAL(valgrindExecutableChanged(QString)), + m_ui->valgrindExeChooser, SLOT(setPath(QString))); + +#ifdef Q_OS_WIN + // FIXME: On Window we know that we don't have a local valgrind + // executable, so having the "Browse" button in the path chooser + // (which is needed for the remote executable) is confusing. + m_ui->valgrindExeChooser->buttonAtIndex(0)->hide(); +#endif + + // + // Callgrind + // + m_ui->enableCacheSim->setChecked(m_settings->enableCacheSim()); + connect(m_ui->enableCacheSim, SIGNAL(toggled(bool)), + m_settings, SLOT(setEnableCacheSim(bool))); + connect(m_settings, SIGNAL(enableCacheSimChanged(bool)), + m_ui->enableCacheSim, SLOT(setChecked(bool))); + + m_ui->enableBranchSim->setChecked(m_settings->enableBranchSim()); + connect(m_ui->enableBranchSim, SIGNAL(toggled(bool)), + m_settings, SLOT(setEnableBranchSim(bool))); + connect(m_settings, SIGNAL(enableBranchSimChanged(bool)), + m_ui->enableBranchSim, SLOT(setChecked(bool))); + + m_ui->collectSystime->setChecked(m_settings->collectSystime()); + connect(m_ui->collectSystime, SIGNAL(toggled(bool)), + m_settings, SLOT(setCollectSystime(bool))); + connect(m_settings, SIGNAL(collectSystimeChanged(bool)), + m_ui->collectSystime, SLOT(setChecked(bool))); + + m_ui->collectBusEvents->setChecked(m_settings->collectBusEvents()); + connect(m_ui->collectBusEvents, SIGNAL(toggled(bool)), + m_settings, SLOT(setCollectBusEvents(bool))); + connect(m_settings, SIGNAL(collectBusEventsChanged(bool)), + m_ui->collectBusEvents, SLOT(setChecked(bool))); + + m_ui->enableEventToolTips->setChecked(m_settings->enableEventToolTips()); + connect(m_ui->enableEventToolTips, SIGNAL(toggled(bool)), + m_settings, SLOT(setEnableEventToolTips(bool))); + connect(m_settings, SIGNAL(enableEventToolTipsChanged(bool)), + m_ui->enableEventToolTips, SLOT(setChecked(bool))); + + m_ui->minimumInclusiveCostRatio->setValue(m_settings->minimumInclusiveCostRatio()); + connect(m_ui->minimumInclusiveCostRatio, SIGNAL(valueChanged(double)), + m_settings, SLOT(setMinimumInclusiveCostRatio(double))); + connect(m_settings, SIGNAL(minimumInclusiveCostRatioChanged(double)), + m_ui->minimumInclusiveCostRatio, SLOT(setValue(double))); + + m_ui->visualisationMinimumInclusiveCostRatio->setValue(m_settings->visualisationMinimumInclusiveCostRatio()); + connect(m_ui->visualisationMinimumInclusiveCostRatio, SIGNAL(valueChanged(double)), + m_settings, SLOT(setVisualisationMinimumInclusiveCostRatio(double))); + connect(m_settings, SIGNAL(visualisationMinimumInclusiveCostRatioChanged(double)), + m_ui->visualisationMinimumInclusiveCostRatio, SLOT(setValue(double))); + + // + // Memcheck + // + m_model = new QStandardItemModel(this); + + m_ui->suppressionList->setModel(m_model); + m_ui->suppressionList->setSelectionMode(QAbstractItemView::MultiSelection); + + connect(m_ui->addSuppression, SIGNAL(clicked()), + this, SLOT(slotAddSuppression())); + connect(m_ui->removeSuppression, SIGNAL(clicked()), + this, SLOT(slotRemoveSuppression())); + + m_ui->numCallers->setValue(m_settings->numCallers()); + connect(m_ui->numCallers, SIGNAL(valueChanged(int)), m_settings, SLOT(setNumCallers(int))); + connect(m_settings, SIGNAL(numCallersChanged(int)), m_ui->numCallers, SLOT(setValue(int))); + + m_ui->trackOrigins->setChecked(m_settings->trackOrigins()); + connect(m_ui->trackOrigins, SIGNAL(toggled(bool)), + m_settings, SLOT(setTrackOrigins(bool))); + connect(m_settings, SIGNAL(trackOriginsChanged(bool)), + m_ui->trackOrigins, SLOT(setChecked(bool))); + + connect(m_settings, SIGNAL(suppressionFilesRemoved(QStringList)), + this, SLOT(slotSuppressionsRemoved(QStringList))); + connect(m_settings, SIGNAL(suppressionFilesAdded(QStringList)), + this, SLOT(slotSuppressionsAdded(QStringList))); + + m_model->clear(); + foreach (const QString &file, m_settings->suppressionFiles()) + m_model->appendRow(new QStandardItem(file)); + + connect(m_ui->suppressionList->selectionModel(), + SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + this, SLOT(slotSuppressionSelectionChanged())); + slotSuppressionSelectionChanged(); + + if (!global) { + // In project settings we want a flat vertical list. + QVBoxLayout *l = new QVBoxLayout; + while (layout()->count()) + if (QWidget *w = layout()->takeAt(0)->widget()) + l->addWidget(w); + delete layout(); + setLayout(l); + } } ValgrindConfigWidget::~ValgrindConfigWidget() { delete m_ui; } + +void ValgrindConfigWidget::slotAddSuppression() +{ + QFileDialog dialog; + dialog.setNameFilter(tr("Valgrind Suppression File (*.supp);;All Files (*)")); + dialog.setAcceptMode(QFileDialog::AcceptOpen); + dialog.setFileMode(QFileDialog::ExistingFiles); + ValgrindGlobalSettings *conf = Analyzer::AnalyzerGlobalSettings::instance()->subConfig<ValgrindGlobalSettings>(); + QTC_ASSERT(conf, return); + dialog.setDirectory(conf->lastSuppressionDialogDirectory()); + dialog.setHistory(conf->lastSuppressionDialogHistory()); + + if (dialog.exec() == QDialog::Accepted) { + foreach (const QString &file, dialog.selectedFiles()) + m_model->appendRow(new QStandardItem(file)); + + m_settings->addSuppressionFiles(dialog.selectedFiles()); + } + + conf->setLastSuppressionDialogDirectory(dialog.directory().absolutePath()); + conf->setLastSuppressionDialogHistory(dialog.history()); +} + +void ValgrindConfigWidget::slotSuppressionsAdded(const QStringList &files) +{ + QStringList filesToAdd = files; + for (int i = 0, c = m_model->rowCount(); i < c; ++i) + filesToAdd.removeAll(m_model->item(i)->text()); + + foreach (const QString &file, filesToAdd) + m_model->appendRow(new QStandardItem(file)); +} + +bool sortReverse(int l, int r) +{ + return l > r; +} + +void ValgrindConfigWidget::slotRemoveSuppression() +{ + // remove from end so no rows get invalidated + QList<int> rows; + + QStringList removed; + foreach (const QModelIndex &index, m_ui->suppressionList->selectionModel()->selectedIndexes()) { + rows << index.row(); + removed << index.data().toString(); + } + + qSort(rows.begin(), rows.end(), sortReverse); + + foreach (int row, rows) + m_model->removeRow(row); + + m_settings->removeSuppressionFiles(removed); +} + +void ValgrindConfigWidget::slotSuppressionsRemoved(const QStringList &files) +{ + for (int i = 0; i < m_model->rowCount(); ++i) { + if (files.contains(m_model->item(i)->text())) { + m_model->removeRow(i); + --i; + } + } +} + +void ValgrindConfigWidget::setSuppressions(const QStringList &files) +{ + m_model->clear(); + foreach (const QString &file, files) + m_model->appendRow(new QStandardItem(file)); +} + +QStringList ValgrindConfigWidget::suppressions() const +{ + QStringList ret; + + for (int i = 0; i < m_model->rowCount(); ++i) + ret << m_model->item(i)->text(); + + return ret; +} + +void ValgrindConfigWidget::slotSuppressionSelectionChanged() +{ + m_ui->removeSuppression->setEnabled(m_ui->suppressionList->selectionModel()->hasSelection()); +} + +} // namespace Internal +} // namespace Valgrind diff --git a/src/plugins/valgrind/valgrindconfigwidget.h b/src/plugins/valgrind/valgrindconfigwidget.h index b63b88248f..948e87ff96 100644 --- a/src/plugins/valgrind/valgrindconfigwidget.h +++ b/src/plugins/valgrind/valgrindconfigwidget.h @@ -32,12 +32,15 @@ ** **************************************************************************/ - -#ifndef ANALYZER_INTERNAL_VALGRINDCONFIGWIDGET_H -#define ANALYZER_INTERNAL_VALGRINDCONFIGWIDGET_H +#ifndef ANALYZER_VALGRINDCONFIGWIDGET_H +#define ANALYZER_VALGRINDCONFIGWIDGET_H #include <QtGui/QWidget> +QT_BEGIN_NAMESPACE +class QStandardItemModel; +QT_END_NAMESPACE + namespace Valgrind { namespace Internal { @@ -45,22 +48,33 @@ namespace Ui { class ValgrindConfigWidget; } -class ValgrindSettings; +class ValgrindBaseSettings; class ValgrindConfigWidget : public QWidget { Q_OBJECT public: - ValgrindConfigWidget(ValgrindSettings *settings, QWidget *parent); + ValgrindConfigWidget(ValgrindBaseSettings *settings, QWidget *parent, bool global); virtual ~ValgrindConfigWidget(); + void setSuppressions(const QStringList &files); + QStringList suppressions() const; + +public Q_SLOTS: + void slotAddSuppression(); + void slotRemoveSuppression(); + void slotSuppressionsRemoved(const QStringList &files); + void slotSuppressionsAdded(const QStringList &files); + void slotSuppressionSelectionChanged(); + private: - ValgrindSettings *m_settings; + ValgrindBaseSettings *m_settings; Ui::ValgrindConfigWidget *m_ui; + QStandardItemModel *m_model; }; -} -} +} // namespace Internal +} // namespace Valgrind -#endif // ANALYZER_INTERNAL_VALGRINDCONFIGWIDGET_H +#endif // ANALYZER_VALGRINDCONFIGWIDGET_H diff --git a/src/plugins/valgrind/valgrindconfigwidget.ui b/src/plugins/valgrind/valgrindconfigwidget.ui index 2b929bfc4c..e793c3a85a 100644 --- a/src/plugins/valgrind/valgrindconfigwidget.ui +++ b/src/plugins/valgrind/valgrindconfigwidget.ui @@ -6,39 +6,322 @@ <rect> <x>0</x> <y>0</y> - <width>445</width> - <height>543</height> + <width>669</width> + <height>312</height> </rect> </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0" colspan="2"> <widget class="QGroupBox" name="commonValgrindOptions"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <horstretch>0</horstretch> - <verstretch>1</verstretch> + <verstretch>0</verstretch> </sizepolicy> </property> <property name="title"> <string>Generic Settings</string> </property> - <layout class="QFormLayout" name="formLayout"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="valgrindExeLabel"> + <property name="text"> + <string>Valgrind executable:</string> + </property> + </widget> + </item> + <item> + <widget class="Utils::PathChooser" name="valgrindExeChooser"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="2"> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>197</width> + <height>1</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="memcheckOptions"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Memory Analysis Options</string> + </property> + <layout class="QFormLayout" name="formLayout_4"> <property name="fieldGrowthPolicy"> <enum>QFormLayout::ExpandingFieldsGrow</enum> </property> + <item row="2" column="0"> + <widget class="QLabel" name="numCallersLabel"> + <property name="text"> + <string>Backtrace frame count:</string> + </property> + <property name="buddy"> + <cstring>numCallers</cstring> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Suppression files:</string> + </property> + <property name="buddy"> + <cstring>suppressionList</cstring> + </property> + </widget> + </item> + <item row="4" column="0" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QListView" name="suppressionList"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,1"> + <property name="sizeConstraint"> + <enum>QLayout::SetMinimumSize</enum> + </property> + <item> + <widget class="QPushButton" name="addSuppression"> + <property name="text"> + <string>Add...</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="removeSuppression"> + <property name="text"> + <string>Remove</string> + </property> + <property name="flat"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </item> + <item row="2" column="1"> + <widget class="QSpinBox" name="numCallers"> + <property name="minimum"> + <number>5</number> + </property> + <property name="maximum"> + <number>50</number> + </property> + <property name="value"> + <number>12</number> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QCheckBox" name="trackOrigins"> + <property name="text"> + <string>Track origins of uninitialized memory</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="1"> + <widget class="QGroupBox" name="memcheckOptions_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Profiling Options</string> + </property> + <layout class="QFormLayout" name="formLayout_2"> <item row="0" column="0"> - <widget class="QLabel" name="valgrindExeLabel"> + <widget class="QLabel" name="minimumInclusiveCostRatioLabel"> + <property name="toolTip"> + <string>Limits the amount of results the profiler gives you. A lower limit will likely increase performance.</string> + </property> <property name="text"> - <string>Valgrind executable:</string> + <string>Result view: Minimum event cost:</string> + </property> + <property name="buddy"> + <cstring>minimumInclusiveCostRatio</cstring> </property> </widget> </item> <item row="0" column="1"> - <widget class="Utils::PathChooser" name="valgrindExeChooser" native="true"/> + <widget class="QDoubleSpinBox" name="minimumInclusiveCostRatio"> + <property name="suffix"> + <string>%</string> + </property> + <property name="decimals"> + <number>2</number> + </property> + <property name="maximum"> + <double>10.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.100000000000000</double> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QGroupBox" name="enableEventToolTips"> + <property name="title"> + <string>Show additional information for events in tooltips</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="0"> + <widget class="QCheckBox" name="enableCacheSim"> + <property name="toolTip"> + <string><html><head/><body> +<p>Does full cache simulation.</p> +<p>By default, only instruction read accesses will be counted ("Ir").</p> +<p> +With cache simulation, further event counters are enabled: +<ul><li>Cache misses on instruction reads ("I1mr"/"I2mr")</li> +<li>Data read accesses ("Dr") and related cache misses ("D1mr"/"D2mr")</li> +<li>Data write accesses ("Dw") and related cache misses ("D1mw"/"D2mw")</li></ul> +</p> + +</body></html></string> + </property> + <property name="text"> + <string>Enable cache simulation</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QCheckBox" name="enableBranchSim"> + <property name="toolTip"> + <string><html><head/><body> +<p>Do branch prediction simulation.</p> +<p>Further event counters are enabled: </p> +<ul><li>Number of executed conditional branches and related predictor misses ( +"Bc"/"Bcm")</li> +<li>Executed indirect jumps and related misses of the jump address predictor ( +"Bi"/"Bim")</li></ul></body></html></string> + </property> + <property name="text"> + <string>Enable branch prediction simulation</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="collectSystime"> + <property name="toolTip"> + <string>Collect information for system call times.</string> + </property> + <property name="text"> + <string>Collect system call time</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QCheckBox" name="collectBusEvents"> + <property name="toolTip"> + <string>Collect the number of global bus events that are executed. The event type "Ge" is used for these events.</string> + </property> + <property name="text"> + <string>Collect global bus events</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="visualisationMinimumInclusiveCostRatioLabel"> + <property name="toolTip"> + <string/> + </property> + <property name="text"> + <string>Visualisation: Minimum event cost:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QDoubleSpinBox" name="visualisationMinimumInclusiveCostRatio"> + <property name="prefix"> + <string/> + </property> + <property name="suffix"> + <string>%</string> + </property> + <property name="minimum"> + <double>0.000000000000000</double> + </property> + <property name="maximum"> + <double>50.000000000000000</double> + </property> + </widget> </item> </layout> </widget> </item> + <item row="2" column="0"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>1</width> + <height>500</height> + </size> + </property> + </spacer> + </item> </layout> </widget> <customwidgets> diff --git a/src/plugins/valgrind/valgrindengine.cpp b/src/plugins/valgrind/valgrindengine.cpp index 3b7279d6fc..6e9728249b 100644 --- a/src/plugins/valgrind/valgrindengine.cpp +++ b/src/plugins/valgrind/valgrindengine.cpp @@ -95,7 +95,7 @@ void ValgrindEngine::start() const AnalyzerStartParameters &sp = startParameters(); runner()->setWorkingDirectory(sp.workingDirectory); - QString valgrindExe = m_settings->subConfig<ValgrindSettings>()->valgrindExecutable(); + QString valgrindExe = m_settings->subConfig<ValgrindBaseSettings>()->valgrindExecutable(); if (!sp.analyzerCmdPrefix.isEmpty()) valgrindExe = sp.analyzerCmdPrefix + ' ' + valgrindExe; runner()->setValgrindExecutable(valgrindExe); @@ -159,7 +159,7 @@ void ValgrindEngine::receiveProcessOutput(const QByteArray &b, Utils::OutputForm void ValgrindEngine::receiveProcessError(const QString &error, QProcess::ProcessError e) { if (e == QProcess::FailedToStart) { - const QString &valgrind = m_settings->subConfig<ValgrindSettings>()->valgrindExecutable(); + const QString &valgrind = m_settings->subConfig<ValgrindBaseSettings>()->valgrindExecutable(); if (!valgrind.isEmpty()) { emit outputReceived(tr("** Error: \"%1\" could not be started: %2 **\n").arg(valgrind).arg(error), Utils::ErrorMessageFormat); } else { diff --git a/src/plugins/valgrind/valgrindplugin.cpp b/src/plugins/valgrind/valgrindplugin.cpp index 86ac42e97f..77353ed0d3 100644 --- a/src/plugins/valgrind/valgrindplugin.cpp +++ b/src/plugins/valgrind/valgrindplugin.cpp @@ -34,9 +34,7 @@ #include "valgrindplugin.h" -#include "callgrindsettings.h" #include "callgrindtool.h" -#include "memchecksettings.h" #include "memchecktool.h" #include "valgrindsettings.h" @@ -44,7 +42,6 @@ #include <analyzerbase/analyzermanager.h> #include <analyzerbase/analyzerrunconfigwidget.h> #include <analyzerbase/analyzerruncontrol.h> -#include <analyzerbase/analyzersettings.h> #include <analyzerbase/analyzerstartparameters.h> #include <analyzerbase/startremotedialog.h> @@ -199,36 +196,19 @@ void ValgrindPlugin::startValgrindTool(IAnalyzerTool *tool, StartMode mode) startRemoteTool(tool, mode); } -static AbstractAnalyzerSubConfig *valgrindConfigFactory() +static AbstractAnalyzerSubConfig *globalValgrindFactory() { - return new ValgrindSettings(); + return new ValgrindGlobalSettings(); } -static AbstractAnalyzerSubConfig *globalCallgrindFactory() +static AbstractAnalyzerSubConfig *projectValgrindFactory() { - return new CallgrindGlobalSettings(); -} - -static AbstractAnalyzerSubConfig *projectCallgrindFactory() -{ - return new CallgrindProjectSettings(); -} - -static AbstractAnalyzerSubConfig *globalMemcheckFactory() -{ - return new MemcheckGlobalSettings(); -} - -static AbstractAnalyzerSubConfig *projectMemcheckFactory() -{ - return new MemcheckProjectSettings(); + return new ValgrindProjectSettings(); } bool ValgrindPlugin::initialize(const QStringList &, QString *) { - AnalyzerGlobalSettings::instance()->registerSubConfigs(&valgrindConfigFactory, &valgrindConfigFactory); - AnalyzerGlobalSettings::instance()->registerSubConfigs(&globalCallgrindFactory, &projectCallgrindFactory); - AnalyzerGlobalSettings::instance()->registerSubConfigs(&globalMemcheckFactory, &projectMemcheckFactory); + AnalyzerGlobalSettings::instance()->registerSubConfigs(&globalValgrindFactory, &projectValgrindFactory); StartModes modes; #ifndef Q_OS_WIN diff --git a/src/plugins/valgrind/valgrindsettings.cpp b/src/plugins/valgrind/valgrindsettings.cpp index 69b7eecb71..e7aebe873b 100644 --- a/src/plugins/valgrind/valgrindsettings.cpp +++ b/src/plugins/valgrind/valgrindsettings.cpp @@ -33,43 +33,136 @@ **************************************************************************/ #include "valgrindsettings.h" - #include "valgrindconfigwidget.h" #include <coreplugin/icore.h> #include <utils/qtcassert.h> +#include <valgrind/xmlprotocol/error.h> #include <QtCore/QSettings> +#include <QtCore/QDebug> + -using namespace Valgrind::Internal; using namespace Analyzer; -static const QLatin1String groupC("Analyzer"); +static const char numCallersC[] = "Analyzer.Valgrind.NumCallers"; +static const char trackOriginsC[] = "Analyzer.Valgrind.TrackOrigins"; +static const char suppressionFilesC[] = "Analyzer.Valgrind.SupressionFiles"; +static const char removedSuppressionFilesC[] = "Analyzer.Valgrind.RemovedSuppressionFiles"; +static const char addedSuppressionFilesC[] = "Analyzer.Valgrind.AddedSuppressionFiles"; +static const char filterExternalIssuesC[] = "Analyzer.Valgrind.FilterExternalIssues"; +static const char visibleErrorKindsC[] = "Analyzer.Valgrind.VisibleErrorKinds"; + +static const char lastSuppressionDirectoryC[] = "Analyzer.Valgrind.LastSuppressionDirectory"; +static const char lastSuppressionHistoryC[] = "Analyzer.Valgrind.LastSuppressionHistory"; + +static const char callgrindEnableCacheSimC[] = "Analyzer.Valgrind.Callgrind.EnableCacheSim"; +static const char callgrindEnableBranchSimC[] = "Analyzer.Valgrind.Callgrind.EnableBranchSim"; +static const char callgrindCollectSystimeC[] = "Analyzer.Valgrind.Callgrind.CollectSystime"; +static const char callgrindCollectBusEventsC[] = "Analyzer.Valgrind.Callgrind.CollectBusEvents"; +static const char callgrindEnableEventToolTipsC[] = "Analyzer.Valgrind.Callgrind.EnableEventToolTips"; +static const char callgrindMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.MinimumCostRatio"; +static const char callgrindVisualisationMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio"; + +static const char callgrindCycleDetectionC[] = "Analyzer.Valgrind.Callgrind.CycleDetection"; +static const char callgrindCostFormatC[] = "Analyzer.Valgrind.Callgrind.CostFormat"; -static const QLatin1String valgrindExeC("Analyzer.Valgrind.ValgrindExecutable"); +static const char valgrindExeC[] = "Analyzer.Valgrind.ValgrindExecutable"; -QVariantMap ValgrindSettings::defaults() const +namespace Valgrind { +namespace Internal { + +////////////////////////////////////////////////////////////////// +// +// ValgrindBaseSettings +// +////////////////////////////////////////////////////////////////// + +QVariantMap ValgrindBaseSettings::defaults() const { QVariantMap map; - map.insert(valgrindExeC, QLatin1String("valgrind")); + + // General + map.insert(QLatin1String(valgrindExeC), QLatin1String("valgrind")); + + // Memcheck + map.insert(QLatin1String(numCallersC), 25); + map.insert(QLatin1String(trackOriginsC), true); + map.insert(QLatin1String(filterExternalIssuesC), true); + QVariantList defaultErrorKinds; + for (int i = 0; i < Valgrind::XmlProtocol::MemcheckErrorKindCount; ++i) + defaultErrorKinds << i; + map.insert(QLatin1String(visibleErrorKindsC), defaultErrorKinds); + + // Callgrind + map.insert(QLatin1String(callgrindEnableCacheSimC), false); + map.insert(QLatin1String(callgrindEnableBranchSimC), false); + map.insert(QLatin1String(callgrindCollectSystimeC), false); + map.insert(QLatin1String(callgrindCollectBusEventsC), false); + map.insert(QLatin1String(callgrindEnableEventToolTipsC), true); + map.insert(QLatin1String(callgrindMinimumCostRatioC), 0.01); + map.insert(QLatin1String(callgrindVisualisationMinimumCostRatioC), 10.0); + return map; } -bool ValgrindSettings::fromMap(const QVariantMap &map) +bool ValgrindBaseSettings::fromMap(const QVariantMap &map) { - setIfPresent(map, valgrindExeC, &m_valgrindExecutable); + // General + setIfPresent(map, QLatin1String(valgrindExeC), &m_valgrindExecutable); + + // Memcheck + setIfPresent(map, QLatin1String(numCallersC), &m_numCallers); + setIfPresent(map, QLatin1String(trackOriginsC), &m_trackOrigins); + setIfPresent(map, QLatin1String(filterExternalIssuesC), &m_filterExternalIssues); + if (map.contains(QLatin1String(visibleErrorKindsC))) { + m_visibleErrorKinds.clear(); + foreach (const QVariant &val, map.value(QLatin1String(visibleErrorKindsC)).toList()) + m_visibleErrorKinds << val.toInt(); + } + + // Callgrind + setIfPresent(map, QLatin1String(callgrindEnableCacheSimC), &m_enableCacheSim); + setIfPresent(map, QLatin1String(callgrindEnableBranchSimC), &m_enableBranchSim); + setIfPresent(map, QLatin1String(callgrindCollectSystimeC), &m_collectSystime); + setIfPresent(map, QLatin1String(callgrindCollectBusEventsC), &m_collectBusEvents); + setIfPresent(map, QLatin1String(callgrindEnableEventToolTipsC), &m_enableEventToolTips); + setIfPresent(map, QLatin1String(callgrindMinimumCostRatioC), &m_minimumInclusiveCostRatio); + setIfPresent(map, QLatin1String(callgrindVisualisationMinimumCostRatioC), + &m_visualisationMinimumInclusiveCostRatio); + return true; } -QVariantMap ValgrindSettings::toMap() const +QVariantMap ValgrindBaseSettings::toMap() const { QVariantMap map; - map.insert(valgrindExeC, m_valgrindExecutable); + // General + map.insert(QLatin1String(valgrindExeC), m_valgrindExecutable); + + // Memcheck + map.insert(QLatin1String(numCallersC), m_numCallers); + map.insert(QLatin1String(trackOriginsC), m_trackOrigins); + map.insert(QLatin1String(filterExternalIssuesC), m_filterExternalIssues); + QVariantList errorKinds; + foreach (int i, m_visibleErrorKinds) + errorKinds << i; + map.insert(QLatin1String(visibleErrorKindsC), errorKinds); + + // Callgrind + map.insert(QLatin1String(callgrindEnableCacheSimC), m_enableCacheSim); + map.insert(QLatin1String(callgrindEnableBranchSimC), m_enableBranchSim); + map.insert(QLatin1String(callgrindCollectSystimeC), m_collectSystime); + map.insert(QLatin1String(callgrindCollectBusEventsC), m_collectBusEvents); + map.insert(QLatin1String(callgrindEnableEventToolTipsC), m_enableEventToolTips); + map.insert(QLatin1String(callgrindMinimumCostRatioC), m_minimumInclusiveCostRatio); + map.insert(QLatin1String(callgrindVisualisationMinimumCostRatioC), + m_visualisationMinimumInclusiveCostRatio); return map; } -void ValgrindSettings::setValgrindExecutable(const QString &valgrindExecutable) +void ValgrindBaseSettings::setValgrindExecutable(const QString &valgrindExecutable) { if (m_valgrindExecutable != valgrindExecutable) { m_valgrindExecutable = valgrindExecutable; @@ -77,22 +170,332 @@ void ValgrindSettings::setValgrindExecutable(const QString &valgrindExecutable) } } -QString ValgrindSettings::valgrindExecutable() const +QString ValgrindBaseSettings::valgrindExecutable() const { return m_valgrindExecutable; } -QString ValgrindSettings::id() const +QString ValgrindBaseSettings::id() const +{ + return "Analyzer.Valgrind.Settings"; +} + +QString ValgrindBaseSettings::displayName() const +{ + return tr("Valgrind"); +} + +void ValgrindBaseSettings::setNumCallers(int numCallers) +{ + if (m_numCallers != numCallers) { + m_numCallers = numCallers; + emit numCallersChanged(numCallers); + } +} + +void ValgrindBaseSettings::setTrackOrigins(bool trackOrigins) +{ + if (m_trackOrigins != trackOrigins) { + m_trackOrigins = trackOrigins; + emit trackOriginsChanged(trackOrigins); + } +} + +void ValgrindBaseSettings::setFilterExternalIssues(bool filterExternalIssues) +{ + if (m_filterExternalIssues != filterExternalIssues) { + m_filterExternalIssues = filterExternalIssues; + emit filterExternalIssuesChanged(filterExternalIssues); + } +} + +void ValgrindBaseSettings::setVisibleErrorKinds(const QList<int> &visibleErrorKinds) +{ + if (m_visibleErrorKinds != visibleErrorKinds) { + m_visibleErrorKinds = visibleErrorKinds; + emit visibleErrorKindsChanged(visibleErrorKinds); + } +} + +void ValgrindBaseSettings::setEnableCacheSim(bool enable) +{ + if (m_enableCacheSim == enable) + return; + + m_enableCacheSim = enable; + emit enableCacheSimChanged(enable); +} + +void ValgrindBaseSettings::setEnableBranchSim(bool enable) +{ + if (m_enableBranchSim == enable) + return; + + m_enableBranchSim = enable; + emit enableBranchSimChanged(enable); +} + +void ValgrindBaseSettings::setCollectSystime(bool collect) +{ + if (m_collectSystime == collect) + return; + + m_collectSystime = collect; + emit collectSystimeChanged(collect); +} + +void ValgrindBaseSettings::setCollectBusEvents(bool collect) +{ + if (m_collectBusEvents == collect) + return; + + m_collectBusEvents = collect; + emit collectBusEventsChanged(collect); +} + +void ValgrindBaseSettings::setEnableEventToolTips(bool enable) +{ + if (m_enableEventToolTips == enable) + return; + + m_enableEventToolTips = enable; + emit enableEventToolTipsChanged(enable); +} + +void ValgrindBaseSettings::setMinimumInclusiveCostRatio( + double minimumInclusiveCostRatio) +{ + if (m_minimumInclusiveCostRatio == minimumInclusiveCostRatio) + return; + + m_minimumInclusiveCostRatio = qBound(0.0, minimumInclusiveCostRatio, 100.0); + emit minimumInclusiveCostRatioChanged(minimumInclusiveCostRatio); +} + +void ValgrindBaseSettings::setVisualisationMinimumInclusiveCostRatio( + double minimumInclusiveCostRatio) +{ + if (m_visualisationMinimumInclusiveCostRatio == minimumInclusiveCostRatio) + return; + + m_visualisationMinimumInclusiveCostRatio = qBound(0.0, minimumInclusiveCostRatio, 100.0); + emit visualisationMinimumInclusiveCostRatioChanged(minimumInclusiveCostRatio); +} + + +////////////////////////////////////////////////////////////////// +// +// ValgrindGlobalSettings +// +////////////////////////////////////////////////////////////////// + +QWidget *ValgrindGlobalSettings::createConfigWidget(QWidget *parent) +{ + return new ValgrindConfigWidget(this, parent, true); +} + +QVariantMap ValgrindGlobalSettings::defaults() const +{ + QVariantMap map = ValgrindBaseSettings::defaults(); + + // Memcheck + map.insert(suppressionFilesC, QStringList()); + map.insert(lastSuppressionDirectoryC, QString()); + map.insert(lastSuppressionHistoryC, QStringList()); + + // Callgrind + map.insert(QLatin1String(callgrindCostFormatC), CostDelegate::FormatRelative); + map.insert(QLatin1String(callgrindCycleDetectionC), true); + + return map; +} + +bool ValgrindGlobalSettings::fromMap(const QVariantMap &map) +{ + ValgrindBaseSettings::fromMap(map); + + // Memcheck + m_suppressionFiles = map.value(suppressionFilesC).toStringList(); + m_lastSuppressionDirectory = map.value(lastSuppressionDirectoryC).toString(); + m_lastSuppressionHistory = map.value(lastSuppressionHistoryC).toStringList(); + + // Callgrind + // special code as the default one does not cope with the enum properly + if (map.contains(QLatin1String(callgrindCostFormatC))) + m_costFormat = static_cast<CostDelegate::CostFormat>(map.value(QLatin1String(callgrindCostFormatC)).toInt()); + setIfPresent(map, QLatin1String(callgrindCycleDetectionC), &m_detectCycles); + + return true; +} + +QVariantMap ValgrindGlobalSettings::toMap() const +{ + QVariantMap map = ValgrindBaseSettings::toMap(); + + // Memcheck + map.insert(suppressionFilesC, m_suppressionFiles); + map.insert(lastSuppressionDirectoryC, m_lastSuppressionDirectory); + map.insert(lastSuppressionHistoryC, m_lastSuppressionHistory); + + // Callgrind + map.insert(QLatin1String(callgrindCostFormatC), m_costFormat); + map.insert(QLatin1String(callgrindCycleDetectionC), m_detectCycles); + + return map; +} + +// +// Memcheck +// +QStringList ValgrindGlobalSettings::suppressionFiles() const +{ + return m_suppressionFiles; +} + +void ValgrindGlobalSettings::addSuppressionFiles(const QStringList &suppressions) +{ + foreach (const QString &s, suppressions) + if (!m_suppressionFiles.contains(s)) + m_suppressionFiles.append(s); +} + + +void ValgrindGlobalSettings::removeSuppressionFiles(const QStringList &suppressions) +{ + foreach (const QString &s, suppressions) + m_suppressionFiles.removeAll(s); +} + +QString ValgrindGlobalSettings::lastSuppressionDialogDirectory() const +{ + return m_lastSuppressionDirectory; +} + +void ValgrindGlobalSettings::setLastSuppressionDialogDirectory(const QString &directory) +{ + m_lastSuppressionDirectory = directory; +} + +QStringList ValgrindGlobalSettings::lastSuppressionDialogHistory() const +{ + return m_lastSuppressionHistory; +} + +void ValgrindGlobalSettings::setLastSuppressionDialogHistory(const QStringList &history) +{ + m_lastSuppressionHistory = history; +} + +// +// Callgrind +// +CostDelegate::CostFormat ValgrindGlobalSettings::costFormat() const +{ + return m_costFormat; +} + +void ValgrindGlobalSettings::setCostFormat(CostDelegate::CostFormat format) +{ + m_costFormat = format; + AnalyzerGlobalSettings::instance()->writeSettings(); +} + +bool ValgrindGlobalSettings::detectCycles() const +{ + return m_detectCycles; +} + +void ValgrindGlobalSettings::setDetectCycles(bool detect) +{ + m_detectCycles = detect; + AnalyzerGlobalSettings::instance()->writeSettings(); +} + +ValgrindGlobalSettings *globalValgrindSettings() { - return "Analyzer.Valgrind.Settings.Generic"; + ValgrindGlobalSettings *ret = AnalyzerGlobalSettings::instance()->subConfig<ValgrindGlobalSettings>(); + QTC_ASSERT(ret, return 0); + return ret; } -QString ValgrindSettings::displayName() const +////////////////////////////////////////////////////////////////// +// +// ValgrindProjectSettings +// +////////////////////////////////////////////////////////////////// + +QWidget *ValgrindProjectSettings::createConfigWidget(QWidget *parent) { - return tr("Generic Settings"); + return new ValgrindConfigWidget(this, parent, false); +} + +QVariantMap ValgrindProjectSettings::defaults() const +{ + QVariantMap map = ValgrindBaseSettings::defaults(); + + // Memcheck + map.insert(addedSuppressionFilesC, QStringList()); + map.insert(removedSuppressionFilesC, QStringList()); + + return map; } -QWidget *ValgrindSettings::createConfigWidget(QWidget *parent) +bool ValgrindProjectSettings::fromMap(const QVariantMap &map) { - return new ValgrindConfigWidget(this, parent); + ValgrindBaseSettings::fromMap(map); + + // Memcheck + setIfPresent(map, addedSuppressionFilesC, &m_addedSuppressionFiles); + setIfPresent(map, removedSuppressionFilesC, &m_disabledGlobalSuppressionFiles); + + return true; } + +QVariantMap ValgrindProjectSettings::toMap() const +{ + QVariantMap map = ValgrindBaseSettings::toMap(); + + // Memcheck + map.insert(addedSuppressionFilesC, m_addedSuppressionFiles); + map.insert(removedSuppressionFilesC, m_disabledGlobalSuppressionFiles); + + return map; +} + +// +// Memcheck +// + +void ValgrindProjectSettings::addSuppressionFiles(const QStringList &suppressions) +{ + QStringList globalSuppressions = globalValgrindSettings()->suppressionFiles(); + foreach (const QString &s, suppressions) { + if (m_addedSuppressionFiles.contains(s)) + continue; + m_disabledGlobalSuppressionFiles.removeAll(s); + if (!globalSuppressions.contains(s)) + m_addedSuppressionFiles.append(s); + } +} + +void ValgrindProjectSettings::removeSuppressionFiles(const QStringList &suppressions) +{ + QStringList globalSuppressions = globalValgrindSettings()->suppressionFiles(); + foreach (const QString &s, suppressions) { + m_addedSuppressionFiles.removeAll(s); + if (globalSuppressions.contains(s)) + m_disabledGlobalSuppressionFiles.append(s); + } +} + +QStringList ValgrindProjectSettings::suppressionFiles() const +{ + QStringList ret = globalValgrindSettings()->suppressionFiles(); + foreach (const QString &s, m_disabledGlobalSuppressionFiles) + ret.removeAll(s); + ret.append(m_addedSuppressionFiles); + return ret; +} + +} // namespace Internal +} // namespace Valgrind diff --git a/src/plugins/valgrind/valgrindsettings.h b/src/plugins/valgrind/valgrindsettings.h index 0e4b5dfe38..347228e87a 100644 --- a/src/plugins/valgrind/valgrindsettings.h +++ b/src/plugins/valgrind/valgrindsettings.h @@ -36,30 +36,37 @@ #define ANALYZER_INTERNAL_VALGRINDSETTINGS_H #include <analyzerbase/analyzersettings.h> +#include "callgrindcostdelegate.h" #include <QtCore/QObject> +#include <QtCore/QString> #include <QtCore/QVariant> namespace Valgrind { namespace Internal { /** - * Generic Valgrind settings shared by all tools. + * Valgrind settings shared for global and per-project. */ -class ValgrindSettings : public Analyzer::AbstractAnalyzerSubConfig +class ValgrindBaseSettings : public Analyzer::AbstractAnalyzerSubConfig { Q_OBJECT + public: - ValgrindSettings() {} + ValgrindBaseSettings() {} virtual QVariantMap toMap() const; virtual QVariantMap defaults() const; - - QString valgrindExecutable() const; + virtual bool fromMap(const QVariantMap &map); virtual QString id() const; virtual QString displayName() const; - virtual QWidget *createConfigWidget(QWidget *parent); + +/** + * Base valgrind settings + */ +public: + QString valgrindExecutable() const; public slots: void setValgrindExecutable(const QString &); @@ -67,11 +74,179 @@ public slots: signals: void valgrindExecutableChanged(const QString &); +private: + QString m_valgrindExecutable; + + +/** + * Base memcheck settings + */ +public: + int numCallers() const { return m_numCallers; } + bool trackOrigins() const { return m_trackOrigins; } + bool filterExternalIssues() const { return m_filterExternalIssues; } + QList<int> visibleErrorKinds() const { return m_visibleErrorKinds; } + + virtual QStringList suppressionFiles() const = 0; + virtual void addSuppressionFiles(const QStringList &) = 0; + virtual void removeSuppressionFiles(const QStringList &) = 0; + +public slots: + void setNumCallers(int); + void setTrackOrigins(bool); + void setFilterExternalIssues(bool); + void setVisibleErrorKinds(const QList<int> &); + +signals: + void numCallersChanged(int); + void trackOriginsChanged(bool); + void filterExternalIssuesChanged(bool); + void visibleErrorKindsChanged(const QList<int> &); + void suppressionFilesRemoved(const QStringList &); + void suppressionFilesAdded(const QStringList &); + protected: - virtual bool fromMap(const QVariantMap &map); + int m_numCallers; + bool m_trackOrigins; + bool m_filterExternalIssues; + QList<int> m_visibleErrorKinds; + +/** + * Base callgrind settings + */ +public: + bool enableCacheSim() const { return m_enableCacheSim; } + bool enableBranchSim() const { return m_enableBranchSim; } + bool collectSystime() const { return m_collectSystime; } + bool collectBusEvents() const { return m_collectBusEvents; } + bool enableEventToolTips() const { return m_enableEventToolTips; } + + /// \return Minimum cost ratio, range [0.0..100.0] + double minimumInclusiveCostRatio() const { return m_minimumInclusiveCostRatio; } + + /// \return Minimum cost ratio, range [0.0..100.0] + double visualisationMinimumInclusiveCostRatio() const { return m_visualisationMinimumInclusiveCostRatio; } + +public slots: + void setEnableCacheSim(bool enable); + void setEnableBranchSim(bool enable); + void setCollectSystime(bool collect); + void setCollectBusEvents(bool collect); + void setEnableEventToolTips(bool enable); + + /// \param minimumInclusiveCostRatio Minimum inclusive cost ratio, valid values are [0.0..100.0] + void setMinimumInclusiveCostRatio(double minimumInclusiveCostRatio); + + /// \param minimumInclusiveCostRatio Minimum inclusive cost ratio, valid values are [0.0..100.0] + void setVisualisationMinimumInclusiveCostRatio(double minimumInclusiveCostRatio); + +signals: + void enableCacheSimChanged(bool); + void enableBranchSimChanged(bool); + void collectSystimeChanged(bool); + void collectBusEventsChanged(bool); + void enableEventToolTipsChanged(bool); + void minimumInclusiveCostRatioChanged(double); + void visualisationMinimumInclusiveCostRatioChanged(double); private: - QString m_valgrindExecutable; + bool m_enableCacheSim; + bool m_collectSystime; + bool m_collectBusEvents; + bool m_enableBranchSim; + bool m_enableEventToolTips; + double m_minimumInclusiveCostRatio; + double m_visualisationMinimumInclusiveCostRatio; +}; + + +/** + * Global valgrind settings + */ +class ValgrindGlobalSettings : public ValgrindBaseSettings +{ + Q_OBJECT + +public: + ValgrindGlobalSettings() {} + + QWidget *createConfigWidget(QWidget *parent); + QVariantMap toMap() const; + QVariantMap defaults() const; + bool fromMap(const QVariantMap &map); + + /* + * Global memcheck settings + */ +public: + QStringList suppressionFiles() const; + // in the global settings we change the internal list directly + void addSuppressionFiles(const QStringList &); + void removeSuppressionFiles(const QStringList &); + + // internal settings which don't require any UI + void setLastSuppressionDialogDirectory(const QString &directory); + QString lastSuppressionDialogDirectory() const; + + void setLastSuppressionDialogHistory(const QStringList &history); + QStringList lastSuppressionDialogHistory() const; + +private: + QStringList m_suppressionFiles; + QString m_lastSuppressionDirectory; + QStringList m_lastSuppressionHistory; + + + /** + * Global callgrind settings + */ +public: + + CostDelegate::CostFormat costFormat() const; + bool detectCycles() const; + +public slots: + void setCostFormat(Valgrind::Internal::CostDelegate::CostFormat format); + void setDetectCycles(bool detect); + +private: + CostDelegate::CostFormat m_costFormat; + bool m_detectCycles; +}; + + +/** + * Per-project valgrind settings. + */ +class ValgrindProjectSettings : public ValgrindBaseSettings +{ + Q_OBJECT + +public: + ValgrindProjectSettings() {} + + QWidget *createConfigWidget(QWidget *parent); + QVariantMap toMap() const; + QVariantMap defaults() const; + bool fromMap(const QVariantMap &map); + + /** + * Per-project memcheck settings, saves a diff to the global suppression files list + */ +public: + QStringList suppressionFiles() const; + // in the project-specific settings we store a diff to the global list + void addSuppressionFiles(const QStringList &suppressions); + void removeSuppressionFiles(const QStringList &suppressions); + +private: + QStringList m_disabledGlobalSuppressionFiles; + QStringList m_addedSuppressionFiles; + + + /** + * Per-project callgrind settings, saves a diff to the global suppression files list + */ }; } // namespace Internal diff --git a/src/plugins/valgrind/xmlprotocol/error.cpp b/src/plugins/valgrind/xmlprotocol/error.cpp index 3742456142..70c7f5427c 100644 --- a/src/plugins/valgrind/xmlprotocol/error.cpp +++ b/src/plugins/valgrind/xmlprotocol/error.cpp @@ -248,7 +248,7 @@ QString Error::toXml() const if (!frame.file().isEmpty()) { stream << " <file>" << frame.file() << "</file>\n"; } - if (!frame.line() == -1) { + if (frame.line() != -1) { stream << " <line>" << frame.line() << "</line>"; } stream << " </frame>\n"; diff --git a/src/plugins/valgrind/xmlprotocol/frame.cpp b/src/plugins/valgrind/xmlprotocol/frame.cpp index 9b36a4a368..876af1bf27 100644 --- a/src/plugins/valgrind/xmlprotocol/frame.cpp +++ b/src/plugins/valgrind/xmlprotocol/frame.cpp @@ -43,9 +43,7 @@ namespace XmlProtocol { class Frame::Private : public QSharedData { public: - explicit Private() : - ip(0), line( -1 ) - {} + Private() : ip(0), line(-1) {} bool operator==(const Private &other) const { @@ -74,7 +72,7 @@ Frame::~Frame() } Frame::Frame(const Frame &other) : - d( other.d ) + d(other.d) { } diff --git a/src/plugins/welcome/images/checked.png b/src/plugins/welcome/images/checked.png Binary files differnew file mode 100644 index 0000000000..68617b2f50 --- /dev/null +++ b/src/plugins/welcome/images/checked.png diff --git a/src/plugins/welcome/images/draw-star.png b/src/plugins/welcome/images/draw-star.png Binary files differnew file mode 100644 index 0000000000..bde01565d8 --- /dev/null +++ b/src/plugins/welcome/images/draw-star.png diff --git a/src/plugins/welcome/images/face-star.png b/src/plugins/welcome/images/face-star.png Binary files differnew file mode 100644 index 0000000000..7455f9dcc2 --- /dev/null +++ b/src/plugins/welcome/images/face-star.png diff --git a/src/plugins/welcome/images/lineedit.png b/src/plugins/welcome/images/lineedit.png Binary files differnew file mode 100644 index 0000000000..1f15c4fcaa --- /dev/null +++ b/src/plugins/welcome/images/lineedit.png diff --git a/src/plugins/welcome/images/rc_combined_transparent.png b/src/plugins/welcome/images/rc_combined_transparent.png Binary files differnew file mode 100644 index 0000000000..90393c7241 --- /dev/null +++ b/src/plugins/welcome/images/rc_combined_transparent.png diff --git a/src/plugins/welcome/images/tab_active.png b/src/plugins/welcome/images/tab_active.png Binary files differindex 7bed3d9d89..c514b8abbf 100644 --- a/src/plugins/welcome/images/tab_active.png +++ b/src/plugins/welcome/images/tab_active.png diff --git a/src/plugins/welcome/images/tab_hover.png b/src/plugins/welcome/images/tab_hover.png Binary files differindex d11cdd71fe..2e0878ef6b 100644 --- a/src/plugins/welcome/images/tab_hover.png +++ b/src/plugins/welcome/images/tab_hover.png diff --git a/src/plugins/welcome/images/tab_inactive.png b/src/plugins/welcome/images/tab_inactive.png Binary files differindex 04e804c0fc..88c77c6ebb 100644 --- a/src/plugins/welcome/images/tab_inactive.png +++ b/src/plugins/welcome/images/tab_inactive.png diff --git a/src/plugins/welcome/welcome.qrc b/src/plugins/welcome/welcome.qrc index 3c1c211dd7..10e450960d 100644 --- a/src/plugins/welcome/welcome.qrc +++ b/src/plugins/welcome/welcome.qrc @@ -25,5 +25,10 @@ <file>images/background_center_frame_v1.png</file> <file>images/background_center_frame_v2.png</file> <file>images/tab_hover.png</file> + <file>images/rc_combined_transparent.png</file> + <file>images/checked.png</file> + <file>images/lineedit.png</file> + <file>images/draw-star.png</file> + <file>images/face-star.png</file> </qresource> </RCC> diff --git a/src/plugins/welcome/welcomeplugin.cpp b/src/plugins/welcome/welcomeplugin.cpp index 0196bda808..920b4beddc 100644 --- a/src/plugins/welcome/welcomeplugin.cpp +++ b/src/plugins/welcome/welcomeplugin.cpp @@ -45,7 +45,6 @@ #include <projectexplorer/projectexplorer.h> #include <utils/styledbar.h> -#include <utils/welcomemodetreewidget.h> #include <utils/iwelcomepage.h> #include <QtGui/QScrollArea> @@ -146,7 +145,7 @@ WelcomeMode::WelcomeMode() : QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); - layout->addWidget(new Utils::StyledBar); +// layout->addWidget(new Utils::StyledBar); layout->addWidget(m_welcomePage); m_modeWidget->setLayout(layout); diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index f3b4c3db89..55e3e5373b 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -298,6 +298,12 @@ public: QStringList qmakeMkspecPaths() const; QStringList qmakeFeaturePaths() const; + void populateDeps( + const ProStringList &deps, const ProString &prefix, + QHash<ProString, QSet<ProString> > &dependencies, + QHash<ProString, ProStringList> &dependees, + ProStringList &rootSet) const; + QString expandEnvVars(const QString &str) const; QString fixPathToLocalOS(const QString &str) const; QString sysrootify(const QString &path, const QString &baseDir) const; @@ -342,7 +348,7 @@ public: E_SPRINTF, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION, E_FIND, E_SYSTEM, E_UNIQUE, E_QUOTE, E_ESCAPE_EXPAND, E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE, - E_REPLACE + E_REPLACE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS }; enum TestFunc { @@ -443,7 +449,9 @@ void ProFileEvaluator::Private::initStatics() { "re_escape", E_RE_ESCAPE }, { "files", E_FILES }, { "prompt", E_PROMPT }, // interactive, so cannot be implemented - { "replace", E_REPLACE } + { "replace", E_REPLACE }, + { "sort_depends", E_SORT_DEPENDS }, + { "resolve_depends", E_RESOLVE_DEPENDS } }; for (unsigned i = 0; i < sizeof(expandInits)/sizeof(expandInits[0]); ++i) statics.expands.insert(ProString(expandInits[i].name), expandInits[i].func); @@ -2029,6 +2037,27 @@ ProStringList ProFileEvaluator::Private::expandVariableReferences( } } +void ProFileEvaluator::Private::populateDeps( + const ProStringList &deps, const ProString &prefix, + QHash<ProString, QSet<ProString> > &dependencies, QHash<ProString, ProStringList> &dependees, + ProStringList &rootSet) const +{ + foreach (const ProString &item, deps) + if (!dependencies.contains(item)) { + QSet<ProString> &dset = dependencies[item]; // Always create entry + ProStringList depends = valuesDirect(ProString(prefix + item + QString::fromLatin1(".depends"))); + if (depends.isEmpty()) { + rootSet << item; + } else { + foreach (const ProString &dep, depends) { + dset.insert(dep); + dependees[dep] << item; + } + populateDeps(depends, prefix, dependencies, dependees, rootSet); + } + } +} + QList<ProStringList> ProFileEvaluator::Private::prepareFunctionArgs(const ushort *&tokPtr) { QList<ProStringList> args_list; @@ -2532,6 +2561,30 @@ ProStringList ProFileEvaluator::Private::evaluateExpandFunction( } } break; + case E_SORT_DEPENDS: + case E_RESOLVE_DEPENDS: + if (args.count() < 1 || args.count() > 2) { + evalError(fL1S("%1(var, prefix) requires one or two arguments").arg(func.toQString(m_tmp1))); + } else { + QHash<ProString, QSet<ProString> > dependencies; + QHash<ProString, ProStringList> dependees; + ProStringList rootSet; + ProStringList orgList = valuesDirect(args.at(0)); + populateDeps(orgList, (args.count() < 2 ? ProString() : args.at(1)), + dependencies, dependees, rootSet); + for (int i = 0; i < rootSet.size(); ++i) { + const ProString &item = rootSet.at(i); + if ((func_t == E_RESOLVE_DEPENDS) || orgList.contains(item)) + ret.prepend(item); + foreach (const ProString &dep, dependees[item]) { + QSet<ProString> &dset = dependencies[dep]; + dset.remove(item); + if (dset.isEmpty()) + rootSet << dep; + } + } + } + break; case E_INVALID: evalError(fL1S("'%1' is not a recognized replace function") .arg(func.toQString(m_tmp1))); diff --git a/src/tools/qtcreatorwidgets/customwidgets.cpp b/src/tools/qtcreatorwidgets/customwidgets.cpp index ac4f2f68f3..c237673d33 100644 --- a/src/tools/qtcreatorwidgets/customwidgets.cpp +++ b/src/tools/qtcreatorwidgets/customwidgets.cpp @@ -240,38 +240,6 @@ Wizard_CW::Wizard_CW(QObject *parent) : { } -WelcomePageWidget_CW::WelcomePageWidget_CW(QObject *parent) : - QObject(parent), - CustomWidget<Utils::WelcomeModeTreeWidget> - (QLatin1String("<utils/welcomemodetreewidget.h>"), - false, - QLatin1String(groupC), - QIcon(), - QLatin1String("Welcome page widget")) -{ -} - -QWidget *WelcomePageWidget_CW::createWidget(QWidget *parent) -{ - Utils::WelcomeModeTreeWidget *rc = new Utils::WelcomeModeTreeWidget(parent); - rc->addNewsItem(QLatin1String("Breaking news"), - QLatin1String("Bla bla bla"), QLatin1String("qt.nokia.com")); - rc->addNewsItem(QLatin1String("Yesterday's breaking news"), - QLatin1String("Blub blub blub"), QLatin1String("qt.nokia.com")); - return rc; -} - -WelcomeModeLabel_CW::WelcomeModeLabel_CW(QObject *parent) : - QObject(parent), - CustomWidget<Utils::WelcomeModeLabel> - (QLatin1String("<utils/welcomemodetreewidget.h>"), - false, - QLatin1String(groupC), - QIcon(), - QLatin1String("Welcome page header label")) -{ -} - CrumblePath_CW::CrumblePath_CW(QObject *parent) : QObject(parent), CustomWidget<Utils::CrumblePath> @@ -281,8 +249,7 @@ CrumblePath_CW::CrumblePath_CW(QObject *parent) : QIcon(), QLatin1String("Crumble Path")) { -}; - +} DetailsWidget_CW::DetailsWidget_CW(QObject *parent) : QObject(parent), @@ -410,8 +377,6 @@ WidgetCollection::WidgetCollection(QObject *parent) : m_plugins.push_back(new StyledBar_CW(this)); m_plugins.push_back(new StyledSeparator_CW(this)); m_plugins.push_back(new Wizard_CW(this)); - m_plugins.push_back(new WelcomePageWidget_CW(this)); - m_plugins.push_back(new WelcomeModeLabel_CW(this)); m_plugins.push_back(new CrumblePath_CW(this)); } diff --git a/src/tools/qtcreatorwidgets/customwidgets.h b/src/tools/qtcreatorwidgets/customwidgets.h index 2fbee7448a..44d43b1739 100644 --- a/src/tools/qtcreatorwidgets/customwidgets.h +++ b/src/tools/qtcreatorwidgets/customwidgets.h @@ -50,7 +50,6 @@ #include <utils/detailswidget.h> #include <utils/styledbar.h> #include <utils/wizard.h> -#include <utils/welcomemodetreewidget.h> #include <utils/crumblepath.h> #include <QtDesigner/QDesignerCustomWidgetCollectionInterface> @@ -238,27 +237,6 @@ public: explicit Wizard_CW(QObject *parent = 0); }; -class WelcomePageWidget_CW : - public QObject, - public CustomWidget<Utils::WelcomeModeTreeWidget> -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) -public: - explicit WelcomePageWidget_CW(QObject *parent = 0); - virtual QWidget *createWidget(QWidget *parent); -}; - -class WelcomeModeLabel_CW : - public QObject, - public CustomWidget<Utils::WelcomeModeLabel> -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) -public: - explicit WelcomeModeLabel_CW(QObject *parent = 0); -}; - class CrumblePath_CW : public QObject, public CustomWidget<Utils::CrumblePath> |