forked from qt-creator/qt-creator
Utils: Use Utils::Link instead of TaskView::Location
Same layout, effectively the same purpose Change-Id: I742d85ed06c07009ebb9696734f00894275859a3 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "algorithm.h"
|
||||
#include "ansiescapecodehandler.h"
|
||||
#include "fileinprojectfinder.h"
|
||||
#include "link.h"
|
||||
#include "qtcassert.h"
|
||||
#include "qtcprocess.h"
|
||||
#include "theme/theme.h"
|
||||
@@ -72,15 +73,14 @@ bool OutputLineParser::isLinkTarget(const QString &target)
|
||||
return target.startsWith(*linkPrefix());
|
||||
}
|
||||
|
||||
void OutputLineParser::parseLinkTarget(const QString &target, FilePath &filePath, int &line,
|
||||
int &column)
|
||||
Link OutputLineParser::parseLinkTarget(const QString &target)
|
||||
{
|
||||
const QStringList parts = target.mid(linkPrefix()->length()).split(*linkSep());
|
||||
if (parts.isEmpty())
|
||||
return;
|
||||
filePath = FilePath::fromString(parts.first());
|
||||
line = parts.length() > 1 ? parts.at(1).toInt() : 0;
|
||||
column = parts.length() > 2 ? parts.at(2).toInt() : 0;
|
||||
return {};
|
||||
return Link(FilePath::fromString(parts.first()),
|
||||
parts.length() > 1 ? parts.at(1).toInt() : 0,
|
||||
parts.length() > 2 ? parts.at(2).toInt() : 0);
|
||||
}
|
||||
|
||||
// The redirection mechanism is needed for broken build tools (e.g. xcodebuild) that get invoked
|
||||
@@ -528,12 +528,10 @@ bool OutputFormatter::handleFileLink(const QString &href)
|
||||
{
|
||||
if (!OutputLineParser::isLinkTarget(href))
|
||||
return false;
|
||||
FilePath filePath;
|
||||
int line;
|
||||
int column;
|
||||
OutputLineParser::parseLinkTarget(href, filePath, line, column);
|
||||
QTC_ASSERT(!filePath.isEmpty(), return false);
|
||||
emit openInEditorRequested(filePath, line, column);
|
||||
|
||||
Link link = OutputLineParser::parseLinkTarget(href);
|
||||
QTC_ASSERT(!link.targetFilePath.isEmpty(), return false);
|
||||
emit openInEditorRequested(link);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -44,6 +44,7 @@ QT_END_NAMESPACE
|
||||
namespace Utils {
|
||||
class FileInProjectFinder;
|
||||
class FormattedText;
|
||||
class Link;
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT OutputLineParser : public QObject
|
||||
{
|
||||
@@ -72,7 +73,7 @@ public:
|
||||
};
|
||||
|
||||
static bool isLinkTarget(const QString &target);
|
||||
static void parseLinkTarget(const QString &target, FilePath &filePath, int &line, int &column);
|
||||
static Utils::Link parseLinkTarget(const QString &target);
|
||||
|
||||
void addSearchDir(const Utils::FilePath &dir);
|
||||
void dropSearchDir(const Utils::FilePath &dir);
|
||||
@@ -172,7 +173,7 @@ private:
|
||||
static QTextCharFormat linkFormat(const QTextCharFormat &inputFormat, const QString &href);
|
||||
|
||||
signals:
|
||||
void openInEditorRequested(const FilePath &filePath, int line, int column);
|
||||
void openInEditorRequested(const Utils::Link &link);
|
||||
|
||||
private:
|
||||
void doAppendMessage(const QString &text, OutputFormat format);
|
||||
|
@@ -148,9 +148,8 @@ OutputWindow::OutputWindow(Context context, const QString &settingsKey, QWidget
|
||||
Core::ICore::settings()->setValueWithDefault(d->settingsKey, fontZoom(), 0.f);
|
||||
});
|
||||
|
||||
connect(outputFormatter(), &OutputFormatter::openInEditorRequested, this,
|
||||
[](const Utils::FilePath &fp, int line, int column) {
|
||||
EditorManager::openEditorAt(fp.toString(), line, column);
|
||||
connect(outputFormatter(), &OutputFormatter::openInEditorRequested, this, [](const Link &link) {
|
||||
EditorManager::openEditorAt(link);
|
||||
});
|
||||
|
||||
connect(verticalScrollBar(), &QAbstractSlider::actionTriggered,
|
||||
|
@@ -52,6 +52,8 @@
|
||||
#include <QToolButton>
|
||||
#include <QScrollBar>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace {
|
||||
const int ELLIPSIS_GRADIENT_WIDTH = 16;
|
||||
const char SESSION_FILTER_CATEGORIES[] = "TaskWindow.Categories";
|
||||
@@ -86,13 +88,7 @@ private:
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
|
||||
class Location {
|
||||
public:
|
||||
Utils::FilePath file;
|
||||
int line;
|
||||
int column;
|
||||
};
|
||||
Location locationForPos(const QPoint &pos);
|
||||
Utils::Link locationForPos(const QPoint &pos);
|
||||
|
||||
bool m_linksActive = true;
|
||||
Qt::MouseButton m_mouseButtonPressed = Qt::NoButton;
|
||||
@@ -229,9 +225,9 @@ void TaskView::mousePressEvent(QMouseEvent *e)
|
||||
void TaskView::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
if (m_linksActive && m_mouseButtonPressed == Qt::LeftButton) {
|
||||
const Location loc = locationForPos(e->pos());
|
||||
if (!loc.file.isEmpty()) {
|
||||
Core::EditorManager::openEditorAt(loc.file.toString(), loc.line, loc.column, {},
|
||||
const Link loc = locationForPos(e->pos());
|
||||
if (!loc.targetFilePath.isEmpty()) {
|
||||
Core::EditorManager::openEditorAt(loc, {},
|
||||
Core::EditorManager::SwitchSplitIfAlreadyVisible);
|
||||
}
|
||||
}
|
||||
@@ -248,23 +244,20 @@ void TaskView::mouseMoveEvent(QMouseEvent *e)
|
||||
if (m_mouseButtonPressed != Qt::NoButton)
|
||||
m_linksActive = false;
|
||||
|
||||
viewport()->setCursor(m_linksActive && !locationForPos(e->pos()).file.isEmpty()
|
||||
viewport()->setCursor(m_linksActive && !locationForPos(e->pos()).targetFilePath.isEmpty()
|
||||
? Qt::PointingHandCursor : Qt::ArrowCursor);
|
||||
ListView::mouseMoveEvent(e);
|
||||
}
|
||||
|
||||
TaskView::Location TaskView::locationForPos(const QPoint &pos)
|
||||
Link TaskView::locationForPos(const QPoint &pos)
|
||||
{
|
||||
const auto delegate = qobject_cast<TaskDelegate *>(itemDelegate(indexAt(pos)));
|
||||
if (!delegate)
|
||||
return {};
|
||||
Utils::OutputFormatter formatter;
|
||||
Location loc;
|
||||
connect(&formatter, &Utils::OutputFormatter::openInEditorRequested, this,
|
||||
[&loc](const Utils::FilePath &fp, int line, int column) {
|
||||
loc.file = fp;
|
||||
loc.line = line;
|
||||
loc.column = column;
|
||||
OutputFormatter formatter;
|
||||
Link loc;
|
||||
connect(&formatter, &OutputFormatter::openInEditorRequested, this, [&loc](const Link &link) {
|
||||
loc = link;
|
||||
});
|
||||
|
||||
const QString href = delegate->hrefForPos(pos);
|
||||
|
Reference in New Issue
Block a user