diff --git a/src/plugins/autotest/testtreeitem.cpp b/src/plugins/autotest/testtreeitem.cpp index 1846b6742f0..7d24b95f6b1 100644 --- a/src/plugins/autotest/testtreeitem.cpp +++ b/src/plugins/autotest/testtreeitem.cpp @@ -57,28 +57,6 @@ TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type ty } } -TestTreeItem::~TestTreeItem() -{ - removeChildren(); -} - -TestTreeItem::TestTreeItem(const TestTreeItem &other) - : TreeItem( { other.m_name } ), - m_name(other.m_name), - m_filePath(other.m_filePath), - m_checked(other.m_checked), - m_type(other.m_type), - m_line(other.m_line), - m_column(other.m_column), - m_mainFile(other.m_mainFile), - m_referencingFile(other.m_referencingFile), - m_state(other.m_state), - m_markedForRemoval(other.m_markedForRemoval) -{ - for (int row = 0, count = other.childCount(); row < count; ++row) - appendChild(new TestTreeItem(*other.childItem(row))); -} - static QIcon testTreeIcon(TestTreeItem::Type type) { static QIcon icons[] = { @@ -169,39 +147,56 @@ bool TestTreeItem::setData(int /*column*/, const QVariant &data, int role) return false; } -bool TestTreeItem::modifyContent(const TestTreeItem *modified) +bool TestTreeItem::modifyTestCaseContent(const QString &name, unsigned line, unsigned column) +{ + bool hasBeenModified = modifyName(name); + hasBeenModified |= modifyLineAndColumn(line, column); + return hasBeenModified; +} + +bool TestTreeItem::modifyTestFunctionContent(const TestCodeLocationAndType &location) +{ + bool hasBeenModified = modifyFilePath(location.m_name); + hasBeenModified |= modifyLineAndColumn(location.m_line, location.m_column); + return hasBeenModified; +} + +bool TestTreeItem::modifyDataTagContent(const QString &fileName, + const TestCodeLocationAndType &location) +{ + bool hasBeenModified = modifyFilePath(fileName); + hasBeenModified |= modifyName(location.m_name); + hasBeenModified |= modifyLineAndColumn(location.m_line, location.m_column); + return hasBeenModified; +} + +bool TestTreeItem::modifyGTestSetContent(const QString &fileName, const QString &referencingFile, + const TestCodeLocationAndType &location) +{ + bool hasBeenModified = modifyFilePath(fileName); + if (m_referencingFile != referencingFile) { + m_referencingFile = referencingFile; + hasBeenModified = true; + } + hasBeenModified |= modifyLineAndColumn(location.m_line, location.m_column); + if (m_state != location.m_state) { + m_state = location.m_state; + hasBeenModified = true; + } + return hasBeenModified; +} + +bool TestTreeItem::modifyLineAndColumn(unsigned line, unsigned column) { bool hasBeenModified = false; - if (m_filePath != modified->m_filePath) { - m_filePath = modified->m_filePath; + if (m_line != line) { + m_line = line; hasBeenModified = true; } - if (m_name != modified->m_name) { - m_name = modified->m_name; + if (m_column != column) { + m_column = column; hasBeenModified = true; } - if (m_line != modified->m_line) { - m_line = modified->m_line; - hasBeenModified = true; - } - if (m_mainFile != modified->m_mainFile) { - m_mainFile = modified->m_mainFile; - hasBeenModified = true; - } - if (m_referencingFile != modified->m_referencingFile) { - m_referencingFile = modified->m_referencingFile; - hasBeenModified = true; - } - if (m_type != modified->m_type) { - m_type = modified->m_type; - hasBeenModified = true; - } - if (m_state != modified->m_state) { - m_state = modified->m_state; - hasBeenModified = true; - } - if (m_markedForRemoval != modified->m_markedForRemoval) - m_markedForRemoval = modified->m_markedForRemoval; return hasBeenModified; } @@ -268,6 +263,38 @@ TestTreeItem *TestTreeItem::childItem(int row) const return static_cast(child(row)); } +TestTreeItem *TestTreeItem::findChildByName(const QString &name) +{ + return findChildBy([name](const TestTreeItem *other) -> bool { + return other->name() == name; + }); +} + +TestTreeItem *TestTreeItem::findChildByFiles(const QString &filePath, + const QString &referencingFile) +{ + return findChildBy([filePath, referencingFile](const TestTreeItem *other) -> bool { + return other->filePath() == filePath && other->referencingFile() == referencingFile; + }); +} + +TestTreeItem *TestTreeItem::findChildByNameAndFile(const QString &name, const QString &filePath) +{ + return findChildBy([name, filePath](const TestTreeItem *other) -> bool { + return other->filePath() == filePath && other->name() == name; + }); +} + +TestTreeItem *TestTreeItem::findChildByNameTypeAndFile(const QString &name, TestTreeItem::Type type, + const QString &referencingFile) +{ + return findChildBy([name, type, referencingFile](const TestTreeItem *other) -> bool { + return other->referencingFile() == referencingFile + && other->name() == name + && other->type() == type; + }); +} + void TestTreeItem::revalidateCheckState() { if (childCount() == 0) @@ -294,5 +321,33 @@ void TestTreeItem::revalidateCheckState() m_checked = (foundUnchecked ? Qt::Unchecked : Qt::Checked); } +inline bool TestTreeItem::modifyFilePath(const QString &filePath) +{ + if (m_filePath != filePath) { + m_filePath = filePath; + return true; + } + return false; +} + +inline bool TestTreeItem::modifyName(const QString &name) +{ + if (m_name != name) { + m_name = name; + return true; + } + return false; +} + +TestTreeItem *TestTreeItem::findChildBy(CompareFunction compare) +{ + for (int row = 0, count = childCount(); row < count; ++row) { + TestTreeItem *child = childItem(row); + if (compare(child)) + return child; + } + return 0; +} + } // namespace Internal } // namespace Autotest diff --git a/src/plugins/autotest/testtreeitem.h b/src/plugins/autotest/testtreeitem.h index d989d11d0a9..26a88259367 100644 --- a/src/plugins/autotest/testtreeitem.h +++ b/src/plugins/autotest/testtreeitem.h @@ -44,6 +44,8 @@ namespace { namespace Autotest { namespace Internal { +struct TestCodeLocationAndType; + class TestTreeItem : public Utils::TreeItem { @@ -72,15 +74,20 @@ public: TestTreeItem(const QString &name = QString(), const QString &filePath = QString(), Type type = Root); - virtual ~TestTreeItem(); - TestTreeItem(const TestTreeItem& other); virtual QVariant data(int column, int role) const override; virtual bool setData(int column, const QVariant &data, int role) override; - bool modifyContent(const TestTreeItem *modified); + bool modifyTestCaseContent(const QString &name, unsigned line, unsigned column); + bool modifyTestFunctionContent(const TestCodeLocationAndType &location); + bool modifyDataTagContent(const QString &fileName, const TestCodeLocationAndType &location); + bool modifyGTestSetContent(const QString &fileName, const QString &referencingFile, + const TestCodeLocationAndType &location); + bool modifyLineAndColumn(unsigned line, unsigned column); const QString name() const { return m_name; } + void setName(const QString &name) { m_name = name; } const QString filePath() const { return m_filePath; } + void setFilePath(const QString &filePath) { m_filePath = filePath; } void setLine(unsigned line) { m_line = line;} unsigned line() const { return m_line; } void setColumn(unsigned column) { m_column = column; } @@ -100,8 +107,19 @@ public: TestTreeItem *parentItem() const; TestTreeItem *childItem(int row) const; + TestTreeItem *findChildByName(const QString &name); + TestTreeItem *findChildByFiles(const QString &filePath, const QString &referencingFile); + TestTreeItem *findChildByNameAndFile(const QString &name, const QString &filePath); + TestTreeItem *findChildByNameTypeAndFile(const QString &name, + TestTreeItem::Type type, const QString &referencingFile); + private: void revalidateCheckState(); + bool modifyFilePath(const QString &filePath); + bool modifyName(const QString &name); + + typedef std::function CompareFunction; + TestTreeItem *findChildBy(CompareFunction compare); QString m_name; QString m_filePath; diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp index 800b2d2f8e9..bfde56e0e6d 100644 --- a/src/plugins/autotest/testtreemodel.cpp +++ b/src/plugins/autotest/testtreemodel.cpp @@ -655,136 +655,90 @@ QMap TestTreeModel::referencingFiles() const return finder.referencingFiles(); } -TestTreeItem *TestTreeModel::findTestTreeItemByContent(TestTreeItem *item, TestTreeItem *parent, - Type type) +static TestTreeItem *constructDataTagTestTreeItem(const QString &fileName, + const TestCodeLocationAndType &location) { - for (int row = 0, count = parent->childCount(); row < count; ++row) { - TestTreeItem *current = parent->childItem(row); - if (current->name() != item->name()) - continue; - - switch (type) { - case AutoTest: - if (current->filePath() == item->filePath()) - return current; - break; - case QuickTest: - if (current->filePath() == item->filePath() && current->mainFile() == item->mainFile()) - return current; - break; - case GoogleTest: - if (current->type() == item->type()) - return current; - break; - case Invalid: - break; - } - } - return 0; + TestTreeItem *tagTreeItem = new TestTreeItem(location.m_name, fileName, location.m_type); + tagTreeItem->setLine(location.m_line); + tagTreeItem->setColumn(location.m_column); + tagTreeItem->setState(location.m_state); + return tagTreeItem; } -void TestTreeModel::addTestTreeItem(TestTreeItem *item, Type type) +static TestTreeItem *constructUnnamedQuickFunctionTestTreeItem(const QString &functionName, + const QString &referencingFile, + const TestCodeLocationAndType &location) { - TestTreeItem *parent = rootItemForType(type); - TestTreeItem *toBeUpdated = findTestTreeItemByContent(item, parent, type); - const int count = item->childCount(); - if (toBeUpdated) { - if (!toBeUpdated->markedForRemoval()) { - for (int row = 0; row < count; ++row) - toBeUpdated->appendChild(new TestTreeItem(*item->childItem(row))); - } else { - for (int childRow = count - 1; childRow >= 0; --childRow) { - TestTreeItem *childItem = item->childItem(childRow); - TestTreeItem *origChild = findTestTreeItemByContent(childItem, toBeUpdated, type); - if (origChild) { - QModelIndex toBeModifiedIndex = indexForItem(origChild); - modifyTestSubtree(toBeModifiedIndex, childItem); - } else { - toBeUpdated->insertChild(qMin(count, toBeUpdated->childCount()), - new TestTreeItem(*childItem)); - } - } - } - delete item; - } else { - parent->appendChild(item); - } - emit testTreeModelChanged(); + TestTreeItem *treeItem = new TestTreeItem(functionName, location.m_name, location.m_type); + treeItem->setLine(location.m_line); + treeItem->setColumn(location.m_column); + treeItem->setMainFile(referencingFile); // FIXME: can be handled by referencingFile + treeItem->setReferencingFile(referencingFile); + return treeItem; } -static TestTreeItem *constructTestTreeItem(const QString &fileName, - const QString &referencingFile, - const QString &testCaseName, - int line, int column, - const QMap &functions, - const QMap dataTags = QMap()) +static TestTreeItem *constructFunctionTestTreeItem(const QString &funcName, + const TestCodeLocationAndType &location, + const TestCodeLocationList &dataTags) +{ + TestTreeItem *treeItem = new TestTreeItem(funcName, location.m_name, location.m_type); + treeItem->setLine(location.m_line); + treeItem->setColumn(location.m_column); + treeItem->setState(location.m_state); + + // if there are any data tags for this function add them + foreach (const TestCodeLocationAndType &tagLocation, dataTags) + treeItem->appendChild(constructDataTagTestTreeItem(location.m_name, tagLocation)); + return treeItem; +} + +static TestTreeItem *constructTestTreeItem(const TestParseResult &result) { TestTreeItem *treeItem; - if (testCaseName.isEmpty()) { // unnamed Quick Test + if (result.testCaseName.isEmpty()) { // unnamed Quick Test treeItem = new TestTreeItem(QString(), QString(), TestTreeItem::TestClass); - foreach (const QString &functionName, functions.keys()) { - const TestCodeLocationAndType locationAndType = functions.value(functionName); - TestTreeItem *testFunction = new TestTreeItem(functionName, locationAndType.m_name, - locationAndType.m_type); - testFunction->setLine(locationAndType.m_line); - testFunction->setColumn(locationAndType.m_column); - testFunction->setMainFile(referencingFile); // FIXME: can be handled by referencingFile - testFunction->setReferencingFile(referencingFile); - treeItem->appendChild(testFunction); + foreach (const QString &functionName, result.functions.keys()) { + treeItem->appendChild(constructUnnamedQuickFunctionTestTreeItem( + functionName, result.referencingFile, result.functions.value(functionName))); } } else { - treeItem = new TestTreeItem(testCaseName, fileName, TestTreeItem::TestClass); - treeItem->setMainFile(referencingFile); // FIXME: can be handled by referencingFile - treeItem->setReferencingFile(referencingFile); - treeItem->setLine(line); - treeItem->setColumn(column); + treeItem = new TestTreeItem(result.testCaseName, result.fileName, TestTreeItem::TestClass); + treeItem->setMainFile(result.referencingFile); // FIXME: can be handled by referencingFile + treeItem->setReferencingFile(result.referencingFile); + treeItem->setLine(result.line); + treeItem->setColumn(result.column); - foreach (const QString &functionName, functions.keys()) { - const TestCodeLocationAndType locationAndType = functions.value(functionName); - TestTreeItem *treeItemChild = new TestTreeItem(functionName, locationAndType.m_name, - locationAndType.m_type); - treeItemChild->setLine(locationAndType.m_line); - treeItemChild->setColumn(locationAndType.m_column); - treeItemChild->setState(locationAndType.m_state); - - // check for data tags and if there are any for this function add them - const QString qualifiedFunctionName = testCaseName + QLatin1String("::") + functionName; - if (dataTags.contains(qualifiedFunctionName)) { - const TestCodeLocationList &tags = dataTags.value(qualifiedFunctionName); - foreach (const TestCodeLocationAndType &tagLocation, tags) { - TestTreeItem *tagTreeItem = new TestTreeItem(tagLocation.m_name, - locationAndType.m_name, - tagLocation.m_type); - tagTreeItem->setLine(tagLocation.m_line); - tagTreeItem->setColumn(tagLocation.m_column); - tagTreeItem->setState(tagLocation.m_state); - treeItemChild->appendChild(tagTreeItem); - } - } - treeItem->appendChild(treeItemChild); + foreach (const QString &functionName, result.functions.keys()) { + const TestCodeLocationAndType locationAndType = result.functions.value(functionName); + const QString qualifiedName = result.testCaseName + QLatin1String("::") + functionName; + treeItem->appendChild( + constructFunctionTestTreeItem(functionName, locationAndType, + result.dataTagsOrTestSets.value(qualifiedName))); } } return treeItem; } -static TestTreeItem *constructGTestTreeItem(const QString &filePath, const QString &testCaseName, - const bool parameterized, - const QString &referencingFile, - const TestCodeLocationList &testSets) +static TestTreeItem *constructGTestSetTreeItem(const QString &filePath, + const QString &referencingFile, + const TestCodeLocationAndType &location) { - TestTreeItem *item = new TestTreeItem(testCaseName, QString(), - parameterized ? TestTreeItem::GTestCaseParameterized - : TestTreeItem::GTestCase); - foreach (const TestCodeLocationAndType &locationAndType, testSets) { - TestTreeItem *treeItemChild = new TestTreeItem(locationAndType.m_name, filePath, - locationAndType.m_type); - treeItemChild->setState(locationAndType.m_state); - treeItemChild->setLine(locationAndType.m_line); - treeItemChild->setColumn(locationAndType.m_column); - treeItemChild->setMainFile(referencingFile); - item->appendChild(treeItemChild); - } - item->setReferencingFile(referencingFile); + TestTreeItem *treeItem = new TestTreeItem(location.m_name, filePath, location.m_type); + treeItem->setState(location.m_state); + treeItem->setLine(location.m_line); + treeItem->setColumn(location.m_column); + treeItem->setMainFile(referencingFile); + return treeItem; +} + +static TestTreeItem *constructGTestTreeItem(const TestParseResult &result) +{ + TestTreeItem *item = new TestTreeItem(result.testCaseName, QString(), + result.parameterized ? TestTreeItem::GTestCaseParameterized + : TestTreeItem::GTestCase); + item->setReferencingFile(result.referencingFile); + foreach (const TestCodeLocationAndType &location, result.dataTagsOrTestSets.first()) + item->appendChild(constructGTestSetTreeItem(result.fileName, result.referencingFile, location)); return item; } @@ -792,17 +746,17 @@ void TestTreeModel::onParseResultReady(TestParseResult result) { switch (result.type) { case AutoTest: + handleParseResult(result); case QuickTest: - addTestTreeItem(constructTestTreeItem(result.fileName, result.referencingFile, - result.testCaseName, result.line, result.column, - result.functions, result.dataTagsOrTestSets), - result.type); + if (result.testCaseName.isEmpty()) { + handleUnnamedQuickParseResult(result); + break; + } + handleParseResult(result); break; case GoogleTest: QTC_ASSERT(result.dataTagsOrTestSets.size() == 1, return); - addTestTreeItem(constructGTestTreeItem(result.fileName, result.testCaseName, - result.parameterized, result.referencingFile, - result.dataTagsOrTestSets.first()), result.type); + handleGTestParseResult(result); break; case Invalid: QTC_ASSERT(false, qWarning("TestParseResult of type Invalid unexpected.")); @@ -810,6 +764,114 @@ void TestTreeModel::onParseResultReady(TestParseResult result) } } +void TestTreeModel::handleParseResult(const TestParseResult &result) +{ + TestTreeItem *root; + switch (result.type) { + case AutoTest: + root = m_autoTestRootItem; + break; + case QuickTest: + root = m_quickTestRootItem; + break; + default: + QTC_ASSERT(false, return); // should never happen, just to avoid warning + } + + TestTreeItem *toBeModified = root->findChildByFiles(result.fileName, result.referencingFile); + // if there's no matching item, add the new one + if (!toBeModified) { + root->appendChild(constructTestTreeItem(result)); + return; + } + // else we have to check level by level.. first the current level... + bool changed = toBeModified->modifyTestCaseContent(result.testCaseName, result.line, + result.column); + toBeModified->markForRemoval(false); + if (changed) + emit dataChanged(indexForItem(toBeModified), indexForItem(toBeModified)); + // ...now the functions + foreach (const QString &func, result.functions.keys()) { + TestTreeItem *functionItem = toBeModified->findChildByName(func); + // if there's no function matching, add the new one + if (!functionItem) { + const QString qualifiedName = result.testCaseName + QLatin1String("::") + func; + toBeModified->appendChild( + constructFunctionTestTreeItem(func, result.functions.value(func), + result.dataTagsOrTestSets.value(qualifiedName))); + continue; + } + // else we have to check level by level.. first the current level... + changed = functionItem->modifyTestFunctionContent(result.functions.value(func)); + functionItem->markForRemoval(false); + if (changed) + emit dataChanged(indexForItem(functionItem), indexForItem(functionItem)); + // ...now the data tags + const QString &funcFileName = result.functions.value(func).m_name; + const QString qualifiedFunctionName = result.testCaseName + QLatin1String("::") + func; + foreach (const TestCodeLocationAndType &location, result.dataTagsOrTestSets.value(qualifiedFunctionName)) { + TestTreeItem *dataTagItem = functionItem->findChildByName(location.m_name); + if (!dataTagItem) { + functionItem->appendChild(constructDataTagTestTreeItem(funcFileName, location)); + continue; + } + changed = dataTagItem->modifyDataTagContent(funcFileName, location); + dataTagItem->markForRemoval(false); + if (changed) + emit dataChanged(indexForItem(dataTagItem), indexForItem(dataTagItem)); + } + } +} + +void TestTreeModel::handleUnnamedQuickParseResult(const TestParseResult &result) +{ + TestTreeItem *toBeModified = unnamedQuickTests(); + if (!toBeModified) { + m_quickTestRootItem->appendChild(constructTestTreeItem(result)); + return; + } + // if we have already Unnamed Quick tests we might update them.. + foreach (const QString &func, result.functions.keys()) { + const TestCodeLocationAndType &location = result.functions.value(func); + TestTreeItem *functionItem = toBeModified->findChildByNameAndFile(func, location.m_name); + if (!functionItem) { + toBeModified->appendChild( + constructUnnamedQuickFunctionTestTreeItem(func, result.referencingFile, + location)); + continue; + } + functionItem->modifyLineAndColumn(result.line, result.column); + functionItem->markForRemoval(false); + } +} + +void TestTreeModel::handleGTestParseResult(const TestParseResult &result) +{ + TestTreeItem::Type type = result.parameterized ? TestTreeItem::GTestCaseParameterized + : TestTreeItem::GTestCase; + TestTreeItem *toBeModified = m_googleTestRootItem->findChildByNameTypeAndFile( + result.testCaseName, type, result.referencingFile); + if (!toBeModified) { + m_googleTestRootItem->appendChild(constructGTestTreeItem(result)); + return; + } + // if found nothing has to be updated as all relevant members are used to find the item + foreach (const TestCodeLocationAndType &location , result.dataTagsOrTestSets.first()) { + TestTreeItem *testSetItem = toBeModified->findChildByNameAndFile(location.m_name, + result.fileName); + if (!testSetItem) { + toBeModified->appendChild(constructGTestSetTreeItem(result.fileName, + result.referencingFile, location)); + continue; + } + bool changed = testSetItem->modifyGTestSetContent(result.fileName, + result.referencingFile, location); + testSetItem->markForRemoval(false); + if (changed) + emit dataChanged(indexForItem(testSetItem), indexForItem(testSetItem)); + } +} + void TestTreeModel::removeAllTestItems() { m_autoTestRootItem->removeChildren(); @@ -833,84 +895,6 @@ TestTreeItem *TestTreeModel::rootItemForType(TestTreeModel::Type type) QTC_ASSERT(false, return 0); } -void TestTreeModel::modifyTestSubtree(QModelIndex &toBeModifiedIndex, const TestTreeItem *newItem) -{ - if (!toBeModifiedIndex.isValid()) - return; - - TestTreeItem *toBeModifiedItem = static_cast(itemForIndex(toBeModifiedIndex)); - if (toBeModifiedItem->modifyContent(newItem)) - emit dataChanged(toBeModifiedIndex, toBeModifiedIndex, - QVector() << Qt::DisplayRole << Qt::ToolTipRole << LinkRole); - - // process sub-items as well... - const int childCount = toBeModifiedItem->childCount(); - const int newChildCount = newItem->childCount(); - - // for keeping the CheckState on modifications - // TODO might still fail for duplicate entries - QHash checkStates; - for (int row = 0; row < childCount; ++row) { - const TestTreeItem *child = toBeModifiedItem->childItem(row); - checkStates.insert(child->name(), child->checked()); - } - - if (childCount <= newChildCount) { - processChildren(toBeModifiedIndex, newItem, childCount, checkStates); - // add additional items - for (int row = childCount; row < newChildCount; ++row) { - const TestTreeItem *newChild = newItem->childItem(row); - TestTreeItem *toBeAdded = new TestTreeItem(*newChild); - if (checkStates.contains(toBeAdded->name()) - && checkStates.value(toBeAdded->name()) != Qt::Checked) - toBeAdded->setChecked(checkStates.value(toBeAdded->name())); - toBeModifiedItem->appendChild(toBeAdded); - } - } else { - processChildren(toBeModifiedIndex, newItem, newChildCount, checkStates); - // remove rest of the items - for (int row = childCount - 1; row > newChildCount; --row) - delete takeItem(toBeModifiedItem->childItem(row)); - } - emit testTreeModelChanged(); -} - -void TestTreeModel::processChildren(QModelIndex &parentIndex, const TestTreeItem *newItem, - const int upperBound, - const QHash &checkStates) -{ - static QVector modificationRoles = QVector() << Qt::DisplayRole - << Qt::ToolTipRole - << LinkRole; - TestTreeItem *toBeModifiedItem = static_cast(itemForIndex(parentIndex)); - for (int row = 0; row < upperBound; ++row) { - QModelIndex child = parentIndex.child(row, 0); - TestTreeItem *toBeModifiedChild = toBeModifiedItem->childItem(row); - const TestTreeItem *modifiedChild = newItem->childItem(row); - if (toBeModifiedChild->modifyContent(modifiedChild)) - emit dataChanged(child, child, modificationRoles); - - // handle data tags - just remove old and add them - if (modifiedChild->childCount() || toBeModifiedChild->childCount()) { - toBeModifiedChild->removeChildren(); - const int count = modifiedChild->childCount(); - for (int childRow = 0; childRow < count; ++childRow) - toBeModifiedChild->appendChild(new TestTreeItem(*modifiedChild->childItem(childRow))); - } - - if (checkStates.contains(toBeModifiedChild->name())) { - Qt::CheckState state = checkStates.value(toBeModifiedChild->name()); - if (state != toBeModifiedChild->checked()) { - toBeModifiedChild->setChecked(state); - emit dataChanged(child, child, QVector() << Qt::CheckStateRole); - } - } else { // newly added (BAD: happens for renaming as well) - toBeModifiedChild->setChecked(Qt::Checked); - emit dataChanged(child, child, QVector() << Qt::CheckStateRole); - } - } -} - #ifdef WITH_TESTS int TestTreeModel::autoTestsCount() const { diff --git a/src/plugins/autotest/testtreemodel.h b/src/plugins/autotest/testtreemodel.h index dd9476ed959..f265a317197 100644 --- a/src/plugins/autotest/testtreemodel.h +++ b/src/plugins/autotest/testtreemodel.h @@ -89,21 +89,19 @@ signals: public slots: private: - void addTestTreeItem(TestTreeItem *item, Type type); void onParseResultReady(TestParseResult result); + void handleParseResult(const TestParseResult &result); + void handleUnnamedQuickParseResult(const TestParseResult &result); + void handleGTestParseResult(const TestParseResult &result); void removeAllTestItems(); void removeFiles(const QStringList &files); void markForRemoval(const QString &filePath, Type type); bool sweepChildren(TestTreeItem *item); - TestTreeItem *findTestTreeItemByContent(TestTreeItem *item, TestTreeItem *parent, Type type); TestTreeItem *unnamedQuickTests() const; TestTreeItem *rootItemForType(Type type); explicit TestTreeModel(QObject *parent = 0); - void modifyTestSubtree(QModelIndex &toBeModifiedIndex, const TestTreeItem *newItem); - void processChildren(QModelIndex &parentIndex, const TestTreeItem *newItem, - const int upperBound, const QHash &checkStates); void setupParsingConnections(); TestTreeItem *m_autoTestRootItem;