TestConfiguration *QuickTestTreeItem::testConfiguration() const { ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); QTC_ASSERT(project, return 0); QuickTestConfiguration *config = 0; switch (type()) { case TestCase: { QStringList testFunctions; for (int row = 0, count = childCount(); row < count; ++row) testFunctions << name() + QLatin1String("::") + childItem(row)->name(); config = new QuickTestConfiguration; config->setTestCases(testFunctions); config->setProFile(proFile()); config->setProject(project); break; } case TestFunctionOrSet: { TestTreeItem *parent = parentItem(); QStringList testFunction(parent->name() + QLatin1String("::") + name()); config = new QuickTestConfiguration; config->setTestCases(testFunction); config->setProFile(parent->proFile()); config->setProject(project); break; } default: return 0; } return config; }
void TestTreeItem::revalidateCheckState() { if (childCount() == 0) return; bool foundChecked = false; bool foundUnchecked = false; for (int row = 0, count = childCount(); row < count; ++row) { TestTreeItem *child = childItem(row); switch (child->type()) { case TestDataFunction: case TestSpecialFunction: continue; default: break; } foundChecked |= (child->checked() != Qt::Unchecked); foundUnchecked |= (child->checked() == Qt::Unchecked); if (foundChecked && foundUnchecked) { m_checked = Qt::PartiallyChecked; return; } } m_checked = (foundUnchecked ? Qt::Unchecked : Qt::Checked); }
QList<QString> TestTreeItem::getChildNames() const { QList<QString> names; for (int row = 0, count = childCount(); row < count; ++row) names << childItem(row)->name(); return names; }
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; }
QStringList ChapterNode::files(const int count) const { QStringList list; for(int i = 0; i < qMin(count, rowCount()); i++) { ChapterFile *file = dynamic_cast<ChapterFile*>(childItem(i)); list.push_back(file->fileName()); } return list; }
QList<TestConfiguration *> QtTestTreeItem::getSelectedTestConfigurations() const { QList<TestConfiguration *> result; ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); if (!project || type() != Root) return result; QtTestConfiguration *testConfiguration = 0; for (int row = 0, count = childCount(); row < count; ++row) { const TestTreeItem *child = childItem(row); switch (child->checked()) { case Qt::Unchecked: continue; case Qt::Checked: testConfiguration = new QtTestConfiguration(); testConfiguration->setTestCaseCount(child->childCount()); testConfiguration->setProFile(child->proFile()); testConfiguration->setProject(project); testConfiguration->setDisplayName( TestUtils::getCMakeDisplayNameIfNecessary(child->filePath(), child->proFile())); result << testConfiguration; continue; case Qt::PartiallyChecked: default: int grandChildCount = child->childCount(); QStringList testCases; for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) { const TestTreeItem *grandChild = child->childItem(grandChildRow); if (grandChild->checked() == Qt::Checked) { testCases << grandChild->name(); } else if (grandChild->checked() == Qt::PartiallyChecked) { const int dtCount = grandChild->childCount(); const QString funcName = grandChild->name(); for (int dtRow = 0; dtRow < dtCount; ++dtRow) { const TestTreeItem *dataTag = grandChild->childItem(dtRow); if (dataTag->checked() == Qt::Checked) testCases << funcName + ':' + dataTag->name(); } } } testConfiguration = new QtTestConfiguration(); testConfiguration->setTestCases(testCases); testConfiguration->setProFile(child->proFile()); testConfiguration->setProject(project); testConfiguration->setDisplayName( TestUtils::getCMakeDisplayNameIfNecessary(child->filePath(), child->proFile())); result << testConfiguration; } } return result; }
void TestTreeItem::markForRemovalRecursively(const QString &filePath) { if (m_filePath == filePath) { markForRemovalRecursively(true); } else { for (int row = 0, count = childCount(); row < count; ++row) { TestTreeItem *child = childItem(row); child->markForRemovalRecursively(filePath); } } }
QModelIndex QvisPluginManagerAttributesDataModel::parent(const QModelIndex &index) const { if(!index.isValid()) return QModelIndex(); TreeItem childItem((int)index.internalId()); TreeItem parentItem(childItem.parent()); if(parentItem == TreeItem(-1)) return QModelIndex(); return createIndex(parentItem.row(), 0, (int)parentItem.index); }
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_state(other.m_state) { for (int row = 0, count = other.childCount(); row < count; ++row) appendChild(new TestTreeItem(*childItem(row))); }
void TestTreeItem::setChecked(const Qt::CheckState checkState) { switch (m_type) { case TestFunctionOrSet: { m_checked = (checkState == Qt::Unchecked ? Qt::Unchecked : Qt::Checked); parentItem()->revalidateCheckState(); break; } case TestCase: { Qt::CheckState usedState = (checkState == Qt::Unchecked ? Qt::Unchecked : Qt::Checked); for (int row = 0, count = childCount(); row < count; ++row) childItem(row)->setChecked(usedState); m_checked = usedState; } default: return; } }
QModelIndex QvisPluginManagerAttributesDataModel::index(int row, int column, const QModelIndex & parent) const { if(!hasIndex(row, column, parent)) return QModelIndex(); TreeItem parentItem; if(!parent.isValid()) parentItem = TreeItem(-1); // root else parentItem = TreeItem((int)parent.internalId()); TreeItem childItem(parentItem.child(row)); if(childItem.exists()) return createIndex(row, column, (quint32)childItem.index); else return QModelIndex(); }
QList<TestConfiguration *> QtTestTreeItem::getAllTestConfigurations() const { QList<TestConfiguration *> result; ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); if (!project || type() != Root) return result; for (int row = 0, count = childCount(); row < count; ++row) { const TestTreeItem *child = childItem(row); TestConfiguration *tc = new QtTestConfiguration(); tc->setTestCaseCount(child->childCount()); tc->setProFile(child->proFile()); tc->setProject(project); tc->setDisplayName(TestUtils::getCMakeDisplayNameIfNecessary(child->filePath(), child->proFile())); result << tc; } return result; }
QList<TestConfiguration *> QuickTestTreeItem::getAllTestConfigurations() const { QList<TestConfiguration *> result; ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); if (!project || type() != Root) return result; QHash<QString, int> foundProFiles; for (int row = 0, count = childCount(); row < count; ++row) { const TestTreeItem *child = childItem(row); // unnamed Quick Tests must be handled separately if (child->name().isEmpty()) { for (int childRow = 0, ccount = child->childCount(); childRow < ccount; ++ childRow) { const TestTreeItem *grandChild = child->childItem(childRow); const QString &proFile = grandChild->proFile(); foundProFiles.insert(proFile, foundProFiles[proFile] + 1); } continue; } // named Quick Test const QString &proFile = child->proFile(); foundProFiles.insert(proFile, foundProFiles[proFile] + child->childCount()); } // create TestConfiguration for each project file QHash<QString, int>::ConstIterator it = foundProFiles.begin(); QHash<QString, int>::ConstIterator end = foundProFiles.end(); for ( ; it != end; ++it) { QuickTestConfiguration *tc = new QuickTestConfiguration; tc->setTestCaseCount(it.value()); tc->setProFile(it.key()); tc->setProject(project); result << tc; } return result; }
// Slot. void TransitionEditorWindow::updateEquationsTree() { if (model_ == nullptr) return; QTreeWidget* tree = ui_->equationsTree; tree->clear(); for (const auto& group : model_->equationGroupList()) { std::unique_ptr<QTreeWidgetItem> item(new QTreeWidgetItem); item->setText(0, group.name.c_str()); item->setFlags(Qt::ItemIsEnabled); for (const auto& equation : group.equationList) { std::unique_ptr<QTreeWidgetItem> childItem(new QTreeWidgetItem); childItem->setText(0, equation->name().c_str()); childItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); item->addChild(childItem.release()); } tree->addTopLevelItem(item.release()); } tree->expandAll(); }
void TestTreeItem::markForRemovalRecursively(bool mark) { markForRemoval(mark); for (int row = 0, count = childCount(); row < count; ++row) childItem(row)->markForRemovalRecursively(mark); }