Qt 4.8
Public Functions | Public Variables | List of all members
QDoubleSpinBoxPrivate Class Reference
Inheritance diagram for QDoubleSpinBoxPrivate:
QAbstractSpinBoxPrivate QWidgetPrivate QObjectPrivate QObjectData

Public Functions

void emitSignals (EmitPolicy ep, const QVariant &)
 
void init ()
 
 QDoubleSpinBoxPrivate ()
 
double round (double input) const
 Rounds to a double value that is restricted to decimals. More...
 
virtual QString textFromValue (const QVariant &n) const
 Virtual method called that calls the public textFromValue() functions in the subclasses. More...
 
QVariant validateAndInterpret (QString &input, int &pos, QValidator::State &state) const
 
virtual QVariant valueFromText (const QString &n) const
 
- Public Functions inherited from QAbstractSpinBoxPrivate
virtual void _q_editorCursorPositionChanged (int oldpos, int newpos)
 Virtual slot connected to the line edit's cursorPositionChanged(int, int) signal. More...
 
void _q_editorTextChanged (const QString &)
 Slot connected to the line edit's textChanged(const QString &) signal. More...
 
virtual QVariant bound (const QVariant &val, const QVariant &old=QVariant(), int steps=0) const
 Bounds val to be within minimum and maximum. More...
 
virtual void clearCache () const
 
virtual QVariant getZeroVariant () const
 Convenience function to get a variant of the right type. More...
 
void init ()
 Initialises the QAbstractSpinBoxPrivate object. More...
 
virtual void interpret (EmitPolicy ep)
 Interprets text and emits signals. More...
 
virtual QStyle::SubControl newHoverControl (const QPoint &pos)
 Returns the hover control at pos. More...
 
 QAbstractSpinBoxPrivate ()
 
void reset ()
 Resets the state of the spinbox. More...
 
virtual void setRange (const QVariant &min, const QVariant &max)
 Convenience function to set min/max values. More...
 
void setValue (const QVariant &val, EmitPolicy ep, bool updateEdit=true)
 Sets the value of the spin box to val. More...
 
bool specialValue () const
 Returns true if a specialValueText has been set and the current value is minimum. More...
 
QString stripped (const QString &text, int *pos=0) const
 Strips any prefix/suffix from text. More...
 
virtual void updateEdit ()
 Updates the line edit to reflect the current value of the spin box. More...
 
virtual void updateEditFieldGeometry ()
 
bool updateHoverControl (const QPoint &pos)
 Updates the old and new hover control. More...
 
void updateState (bool up, bool fromKeyboard=false)
 Updates the state of the spinbox. More...
 
 ~QAbstractSpinBoxPrivate ()
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

double actualMax
 
double actualMin
 
int decimals
 
- Public Variables inherited from QAbstractSpinBoxPrivate
uint accelerate: 1
 
int acceleration
 
uint buttonState
 
QAbstractSpinBox::ButtonSymbols buttonSymbols
 
QSize cachedMinimumSizeHint
 
QSize cachedSizeHint
 
QValidator::State cachedState
 
QString cachedText
 
QVariant cachedValue
 
uint cleared: 1
 
QAbstractSpinBox::CorrectionMode correctionMode
 
QLineEditedit
 
int effectiveSpinRepeatRate
 
uint frame: 1
 
QStyle::SubControl hoverControl
 
QRect hoverRect
 
uint ignoreCursorPositionChanged: 1
 
uint ignoreUpdateEdit: 1
 
uint keyboardTracking: 1
 
QVariant maximum
 
QVariant minimum
 
uint pendingEmit: 1
 
QString prefix
 
uint readOnly: 1
 
QVariant singleStep
 
QString specialValueText
 
int spinClickThresholdTimerId
 
int spinClickThresholdTimerInterval
 
int spinClickTimerId
 
int spinClickTimerInterval
 
QString suffix
 
QVariant::Type type
 
QSpinBoxValidatorvalidator
 
QVariant value
 
uint wrapping: 1
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QAbstractSpinBoxPrivate
static QVariant variantBound (const QVariant &min, const QVariant &value, const QVariant &max)
 
static int variantCompare (const QVariant &arg1, const QVariant &arg2)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 83 of file qspinbox.cpp.

Constructors and Destructors

◆ QDoubleSpinBoxPrivate()

QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate ( )
Warning
This function is not part of the public interface. Constructs a QSpinBoxPrivate object

Definition at line 1130 of file qspinbox.cpp.

