diff options
author | Christian Stenger <christian.stenger@qt.io> | 2024-03-22 11:26:04 +0100 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2024-03-22 15:05:45 +0000 |
commit | 99aed851ef8abdccb3c13686db61f644a51fe44c (patch) | |
tree | a6b8198179898af3623c0a67154c6f60d0d60232 | |
parent | 34eeda4b0572b127cbcdb842368dae06b7e30422 (diff) |
Axivion: Improve path mapping
If the linked project is not the top level project our
path mappings did not work.
Try to get the correct file path by using QC internal
find functionality.
This helps for opening files by activating issues inside
the issues table or when clicking links of the issue
details.
Unfortunately this does not help for the inline
annotations or respective marks.
Change-Id: Ie34e1b20ff8b1b2b37e9f04c1d41bc2a4c33f260
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r-- | src/plugins/axivion/axivionoutputpane.cpp | 2 | ||||
-rw-r--r-- | src/plugins/axivion/axivionplugin.cpp | 24 | ||||
-rw-r--r-- | src/plugins/axivion/axivionplugin.h | 2 |
3 files changed, 24 insertions, 4 deletions
diff --git a/src/plugins/axivion/axivionoutputpane.cpp b/src/plugins/axivion/axivionoutputpane.cpp index 79c90936cf..d66468590b 100644 --- a/src/plugins/axivion/axivionoutputpane.cpp +++ b/src/plugins/axivion/axivionoutputpane.cpp @@ -235,7 +235,7 @@ public: }).link; Project *project = ProjectManager::startupProject(); FilePath baseDir = project ? project->projectDirectory() : FilePath{}; - link.targetFilePath = baseDir.resolvePath(link.targetFilePath); + link.targetFilePath = findFileForIssuePath(link.targetFilePath); if (link.targetFilePath.exists()) EditorManager::openEditorAt(link); } diff --git a/src/plugins/axivion/axivionplugin.cpp b/src/plugins/axivion/axivionplugin.cpp index fa455c07eb..0f4686e403 100644 --- a/src/plugins/axivion/axivionplugin.cpp +++ b/src/plugins/axivion/axivionplugin.cpp @@ -36,6 +36,7 @@ #include <utils/async.h> #include <utils/checkablemessagebox.h> #include <utils/environment.h> +#include <utils/fileinprojectfinder.h> #include <utils/networkaccessmanager.h> #include <utils/qtcassert.h> #include <utils/utilsicons.h> @@ -236,6 +237,7 @@ public: TaskTreeRunner m_taskTreeRunner; std::unordered_map<IDocument *, std::unique_ptr<TaskTree>> m_docMarksTrees; TaskTreeRunner m_issueInfoRunner; + FileInProjectFinder m_fileFinder; // FIXME maybe obsolete when path mapping is implemented }; static AxivionPluginPrivate *dd = nullptr; @@ -337,10 +339,17 @@ void AxivionPluginPrivate::onStartupProjectChanged(Project *project) m_currentProjectInfo = {}; updateDashboard(); - if (!m_project) + if (!m_project) { + m_fileFinder.setProjectDirectory({}); + m_fileFinder.setProjectFiles({}); return; + } - connect(m_project, &Project::fileListChanged, this, &AxivionPluginPrivate::handleOpenedDocs); + m_fileFinder.setProjectDirectory(m_project->projectDirectory()); + connect(m_project, &Project::fileListChanged, this, [this]{ + m_fileFinder.setProjectFiles(m_project->files(Project::AllFiles)); + handleOpenedDocs(); + }); const AxivionProjectSettings *projSettings = AxivionProjectSettings::projectSettings(m_project); fetchProjectInfo(projSettings->dashboardProjectName()); } @@ -961,7 +970,7 @@ void AxivionPluginPrivate::handleAnchorClicked(const QUrl &url) return; Link link; if (const QString path = query.queryItemValue("filename", QUrl::FullyDecoded); !path.isEmpty()) - link.targetFilePath = m_project->projectDirectory().pathAppended(path); + link.targetFilePath = findFileForIssuePath(FilePath::fromUserInput(path)); if (const QString line = query.queryItemValue("line"); !line.isEmpty()) link.targetLine = line.toInt(); // column entry is wrong - so, ignore it @@ -1040,6 +1049,15 @@ const std::optional<DashboardInfo> currentDashboardInfo() return dd->m_dashboardInfo; } +Utils::FilePath findFileForIssuePath(const Utils::FilePath &issuePath) +{ + QTC_ASSERT(dd, return {}); + const FilePaths result = dd->m_fileFinder.findFile(QUrl::fromLocalFile(issuePath.toString())); + if (result.size() == 1) + return dd->m_project->projectDirectory().resolvePath(result.first()); + return {}; +} + } // Axivion::Internal #include "axivionplugin.moc" diff --git a/src/plugins/axivion/axivionplugin.h b/src/plugins/axivion/axivionplugin.h index db2f8494cb..059e950ecc 100644 --- a/src/plugins/axivion/axivionplugin.h +++ b/src/plugins/axivion/axivionplugin.h @@ -79,5 +79,7 @@ void fetchIssueInfo(const QString &id); const std::optional<DashboardInfo> currentDashboardInfo(); +Utils::FilePath findFileForIssuePath(const Utils::FilePath &issuePath); + } // Axivion::Internal |