diff options
Diffstat (limited to 'src/widgets/widgets/qabstractspinbox.cpp')
-rw-r--r-- | src/widgets/widgets/qabstractspinbox.cpp | 209 |
1 files changed, 89 insertions, 120 deletions
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index b1e1c9bc1b..f377275d23 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <qplatformdefs.h> #include <private/qabstractspinbox_p.h> @@ -58,10 +22,11 @@ #include <qpalette.h> #include <qstylepainter.h> #include <qdebug.h> -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) # include <qaccessible.h> #endif +#include <QtCore/qpointer.h> //#define QABSTRACTSPINBOX_QSBDEBUG #ifdef QABSTRACTSPINBOX_QSBDEBUG @@ -72,6 +37,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! \class QAbstractSpinBox \brief The QAbstractSpinBox class provides a spinbox and a line edit to @@ -420,7 +387,7 @@ bool QAbstractSpinBox::isAccelerated() const \since 5.3 - This property holds whether a thousands separator is enabled. By default this + \brief whether a thousands separator is enabled. By default this property is false. */ bool QAbstractSpinBox::isGroupSeparatorShown() const @@ -570,7 +537,7 @@ void QAbstractSpinBox::clear() QAbstractSpinBox::StepEnabled QAbstractSpinBox::stepEnabled() const { Q_D(const QAbstractSpinBox); - if (d->readOnly || d->type == QVariant::Invalid) + if (d->readOnly || d->type == QMetaType::UnknownType) return StepNone; if (d->wrapping) return StepEnabled(StepUpEnabled | StepDownEnabled); @@ -671,7 +638,8 @@ void QAbstractSpinBox::stepBy(int steps) } else if (e == AlwaysEmit) { d->emitSignals(e, old); } - selectAll(); + if (style()->styleHint(QStyle::SH_SpinBox_SelectOnStep, nullptr, this, nullptr)) + selectAll(); } /*! @@ -723,15 +691,15 @@ void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit) d->edit->setFocusProxy(this); d->edit->setAcceptDrops(false); - if (d->type != QVariant::Invalid) { - 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())); + if (d->type != QMetaType::UnknownType) { + 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); @@ -795,7 +763,7 @@ bool QAbstractSpinBox::event(QEvent *event) case QEvent::HoverEnter: case QEvent::HoverLeave: case QEvent::HoverMove: - d->updateHoverControl(static_cast<const QHoverEvent *>(event)->pos()); + d->updateHoverControl(static_cast<const QHoverEvent *>(event)->position().toPoint()); break; case QEvent::ShortcutOverride: if (d->edit->event(event)) @@ -848,9 +816,9 @@ void QAbstractSpinBox::changeEvent(QEvent *event) switch (event->type()) { case QEvent::StyleChange: - d->spinClickTimerInterval = style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, 0, this); + d->spinClickTimerInterval = style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, nullptr, this); d->spinClickThresholdTimerInterval = - style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, 0, this); + style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, nullptr, this); if (d->edit) d->edit->setFrame(!style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this)); d->stepModifier = static_cast<Qt::KeyboardModifier>(style()->styleHint(QStyle::SH_SpinBox_StepModifier, nullptr, this)); @@ -905,7 +873,7 @@ QSize QAbstractSpinBox::sizeHint() const int h = d->edit->sizeHint().height(); int w = 0; QString s; - QString fixedContent = d->prefix + d->suffix + QLatin1Char(' '); + QString fixedContent = d->prefix + d->suffix + u' '; s = d->textFromValue(d->minimum); s.truncate(18); s += fixedContent; @@ -924,8 +892,7 @@ QSize QAbstractSpinBox::sizeHint() const QStyleOptionSpinBox opt; initStyleOption(&opt); QSize hint(w, h); - d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this) - .expandedTo(QApplication::globalStrut()); + d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this); } return d->cachedSizeHint; } @@ -946,7 +913,7 @@ QSize QAbstractSpinBox::minimumSizeHint() const int w = 0; QString s; - QString fixedContent = d->prefix + QLatin1Char(' '); + QString fixedContent = d->prefix + u' '; s = d->textFromValue(d->minimum); s.truncate(18); s += fixedContent; @@ -966,8 +933,7 @@ QSize QAbstractSpinBox::minimumSizeHint() const initStyleOption(&opt); QSize hint(w, h); - d->cachedMinimumSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this) - .expandedTo(QApplication::globalStrut()); + d->cachedMinimumSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this); } return d->cachedMinimumSizeHint; } @@ -1012,6 +978,8 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event) { Q_D(QAbstractSpinBox); + d->keyboardModifiers = event->modifiers(); + if (!event->text().isEmpty() && d->edit->cursorPosition() < d->prefix.size()) d->edit->setCursorPosition(d->prefix.size()); @@ -1043,17 +1011,17 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event) steps *= 10; if (!up) steps *= -1; - if (style()->styleHint(QStyle::SH_SpinBox_AnimateButton, 0, this)) { + if (style()->styleHint(QStyle::SH_SpinBox_AnimateButton, nullptr, this)) { d->buttonState = (Keyboard | (up ? Up : Down)); } if (d->spinClickTimerId == -1) stepBy(steps); - if(event->isAutoRepeat() && !isPgUpOrDown) { - if(d->spinClickThresholdTimerId == -1 && d->spinClickTimerId == -1) { + if (event->isAutoRepeat() && !isPgUpOrDown) { + if (d->spinClickThresholdTimerId == -1 && d->spinClickTimerId == -1) { d->updateState(up, true); } } -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleValueChangeEvent event(this, d->value); QAccessible::updateAccessibility(&event); #endif @@ -1095,7 +1063,7 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event) case Qt::Key_U: if (event->modifiers() & Qt::ControlModifier - && QGuiApplication::platformName() == QLatin1String("xcb")) { // only X11 + && QGuiApplication::platformName() == "xcb"_L1) { // only X11 event->accept(); if (!isReadOnly()) clear(); @@ -1152,6 +1120,7 @@ void QAbstractSpinBox::keyReleaseEvent(QKeyEvent *event) { Q_D(QAbstractSpinBox); + d->keyboardModifiers = event->modifiers(); if (d->buttonState & Keyboard && !event->isAutoRepeat()) { d->reset(); } else { @@ -1268,7 +1237,7 @@ void QAbstractSpinBox::timerEvent(QTimerEvent *event) killTimer(d->spinClickThresholdTimerId); d->spinClickThresholdTimerId = -1; d->effectiveSpinRepeatRate = d->buttonState & Keyboard - ? QGuiApplication::styleHints()->keyboardAutoRepeatRate() + ? QGuiApplication::styleHints()->keyboardAutoRepeatRateF() : d->spinClickTimerInterval; d->spinClickTimerId = startTimer(d->effectiveSpinRepeatRate); doStep = true; @@ -1284,7 +1253,7 @@ void QAbstractSpinBox::timerEvent(QTimerEvent *event) } if (doStep) { - const bool increaseStepRate = QGuiApplication::keyboardModifiers() & d->stepModifier; + const bool increaseStepRate = d->keyboardModifiers & d->stepModifier; const StepEnabled st = stepEnabled(); if (d->buttonState & Up) { if (!(st & StepUpEnabled)) { @@ -1361,7 +1330,8 @@ void QAbstractSpinBox::mouseMoveEvent(QMouseEvent *event) { Q_D(QAbstractSpinBox); - d->updateHoverControl(event->pos()); + d->keyboardModifiers = event->modifiers(); + d->updateHoverControl(event->position().toPoint()); // If we have a timer ID, update the state if (d->spinClickTimerId != -1 && d->buttonSymbols != NoButtons) { @@ -1384,11 +1354,12 @@ void QAbstractSpinBox::mousePressEvent(QMouseEvent *event) { Q_D(QAbstractSpinBox); + d->keyboardModifiers = event->modifiers(); if (event->button() != Qt::LeftButton || d->buttonState != None) { return; } - d->updateHoverControl(event->pos()); + d->updateHoverControl(event->position().toPoint()); event->accept(); const StepEnabled se = (d->buttonSymbols == NoButtons) ? StepEnabled(StepNone) : stepEnabled(); @@ -1408,6 +1379,7 @@ void QAbstractSpinBox::mouseReleaseEvent(QMouseEvent *event) { Q_D(QAbstractSpinBox); + d->keyboardModifiers = event->modifiers(); if ((d->buttonState & Mouse) != 0) d->reset(); event->accept(); @@ -1421,15 +1393,9 @@ void QAbstractSpinBox::mouseReleaseEvent(QMouseEvent *event) */ QAbstractSpinBoxPrivate::QAbstractSpinBoxPrivate() - : edit(0), type(QVariant::Invalid), spinClickTimerId(-1), - spinClickTimerInterval(100), spinClickThresholdTimerId(-1), spinClickThresholdTimerInterval(-1), - effectiveSpinRepeatRate(1), buttonState(None), cachedText(QLatin1String("\x01")), - cachedState(QValidator::Invalid), pendingEmit(false), readOnly(false), wrapping(false), - ignoreCursorPositionChanged(false), frame(true), accelerate(false), keyboardTracking(true), - cleared(false), ignoreUpdateEdit(false), correctionMode(QAbstractSpinBox::CorrectToPreviousValue), - stepModifier(Qt::ControlModifier), acceleration(0), hoverControl(QStyle::SC_None), - buttonSymbols(QAbstractSpinBox::UpDownArrows), validator(0), showGroupSeparator(0), - wheelDeltaRemainder(0) + : pendingEmit(false), readOnly(false), wrapping(false), + ignoreCursorPositionChanged(false), frame(true), accelerate(false), keyboardTracking(true), + cleared(false), ignoreUpdateEdit(false), showGroupSeparator(false) { } @@ -1484,7 +1450,7 @@ QStyle::SubControl QAbstractSpinBoxPrivate::newHoverControl(const QPoint &pos) QString QAbstractSpinBoxPrivate::stripped(const QString &t, int *pos) const { - QStringRef text(&t); + QStringView text(t); if (specialValueText.size() == 0 || text != specialValueText) { int from = 0; int size = text.size(); @@ -1545,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); @@ -1575,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; @@ -1626,11 +1592,13 @@ void QAbstractSpinBoxPrivate::init() Q_Q(QAbstractSpinBox); q->setLineEdit(new QLineEdit(q)); - edit->setObjectName(QLatin1String("qt_spinbox_lineedit")); + edit->setObjectName("qt_spinbox_lineedit"_L1); validator = new QSpinBoxValidator(q, this); edit->setValidator(validator); QStyleOptionSpinBox opt; + // ### This is called from the ctor and thus we shouldn't call initStyleOption yet + // ### as we only call the base class implementation of initStyleOption called. q->initStyleOption(&opt); spinClickTimerInterval = q->style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, &opt, q); spinClickThresholdTimerInterval = q->style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, &opt, q); @@ -1678,13 +1646,13 @@ void QAbstractSpinBoxPrivate::updateState(bool up, bool fromKeyboard /* = false reset(); if (q && (q->stepEnabled() & (up ? QAbstractSpinBox::StepUpEnabled : QAbstractSpinBox::StepDownEnabled))) { - spinClickThresholdTimerId = q->startTimer(spinClickThresholdTimerInterval); buttonState = (up ? Up : Down) | (fromKeyboard ? Keyboard : Mouse); int steps = up ? 1 : -1; - if (QGuiApplication::keyboardModifiers() & stepModifier) + if (keyboardModifiers & stepModifier) steps *= 10; q->stepBy(steps); -#ifndef QT_NO_ACCESSIBILITY + spinClickThresholdTimerId = q->startTimer(spinClickThresholdTimerInterval); +#if QT_CONFIG(accessibility) QAccessibleValueChangeEvent event(q, value); QAccessible::updateAccessibility(&event); #endif @@ -1805,7 +1773,7 @@ void QAbstractSpinBoxPrivate::setValue(const QVariant &val, EmitPolicy ep, void QAbstractSpinBoxPrivate::updateEdit() { Q_Q(QAbstractSpinBox); - if (type == QVariant::Invalid) + if (type == QMetaType::UnknownType) return; const QString newText = specialValue() ? specialValueText : prefix + textFromValue(value) + suffix; if (newText == edit->displayText() || cleared) @@ -1865,8 +1833,8 @@ QVariant QAbstractSpinBoxPrivate::getZeroVariant() const { QVariant ret; switch (type) { - case QVariant::Int: ret = QVariant((int)0); break; - case QVariant::Double: ret = QVariant((double)0.0); break; + case QMetaType::Int: ret = QVariant(0); break; + case QMetaType::Double: ret = QVariant(0.0); break; default: break; } return ret; @@ -1913,7 +1881,7 @@ QVariant QAbstractSpinBoxPrivate::valueFromText(const QString &) const void QAbstractSpinBoxPrivate::interpret(EmitPolicy ep) { Q_Q(QAbstractSpinBox); - if (type == QVariant::Invalid || cleared) + if (type == QMetaType::UnknownType || cleared) return; QVariant v = getZeroVariant(); @@ -1954,7 +1922,7 @@ void QAbstractSpinBoxPrivate::clearCache() const QVariant QAbstractSpinBoxPrivate::calculateAdaptiveDecimalStep(int steps) const { - Q_UNUSED(steps) + Q_UNUSED(steps); return singleStep; } @@ -1968,7 +1936,7 @@ QVariant QAbstractSpinBoxPrivate::calculateAdaptiveDecimalStep(int steps) const QSpinBoxValidator::QSpinBoxValidator(QAbstractSpinBox *qp, QAbstractSpinBoxPrivate *dp) : QValidator(qp), qptr(qp), dptr(dp) { - setObjectName(QLatin1String("qt_spinboxvalidator")); + setObjectName("qt_spinboxvalidator"_L1); } /*! @@ -1985,7 +1953,7 @@ QValidator::State QSpinBoxValidator::validate(QString &input, int &pos) const if (!dptr->prefix.isEmpty() && !input.startsWith(dptr->prefix)) { input.prepend(dptr->prefix); - pos += dptr->prefix.length(); + pos += dptr->prefix.size(); } if (!dptr->suffix.isEmpty() && !input.endsWith(dptr->suffix)) @@ -2013,11 +1981,11 @@ void QSpinBoxValidator::fixup(QString &input) const QVariant operator+(const QVariant &arg1, const QVariant &arg2) { QVariant ret; - if (Q_UNLIKELY(arg1.type() != arg2.type())) + if (Q_UNLIKELY(arg1.userType() != arg2.userType())) qWarning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)", arg1.typeName(), arg2.typeName(), __FILE__, __LINE__); - switch (arg1.type()) { - case QVariant::Int: { + switch (arg1.userType()) { + case QMetaType::Int: { const int int1 = arg1.toInt(); const int int2 = arg2.toInt(); if (int1 > 0 && (int2 >= INT_MAX - int1)) { @@ -2031,9 +1999,9 @@ QVariant operator+(const QVariant &arg1, const QVariant &arg2) } break; } - case QVariant::Double: ret = QVariant(arg1.toDouble() + arg2.toDouble()); break; + case QMetaType::Double: ret = QVariant(arg1.toDouble() + arg2.toDouble()); break; #if QT_CONFIG(datetimeparser) - case QVariant::DateTime: { + case QMetaType::QDateTime: { QDateTime a2 = arg2.toDateTime(); QDateTime a1 = arg1.toDateTime().addDays(QDATETIMEEDIT_DATE_MIN.daysTo(a2.date())); a1.setTime(a1.time().addMSecs(a2.time().msecsSinceStartOfDay())); @@ -2055,13 +2023,13 @@ QVariant operator+(const QVariant &arg1, const QVariant &arg2) QVariant operator-(const QVariant &arg1, const QVariant &arg2) { QVariant ret; - if (Q_UNLIKELY(arg1.type() != arg2.type())) + if (Q_UNLIKELY(arg1.userType() != arg2.userType())) qWarning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)", arg1.typeName(), arg2.typeName(), __FILE__, __LINE__); - switch (arg1.type()) { - case QVariant::Int: ret = QVariant(arg1.toInt() - arg2.toInt()); break; - case QVariant::Double: ret = QVariant(arg1.toDouble() - arg2.toDouble()); break; - case QVariant::DateTime: { + switch (arg1.userType()) { + case QMetaType::Int: ret = QVariant(arg1.toInt() - arg2.toInt()); break; + case QMetaType::Double: ret = QVariant(arg1.toDouble() - arg2.toDouble()); break; + case QMetaType::QDateTime: { QDateTime a1 = arg1.toDateTime(); QDateTime a2 = arg2.toDateTime(); int days = a2.daysTo(a1); @@ -2075,6 +2043,7 @@ QVariant operator-(const QVariant &arg1, const QVariant &arg2) dt.setTime(dt.time().addMSecs(msecs)); ret = QVariant(dt); } + break; } default: break; } @@ -2090,13 +2059,13 @@ QVariant operator*(const QVariant &arg1, double multiplier) { QVariant ret; - switch (arg1.type()) { - case QVariant::Int: + switch (arg1.userType()) { + case QMetaType::Int: ret = static_cast<int>(qBound<double>(INT_MIN, arg1.toInt() * multiplier, INT_MAX)); break; - case QVariant::Double: ret = QVariant(arg1.toDouble() * multiplier); break; + case QMetaType::Double: ret = QVariant(arg1.toDouble() * multiplier); break; #if QT_CONFIG(datetimeparser) - case QVariant::DateTime: { + case QMetaType::QDateTime: { double days = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDateTime().date()) * multiplier; const qint64 daysInt = qint64(days); days -= daysInt; @@ -2119,17 +2088,17 @@ double operator/(const QVariant &arg1, const QVariant &arg2) double a1 = 0; double a2 = 0; - switch (arg1.type()) { - case QVariant::Int: + switch (arg1.userType()) { + case QMetaType::Int: a1 = (double)arg1.toInt(); a2 = (double)arg2.toInt(); break; - case QVariant::Double: + case QMetaType::Double: a1 = arg1.toDouble(); a2 = arg2.toDouble(); break; #if QT_CONFIG(datetimeparser) - case QVariant::DateTime: + case QMetaType::QDateTime: a1 = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDate()); a2 = QDATETIMEEDIT_DATE_MIN.daysTo(arg2.toDate()); a1 += arg1.toDateTime().time().msecsSinceStartOfDay() / (36e5 * 24); @@ -2144,9 +2113,9 @@ double operator/(const QVariant &arg1, const QVariant &arg2) int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant &arg2) { - switch (arg2.type()) { - case QVariant::Date: - Q_ASSERT_X(arg1.type() == QVariant::Date, "QAbstractSpinBoxPrivate::variantCompare", + switch (arg2.userType()) { + case QMetaType::QDate: + Q_ASSERT_X(arg1.userType() == QMetaType::QDate, "QAbstractSpinBoxPrivate::variantCompare", qPrintable(QString::fromLatin1("Internal error 1 (%1)"). arg(QString::fromLatin1(arg1.typeName())))); if (arg1.toDate() == arg2.toDate()) { @@ -2156,8 +2125,8 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant } else { return 1; } - case QVariant::Time: - Q_ASSERT_X(arg1.type() == QVariant::Time, "QAbstractSpinBoxPrivate::variantCompare", + case QMetaType::QTime: + Q_ASSERT_X(arg1.userType() == QMetaType::QTime, "QAbstractSpinBoxPrivate::variantCompare", qPrintable(QString::fromLatin1("Internal error 2 (%1)"). arg(QString::fromLatin1(arg1.typeName())))); if (arg1.toTime() == arg2.toTime()) { @@ -2169,7 +2138,7 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant } - case QVariant::DateTime: + case QMetaType::QDateTime: if (arg1.toDateTime() == arg2.toDateTime()) { return 0; } else if (arg1.toDateTime() < arg2.toDateTime()) { @@ -2177,7 +2146,7 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant } else { return 1; } - case QVariant::Int: + case QMetaType::Int: if (arg1.toInt() == arg2.toInt()) { return 0; } else if (arg1.toInt() < arg2.toInt()) { @@ -2185,7 +2154,7 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant } else { return 1; } - case QVariant::Double: + case QMetaType::Double: if (arg1.toDouble() == arg2.toDouble()) { return 0; } else if (arg1.toDouble() < arg2.toDouble()) { @@ -2193,8 +2162,8 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant } else { return 1; } - case QVariant::Invalid: - if (arg2.type() == QVariant::Invalid) + case QMetaType::UnknownType: + if (arg2.userType() == QMetaType::UnknownType) return 0; Q_FALLTHROUGH(); default: |