diff options
author | Eike Ziller <eike.ziller@qt.io> | 2019-02-19 09:08:53 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2019-02-19 09:08:53 +0100 |
commit | 6d43aaf1340bc7b2ac52798707947baacb76d34d (patch) | |
tree | 12d39921f7876ea36c0ff45dd4555a986ecb1934 /src/plugins/projectexplorer | |
parent | bfa53a8080b49b1fc16282aa5e28469e4fbd9224 (diff) | |
parent | 29492ecf2494d875e3e2fa4951326aed275a3033 (diff) | |
download | qt-creator-6d43aaf1340bc7b2ac52798707947baacb76d34d.tar.gz |
Merge remote-tracking branch 'origin/4.9'
Change-Id: I7bdb6a4658c5fca1a7e1dda5adbb5613dabc6d18
Diffstat (limited to 'src/plugins/projectexplorer')
-rw-r--r-- | src/plugins/projectexplorer/extracompiler.cpp | 23 | ||||
-rw-r--r-- | src/plugins/projectexplorer/extracompiler.h | 24 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.cpp | 27 |
3 files changed, 55 insertions, 19 deletions
diff --git a/src/plugins/projectexplorer/extracompiler.cpp b/src/plugins/projectexplorer/extracompiler.cpp index 7924945bb8..30b7fbef01 100644 --- a/src/plugins/projectexplorer/extracompiler.cpp +++ b/src/plugins/projectexplorer/extracompiler.cpp @@ -52,7 +52,7 @@ namespace ProjectExplorer { Q_GLOBAL_STATIC(QThreadPool, s_extraCompilerThreadPool); Q_GLOBAL_STATIC(QList<ExtraCompilerFactory *>, factories); - +Q_GLOBAL_STATIC(QVector<ExtraCompilerFactoryObserver *>, observers); class ExtraCompilerPrivate { public: @@ -310,7 +310,8 @@ void ExtraCompiler::setContent(const Utils::FileName &file, const QByteArray &co } } -ExtraCompilerFactory::ExtraCompilerFactory(QObject *parent) : QObject(parent) +ExtraCompilerFactory::ExtraCompilerFactory(QObject *parent) + : QObject(parent) { factories->append(this); } @@ -320,6 +321,14 @@ ExtraCompilerFactory::~ExtraCompilerFactory() factories->removeAll(this); } +void ExtraCompilerFactory::annouceCreation(const Project *project, + const Utils::FileName &source, + const Utils::FileNameList &targets) +{ + for (ExtraCompilerFactoryObserver *observer : *observers) + observer->newExtraCompiler(project, source, targets); +} + QList<ExtraCompilerFactory *> ExtraCompilerFactory::extraCompilerFactories() { return *factories(); @@ -455,4 +464,14 @@ void ProcessExtraCompiler::cleanUp() setCompileTime(QDateTime::currentDateTime()); } +ExtraCompilerFactoryObserver::ExtraCompilerFactoryObserver() +{ + observers->push_back(this); +} + +ExtraCompilerFactoryObserver::~ExtraCompilerFactoryObserver() +{ + observers->removeOne(this); +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/extracompiler.h b/src/plugins/projectexplorer/extracompiler.h index c93830b10c..006555ffc6 100644 --- a/src/plugins/projectexplorer/extracompiler.h +++ b/src/plugins/projectexplorer/extracompiler.h @@ -137,6 +137,20 @@ private: QFutureWatcher<FileNameToContentsHash> *m_watcher = nullptr; }; +class PROJECTEXPLORER_EXPORT ExtraCompilerFactoryObserver +{ + friend class ExtraCompilerFactory; + +protected: + ExtraCompilerFactoryObserver(); + ~ExtraCompilerFactoryObserver(); + + virtual void newExtraCompiler(const Project *project, + const Utils::FileName &source, + const Utils::FileNameList &targets) + = 0; +}; + class PROJECTEXPLORER_EXPORT ExtraCompilerFactory : public QObject { Q_OBJECT @@ -147,8 +161,14 @@ public: virtual FileType sourceType() const = 0; virtual QString sourceTag() const = 0; - virtual ExtraCompiler *create(const Project *project, const Utils::FileName &source, - const Utils::FileNameList &targets) = 0; + virtual ExtraCompiler *create(const Project *project, + const Utils::FileName &source, + const Utils::FileNameList &targets) + = 0; + + void annouceCreation(const Project *project, + const Utils::FileName &source, + const Utils::FileNameList &targets); static QList<ExtraCompilerFactory *> extraCompilerFactories(); }; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index ed66ee746b..0e78a50abc 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1143,14 +1143,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES); msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES); - // unload project again, in right position - dd->m_unloadActionContextMenu = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""), - Utils::ParameterAction::EnabledWithParameter, this); - cmd = ActionManager::registerAction(dd->m_unloadActionContextMenu, Constants::UNLOADCM); - cmd->setAttribute(Command::CA_UpdateText); - cmd->setDescription(dd->m_unloadActionContextMenu->text()); - mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST); - dd->m_closeProjectFilesActionContextMenu = new Utils::ParameterAction( tr("Close All Files"), tr("Close All Files in Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); @@ -1160,6 +1152,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er cmd->setDescription(dd->m_closeProjectFilesActionContextMenu->text()); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST); + // unload project again, in right position + dd->m_unloadActionContextMenu = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""), + Utils::ParameterAction::EnabledWithParameter, this); + cmd = ActionManager::registerAction(dd->m_unloadActionContextMenu, Constants::UNLOADCM); + cmd->setAttribute(Command::CA_UpdateText); + cmd->setDescription(dd->m_unloadActionContextMenu->text()); + mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST); + // file properties action dd->m_filePropertiesAction = new QAction(tr("Properties..."), this); cmd = ActionManager::registerAction(dd->m_filePropertiesAction, Constants::FILEPROPERTIES, @@ -1854,18 +1854,15 @@ void ProjectExplorerPluginPrivate::setStartupProject(Project *project) bool ProjectExplorerPluginPrivate::closeAllFilesInProject(const Project *project) { QTC_ASSERT(project, return false); - const Utils::FileNameList filesInProject = project->files(Project::AllFiles); QList<IDocument *> openFiles = DocumentModel::openedDocuments(); - Utils::erase(openFiles, [filesInProject](const IDocument *doc) { - return !filesInProject.contains(doc->filePath()); + Utils::erase(openFiles, [project](const IDocument *doc) { + return !project->isKnownFile(doc->filePath()); }); for (const Project * const otherProject : SessionManager::projects()) { if (otherProject == project) continue; - const Utils::FileNameList filesInOtherProject - = otherProject->files(Project::AllFiles); - Utils::erase(openFiles, [filesInOtherProject](const IDocument *doc) { - return filesInOtherProject.contains(doc->filePath()); + Utils::erase(openFiles, [otherProject](const IDocument *doc) { + return otherProject->isKnownFile(doc->filePath()); }); } return EditorManager::closeDocuments(openFiles); |