forked from qt-creator/qt-creator
Rename LineColumnLabel
It is not only used for line and column. Change-Id: I544244dbca0b9f084e45ff2d7e4f28f79d2cae09 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -23,55 +23,57 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "linecolumnlabel.h"
|
||||
#include "fixedsizeclicklabel.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
/*!
|
||||
\class Utils::LineColumnLabel
|
||||
\class Utils::FixedSizeClickLabel
|
||||
|
||||
\brief The LineColumnLabel class is a label suitable for displaying cursor
|
||||
positions, and so on, with a fixed
|
||||
width derived from a sample text.
|
||||
\brief The FixedSizeClickLabel class is a label with a size hint derived from a sample text
|
||||
that can be different to the text that is shown.
|
||||
|
||||
For convenience it also has a clicked signal that is emitted whenever the label receives a mouse
|
||||
click.
|
||||
*/
|
||||
|
||||
namespace Utils {
|
||||
|
||||
LineColumnLabel::LineColumnLabel(QWidget *parent)
|
||||
FixedSizeClickLabel::FixedSizeClickLabel(QWidget *parent)
|
||||
: QLabel(parent)
|
||||
, m_pressed(false)
|
||||
{
|
||||
}
|
||||
|
||||
void LineColumnLabel::setText(const QString &text, const QString &maxText)
|
||||
void FixedSizeClickLabel::setText(const QString &text, const QString &maxText)
|
||||
{
|
||||
QLabel::setText(text);
|
||||
m_maxText = maxText;
|
||||
}
|
||||
|
||||
QSize LineColumnLabel::sizeHint() const
|
||||
QSize FixedSizeClickLabel::sizeHint() const
|
||||
{
|
||||
return fontMetrics().boundingRect(m_maxText).size();
|
||||
}
|
||||
|
||||
QString LineColumnLabel::maxText() const
|
||||
QString FixedSizeClickLabel::maxText() const
|
||||
{
|
||||
return m_maxText;
|
||||
}
|
||||
|
||||
void LineColumnLabel::setMaxText(const QString &maxText)
|
||||
void FixedSizeClickLabel::setMaxText(const QString &maxText)
|
||||
{
|
||||
m_maxText = maxText;
|
||||
}
|
||||
|
||||
void LineColumnLabel::mousePressEvent(QMouseEvent *ev)
|
||||
void FixedSizeClickLabel::mousePressEvent(QMouseEvent *ev)
|
||||
{
|
||||
QLabel::mousePressEvent(ev);
|
||||
if (ev->button() == Qt::LeftButton)
|
||||
m_pressed = true;
|
||||
}
|
||||
|
||||
void LineColumnLabel::mouseReleaseEvent(QMouseEvent *ev)
|
||||
void FixedSizeClickLabel::mouseReleaseEvent(QMouseEvent *ev)
|
||||
{
|
||||
QLabel::mouseReleaseEvent(ev);
|
||||
if (ev->button() != Qt::LeftButton)
|
@@ -30,13 +30,13 @@
|
||||
|
||||
namespace Utils {
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT LineColumnLabel : public QLabel
|
||||
class QTCREATOR_UTILS_EXPORT FixedSizeClickLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString maxText READ maxText WRITE setMaxText DESIGNABLE true)
|
||||
|
||||
public:
|
||||
explicit LineColumnLabel(QWidget *parent = 0);
|
||||
explicit FixedSizeClickLabel(QWidget *parent = 0);
|
||||
|
||||
void setText(const QString &text, const QString &maxText);
|
||||
QSize sizeHint() const;
|
@@ -50,7 +50,6 @@ SOURCES += \
|
||||
$$PWD/codegeneration.cpp \
|
||||
$$PWD/newclasswidget.cpp \
|
||||
$$PWD/classnamevalidatinglineedit.cpp \
|
||||
$$PWD/linecolumnlabel.cpp \
|
||||
$$PWD/fancylineedit.cpp \
|
||||
$$PWD/qtcolorbutton.cpp \
|
||||
$$PWD/savedaction.cpp \
|
||||
@@ -120,7 +119,8 @@ SOURCES += \
|
||||
$$PWD/fuzzymatcher.cpp \
|
||||
$$PWD/textutils.cpp \
|
||||
$$PWD/url.cpp \
|
||||
$$PWD/filecrumblabel.cpp
|
||||
$$PWD/filecrumblabel.cpp \
|
||||
$$PWD/fixedsizeclicklabel.cpp
|
||||
|
||||
win32:SOURCES += $$PWD/consoleprocess_win.cpp
|
||||
else:SOURCES += $$PWD/consoleprocess_unix.cpp
|
||||
@@ -156,7 +156,6 @@ HEADERS += \
|
||||
$$PWD/codegeneration.h \
|
||||
$$PWD/newclasswidget.h \
|
||||
$$PWD/classnamevalidatinglineedit.h \
|
||||
$$PWD/linecolumnlabel.h \
|
||||
$$PWD/fancylineedit.h \
|
||||
$$PWD/qtcolorbutton.h \
|
||||
$$PWD/savedaction.h \
|
||||
@@ -256,7 +255,8 @@ HEADERS += \
|
||||
$$PWD/url.h \
|
||||
$$PWD/filecrumblabel.h \
|
||||
$$PWD/linecolumn.h \
|
||||
$$PWD/link.h
|
||||
$$PWD/link.h \
|
||||
$$PWD/fixedsizeclicklabel.h
|
||||
|
||||
FORMS += $$PWD/filewizardpage.ui \
|
||||
$$PWD/projectintropage.ui \
|
||||
|
@@ -114,6 +114,8 @@ Project {
|
||||
"filewizardpage.cpp",
|
||||
"filewizardpage.h",
|
||||
"filewizardpage.ui",
|
||||
"fixedsizeclicklabel.cpp",
|
||||
"fixedsizeclicklabel.h",
|
||||
"flowlayout.cpp",
|
||||
"flowlayout.h",
|
||||
"functiontraits.h",
|
||||
@@ -136,8 +138,6 @@ Project {
|
||||
"json.cpp",
|
||||
"json.h",
|
||||
"linecolumn.h",
|
||||
"linecolumnlabel.cpp",
|
||||
"linecolumnlabel.h",
|
||||
"link.h",
|
||||
"listutils.h",
|
||||
"macroexpander.cpp",
|
||||
|
@@ -77,7 +77,7 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/asconst.h>
|
||||
#include <utils/textutils.h>
|
||||
#include <utils/linecolumnlabel.h>
|
||||
#include <utils/fixedsizeclicklabel.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/dropsupport.h>
|
||||
#include <utils/fadingindicator.h>
|
||||
@@ -566,8 +566,8 @@ public:
|
||||
TextEditorWidget *q;
|
||||
QToolBar *m_toolBar = nullptr;
|
||||
QWidget *m_stretchWidget = nullptr;
|
||||
LineColumnLabel *m_cursorPositionLabel = nullptr;
|
||||
LineColumnLabel *m_fileEncodingLabel = nullptr;
|
||||
FixedSizeClickLabel *m_cursorPositionLabel = nullptr;
|
||||
FixedSizeClickLabel *m_fileEncodingLabel = nullptr;
|
||||
QAction *m_cursorPositionLabelAction = nullptr;
|
||||
QAction *m_fileEncodingLabelAction = nullptr;
|
||||
|
||||
@@ -760,11 +760,11 @@ TextEditorWidgetPrivate::TextEditorWidgetPrivate(TextEditorWidget *parent)
|
||||
m_toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
||||
m_toolBar->addWidget(m_stretchWidget);
|
||||
|
||||
m_cursorPositionLabel = new LineColumnLabel;
|
||||
m_cursorPositionLabel = new FixedSizeClickLabel;
|
||||
const int spacing = q->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2;
|
||||
m_cursorPositionLabel->setContentsMargins(spacing, 0, spacing, 0);
|
||||
|
||||
m_fileEncodingLabel = new LineColumnLabel;
|
||||
m_fileEncodingLabel = new FixedSizeClickLabel;
|
||||
m_fileEncodingLabel->setContentsMargins(spacing, 0, spacing, 0);
|
||||
|
||||
m_cursorPositionLabelAction = m_toolBar->addWidget(m_cursorPositionLabel);
|
||||
@@ -957,7 +957,7 @@ void TextEditorWidgetPrivate::ctor(const QSharedPointer<TextDocument> &doc)
|
||||
q, &TextEditorWidget::aboutToOpen);
|
||||
QObject::connect(m_document.data(), &TextDocument::openFinishedSuccessfully,
|
||||
q, &TextEditorWidget::openFinishedSuccessfully);
|
||||
connect(m_fileEncodingLabel, &LineColumnLabel::clicked,
|
||||
connect(m_fileEncodingLabel, &FixedSizeClickLabel::clicked,
|
||||
q, &TextEditorWidget::selectEncoding);
|
||||
connect(m_document->document(), &QTextDocument::modificationChanged,
|
||||
q, &TextEditorWidget::updateTextCodecLabel);
|
||||
@@ -8601,7 +8601,7 @@ BaseTextEditor *TextEditorFactoryPrivate::createEditorHelper(const TextDocumentP
|
||||
widget->finalizeInitialization();
|
||||
editor->finalizeInitialization();
|
||||
|
||||
QObject::connect(widget->d->m_cursorPositionLabel, &LineColumnLabel::clicked, [editor] {
|
||||
QObject::connect(widget->d->m_cursorPositionLabel, &FixedSizeClickLabel::clicked, [editor] {
|
||||
EditorManager::activateEditor(editor, EditorManager::IgnoreNavigationHistory);
|
||||
if (Command *cmd = ActionManager::command(Core::Constants::GOTO)) {
|
||||
if (QAction *act = cmd->action())
|
||||
|
Reference in New Issue
Block a user