Debugger: Trim file path for breakpoint

Show trimmed file path in the breakpoint view. ToolTip shows
full path.

Fixes: QTCREATORBUG-24229
Change-Id: I90301703941e16cbd1e216366e97e61c3c741bcd
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Artem Sokolovskii
2024-10-01 16:56:09 +02:00
parent 94b63ad3b4
commit 9eb0f82d2c

View File

@@ -20,6 +20,9 @@
#include <coreplugin/idocument.h>
#include <coreplugin/session.h>
#include <projectexplorer/projecttree.h>
#include <projectexplorer/project.h>
#include <texteditor/textmark.h>
#include <texteditor/texteditor.h>
@@ -1001,6 +1004,16 @@ int BreakHandler::threadSpecFromDisplay(const QString &str)
return ok ? result : -1;
}
static QString trimmedFileName(const FilePath &fullPath)
{
const Project *project = ProjectTree::currentProject();
const FilePath projectDirectory = project ? project->projectDirectory() : FilePath();
if (projectDirectory.exists())
return FilePath::calcRelativePath(fullPath.path(), projectDirectory.toUserOutput());
return fullPath.toUserOutput();
}
const QString empty("-");
QVariant BreakpointItem::data(int column, int role) const
@@ -1054,6 +1067,8 @@ QVariant BreakpointItem::data(int column, int role) const
break;
case BreakpointFileColumn:
if (role == Qt::DisplayRole)
return trimmedFileName(markerFileName());
if (role == Qt::ToolTipRole)
return markerFileName().toUserOutput();
break;
case BreakpointLineColumn:
@@ -2208,6 +2223,8 @@ QVariant GlobalBreakpointItem::data(int column, int role) const
break;
case BreakpointFileColumn:
if (role == Qt::DisplayRole)
return trimmedFileName(m_params.fileName);
if (role == Qt::ToolTipRole)
return m_params.fileName.toUserOutput();
break;
case BreakpointLineColumn: