diff options
Diffstat (limited to 'src/plugins/cmakeprojectmanager')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeeditor.cpp | 42 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeeditor.h | 10 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeproject.cpp | 39 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeproject.h | 7 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp | 19 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeprojectmanager.h | 5 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmaketarget.cpp | 10 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmaketarget.h | 2 |
8 files changed, 67 insertions, 67 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp index 67beed6723..360f213676 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp @@ -35,7 +35,10 @@ #include "cmakehighlighter.h" #include "cmakeeditorfactory.h" #include "cmakeprojectconstants.h" +#include "cmakeproject.h" +#include <projectexplorer/projectexplorer.h> +#include <projectexplorer/session.h> #include <texteditor/fontsettings.h> #include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditorconstants.h> @@ -51,14 +54,11 @@ using namespace CMakeProjectManager::Internal; // CMakeEditor::CMakeEditor(CMakeEditorWidget *editor) - : BaseTextEditor(editor), - m_context(CMakeProjectManager::Constants::C_CMAKEEDITOR, - TextEditor::Constants::C_TEXTEDITOR) -{ } - -Core::Context CMakeEditor::context() const + : BaseTextEditor(editor) { - return m_context; + setContext(Core::Context(CMakeProjectManager::Constants::C_CMAKEEDITOR, + TextEditor::Constants::C_TEXTEDITOR)); + connect(this, SIGNAL(changed()), this, SLOT(markAsChanged())); } Core::IEditor *CMakeEditor::duplicate(QWidget *parent) @@ -75,6 +75,30 @@ QString CMakeEditor::id() const return QLatin1String(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); } +void CMakeEditor::markAsChanged() +{ + Core::EditorManager::instance()-> + showEditorInfoBar(QLatin1String("CMakeEditor.RunCMake"), + tr("Changes to cmake files are shown in the project tree after building."), + tr("Build now"), + this, SLOT(build())); +} + +void CMakeEditor::build() +{ + QList<ProjectExplorer::Project *> projects = + ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects(); + foreach (ProjectExplorer::Project *p, projects) { + CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p); + if (cmakeProject) { + if (cmakeProject->isProjectFile(file()->fileName())) { + ProjectExplorer::ProjectExplorerPlugin::instance()->buildProject(cmakeProject); + break; + } + } + } +} + // // CMakeEditor // @@ -91,10 +115,6 @@ CMakeEditorWidget::CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factor baseTextDocument()->setSyntaxHighlighter(new CMakeHighlighter); } -CMakeEditorWidget::~CMakeEditorWidget() -{ -} - TextEditor::BaseTextEditor *CMakeEditorWidget::createEditor() { return new CMakeEditor(this); diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.h b/src/plugins/cmakeprojectmanager/cmakeeditor.h index cf4562214c..0c12a0a836 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.h +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.h @@ -52,16 +52,19 @@ class CMakeManager; class CMakeEditor : public TextEditor::BaseTextEditor { + Q_OBJECT + public: CMakeEditor(CMakeEditorWidget *); - Core::Context context() const; bool duplicateSupported() const { return true; } Core::IEditor *duplicate(QWidget *parent); QString id() const; bool isTemporary() const { return false; } -private: - const Core::Context m_context; + +private slots: + void markAsChanged(); + void build(); }; class CMakeEditorWidget : public TextEditor::BaseTextEditorWidget @@ -70,7 +73,6 @@ class CMakeEditorWidget : public TextEditor::BaseTextEditorWidget public: CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah); - ~CMakeEditorWidget(); bool save(const QString &fileName = QString()); diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index 6aec0f17b1..28886c5586 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -96,9 +96,11 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName) : m_manager(manager), m_fileName(fileName), m_rootNode(new CMakeProjectNode(m_fileName)), - m_insideFileChanged(false), m_lastEditor(0) { + setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT)); + setProjectLanguage(Core::Context(ProjectExplorer::Constants::LANG_CXX)); + m_file = new CMakeFile(this, fileName); connect(this, SIGNAL(addedTarget(ProjectExplorer::Target*)), @@ -125,15 +127,8 @@ CMakeProject::~CMakeProject() void CMakeProject::fileChanged(const QString &fileName) { Q_UNUSED(fileName) - if (!activeTarget() || - !activeTarget()->activeBuildConfiguration()) - return; - if (m_insideFileChanged) - return; - m_insideFileChanged = true; - changeActiveBuildConfiguration(activeTarget()->activeBuildConfiguration()); - m_insideFileChanged = false; + parseCMakeLists(); } void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration *bc) @@ -200,6 +195,8 @@ bool CMakeProject::parseCMakeLists() !activeTarget()->activeBuildConfiguration()) return false; + Core::EditorManager::instance()->hideEditorInfoBar("CMakeEditor.RunCMake"); + // Find cbp file CMakeBuildConfiguration *activeBC = activeTarget()->activeBuildConfiguration(); QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory()); @@ -211,12 +208,17 @@ bool CMakeProject::parseCMakeLists() //qDebug()<<"Parsing file "<<cbpFile; if (!cbpparser.parseCbpFile(cbpFile)) { // TODO report error - qDebug()<<"Parsing failed"; - // activeBC->updateToolChain(QString::null); emit buildTargetsChanged(); return false; } + foreach (const QString &file, m_watcher->files()) + if (file != cbpFile) + m_watcher->removePath(file); + + // how can we ensure that it is completly written? + m_watcher->addPath(cbpFile); + // ToolChain // activeBC->updateToolChain(cbpparser.compilerName()); m_projectName = cbpparser.projectName(); @@ -237,12 +239,6 @@ bool CMakeProject::parseCMakeLists() projectFiles.insert(cmakeListTxt); } - QSet<QString> added = projectFiles; - added.subtract(m_watchedFiles); - foreach(const QString &add, added) - m_watcher->addFile(add); - foreach(const QString &remove, m_watchedFiles.subtract(projectFiles)) - m_watcher->removeFile(remove); m_watchedFiles = projectFiles; m_files.clear(); @@ -278,7 +274,6 @@ bool CMakeProject::parseCMakeLists() } cmakeCache.close(); - //qDebug()<<"Updating CodeModel"; createUiCodeModelSupport(); if (!activeBC->toolChain()) @@ -316,12 +311,16 @@ bool CMakeProject::parseCMakeLists() m_codeModelFuture = modelmanager->updateSourceFiles(pinfo.sourceFiles); } } - emit buildTargetsChanged(); emit fileListChanged(); return true; } +bool CMakeProject::isProjectFile(const QString &fileName) +{ + return m_watchedFiles.contains(fileName); +} + QList<CMakeBuildTarget> CMakeProject::buildTargets() const { return m_buildTargets; @@ -561,7 +560,7 @@ bool CMakeProject::fromMap(const QVariantMap &map) } } - m_watcher = new ProjectExplorer::FileWatcher(this); + m_watcher = new QFileSystemWatcher(this); connect(m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString))); if (!parseCMakeLists()) // Gets the directory from the active buildconfiguration diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index 54ae009630..563ae9f424 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -45,9 +45,11 @@ #include <projectexplorer/filewatcher.h> #include <projectexplorer/buildconfiguration.h> #include <coreplugin/ifile.h> +#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/ieditor.h> #include <QtCore/QXmlStreamReader> +#include <QtCore/QFileSystemWatcher> #include <QtGui/QPushButton> #include <QtGui/QLineEdit> @@ -104,6 +106,8 @@ public: QString uicCommand() const; + bool isProjectFile(const QString &fileName); + signals: /// emitted after parsing void buildTargetsChanged(); @@ -141,8 +145,7 @@ private: CMakeProjectNode *m_rootNode; QStringList m_files; QList<CMakeBuildTarget> m_buildTargets; - ProjectExplorer::FileWatcher *m_watcher; - bool m_insideFileChanged; + QFileSystemWatcher *m_watcher; QSet<QString> m_watchedFiles; QFuture<void> m_codeModelFuture; diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index 566c487647..ad46cd07e3 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -62,9 +62,6 @@ using namespace CMakeProjectManager::Internal; CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage) : m_settingsPage(cmakeSettingsPage) { - m_projectContext = Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT); - m_projectLanguage = Core::Context(ProjectExplorer::Constants::LANG_CXX); - ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); connect(projectExplorer, SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)), this, SLOT(updateContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*))); @@ -78,14 +75,16 @@ CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage) Core::ActionContainer *msubproject = am->actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT); + const Core::Context projectContext(CMakeProjectManager::Constants::PROJECTCONTEXT); + m_runCMakeAction = new QAction(QIcon(), tr("Run CMake"), this); - Core::Command *command = am->registerAction(m_runCMakeAction, Constants::RUNCMAKE, m_projectContext); + Core::Command *command = am->registerAction(m_runCMakeAction, Constants::RUNCMAKE, projectContext); command->setAttribute(Core::Command::CA_Hide); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_PROJECT); connect(m_runCMakeAction, SIGNAL(triggered()), this, SLOT(runCMake())); m_runCMakeActionContextMenu = new QAction(QIcon(), tr("Run CMake"), this); - command = am->registerAction(m_runCMakeActionContextMenu, Constants::RUNCMAKECONTEXTMENU, m_projectContext); + command = am->registerAction(m_runCMakeActionContextMenu, Constants::RUNCMAKECONTEXTMENU, projectContext); command->setAttribute(Core::Command::CA_Hide); mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); @@ -132,16 +131,6 @@ void CMakeManager::runCMake(ProjectExplorer::Project *project) } } -Core::Context CMakeManager::projectContext() const -{ - return m_projectContext; -} - -Core::Context CMakeManager::projectLanguage() const -{ - return m_projectLanguage; -} - ProjectExplorer::Project *CMakeManager::openProject(const QString &fileName) { // TODO check whether this project is already opened diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h index 1383a9d255..4253944840 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h @@ -65,9 +65,6 @@ class CMakeManager : public ProjectExplorer::IProjectManager public: CMakeManager(CMakeSettingsPage *cmakeSettingsPage); - virtual Core::Context projectContext() const; - virtual Core::Context projectLanguage() const; - virtual ProjectExplorer::Project *openProject(const QString &fileName); virtual QString mimeType() const; @@ -94,8 +91,6 @@ private: void runCMake(ProjectExplorer::Project *project); static QString qtVersionForQMake(const QString &qmakePath); static QPair<QString, QString> findQtDir(const Utils::Environment &env); - Core::Context m_projectContext; - Core::Context m_projectLanguage; CMakeSettingsPage *m_settingsPage; QAction *m_runCMakeAction; QAction *m_runCMakeActionContextMenu; diff --git a/src/plugins/cmakeprojectmanager/cmaketarget.cpp b/src/plugins/cmakeprojectmanager/cmaketarget.cpp index 026f545aa9..ec0bb308b2 100644 --- a/src/plugins/cmakeprojectmanager/cmaketarget.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketarget.cpp @@ -64,8 +64,7 @@ QString displayNameForId(const QString &id) { CMakeTarget::CMakeTarget(CMakeProject *parent) : ProjectExplorer::Target(parent, QLatin1String(DEFAULT_CMAKE_TARGET_ID)), - m_buildConfigurationFactory(new CMakeBuildConfigurationFactory(this)), - m_deployConfigurationFactory(new ProjectExplorer::DeployConfigurationFactory(this)) + m_buildConfigurationFactory(new CMakeBuildConfigurationFactory(this)) { setDefaultDisplayName(displayNameForId(id())); setIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon)); @@ -101,11 +100,6 @@ CMakeBuildConfigurationFactory *CMakeTarget::buildConfigurationFactory() const return m_buildConfigurationFactory; } -ProjectExplorer::DeployConfigurationFactory *CMakeTarget::deployConfigurationFactory() const -{ - return m_deployConfigurationFactory; -} - QString CMakeTarget::defaultBuildDirectory() const { return cmakeProject()->defaultBuildDirectory(); @@ -227,7 +221,7 @@ CMakeTarget *CMakeTargetFactory::create(ProjectExplorer::Project *parent, const t->addBuildConfiguration(bc); - t->addDeployConfiguration(t->deployConfigurationFactory()->create(t, ProjectExplorer::Constants::DEFAULT_DEPLOYCONFIGURATION_ID)); + t->addDeployConfiguration(t->createDeployConfiguration(ProjectExplorer::Constants::DEFAULT_DEPLOYCONFIGURATION_ID)); t->updateRunConfigurations(); diff --git a/src/plugins/cmakeprojectmanager/cmaketarget.h b/src/plugins/cmakeprojectmanager/cmaketarget.h index 5d97419b44..794878b385 100644 --- a/src/plugins/cmakeprojectmanager/cmaketarget.h +++ b/src/plugins/cmakeprojectmanager/cmaketarget.h @@ -63,7 +63,6 @@ public: CMakeBuildConfiguration *activeBuildConfiguration() const; CMakeBuildConfigurationFactory *buildConfigurationFactory() const; - ProjectExplorer::DeployConfigurationFactory *deployConfigurationFactory() const; QString defaultBuildDirectory() const; @@ -75,7 +74,6 @@ private slots: private: CMakeBuildConfigurationFactory *m_buildConfigurationFactory; - ProjectExplorer::DeployConfigurationFactory *m_deployConfigurationFactory; }; class CMakeTargetFactory : public ProjectExplorer::ITargetFactory |