aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/autotest/catch/catchtreeitem.cpp
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2020-07-21 12:42:37 +0200
committerChristian Stenger <christian.stenger@qt.io>2020-08-10 08:24:38 +0000
commit63823a55acf2739c77a27a1b56ecf4c5a3f52ad7 (patch)
treefeadff9ae849c1e484c901bc3e9890e4e0d28fae /src/plugins/autotest/catch/catchtreeitem.cpp
parentc6c320a6ea4245bfa4efb83a495c9dc91a555887 (diff)
AutoTest: Display relative path for file nodes
Using the full path for the file nodes may be quite long depending on the location of the project. Display its name relative to the project directory or the parent group node instead. Fixes: QTCREATORBUG-24374 Change-Id: I4ce57a0940008d99c51e63c2265a371a0ffe20ef Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/autotest/catch/catchtreeitem.cpp')
-rw-r--r--src/plugins/autotest/catch/catchtreeitem.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/plugins/autotest/catch/catchtreeitem.cpp b/src/plugins/autotest/catch/catchtreeitem.cpp
index cdd48d85368..e62cbe0da78 100644
--- a/src/plugins/autotest/catch/catchtreeitem.cpp
+++ b/src/plugins/autotest/catch/catchtreeitem.cpp
@@ -27,6 +27,7 @@
#include "catchconfiguration.h"
#include "catchframework.h"
+#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
#include <utils/qtcassert.h>
@@ -38,14 +39,26 @@ QString CatchTreeItem::testCasesString() const
return m_state & CatchTreeItem::Parameterized ? QString(name() + " -*") : name();
}
-QVariant CatchTreeItem::data(int column, int role) const
+static QString nonRootDisplayName(const CatchTreeItem *it)
{
+ if (it->type() != TestTreeItem::TestSuite)
+ return it->name();
+ ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
+ if (!project)
+ return it->name();
+ TestTreeItem *parent = it->parentItem();
+ int baseDirSize = (parent->type() == TestTreeItem::GroupNode)
+ ? parent->filePath().size() : project->projectDirectory().toString().size();
+ return it->name().mid(baseDirSize + 1);
+}
+QVariant CatchTreeItem::data(int column, int role) const
+{
switch (role) {
case Qt::DisplayRole:
if (type() == Root)
break;
- return QString(name() + stateSuffix());
+ return QString(nonRootDisplayName(this) + stateSuffix());
case Qt::CheckStateRole:
switch (type()) {
case Root: