QAbstractSpinBox: use pmf-style connects

Use pmf-style connections instead old string-based ones.

Change-Id: Idab3a9d60e7cddcd2076476a21dbb1b5d2e4189c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2023-11-05 17:35:09 +01:00
parent 83e92e2557
commit e0b09e86d8
5 changed files with 16 additions and 19 deletions

View File

@ -692,14 +692,14 @@ void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit)
d->edit->setAcceptDrops(false);
if (d->type != QMetaType::UnknownType) {
connect(d->edit, SIGNAL(textChanged(QString)),
this, SLOT(_q_editorTextChanged(QString)));
connect(d->edit, SIGNAL(cursorPositionChanged(int,int)),
this, SLOT(_q_editorCursorPositionChanged(int,int)));
connect(d->edit, SIGNAL(cursorPositionChanged(int,int)),
this, SLOT(updateMicroFocus()));
connect(d->edit->d_func()->control, SIGNAL(updateMicroFocus()),
this, SLOT(updateMicroFocus()));
QObjectPrivate::connect(d->edit, &QLineEdit::textChanged,
d, &QAbstractSpinBoxPrivate::editorTextChanged);
QObjectPrivate::connect(d->edit, &QLineEdit::cursorPositionChanged,
d, &QAbstractSpinBoxPrivate::editorCursorPositionChanged);
connect(d->edit, &QLineEdit::cursorPositionChanged,
this, [this]() { updateMicroFocus(); });
connect(d->edit->d_func()->control, &QWidgetLineControl::updateMicroFocus,
this, [this]() { updateMicroFocus(); });
}
d->updateEditFieldGeometry();
d->edit->setContextMenuPolicy(Qt::NoContextMenu);
@ -1511,7 +1511,7 @@ void QAbstractSpinBoxPrivate::emitSignals(EmitPolicy, const QVariant &)
signal.
*/
void QAbstractSpinBoxPrivate::_q_editorTextChanged(const QString &t)
void QAbstractSpinBoxPrivate::editorTextChanged(const QString &t)
{
Q_Q(QAbstractSpinBox);
@ -1541,7 +1541,7 @@ void QAbstractSpinBoxPrivate::_q_editorTextChanged(const QString &t)
the different sections etc.
*/
void QAbstractSpinBoxPrivate::_q_editorCursorPositionChanged(int oldpos, int newpos)
void QAbstractSpinBoxPrivate::editorCursorPositionChanged(int oldpos, int newpos)
{
if (!edit->hasSelectedText() && !ignoreCursorPositionChanged && !specialValue()) {
ignoreCursorPositionChanged = true;

View File

@ -136,9 +136,6 @@ protected:
QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent = nullptr);
private:
Q_PRIVATE_SLOT(d_func(), void _q_editorTextChanged(const QString &))
Q_PRIVATE_SLOT(d_func(), void _q_editorCursorPositionChanged(int, int))
Q_DECLARE_PRIVATE(QAbstractSpinBox)
Q_DISABLE_COPY(QAbstractSpinBox)
friend class QAccessibleAbstractSpinBox;

View File

@ -74,8 +74,8 @@ public:
virtual QString textFromValue(const QVariant &n) const;
virtual QVariant valueFromText(const QString &input) const;
void _q_editorTextChanged(const QString &);
virtual void _q_editorCursorPositionChanged(int oldpos, int newpos);
void editorTextChanged(const QString &);
virtual void editorCursorPositionChanged(int oldpos, int newpos);
virtual QStyle::SubControl newHoverControl(const QPoint &pos);
bool updateHoverControl(const QPoint &pos);

View File

@ -948,7 +948,7 @@ void QDateTimeEdit::setDisplayFormat(const QString &format)
d->value = d->value.toDate().startOfDay(d->timeZone);
}
d->updateEdit();
d->_q_editorCursorPositionChanged(-1, 0);
d->editorCursorPositionChanged(-1, 0);
}
}
@ -2296,7 +2296,7 @@ void QDateTimeEditPrivate::emitSignals(EmitPolicy ep, const QVariant &old)
\internal
*/
void QDateTimeEditPrivate::_q_editorCursorPositionChanged(int oldpos, int newpos)
void QDateTimeEditPrivate::editorCursorPositionChanged(int oldpos, int newpos)
{
if (ignoreCursorPositionChanged || specialValue())
return;
@ -2354,7 +2354,7 @@ void QDateTimeEditPrivate::_q_editorCursorPositionChanged(int oldpos, int newpos
currentSectionIndex = s;
Q_ASSERT_X(currentSectionIndex < sectionNodes.size(),
"QDateTimeEditPrivate::_q_editorCursorPositionChanged()",
"QDateTimeEditPrivate::editorCursorPositionChanged()",
qPrintable(QString::fromLatin1("Internal error (%1 %2)").
arg(currentSectionIndex).
arg(sectionNodes.size())));

View File

@ -50,7 +50,7 @@ public:
void emitSignals(EmitPolicy ep, const QVariant &old) override;
QString textFromValue(const QVariant &f) const override;
QVariant valueFromText(const QString &f) const override;
void _q_editorCursorPositionChanged(int oldpos, int newpos) override;
void editorCursorPositionChanged(int oldpos, int newpos) override;
void interpret(EmitPolicy ep) override;
void clearCache() const override;
QStyle::SubControl newHoverControl(const QPoint &pos) override;