diff options
author | Lorenz Haas <[email protected]> | 2013-04-15 18:19:34 +0200 |
---|---|---|
committer | David Schulz <[email protected]> | 2013-04-18 11:23:23 +0200 |
commit | e89c30feb81941d4d0995a76f3f6edca59ccf9a1 (patch) | |
tree | 1ae5000fd28bb51b6ad47c348aefd457fc3bcc60 /src/libs/utils/linecolumnlabel.cpp | |
parent | ad0331a2a9bf32bcfbb2cd6d1eec2d277cdd90d4 (diff) |
BaseEditor: Open locator "l <line:column>" on toolbar line widget click
Task-number: QTCREATORBUG-8811
Change-Id: Ia3ece9efb7e2c6d227ab3395aca636a27f667f0d
Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/libs/utils/linecolumnlabel.cpp')
-rw-r--r-- | src/libs/utils/linecolumnlabel.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/libs/utils/linecolumnlabel.cpp b/src/libs/utils/linecolumnlabel.cpp index 85f6e307666..cb0eb66146f 100644 --- a/src/libs/utils/linecolumnlabel.cpp +++ b/src/libs/utils/linecolumnlabel.cpp @@ -29,6 +29,8 @@ #include "linecolumnlabel.h" +#include <QMouseEvent> + /*! \class Utils::LineColumnLabel @@ -39,7 +41,8 @@ namespace Utils { 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); m_maxText = maxText; } + QSize LineColumnLabel::sizeHint() const { return fontMetrics().boundingRect(m_maxText).size(); @@ -60,7 +64,24 @@ QString LineColumnLabel::maxText() const 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 |