summaryrefslogtreecommitdiff
path: root/plugins/autotest/testtreemodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/autotest/testtreemodel.cpp')
-rw-r--r--plugins/autotest/testtreemodel.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp
index 605167c249..0e3b09b439 100644
--- a/plugins/autotest/testtreemodel.cpp
+++ b/plugins/autotest/testtreemodel.cpp
@@ -96,13 +96,17 @@ TestTreeModel::~TestTreeModel()
void TestTreeModel::enableParsing()
{
m_refCounter.ref();
+
+ if (!m_connectionsInitialized)
+ m_parser->setDirty();
+
m_parser->setState(TestCodeParser::Idle);
if (m_connectionsInitialized)
return;
ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance();
connect(sm, &ProjectExplorer::SessionManager::startupProjectChanged,
- m_parser, &TestCodeParser::emitUpdateTestTree);
+ m_parser, &TestCodeParser::onStartupProjectChanged);
CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
connect(cppMM, &CppTools::CppModelManager::documentUpdated,
@@ -176,12 +180,13 @@ int TestTreeModel::columnCount(const QModelIndex &) const
static QIcon testTreeIcon(TestTreeItem::Type type)
{
- static QIcon icons[3] = {
+ static QIcon icons[] = {
QIcon(),
QIcon(QLatin1String(":/images/class.png")),
- QIcon(QLatin1String(":/images/func.png"))
+ QIcon(QLatin1String(":/images/func.png")),
+ QIcon(QLatin1String(":/images/data.png"))
};
- if (type >= 3)
+ if (type >= sizeof(icons) / sizeof(icons[0]))
return icons[2];
return icons[type];
}
@@ -200,7 +205,7 @@ QVariant TestTreeModel::data(const QModelIndex &index, int role) const
|| (item == m_quickTestRootItem && m_quickTestRootItem->childCount() == 0)) {
return QString(item->name() + tr(" (none)"));
} else {
- if (item->name().isEmpty())
+ if (item->name().isEmpty() && item->type() == TestTreeItem::TEST_CLASS)
return tr(Constants::UNNAMED_QUICKTESTS);
return item->name();
}
@@ -218,6 +223,7 @@ QVariant TestTreeModel::data(const QModelIndex &index, int role) const
case Qt::CheckStateRole:
switch (item->type()) {
case TestTreeItem::ROOT:
+ case TestTreeItem::TEST_DATATAG:
case TestTreeItem::TEST_DATAFUNCTION:
case TestTreeItem::TEST_SPECIALFUNCTION:
return QVariant();
@@ -680,7 +686,7 @@ void TestTreeModel::updateUnnamedQuickTest(const QString &fileName, const QStrin
foreach (const QString &functionName, functions.keys()) {
const TestCodeLocationAndType locationAndType = functions.value(functionName);
- TestTreeItem *testFunction = new TestTreeItem(functionName, locationAndType.m_fileName,
+ TestTreeItem *testFunction = new TestTreeItem(functionName, locationAndType.m_name,
locationAndType.m_type, &unnamed);
testFunction->setLine(locationAndType.m_line);
testFunction->setColumn(locationAndType.m_column);
@@ -817,6 +823,19 @@ void TestTreeModel::processChildren(QModelIndex &parentIndex, const TestTreeItem
TestTreeItem *modifiedChild = newItem.child(row);
if (toBeModifiedChild->modifyContent(modifiedChild))
emit dataChanged(child, child, modificationRoles);
+
+ // handle data tags - just remove old and add them
+ if (modifiedChild->childCount() || toBeModifiedChild->childCount()) {
+ beginRemoveRows(child, 0, toBeModifiedChild->childCount());
+ toBeModifiedChild->removeChildren();
+ endRemoveRows();
+ const int count = modifiedChild->childCount();
+ beginInsertRows(child, 0, count);
+ for (int childRow = 0; childRow < count; ++childRow)
+ toBeModifiedChild->appendChild(new TestTreeItem(*modifiedChild->child(childRow)));
+ endInsertRows();
+ }
+
if (checkStates.contains(toBeModifiedChild->name())) {
Qt::CheckState state = checkStates.value(toBeModifiedChild->name());
if (state != toBeModifiedChild->checked()) {