summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp58
-rw-r--r--src/plugins/cmakeprojectmanager/cmakelocatorfilter.h17
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp2
3 files changed, 48 insertions, 29 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp
index b6f33a754f..9ea23469e1 100644
--- a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp
@@ -47,11 +47,6 @@ using namespace Utils;
CMakeTargetLocatorFilter::CMakeTargetLocatorFilter()
{
- setId("Build CMake target");
- setDisplayName(tr("Build CMake target"));
- setShortcutString("cm");
- setPriority(High);
-
connect(SessionManager::instance(), &SessionManager::projectAdded,
this, &CMakeTargetLocatorFilter::projectListUpdated);
connect(SessionManager::instance(), &SessionManager::projectRemoved,
@@ -89,23 +84,49 @@ QList<Core::LocatorFilterEntry> CMakeTargetLocatorFilter::matchesFor(QFutureInte
return m_result;
}
-void CMakeTargetLocatorFilter::accept(Core::LocatorFilterEntry selection,
- QString *newText, int *selectionStart, int *selectionLength) const
+void CMakeTargetLocatorFilter::refresh(QFutureInterface<void> &future)
+{
+ Q_UNUSED(future)
+}
+
+void CMakeTargetLocatorFilter::projectListUpdated()
+{
+ // Enable the filter if there's at least one CMake project
+ setEnabled(Utils::contains(SessionManager::projects(), [](Project *p) { return qobject_cast<CMakeProject *>(p); }));
+}
+
+// --------------------------------------------------------------------
+// BuildCMakeTargetLocatorFilter:
+// --------------------------------------------------------------------
+
+BuildCMakeTargetLocatorFilter::BuildCMakeTargetLocatorFilter()
+{
+ setId("Build CMake target");
+ setDisplayName(tr("Build CMake target"));
+ setShortcutString("cm");
+ setPriority(High);
+}
+
+void BuildCMakeTargetLocatorFilter::accept(Core::LocatorFilterEntry selection,
+ QString *newText,
+ int *selectionStart,
+ int *selectionLength) const
{
Q_UNUSED(newText)
Q_UNUSED(selectionStart)
Q_UNUSED(selectionLength)
// Get the project containing the target selected
const auto cmakeProject = qobject_cast<CMakeProject *>(
- Utils::findOrDefault(SessionManager::projects(), [selection](Project *p) {
- return p->projectFilePath().toString() == selection.internalData.toString();
- }));
- if (!cmakeProject || !cmakeProject->activeTarget() || !cmakeProject->activeTarget()->activeBuildConfiguration())
+ Utils::findOrDefault(SessionManager::projects(), [selection](Project *p) {
+ return p->projectFilePath().toString() == selection.internalData.toString();
+ }));
+ if (!cmakeProject || !cmakeProject->activeTarget()
+ || !cmakeProject->activeTarget()->activeBuildConfiguration())
return;
// Find the make step
- BuildStepList *buildStepList = cmakeProject->activeTarget()->activeBuildConfiguration()
- ->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
+ BuildStepList *buildStepList = cmakeProject->activeTarget()->activeBuildConfiguration()->stepList(
+ ProjectExplorer::Constants::BUILDSTEPS_BUILD);
auto buildStep = buildStepList->firstOfType<CMakeBuildStep>();
if (!buildStep)
return;
@@ -119,14 +140,3 @@ void CMakeTargetLocatorFilter::accept(Core::LocatorFilterEntry selection,
ProjectExplorerPlugin::buildProject(cmakeProject);
buildStep->setBuildTarget(oldTarget);
}
-
-void CMakeTargetLocatorFilter::refresh(QFutureInterface<void> &future)
-{
- Q_UNUSED(future)
-}
-
-void CMakeTargetLocatorFilter::projectListUpdated()
-{
- // Enable the filter if there's at least one CMake project
- setEnabled(Utils::contains(SessionManager::projects(), [](Project *p) { return qobject_cast<CMakeProject *>(p); }));
-}
diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h
index f07b56113b..d68db1a496 100644
--- a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h
+++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h
@@ -40,10 +40,6 @@ public:
void prepareSearch(const QString &entry) override;
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry) final;
- void accept(Core::LocatorFilterEntry selection,
- QString *newText,
- int *selectionStart,
- int *selectionLength) const final;
void refresh(QFutureInterface<void> &future) final;
private:
@@ -52,5 +48,18 @@ private:
QList<Core::LocatorFilterEntry> m_result;
};
+class BuildCMakeTargetLocatorFilter : CMakeTargetLocatorFilter
+{
+ Q_OBJECT
+
+public:
+ BuildCMakeTargetLocatorFilter();
+
+ void accept(Core::LocatorFilterEntry selection,
+ QString *newText,
+ int *selectionStart,
+ int *selectionLength) const final;
+};
+
} // namespace Internal
} // namespace CMakeProjectManager
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
index 4a1aa92694..facbcaa9f6 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
@@ -75,7 +75,7 @@ public:
SimpleRunWorkerFactory<SimpleTargetRunner, CMakeRunConfiguration> runWorkerFactory;
CMakeBuildConfigurationFactory buildConfigFactory;
CMakeEditorFactory editorFactor;
- CMakeTargetLocatorFilter locatorFiler;
+ BuildCMakeTargetLocatorFilter buildCMakeTargetLocatorFiler;
CMakeKitAspect cmakeKitAspect;
CMakeGeneratorKitAspect cmakeGeneratorKitAspect;