summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-07-02 18:37:26 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-07-07 06:29:07 +0200
commitd2e3f003676c703ebafb00bc7765070dffa65f1a (patch)
tree00a3b6244e7db9a0da83a7571a197a15aaa90878
parentbb5171fb54fb036e9d231c11e8fc7483978b623f (diff)
Clean up data members and initialization in QAbstractSpinBox
Group the bit flags together and generally order roughly by size to give the compiler better packing options. Change-Id: I9468d5aaef96e115ad363c59222e626d792a0edc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp12
-rw-r--r--src/widgets/widgets/qabstractspinbox_p.h39
2 files changed, 25 insertions, 26 deletions
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index bdda50603b..f87e4d1a2a 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -1425,15 +1425,9 @@ void QAbstractSpinBox::mouseReleaseEvent(QMouseEvent *event)
*/
QAbstractSpinBoxPrivate::QAbstractSpinBoxPrivate()
- : edit(nullptr), type(QMetaType::UnknownType), spinClickTimerId(-1),
- spinClickTimerInterval(100), spinClickThresholdTimerId(-1), spinClickThresholdTimerInterval(-1),
- effectiveSpinRepeatRate(1), buttonState(None), keyboardModifiers{}, 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(nullptr), showGroupSeparator(0),
- wheelDeltaRemainder(0)
+ : pendingEmit(false), readOnly(false), wrapping(false),
+ ignoreCursorPositionChanged(false), frame(true), accelerate(false), keyboardTracking(true),
+ cleared(false), ignoreUpdateEdit(false), showGroupSeparator(false)
{
}
diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h
index aa9ec4d646..bfde96372c 100644
--- a/src/widgets/widgets/qabstractspinbox_p.h
+++ b/src/widgets/widgets/qabstractspinbox_p.h
@@ -124,18 +124,32 @@ public:
virtual QVariant calculateAdaptiveDecimalStep(int steps) const;
- QLineEdit *edit;
QString prefix, suffix, specialValueText;
QVariant value, minimum, maximum, singleStep;
- QMetaType::Type type;
- int spinClickTimerId, spinClickTimerInterval, spinClickThresholdTimerId, spinClickThresholdTimerInterval;
- int effectiveSpinRepeatRate;
- uint buttonState;
- Qt::KeyboardModifiers keyboardModifiers;
- mutable QString cachedText;
+ QRect hoverRect;
+
+ mutable QString cachedText = QLatin1String("\x01");
mutable QVariant cachedValue;
- mutable QValidator::State cachedState;
mutable QSize cachedSizeHint, cachedMinimumSizeHint;
+ QLineEdit *edit = nullptr;
+ QSpinBoxValidator *validator = nullptr;
+ QMetaType::Type type = QMetaType::UnknownType;
+ int spinClickTimerId = -1;
+ int spinClickTimerInterval = 100;
+ int spinClickThresholdTimerId = -1;
+ int spinClickThresholdTimerInterval = -1;
+ int effectiveSpinRepeatRate = 1;
+ int acceleration = 0;
+ int wheelDeltaRemainder = 0;
+
+ Qt::KeyboardModifiers keyboardModifiers = Qt::NoModifier;
+ Qt::KeyboardModifier stepModifier = Qt::ControlModifier;
+ QAbstractSpinBox::CorrectionMode correctionMode = QAbstractSpinBox::CorrectToPreviousValue;
+ QAbstractSpinBox::StepType stepType = QAbstractSpinBox::StepType::DefaultStepType;
+ QAbstractSpinBox::ButtonSymbols buttonSymbols = QAbstractSpinBox::UpDownArrows;
+ QStyle::SubControl hoverControl = QStyle::SC_None;
+ mutable QValidator::State cachedState = QValidator::Invalid;
+ uint buttonState = None;
uint pendingEmit : 1;
uint readOnly : 1;
uint wrapping : 1;
@@ -145,16 +159,7 @@ public:
uint keyboardTracking : 1;
uint cleared : 1;
uint ignoreUpdateEdit : 1;
- QAbstractSpinBox::CorrectionMode correctionMode;
- QAbstractSpinBox::StepType stepType = QAbstractSpinBox::StepType::DefaultStepType;
- Qt::KeyboardModifier stepModifier = Qt::ControlModifier;
- int acceleration;
- QStyle::SubControl hoverControl;
- QRect hoverRect;
- QAbstractSpinBox::ButtonSymbols buttonSymbols;
- QSpinBoxValidator *validator;
uint showGroupSeparator : 1;
- int wheelDeltaRemainder;
};
class QSpinBoxValidator : public QValidator