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>
This commit is contained in:
Volker Hilsheimer 2020-07-02 18:37:26 +02:00
parent bb5171fb54
commit d2e3f00367
2 changed files with 25 additions and 26 deletions

View File

@ -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)
{
}

View File

@ -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