From 6b1bc495a0b4688e134342027c7c58add92c4f98 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Tue, 6 Sep 2011 17:21:51 +0200 Subject: [PATCH] Add Qt4PriFileNode::subProjectNodesExact which uses the exact parse Change-Id: Ic6b8dedbc31830295e3dccea82c5f6514840dc57 Reviewed-on: http://codereview.qt.nokia.com/4282 Reviewed-by: Christian Kandeler Reviewed-by: Qt Sanity Bot --- src/plugins/qt4projectmanager/qt4nodes.cpp | 42 +++++++++++++++++++--- src/plugins/qt4projectmanager/qt4nodes.h | 7 ++++ 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index 033b12e5243..2b6eb8575fa 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -248,7 +248,8 @@ Qt4PriFileNode::Qt4PriFileNode(Qt4Project *project, Qt4ProFileNode* qt4ProFileNo m_project(project), m_qt4ProFileNode(qt4ProFileNode), m_projectFilePath(QDir::fromNativeSeparators(filePath)), - m_projectDir(QFileInfo(filePath).absolutePath()) + m_projectDir(QFileInfo(filePath).absolutePath()), + m_includedInExactParse(true) { Q_ASSERT(project); m_qt4PriFile = new Qt4PriFile(this); @@ -768,6 +769,27 @@ QList Qt4PriFileNode::runConfigurationsFor( return m_project->activeTarget()->runConfigurationsForNode(node); } +QList Qt4PriFileNode::subProjectNodesExact() const +{ + QList nodes; + foreach (ProjectNode *node, subProjectNodes()) { + Qt4PriFileNode *n = qobject_cast(node); + if (n && n->includedInExactParse()) + nodes << n; + } + return nodes; +} + +bool Qt4PriFileNode::includedInExactParse() const +{ + return m_includedInExactParse; +} + +void Qt4PriFileNode::setIncludedInExactParse(bool b) +{ + m_includedInExactParse = b; +} + QList Qt4PriFileNode::supportedActions(Node *node) const { QList actions; @@ -1618,10 +1640,13 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async) QStringList newProjectFilesExact; QHash includeFilesExact; + QSet exactSubdirs; ProFile *fileForCurrentProjectExact = 0; if (evalResult == EvalOk) { - if (m_projectType == SubDirsTemplate) + if (m_projectType == SubDirsTemplate) { newProjectFilesExact = subDirsPaths(m_readerExact); + exactSubdirs = newProjectFilesExact.toSet(); + } foreach (ProFile *includeFile, m_readerExact->includeFiles()) { if (includeFile->fileName() == m_projectFilePath) { // this file fileForCurrentProjectExact = includeFile; @@ -1718,15 +1743,20 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async) ProFile *fileExact = includeFilesExact.value((*existingIt)->path()); ProFile *fileCumlative = includeFilesCumlative.value((*existingIt)->path()); if (fileExact || fileCumlative) { - static_cast(*existingIt)->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative); + Qt4PriFileNode *priFileNode = static_cast(*existingIt); + priFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative); + priFileNode->setIncludedInExactParse(fileExact != 0 && includedInExactParse()); } else { // We always parse exactly, because we later when async parsing don't know whether // the .pro file is included in this .pro file // So to compare that later parse with the sync one + Qt4ProFileNode *proFileNode = static_cast(*existingIt); + // TODO that could be made faster... + proFileNode->setIncludedInExactParse(exactSubdirs.contains(proFileNode->path()) && includedInExactParse()); if (async) - static_cast(*existingIt)->asyncUpdate(); + proFileNode->asyncUpdate(); else - static_cast(*existingIt)->update(); + proFileNode->update(); } ++existingIt; // newCumalativeIt and newExactIt are already incremented @@ -1752,11 +1782,13 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async) } else if (fileExact || fileCumlative) { Qt4PriFileNode *qt4PriFileNode = new Qt4PriFileNode(m_project, this, nodeToAdd); qt4PriFileNode->setParentFolderNode(this); // Needed for loop detection + qt4PriFileNode->setIncludedInExactParse(fileExact != 0 && includedInExactParse()); qt4PriFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative); toAdd << qt4PriFileNode; } else { Qt4ProFileNode *qt4ProFileNode = new Qt4ProFileNode(m_project, nodeToAdd); qt4ProFileNode->setParentFolderNode(this); // Needed for loop detection + qt4ProFileNode->setIncludedInExactParse(exactSubdirs.contains(qt4ProFileNode->path()) && includedInExactParse()); if (async) qt4ProFileNode->asyncUpdate(); else diff --git a/src/plugins/qt4projectmanager/qt4nodes.h b/src/plugins/qt4projectmanager/qt4nodes.h index e7cebd986ae..bac9cd37312 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.h +++ b/src/plugins/qt4projectmanager/qt4nodes.h @@ -151,7 +151,13 @@ public: bool deploysFolder(const QString &folder) const; QList runConfigurationsFor(Node *node); + QList subProjectNodesExact() const; + + // Set by parent + bool includedInExactParse() const; + protected: + void setIncludedInExactParse(bool b); void clear(); static QStringList varNames(FileType type); static QStringList dynamicVarNames(QtSupport::ProFileReader *readerExact, QtSupport::ProFileReader *readerCumulative); @@ -197,6 +203,7 @@ private: QMap > m_files; QSet m_recursiveEnumerateFiles; QSet m_watchedFolders; + bool m_includedInExactParse; // managed by Qt4ProFileNode friend class Qt4ProjectManager::Qt4ProFileNode;