forked from qt-creator/qt-creator
BaseEditor: Open locator "l <line:column>" on toolbar line widget click
Task-number: QTCREATORBUG-8811 Change-Id: Ia3ece9efb7e2c6d227ab3395aca636a27f667f0d Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
committed by
David Schulz
parent
ad0331a2a9
commit
e89c30feb8
@@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include "linecolumnlabel.h"
|
#include "linecolumnlabel.h"
|
||||||
|
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Utils::LineColumnLabel
|
\class Utils::LineColumnLabel
|
||||||
|
|
||||||
@@ -39,7 +41,8 @@
|
|||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
LineColumnLabel::LineColumnLabel(QWidget *parent)
|
LineColumnLabel::LineColumnLabel(QWidget *parent)
|
||||||
: QLabel(parent), m_unused(0)
|
: QLabel(parent)
|
||||||
|
, m_pressed(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ void LineColumnLabel::setText(const QString &text, const QString &maxText)
|
|||||||
QLabel::setText(text);
|
QLabel::setText(text);
|
||||||
m_maxText = maxText;
|
m_maxText = maxText;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize LineColumnLabel::sizeHint() const
|
QSize LineColumnLabel::sizeHint() const
|
||||||
{
|
{
|
||||||
return fontMetrics().boundingRect(m_maxText).size();
|
return fontMetrics().boundingRect(m_maxText).size();
|
||||||
@@ -60,7 +64,24 @@ QString LineColumnLabel::maxText() const
|
|||||||
|
|
||||||
void LineColumnLabel::setMaxText(const QString &maxText)
|
void LineColumnLabel::setMaxText(const QString &maxText)
|
||||||
{
|
{
|
||||||
m_maxText = maxText;
|
m_maxText = maxText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineColumnLabel::mousePressEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
QLabel::mousePressEvent(ev);
|
||||||
|
if (ev->button() == Qt::LeftButton)
|
||||||
|
m_pressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineColumnLabel::mouseReleaseEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
QLabel::mouseReleaseEvent(ev);
|
||||||
|
if (ev->button() != Qt::LeftButton)
|
||||||
|
return;
|
||||||
|
if (m_pressed && rect().contains(ev->pos()))
|
||||||
|
emit clicked();
|
||||||
|
m_pressed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
@@ -49,9 +49,16 @@ public:
|
|||||||
QString maxText() const;
|
QString maxText() const;
|
||||||
void setMaxText(const QString &maxText);
|
void setMaxText(const QString &maxText);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent *ev);
|
||||||
|
void mouseReleaseEvent(QMouseEvent *ev);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_maxText;
|
QString m_maxText;
|
||||||
void *m_unused;
|
bool m_pressed;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
@@ -54,6 +54,7 @@
|
|||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/infobar.h>
|
#include <coreplugin/infobar.h>
|
||||||
#include <coreplugin/manhattanstyle.h>
|
#include <coreplugin/manhattanstyle.h>
|
||||||
#include <find/basetextfind.h>
|
#include <find/basetextfind.h>
|
||||||
@@ -6285,6 +6286,7 @@ BaseTextEditor::BaseTextEditor(BaseTextEditorWidget *editor)
|
|||||||
m_cursorPositionLabelAction = m_toolBar->addWidget(m_cursorPositionLabel);
|
m_cursorPositionLabelAction = m_toolBar->addWidget(m_cursorPositionLabel);
|
||||||
|
|
||||||
connect(editor, SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition()));
|
connect(editor, SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition()));
|
||||||
|
connect(m_cursorPositionLabel, SIGNAL(clicked()), this, SLOT(openGotoLocator()));
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextEditor::~BaseTextEditor()
|
BaseTextEditor::~BaseTextEditor()
|
||||||
@@ -6420,6 +6422,16 @@ void BaseTextEditor::updateCursorPosition()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseTextEditor::openGotoLocator()
|
||||||
|
{
|
||||||
|
Core::EditorManager::activateEditor(this, Core::EditorManager::IgnoreNavigationHistory);
|
||||||
|
if (Core::Command *cmd = Core::ActionManager::command(Core::Constants::GOTO)) {
|
||||||
|
if (QAction *act = cmd->action()) {
|
||||||
|
act->trigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString BaseTextEditor::contextHelpId() const
|
QString BaseTextEditor::contextHelpId() const
|
||||||
{
|
{
|
||||||
if (m_contextHelpId.isEmpty())
|
if (m_contextHelpId.isEmpty())
|
||||||
|
@@ -669,8 +669,10 @@ public:
|
|||||||
void setCursorPosition(int pos);
|
void setCursorPosition(int pos);
|
||||||
void select(int toPos);
|
void select(int toPos);
|
||||||
const Utils::CommentDefinition* commentDefinition() const;
|
const Utils::CommentDefinition* commentDefinition() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateCursorPosition();
|
void updateCursorPosition();
|
||||||
|
void openGotoLocator();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BaseTextEditorWidget *e;
|
BaseTextEditorWidget *e;
|
||||||
|
Reference in New Issue
Block a user