From 9eb0f82d2c35cc53e104914d8c4bf01174702302 Mon Sep 17 00:00:00 2001 From: Artem Sokolovskii Date: Tue, 1 Oct 2024 16:56:09 +0200 Subject: [PATCH] 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 --- src/plugins/debugger/breakhandler.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 3d907d20be6..5d0b25a3729 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -20,6 +20,9 @@ #include #include +#include +#include + #include #include @@ -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: