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 #include #include @@ -38,14 +39,26 @@ QString CatchTreeItem::testCasesString() const return m_state & CatchTreeItem::Parameterized ? QString(name() + " -*") : name(); } +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: