diff options
Diffstat (limited to 'src/plugins/genericprojectmanager/genericproject.cpp')
-rw-r--r-- | src/plugins/genericprojectmanager/genericproject.cpp | 71 |
1 files changed, 43 insertions, 28 deletions
diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index 9070dabd5c..c0f497c062 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -31,6 +31,7 @@ #include "genericprojectconstants.h" #include "genericmakestep.h" +#include <projectexplorer/toolchain.h> #include <projectexplorer/projectexplorerconstants.h> #include <cpptools/cppmodelmanagerinterface.h> #include <extensionsystem/pluginmanager.h> @@ -112,12 +113,12 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName) m_toolChain(0) { QFileInfo fileInfo(m_fileName); - const QString projectBaseName = fileInfo.baseName(); QDir dir = fileInfo.dir(); - m_filesFileName = QFileInfo(dir, projectBaseName + QLatin1String(".files")).absoluteFilePath(); - m_includesFileName = QFileInfo(dir, projectBaseName + QLatin1String(".includes")).absoluteFilePath(); - m_configFileName = QFileInfo(dir, projectBaseName + QLatin1String(".config")).absoluteFilePath(); + m_projectName = fileInfo.baseName(); + m_filesFileName = QFileInfo(dir, m_projectName + QLatin1String(".files")).absoluteFilePath(); + m_includesFileName = QFileInfo(dir, m_projectName + QLatin1String(".includes")).absoluteFilePath(); + m_configFileName = QFileInfo(dir, m_projectName + QLatin1String(".config")).absoluteFilePath(); m_file = new GenericProjectFile(this, fileName); m_rootNode = new GenericProjectNode(this, m_file); @@ -142,7 +143,7 @@ QString GenericProject::includesFileName() const QString GenericProject::configFileName() const { return m_configFileName; } -QStringList GenericProject::readLines(const QString &absoluteFileName) const +static QStringList readLines(const QString &absoluteFileName) { QStringList lines; @@ -167,34 +168,41 @@ QStringList GenericProject::readLines(const QString &absoluteFileName) const } -void GenericProject::parseProject() +void GenericProject::parseProject(RefreshOptions options) { - const QFileInfo projectFileInfo(m_fileName); - - QSettings projectInfo(m_fileName, QSettings::IniFormat); - - m_files = convertToAbsoluteFiles(readLines(filesFileName())); - m_files.removeDuplicates(); + if (options & Files) { + m_files = convertToAbsoluteFiles(readLines(filesFileName())); + m_files.removeDuplicates(); + } - m_projectIncludePaths = readLines(includesFileName()); - m_projectIncludePaths.removeDuplicates(); + if (options & Configuration) { + m_projectIncludePaths = readLines(includesFileName()); + m_projectIncludePaths.removeDuplicates(); - m_generated = convertToAbsoluteFiles(projectInfo.value(QLatin1String("generated")).toStringList()); + QSettings projectInfo(m_fileName, QSettings::IniFormat); + m_generated = convertToAbsoluteFiles(projectInfo.value(QLatin1String("generated")).toStringList()); - m_defines.clear(); + m_defines.clear(); - QFile configFile(configFileName()); - if (configFile.open(QFile::ReadOnly)) - m_defines = configFile.readAll(); + QFile configFile(configFileName()); + if (configFile.open(QFile::ReadOnly)) + m_defines = configFile.readAll(); + } - emit fileListChanged(); + if (options & Files) + emit fileListChanged(); } -void GenericProject::refresh() +void GenericProject::refresh(RefreshOptions options) { - parseProject(); + QSet<QString> oldFileList; + if (!(options & Configuration)) + oldFileList = m_files.toSet(); - m_rootNode->refresh(); + parseProject(options); + + if (options & Files) + m_rootNode->refresh(); CppTools::CppModelManagerInterface *modelManager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>(); @@ -213,7 +221,6 @@ void GenericProject::refresh() foreach (const ProjectExplorer::HeaderPath &headerPath, m_toolChain->systemHeaderPaths()) { if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath) allFrameworkPaths.append(headerPath.path()); - else allIncludePaths.append(headerPath.path()); } @@ -227,8 +234,17 @@ void GenericProject::refresh() pinfo.sourceFiles = files(); pinfo.sourceFiles += generated(); - QStringList filesToUpdate = pinfo.sourceFiles; - filesToUpdate.append(QLatin1String("<configuration>")); // XXX don't hardcode configuration file name + QStringList filesToUpdate; + + if (options & Configuration) { + filesToUpdate = pinfo.sourceFiles; + filesToUpdate.append(QLatin1String("<configuration>")); // XXX don't hardcode configuration file name + } else if (options & Files) { + // Only update files that got added to the list + QSet<QString> newFileList = m_files.toSet(); + newFileList.subtract(oldFileList); + filesToUpdate.append(newFileList.toList()); + } modelManager->updateProjectInfo(pinfo); modelManager->updateSourceFiles(filesToUpdate); @@ -449,8 +465,7 @@ void GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead setIncludePaths(allIncludePaths()); - parseProject(); - refresh(); + refresh(Everything); } void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer) |