summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp145
-rw-r--r--src/plugins/cmakeprojectmanager/cmakelocatorfilter.h66
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.qrc2
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro11
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp2
-rw-r--r--src/plugins/cmakeprojectmanager/makestep.cpp15
-rw-r--r--src/plugins/cmakeprojectmanager/makestep.h6
7 files changed, 244 insertions, 3 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp
new file mode 100644
index 0000000000..a6260de445
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp
@@ -0,0 +1,145 @@
+
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2011 Nicolas Arnaud-Cormos
+**
+** Contact: KDAB (info@kdab.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 "cmakelocatorfilter.h"
+#include "cmaketarget.h"
+#include "cmakeproject.h"
+#include "makestep.h"
+
+#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/session.h>
+#include <projectexplorer/projectexplorerconstants.h>
+#include <projectexplorer/buildsteplist.h>
+
+
+using namespace CMakeProjectManager;
+using namespace CMakeProjectManager::Internal;
+
+CMakeLocatorFilter::CMakeLocatorFilter()
+{
+ setShortcutString(QLatin1String("cm"));
+
+ ProjectExplorer::SessionManager *sm = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
+ connect(sm, SIGNAL(projectAdded(ProjectExplorer::Project*)),
+ this, SLOT(slotProjectListUpdated()));
+ connect(sm, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
+ this, SLOT(slotProjectListUpdated()));
+}
+
+CMakeLocatorFilter::~CMakeLocatorFilter()
+{
+
+}
+
+QList<Locator::FilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
+{
+ Q_UNUSED(future)
+ QList<Locator::FilterEntry> result;
+
+ QList<ProjectExplorer::Project *> projects =
+ ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects();
+ foreach (ProjectExplorer::Project *p, projects) {
+ CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p);
+ if (cmakeProject) {
+ foreach (CMakeBuildTarget ct, cmakeProject->buildTargets()) {
+ if (ct.title.contains(entry)) {
+ Locator::FilterEntry entry(this, ct.title, cmakeProject->file()->fileName());
+ entry.extraInfo = cmakeProject->file()->fileName();
+ result.append(entry);
+ }
+ }
+ }
+ }
+
+ return result;
+}
+
+void CMakeLocatorFilter::accept(Locator::FilterEntry selection) const
+{
+ // Get the project containing the target selected
+ CMakeProject *cmakeProject = 0;
+
+ QList<ProjectExplorer::Project *> projects =
+ ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects();
+ foreach (ProjectExplorer::Project *p, projects) {
+ cmakeProject = qobject_cast<CMakeProject *>(p);
+ if (cmakeProject && cmakeProject->file()->fileName() == selection.internalData.toString())
+ break;
+ cmakeProject = 0;
+ }
+ if (!cmakeProject)
+ return;
+
+ // Find the make step
+ MakeStep *makeStep = 0;
+ ProjectExplorer::BuildStepList *buildStepList = cmakeProject->activeTarget()->activeBuildConfiguration()
+ ->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
+ for (int i = 0; i < buildStepList->count(); ++i) {
+ makeStep = qobject_cast<MakeStep *>(buildStepList->at(i));
+ if (makeStep)
+ break;
+ }
+ if (!makeStep)
+ return;
+
+ // Change the make step to build only the given target
+ QStringList oldTargets = makeStep->buildTargets();
+ makeStep->setClean(false);
+ makeStep->clearBuildTargets();
+ makeStep->setBuildTarget(selection.displayName, true);
+
+ // Build
+ ProjectExplorer::ProjectExplorerPlugin::instance()->buildProject(cmakeProject);
+ makeStep->setBuildTargets(oldTargets);
+}
+
+void CMakeLocatorFilter::refresh(QFutureInterface<void> &future)
+{
+ Q_UNUSED(future)
+}
+
+void CMakeLocatorFilter::slotProjectListUpdated()
+{
+ CMakeProject *cmakeProject = 0;
+
+ QList<ProjectExplorer::Project *> projects =
+ ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects();
+ foreach (ProjectExplorer::Project *p, projects) {
+ cmakeProject = qobject_cast<CMakeProject *>(p);
+ if (cmakeProject)
+ break;
+ }
+
+ // Hide the locator if there's no CMake project
+ setHidden(!cmakeProject);
+}
diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h
new file mode 100644
index 0000000000..ddacc0caee
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h
@@ -0,0 +1,66 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2011 Nicolas Arnaud-Cormos
+**
+** Contact: KDAB (info@kdab.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 CMAKEPROJECTMANAGER_INTERNAL_CMAKEFILTER_H
+#define CMAKEPROJECTMANAGER_INTERNAL_CMAKEFILTER_H
+
+#include <locator/ilocatorfilter.h>
+
+#include <QtGui/QIcon>
+
+namespace CMakeProjectManager {
+namespace Internal {
+
+class CMakeLocatorFilter : public Locator::ILocatorFilter
+{
+ Q_OBJECT
+
+public:
+ CMakeLocatorFilter();
+ ~CMakeLocatorFilter();
+
+ QString displayName() const { return tr("Build CMake target"); }
+ QString id() const { return QLatin1String("Build CMake target"); }
+ Priority priority() const { return Medium; }
+
+ QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
+ void accept(Locator::FilterEntry selection) const;
+ void refresh(QFutureInterface<void> &future);
+
+private slots:
+ void slotProjectListUpdated();
+};
+
+} // namespace Internal
+} // namespace CMakeProjectManager
+
+#endif // CMAKEPROJECTMANAGER_INTERNAL_CMAKEFILTER_H
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.qrc b/src/plugins/cmakeprojectmanager/cmakeproject.qrc
index e9ae51f460..3705dfac04 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.qrc
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.qrc
@@ -1,5 +1,5 @@
<RCC>
- <qresource prefix="/cmakeproject" >
+ <qresource prefix="/cmakeproject">
<file>CMakeProject.mimetypes.xml</file>
</qresource>
</RCC>
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
index 370330860e..d1c2914899 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
@@ -1,7 +1,9 @@
TEMPLATE = lib
TARGET = CMakeProjectManager
+
include(../../qtcreatorplugin.pri)
include(cmakeprojectmanager_dependencies.pri)
+
HEADERS = cmakeproject.h \
cmakeprojectplugin.h \
cmakeprojectmanager.h \
@@ -15,7 +17,9 @@ HEADERS = cmakeproject.h \
cmakeeditorfactory.h \
cmakeeditor.h \
cmakehighlighter.h \
- cmakeuicodemodelsupport.h
+ cmakeuicodemodelsupport.h \
+ cmakelocatorfilter.h
+
SOURCES = cmakeproject.cpp \
cmakeprojectplugin.cpp \
cmakeprojectmanager.cpp \
@@ -28,8 +32,11 @@ SOURCES = cmakeproject.cpp \
cmakeeditorfactory.cpp \
cmakeeditor.cpp \
cmakehighlighter.cpp \
- cmakeuicodemodelsupport.cpp
+ cmakeuicodemodelsupport.cpp \
+ cmakelocatorfilter.cpp
+
RESOURCES += cmakeproject.qrc
+
FORMS +=
OTHER_FILES += CMakeProject.mimetypes.xml
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
index 123d6af6fb..b5db28b4f4 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
@@ -37,6 +37,7 @@
#include "makestep.h"
#include "cmakeprojectconstants.h"
#include "cmaketarget.h"
+#include "cmakelocatorfilter.h"
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
@@ -72,6 +73,7 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
addAutoReleasedObject(new CMakeEditorFactory(manager, editorHandler));
addAutoReleasedObject(new CMakeTargetFactory);
+ addAutoReleasedObject(new CMakeLocatorFilter);
return true;
}
diff --git a/src/plugins/cmakeprojectmanager/makestep.cpp b/src/plugins/cmakeprojectmanager/makestep.cpp
index d3ef7c3418..8e5fb897b5 100644
--- a/src/plugins/cmakeprojectmanager/makestep.cpp
+++ b/src/plugins/cmakeprojectmanager/makestep.cpp
@@ -187,6 +187,11 @@ void MakeStep::stdOutput(const QString &line)
AbstractProcessStep::stdOutput(line);
}
+QStringList MakeStep::buildTargets() const
+{
+ return m_buildTargets;
+}
+
bool MakeStep::buildsBuildTarget(const QString &target) const
{
return m_buildTargets.contains(target);
@@ -202,6 +207,16 @@ void MakeStep::setBuildTarget(const QString &buildTarget, bool on)
m_buildTargets = old;
}
+void MakeStep::setBuildTargets(const QStringList &targets)
+{
+ m_buildTargets = targets;
+}
+
+void MakeStep::clearBuildTargets()
+{
+ m_buildTargets.clear();
+}
+
QString MakeStep::additionalArguments() const
{
return m_additionalArguments;
diff --git a/src/plugins/cmakeprojectmanager/makestep.h b/src/plugins/cmakeprojectmanager/makestep.h
index 53d55d5e4b..0d4022e9e7 100644
--- a/src/plugins/cmakeprojectmanager/makestep.h
+++ b/src/plugins/cmakeprojectmanager/makestep.h
@@ -66,8 +66,13 @@ public:
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
virtual bool immutable() const;
+
+ QStringList buildTargets() const;
bool buildsBuildTarget(const QString &target) const;
void setBuildTarget(const QString &target, bool on);
+ void setBuildTargets(const QStringList &targets);
+ void clearBuildTargets();
+
QString additionalArguments() const;
void setAdditionalArguments(const QString &list);
@@ -75,6 +80,7 @@ public:
QVariantMap toMap() const;
+
protected:
MakeStep(ProjectExplorer::BuildStepList *bsl, MakeStep *bs);
MakeStep(ProjectExplorer::BuildStepList *bsl, const QString &id);