forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
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:
|
||||
|
Reference in New Issue
Block a user