diff options
author | hjk <hjk@theqtcompany.com> | 2015-03-03 23:43:37 +0100 |
---|---|---|
committer | hjk <hjk@theqtcompany.com> | 2015-03-04 09:56:07 +0000 |
commit | 33eeb5880b7d477887b714bf032884f3d5501096 (patch) | |
tree | 9e20eb5ac19b9120d0ae9018041d7dfc02c30955 | |
parent | e36b40161ef026f1a6b8c480cf76112f85f29d6f (diff) | |
download | qt-creator-33eeb5880b7d477887b714bf032884f3d5501096.tar.gz |
ProjectExplorer: Replace two uses of QAction::setData
... by a connection to a lambda.
Change-Id: I32a276146cf6a4cfc79ae9c133a4cb5f0783c867
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
-rw-r--r-- | src/plugins/projectexplorer/kitmanagerconfigwidget.cpp | 19 | ||||
-rw-r--r-- | src/plugins/projectexplorer/kitmanagerconfigwidget.h | 1 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.cpp | 19 |
3 files changed, 13 insertions, 26 deletions
diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp index 06f33d3f5b..56476a4543 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp @@ -219,12 +219,15 @@ void KitManagerConfigWidget::addConfigWidget(KitConfigWidget *widget) QAction *action = new QAction(tr("Mark as Mutable"), 0); action->setCheckable(true); - action->setData(QVariant::fromValue(qobject_cast<QObject *>(widget))); action->setChecked(widget->isMutable()); action->setEnabled(!widget->isSticky()); widget->mainWidget()->addAction(action); widget->mainWidget()->setContextMenuPolicy(Qt::ActionsContextMenu); - connect(action, &QAction::toggled, this, &KitManagerConfigWidget::updateMutableState); + connect(action, &QAction::toggled, this, [this, widget, action] { + widget->setMutable(action->isChecked()); + emit dirty(); + }); + m_actions << action; int row = m_layout->rowCount(); @@ -363,18 +366,6 @@ void KitManagerConfigWidget::kitWasUpdated(Kit *k) updateVisibility(); } -void KitManagerConfigWidget::updateMutableState() -{ - QAction *action = qobject_cast<QAction *>(sender()); - if (!action) - return; - KitConfigWidget *widget = qobject_cast<KitConfigWidget *>(action->data().value<QObject *>()); - if (!widget) - return; - widget->setMutable(action->isChecked()); - emit dirty(); -} - QLabel *KitManagerConfigWidget::createLabel(const QString &name, const QString &toolTip) { QLabel *label = new QLabel(name); diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.h b/src/plugins/projectexplorer/kitmanagerconfigwidget.h index 750ed14eab..2d00ef0c6b 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.h +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.h @@ -85,7 +85,6 @@ private slots: void setFileSystemFriendlyName(); void workingCopyWasUpdated(ProjectExplorer::Kit *k); void kitWasUpdated(ProjectExplorer::Kit *k); - void updateMutableState(); private: enum LayoutColumns { diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index faef1ed2cf..97be5283c6 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -266,7 +266,7 @@ public: void updateRecentProjectMenu(); void clearRecentProjects(); - void openRecentProject(); + void openRecentProject(const QString &fileName); void updateUnloadProjectMenu(); void openTerminalHere(); @@ -2830,12 +2830,13 @@ void ProjectExplorerPluginPrivate::updateRecentProjectMenu() //projects (ignore sessions, they used to be in this list) const StringPairListConstIterator end = dd->m_recentProjects.constEnd(); for (StringPairListConstIterator it = dd->m_recentProjects.constBegin(); it != end; ++it) { - const QPair<QString, QString> &s = *it; - if (s.first.endsWith(QLatin1String(".qws"))) + const QString fileName = it->first; + if (fileName.endsWith(QLatin1String(".qws"))) continue; - QAction *action = menu->addAction(Utils::withTildeHomePath(s.first)); - action->setData(s.first); - connect(action, &QAction::triggered, this, &ProjectExplorerPluginPrivate::openRecentProject); + QAction *action = menu->addAction(Utils::withTildeHomePath(fileName)); + connect(action, &QAction::triggered, this, [this, fileName] { + openRecentProject(fileName); + }); hasRecentProjects = true; } menu->setEnabled(hasRecentProjects); @@ -2856,15 +2857,11 @@ void ProjectExplorerPluginPrivate::clearRecentProjects() updateWelcomePage(); } -void ProjectExplorerPluginPrivate::openRecentProject() +void ProjectExplorerPluginPrivate::openRecentProject(const QString &fileName) { if (debug) qDebug() << "ProjectExplorerPlugin::openRecentProject()"; - QAction *a = qobject_cast<QAction*>(sender()); - if (!a) - return; - QString fileName = a->data().toString(); if (!fileName.isEmpty()) { QString errorMessage; ProjectExplorerPlugin::openProject(fileName, &errorMessage); |