VCS: Pass links to the correct VCS

Current implementation requires each VCS to connect to the referenceClicked
signal. Only Git does it, but this is conceptually wrong. If other VCSs
would connect to the same signal, all of them will act upon clicking a
link, which can result in multiple editors, most of them are likely to be
invalid anyway.

By default executes vcsDescribe. Can be extended or modified by subclasses.

Change-Id: Ib953009efd77446a4b2963f0aa8a2f3f3d26509f
Reviewed-by: Artur Shepilko <artur.shepilko@nomadbyte.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2020-06-18 00:04:17 +03:00
committed by Orgad Shaneh
parent cb0b8556c8
commit 92a4c0d38a
11 changed files with 70 additions and 37 deletions

View File

@@ -201,6 +201,13 @@ void IVersionControl::fillLinkContextMenu(QMenu *, const QString &, const QStrin
{
}
bool IVersionControl::handleLink(const QString &workingDirectory, const QString &reference)
{
QTC_ASSERT(!reference.isEmpty(), return false);
vcsDescribe(workingDirectory, reference);
return true;
}
} // namespace Core
#if defined(WITH_TESTS)

View File

@@ -237,6 +237,8 @@ public:
const QString &workingDirectory,
const QString &reference);
virtual bool handleLink(const QString &workingDirectory, const QString &reference);
class CORE_EXPORT RepoUrl {
public:
RepoUrl(const QString &location);

View File

@@ -183,13 +183,17 @@ void OutputWindow::mousePressEvent(QMouseEvent *e)
QPlainTextEdit::mousePressEvent(e);
}
void OutputWindow::handleLink(const QPoint &pos)
{
const QString href = anchorAt(pos);
if (!href.isEmpty())
d->formatter.handleLink(href);
}
void OutputWindow::mouseReleaseEvent(QMouseEvent *e)
{
if (d->linksActive && d->mouseButtonPressed == Qt::LeftButton) {
const QString href = anchorAt(e->pos());
if (!href.isEmpty())
d->formatter.handleLink(href);
}
if (d->linksActive && d->mouseButtonPressed == Qt::LeftButton)
handleLink(e->pos());
// Mouse was released, activate links again
d->linksActive = true;

View File

@@ -92,6 +92,7 @@ public slots:
protected:
bool isScrollbarAtBottom() const;
virtual void handleLink(const QPoint &pos);
private:
QMimeData *createMimeDataFromSelection() const override;