From 09cc4507973165154e88622ded59d6b5ec8ca29f Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 23 Feb 2024 13:45:15 +0100 Subject: [PATCH] Axivion: Handle links more appropriate If the user clicks on a row's column holding a location information then use this explicitly instead of always using the first available link. Change-Id: Ifecbecac632a4bfd4d31614a8c43ab6c80de4819 Reviewed-by: hjk --- src/plugins/axivion/axivionoutputpane.cpp | 44 +++++++++++++++++------ 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/plugins/axivion/axivionoutputpane.cpp b/src/plugins/axivion/axivionoutputpane.cpp index 5164cd743b6..063fafdc988 100644 --- a/src/plugins/axivion/axivionoutputpane.cpp +++ b/src/plugins/axivion/axivionoutputpane.cpp @@ -17,6 +17,7 @@ #include +#include #include #include #include @@ -190,6 +191,12 @@ void DashboardWidget::updateUi() addValuesWidgets(Tr::tr("Total:"), allTotal, allAdded, allRemoved, row); } +struct LinkWithColumns +{ + Link link; + QList columns; +}; + class IssueListItem final : public ListItem { public: @@ -200,7 +207,7 @@ public: , m_toolTips(toolTips) {} - void setLinks(const Links &links) { m_links = links; } + void setLinks(const QList &links) { m_links = links; } QVariant data(int column, int role) const { @@ -215,8 +222,10 @@ public: { if (role == BaseTreeView::ItemActivatedRole) { if (!m_links.isEmpty()) { - // TODO for now only simple - just the first.. - Link link = m_links.first(); + Link link + = Utils::findOr(m_links, m_links.first(), [column](const LinkWithColumns &link) { + return link.columns.contains(column); + }).link; Project *project = ProjectManager::startupProject(); FilePath baseDir = project ? project->projectDirectory() : FilePath{}; link.targetFilePath = baseDir.resolvePath(link.targetFilePath); @@ -234,7 +243,7 @@ private: const QString m_id; QStringList m_data; QStringList m_toolTips; - Links m_links; + QList m_links; }; class IssuesWidget : public QScrollArea @@ -399,19 +408,34 @@ void IssuesWidget::updateTable() m_headerView->resizeSections(QHeaderView::ResizeToContents); } -static Links linksForIssue(const std::map &issueRow) +static QList linksForIssue(const std::map &issueRow, + const std::vector &columnInfos) { - Links links; + QList links; auto end = issueRow.end(); - auto findAndAppend = [&links, &issueRow, &end](const QString &path, const QString &line) { + auto findColumn = [columnInfos](const QString &columnKey) { + int col = 0; + for (auto it = columnInfos.cbegin(), end = columnInfos.cend(); it != end; ++it) { + if (it->key == columnKey) + return col; + ++col; + } + return -1; + }; + auto findAndAppend = [&links, &issueRow, &columnInfos, &findColumn, &end](const QString &path, + const QString &line) { + QList columns; auto it = issueRow.find(path); if (it != end) { Link link{ FilePath::fromUserInput(it->second.getString()) }; + columns.append(findColumn(it->first)); it = issueRow.find(line); - if (it != end) + if (it != end) { link.targetLine = it->second.getDouble(); - links.append(link); + columns.append(findColumn(it->first)); + } + links.append({link, columns}); } }; // do these always? or just for their "expected" kind @@ -455,7 +479,7 @@ void IssuesWidget::addIssues(const Dto::IssueTableDto &dto, int startRow) } } IssueListItem *it = new IssueListItem(startRow++, id, data, data); - it->setLinks(linksForIssue(row)); + it->setLinks(linksForIssue(row, tableColumns)); items.append(it); } m_issuesModel->setItems(items);