diff options
Diffstat (limited to 'src/plugins/autotest/testtreemodel.cpp')
-rw-r--r-- | src/plugins/autotest/testtreemodel.cpp | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp index 8842734f0c5..5e7fcb85a86 100644 --- a/src/plugins/autotest/testtreemodel.cpp +++ b/src/plugins/autotest/testtreemodel.cpp @@ -10,12 +10,16 @@ #include "testprojectsettings.h" #include <cppeditor/cppmodelmanager.h> + #include <projectexplorer/buildsystem.h> #include <projectexplorer/project.h> -#include <projectexplorer/session.h> +#include <projectexplorer/projectmanager.h> #include <projectexplorer/target.h> + #include <qmljs/qmljsmodelmanagerinterface.h> + #include <texteditor/texteditor.h> + #include <utils/algorithm.h> #include <utils/fileutils.h> #include <utils/qtcassert.h> @@ -38,7 +42,7 @@ TestTreeModel::TestTreeModel(TestCodeParser *parser) : connect(m_parser, &TestCodeParser::aboutToPerformFullParse, this, &TestTreeModel::removeAllTestItems, Qt::QueuedConnection); connect(m_parser, &TestCodeParser::testParseResultReady, - this, &TestTreeModel::onParseResultReady, Qt::QueuedConnection); + this, &TestTreeModel::onParseResultReady); connect(m_parser, &TestCodeParser::parsingFinished, this, &TestTreeModel::sweep, Qt::QueuedConnection); connect(m_parser, &TestCodeParser::parsingFailed, @@ -70,8 +74,8 @@ void TestTreeModel::setupParsingConnections() m_parser->setDirty(); m_parser->setState(TestCodeParser::Idle); - SessionManager *sm = SessionManager::instance(); - connect(sm, &SessionManager::startupProjectChanged, this, [this, sm](Project *project) { + ProjectManager *sm = ProjectManager::instance(); + connect(sm, &ProjectManager::startupProjectChanged, this, [this, sm](Project *project) { synchronizeTestFrameworks(); // we might have project settings m_parser->onStartupProjectChanged(project); removeAllTestToolItems(); @@ -96,8 +100,8 @@ void TestTreeModel::setupParsingConnections() m_parser, &TestCodeParser::onCppDocumentUpdated, Qt::QueuedConnection); connect(cppMM, &CppEditor::CppModelManager::aboutToRemoveFiles, this, [this](const QStringList &files) { - const FilePaths filesToRemove = FileUtils::toFilePathList(files); - removeFiles(filesToRemove); + markForRemoval(transform<QSet>(files, &FilePath::fromString)); + sweep(); }, Qt::QueuedConnection); connect(cppMM, &CppEditor::CppModelManager::projectPartsUpdated, m_parser, &TestCodeParser::onProjectPartsUpdated); @@ -105,11 +109,11 @@ void TestTreeModel::setupParsingConnections() QmlJS::ModelManagerInterface *qmlJsMM = QmlJS::ModelManagerInterface::instance(); connect(qmlJsMM, &QmlJS::ModelManagerInterface::documentUpdated, m_parser, &TestCodeParser::onQmlDocumentUpdated, Qt::QueuedConnection); - connect(qmlJsMM, - &QmlJS::ModelManagerInterface::aboutToRemoveFiles, - this, - &TestTreeModel::removeFiles, - Qt::QueuedConnection); + connect(qmlJsMM, &QmlJS::ModelManagerInterface::aboutToRemoveFiles, + this, [this](const FilePaths &filePaths) { + markForRemoval(Utils::toSet(filePaths)); + sweep(); + }, Qt::QueuedConnection); connectionsInitialized = true; } @@ -226,7 +230,7 @@ static QList<ITestTreeItem *> testItemsByName(TestTreeItem *root, const QString void TestTreeModel::onTargetChanged(Target *target) { if (target && target->buildSystem()) { - const Target *topLevelTarget = SessionManager::startupProject()->targets().first(); + const Target *topLevelTarget = ProjectManager::startupProject()->targets().first(); connect(topLevelTarget->buildSystem(), &BuildSystem::testInformationUpdated, this, &TestTreeModel::onBuildSystemTestsUpdated, Qt::UniqueConnection); disconnect(target->project(), &Project::activeTargetChanged, @@ -236,7 +240,7 @@ void TestTreeModel::onTargetChanged(Target *target) void TestTreeModel::onBuildSystemTestsUpdated() { - const BuildSystem *bs = SessionManager::startupBuildSystem(); + const BuildSystem *bs = ProjectManager::startupBuildSystem(); if (!bs || !bs->project()) return; @@ -333,7 +337,7 @@ void TestTreeModel::synchronizeTestFrameworks() void TestTreeModel::synchronizeTestTools() { - ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); + ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject(); TestTools tools; if (!project || AutotestPlugin::projectSettings(project)->useGlobalSettings()) { tools = Utils::filtered(TestFrameworkManager::registeredTestTools(), @@ -459,13 +463,6 @@ void TestTreeModel::clearFailedMarks() m_failedStateCache.clear(); } -void TestTreeModel::removeFiles(const FilePaths &files) -{ - for (const FilePath &file : files) - markForRemoval(file); - sweep(); -} - void TestTreeModel::markAllFrameworkItemsForRemoval() { for (TestTreeItem *frameworkRoot : frameworkRootNodes()) { @@ -475,15 +472,12 @@ void TestTreeModel::markAllFrameworkItemsForRemoval() } } -void TestTreeModel::markForRemoval(const FilePath &filePath) +void TestTreeModel::markForRemoval(const QSet<Utils::FilePath> &filePaths) { - if (filePath.isEmpty()) - return; - for (TestTreeItem *frameworkRoot : frameworkRootNodes()) { for (int childRow = frameworkRoot->childCount() - 1; childRow >= 0; --childRow) { TestTreeItem *child = frameworkRoot->childItem(childRow); - child->markForRemovalRecursively(filePath); + child->markForRemovalRecursively(filePaths); } } } |