summaryrefslogtreecommitdiff
path: root/plugins/autotest/testtreemodel.cpp
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@theqtcompany.com>2015-08-04 15:53:09 +0200
committerChristian Stenger <christian.stenger@theqtcompany.com>2015-08-31 11:22:16 +0300
commitd284cd99d4143ebe21844347e9a0bc4627494c4c (patch)
tree5189881be39e99026f3e9faac7f0541cb2107470 /plugins/autotest/testtreemodel.cpp
parentafcb9283b0f7f8a8e9f1c1376b378353f6a6fd9d (diff)
downloadqt-creator-d284cd99d4143ebe21844347e9a0bc4627494c4c.tar.gz
Add basic support for data tags
This enables displaying data tags for data functions inside the test tree. Clicking on the data tag opens the editor at the location the respective QTest::newRow() call is done. Change-Id: Ia91bf87437c2608a05bae88ed715711217685fdf Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'plugins/autotest/testtreemodel.cpp')
-rw-r--r--plugins/autotest/testtreemodel.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp
index 5eea7b7d98..e30b7f651c 100644
--- a/plugins/autotest/testtreemodel.cpp
+++ b/plugins/autotest/testtreemodel.cpp
@@ -180,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];
}
@@ -204,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();
}
@@ -222,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();
@@ -682,7 +684,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);
@@ -819,6 +821,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()) {