1131 {
1132  actualMin = 0.0;
1133  actualMax = 99.99;
1136  value = minimum;
1137  singleStep = QVariant(1.0);
1138  decimals = 2;
1140 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92

Functions

◆ emitSignals()

void QDoubleSpinBoxPrivate::emitSignals ( EmitPolicy  ep,
const QVariant old 
)
virtual
Warning
This function is not part of the public interface. Reimplemented Function

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 1147 of file qspinbox.cpp.

1148 {
1150  if (ep != NeverEmit) {
1151  pendingEmit = false;
1152  if (ep == AlwaysEmit || value != old) {
1153  emit q->valueChanged(edit->displayText());
1154  emit q->valueChanged(value.toDouble());
1155  }
1156  }
1157 }
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
The QDoubleSpinBox class provides a spin box widget that takes doubles.
Definition: qspinbox.h:126
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
QString displayText
the displayed text
Definition: qlineedit.h:76

◆ init()

void QDoubleSpinBoxPrivate::init ( )
inline

Definition at line 98 of file qspinbox.cpp.

98  {
100  q->setInputMethodHints(Qt::ImhFormattedNumbersOnly);
101  }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QDoubleSpinBox class provides a spin box widget that takes doubles.
Definition: qspinbox.h:126

◆ round()

double QDoubleSpinBoxPrivate::round ( double  value) const

Rounds to a double value that is restricted to decimals.

Warning
This function is not part of the public interface.

E.g. // decimals = 2

round(5.555) => 5.56

Definition at line 1181 of file qspinbox.cpp.

1182 {
1183  return QString::number(value, 'f', decimals).toDouble();
1184 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
double toDouble(bool *ok=0) const
Returns the string converted to a double value.
Definition: qstring.cpp:6227

◆ textFromValue()

QString QDoubleSpinBoxPrivate::textFromValue ( const QVariant n) const
virtual

Virtual method called that calls the public textFromValue() functions in the subclasses.

Warning
This function is not part of the public interface.

Needed to change signature from QVariant to int/double/QDateTime etc. Used when needing to display a value textually.

This method is reimeplemented in the various subclasses.

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 1345 of file qspinbox.cpp.

1346 {
1347  Q_Q(const QDoubleSpinBox);
1348  return q->textFromValue(f.toDouble());
1349 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QDoubleSpinBox class provides a spin box widget that takes doubles.
Definition: qspinbox.h:126

◆ validateAndInterpret()

QVariant QDoubleSpinBoxPrivate::validateAndInterpret ( QString input,
int &  pos,
QValidator::State state 
) const
Warning
This function is not part of the public interface. Multi purpose function that parses input, sets state to the appropriate state and returns the value it will be interpreted as.

Definition at line 1193 of file qspinbox.cpp.

1195 {
1196  if (cachedText == input && !input.isEmpty()) {
1197  state = cachedState;
1198  QSBDEBUG() << "cachedText was '" << cachedText << "' state was "
1199  << state << " and value was " << cachedValue;
1200  return cachedValue;
1201  }
1202  const double max = maximum.toDouble();
1203  const double min = minimum.toDouble();
1204 
1205  QString copy = stripped(input, &pos);
1206  QSBDEBUG() << "input" << input << "copy" << copy;
1207  int len = copy.size();
1208  double num = min;
1209  const bool plus = max >= 0;
1210  const bool minus = min <= 0;
1211 
1212  switch (len) {
1213  case 0:
1214  state = max != min ? QValidator::Intermediate : QValidator::Invalid;
1215  goto end;
1216  case 1:
1217  if (copy.at(0) == locale.decimalPoint()
1218  || (plus && copy.at(0) == QLatin1Char('+'))
1219  || (minus && copy.at(0) == QLatin1Char('-'))) {
1220  state = QValidator::Intermediate;
1221  goto end;
1222  }
1223  break;
1224  case 2:
1225  if (copy.at(1) == locale.decimalPoint()
1226  && ((plus && copy.at(0) == QLatin1Char('+')) || (minus && copy.at(0) == QLatin1Char('-')))) {
1227  state = QValidator::Intermediate;
1228  goto end;
1229  }
1230  break;
1231  default: break;
1232  }
1233 
1234  if (copy.at(0) == locale.groupSeparator()) {
1235  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1236  state = QValidator::Invalid;
1237  goto end;
1238  } else if (len > 1) {
1239  const int dec = copy.indexOf(locale.decimalPoint());
1240  if (dec != -1) {
1241  if (dec + 1 < copy.size() && copy.at(dec + 1) == locale.decimalPoint() && pos == dec + 1) {
1242  copy.remove(dec + 1, 1); // typing a delimiter when you are on the delimiter
1243  } // should be treated as typing right arrow
1244 
1245  if (copy.size() - dec > decimals + 1) {
1246  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1247  state = QValidator::Invalid;
1248  goto end;
1249  }
1250  for (int i=dec + 1; i<copy.size(); ++i) {
1251  if (copy.at(i).isSpace() || copy.at(i) == locale.groupSeparator()) {
1252  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1253  state = QValidator::Invalid;
1254  goto end;
1255  }
1256  }
1257  } else {
1258  const QChar &last = copy.at(len - 1);
1259  const QChar &secondLast = copy.at(len - 2);
1260  if ((last == locale.groupSeparator() || last.isSpace())
1261  && (secondLast == locale.groupSeparator() || secondLast.isSpace())) {
1262  state = QValidator::Invalid;
1263  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1264  goto end;
1265  } else if (last.isSpace() && (!locale.groupSeparator().isSpace() || secondLast.isSpace())) {
1266  state = QValidator::Invalid;
1267  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1268  goto end;
1269  }
1270  }
1271  }
1272 
1273  {
1274  bool ok = false;
1275  num = locale.toDouble(copy, &ok);
1276  QSBDEBUG() << __FILE__ << __LINE__ << locale << copy << num << ok;
1277 
1278  if (!ok) {
1279  if (locale.groupSeparator().isPrint()) {
1280  if (max < 1000 && min > -1000 && copy.contains(locale.groupSeparator())) {
1281  state = QValidator::Invalid;
1282  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1283  goto end;
1284  }
1285 
1286  const int len = copy.size();
1287  for (int i=0; i<len- 1; ++i) {
1288  if (copy.at(i) == locale.groupSeparator() && copy.at(i + 1) == locale.groupSeparator()) {
1289  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1290  state = QValidator::Invalid;
1291  goto end;
1292  }
1293  }
1294 
1295  QString copy2 = copy;
1296  copy2.remove(locale.groupSeparator());
1297  num = locale.toDouble(copy2, &ok);
1298  QSBDEBUG() << locale.groupSeparator() << num << copy2 << ok;
1299 
1300  if (!ok) {
1301  state = QValidator::Invalid;
1302  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1303  goto end;
1304  }
1305  }
1306  }
1307 
1308  if (!ok) {
1309  state = QValidator::Invalid;
1310  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1311  } else if (num >= min && num <= max) {
1312  state = QValidator::Acceptable;
1313  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Acceptable";
1314  } else if (max == min) { // when max and min is the same the only non-Invalid input is max (or min)
1315  state = QValidator::Invalid;
1316  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1317  } else {
1318  if ((num >= 0 && num > max) || (num < 0 && num < min)) {
1319  state = QValidator::Invalid;
1320  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1321  } else {
1322  state = QValidator::Intermediate;
1323  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Intermediate";
1324  }
1325  }
1326  }
1327 
1328 end:
1329  if (state != QValidator::Acceptable) {
1330  num = max > 0 ? min : max;
1331  }
1332 
1333  input = prefix + copy + suffix;
1334  cachedText = input;
1335  cachedState = state;
1336  cachedValue = QVariant(num);
1337  return QVariant(num);
1338 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isPrint() const
Returns true if the character is a printable character; otherwise returns false.
Definition: qchar.cpp:598
QLocale locale
Definition: qwidget_p.h:757
#define QSBDEBUG
Definition: qspinbox.cpp:61
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Q_CORE_EXPORT QTextStream & dec(QTextStream &s)
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
QChar decimalPoint() const
Returns the decimal point character of this locale.
Definition: qlocale.cpp:1765
QValidator::State cachedState
QChar groupSeparator() const
Returns the group separator character of this locale.
Definition: qlocale.cpp:1778
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString stripped(const QString &text, int *pos=0) const
Strips any prefix/suffix from text.
double toDouble(const QString &s, bool *ok=0) const
Returns the double represented by the localized string s, or 0.0 if the conversion failed...
Definition: qlocale.cpp:1279
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
static const KeyPair *const end
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ valueFromText()

QVariant QDoubleSpinBoxPrivate::valueFromText ( const QString f) const
virtual
Warning
This function is not part of the public interface. Reimplemented Function

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 1164 of file qspinbox.cpp.

1165 {
1166  Q_Q(const QDoubleSpinBox);
1167  return QVariant(q->valueFromText(f));
1168 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
#define Q_Q(Class)
Definition: qglobal.h:2483
The QDoubleSpinBox class provides a spin box widget that takes doubles.
Definition: qspinbox.h:126

Properties

◆ actualMax

double QDoubleSpinBoxPrivate::actualMax

Definition at line 105 of file qspinbox.cpp.

◆ actualMin

double QDoubleSpinBoxPrivate::actualMin

Definition at line 104 of file qspinbox.cpp.

◆ decimals

int QDoubleSpinBoxPrivate::decimals

Definition at line 96 of file qspinbox.cpp.


The documentation for this class was generated from the following file: