From e330d9666855fe8cc87eba203d851b2fe4c18eec Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 23 Feb 2009 15:57:37 +0100 Subject: [PATCH] Better values for the progress bar. --- src/plugins/cpptools/cppmodelmanager.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 3cbabb8fddc..c23b0c3204a 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -169,11 +169,16 @@ public: void setIncludePaths(const QStringList &includePaths); void setFrameworkPaths(const QStringList &frameworkPaths); void setProjectFiles(const QStringList &files); + void setTodo(const QStringList &files); + void run(QString &fileName); void operator()(QString &fileName); void resetEnvironment(); + const QSet &todo() const + { return m_todo; } + public: // attributes Snapshot snapshot; @@ -207,6 +212,7 @@ private: QStringList m_frameworkPaths; QSet m_included; CPlusPlus::Document::Ptr m_currentDoc; + QSet m_todo; }; } // namespace Internal @@ -230,6 +236,9 @@ void CppPreprocessor::setFrameworkPaths(const QStringList &frameworkPaths) void CppPreprocessor::setProjectFiles(const QStringList &files) { m_projectFiles = files; } +void CppPreprocessor::setTodo(const QStringList &files) +{ m_todo = QSet::fromList(files); } + void CppPreprocessor::run(QString &fileName) { sourceNeeded(fileName, IncludeGlobal, /*line = */ 0); } @@ -447,6 +456,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type, m_currentDoc->addDiagnosticMessage(d); //qWarning() << "file not found:" << fileName << m_currentDoc->fileName() << env.current_line; + return; } } @@ -483,6 +493,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type, m_modelManager->emitDocumentUpdated(m_currentDoc); // ### TODO: compress (void) switchDocument(previousDoc); + m_todo.remove(fileName); } Document::Ptr CppPreprocessor::switchDocument(Document::Ptr doc) @@ -904,6 +915,8 @@ void CppModelManager::parse(QFutureInterface &future, files = sources; files += headers; + preproc->setTodo(files); + // Change the priority of the background parser thread to idle. QThread::currentThread()->setPriority(QThread::IdlePriority); @@ -921,8 +934,6 @@ void CppModelManager::parse(QFutureInterface &future, if (future.isCanceled()) break; - future.setProgressValue(i); - #ifdef CPPTOOLS_DEBUG_PARSING_TIME QTime tm; tm.start(); @@ -945,6 +956,8 @@ void CppModelManager::parse(QFutureInterface &future, preproc->run(fileName); + future.setProgressValue(files.size() - preproc->todo().size()); + if (isSourceFile) preproc->resetEnvironment();