Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QDateTimeEditPrivate Class Reference

#include <qdatetimeedit_p.h>

Inheritance diagram for QDateTimeEditPrivate:
QAbstractSpinBoxPrivate QDateTimeParser QWidgetPrivate QObjectPrivate QObjectData

Public Functions

virtual void _q_editorCursorPositionChanged (int oldpos, int newpos)
 
void _q_resetButton ()
 
int absoluteIndex (QDateTimeEdit::Section s, int index) const
 
int absoluteIndex (const SectionNode &s) const
 
bool calendarPopupEnabled () const
 
virtual void clearCache () const
 
void clearSection (int index)
 Clears the text of section s. More...
 
int closestSection (int index, bool forward) const
 Returns the closest section of index index. More...
 
int cursorPosition () const
 
virtual QString displayText () const
 
void emitSignals (EmitPolicy ep, const QVariant &old)
 
QString getAmPmText (AmPm ap, Case cs) const
 
virtual QDateTime getMaximum () const
 
virtual QDateTime getMinimum () const
 
virtual QVariant getZeroVariant () const
 Convenience function to get a variant of the right type. More...
 
void init (const QVariant &var)
 
void initCalendarPopup (QCalendarWidget *cw=0)
 
virtual void interpret (EmitPolicy ep)
 Interprets text and emits signals. More...
 
bool isSeparatorKey (const QKeyEvent *k) const
 
virtual QLocale locale () const
 
virtual QStyle::SubControl newHoverControl (const QPoint &pos)
 Returns the hover control at pos. More...
 
int nextPrevSection (int index, bool forward) const
 Returns a copy of the section that is before or after current, depending on forward. More...
 
void positionCalendarPopup ()
 
 QDateTimeEditPrivate ()
 
void readLocaleSettings ()
 
int sectionAt (int pos) const
 Returns the section at index index or NoSection if there are no sections there. More...
 
virtual void setRange (const QVariant &min, const QVariant &max)
 Convenience function to set min/max values. More...
 
void setSelected (int index, bool forward=false)
 Selects the section s. More...
 
QDateTime stepBy (int index, int steps, bool test=false) const
 Internal function called by QDateTimeEdit::stepBy(). More...
 
void syncCalendarWidget ()
 
QString textFromValue (const QVariant &f) const
 
void updateArrow (QStyle::StateFlag state)
 
void updateCache (const QVariant &val, const QString &str) const
 
void updateEdit ()
 Updates the line edit to reflect the current value of the spin box. More...
 
virtual void updateEditFieldGeometry ()
 
void updateTimeSpec ()
 
QDateTime validateAndInterpret (QString &input, int &, QValidator::State &state, bool fixup=false) const
 
QVariant valueFromText (const QString &f) const
 This function's name is slightly confusing; it is not to be confused with QAbstractSpinBox::valueFromText(). More...
 
QString valueToText (const QVariant &var) const
 
- Public Functions inherited from QAbstractSpinBoxPrivate
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...
 
void init ()
 Initialises the QAbstractSpinBoxPrivate object. More...
 
 QAbstractSpinBoxPrivate ()
 
void reset ()
 Resets the state of the spinbox. 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...
 
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 Functions inherited from QDateTimeParser
int absoluteMax (int index, const QDateTime &value=QDateTime()) const
 \ More...
 
int absoluteMin (int index) const
 
FieldInfo fieldInfo (int index) const
 
int findAmPm (QString &str1, int index, int *used=0) const
 
int findDay (const QString &str1, int intDaystart, int sectionIndex, QString *dayName=0, int *used=0) const
 
int findMonth (const QString &str1, int monthstart, int sectionIndex, QString *monthName=0, int *used=0) const
 
bool fromString (const QString &text, QDate *date, QTime *time) const
 
int getDigit (const QDateTime &dt, int index) const
 Gets the digit from a datetime. More...
 
int maxChange (int s) const
 Max number of units that can be changed by this section. More...
 
StateNode parse (QString &input, int &cursorPosition, const QDateTime &currentValue, bool fixup) const
 
bool parseFormat (const QString &format)
 
int parseSection (const QDateTime &currentValue, int sectionIndex, QString &txt, int &cursorPosition, int index, QDateTimeParser::State &state, int *used=0) const
 
bool potentialValue (const QString &str, int min, int max, int index, const QDateTime &currentValue, int insert) const
 
 QDateTimeParser (QVariant::Type t, Context ctx)
 
QString sectionFormat (int index) const
 
QString sectionFormat (Section s, int count) const
 
int sectionMaxSize (int index) const
 
int sectionMaxSize (Section s, int count) const
 
QString sectionName (int s) const
 For debugging. More...
 
const SectionNodesectionNode (int index) const
 Returns the sectionNode for the Section s. More...
 
int sectionPos (int index) const
 Returns the starting position for section s. More...
 
int sectionPos (const SectionNode &sn) const
 
int sectionSize (int index) const
 Returns the size of section s. More...
 
QString sectionText (int sectionIndex) const
 
QString sectionText (const QString &text, int sectionIndex, int index) const
 Returns the text of section s. More...
 
Section sectionType (int index) const
 
bool setDigit (QDateTime &t, int index, int newval) const
 Sets a digit in a datetime. More...
 
bool skipToNextSection (int section, const QDateTime &current, const QString &sectionText) const
 
QString stateName (int s) const
 For debugging. More...
 
virtual ~QDateTimeParser ()
 

Static Public Functions

static QDateTimeEdit::Sections convertSections (QDateTimeParser::Sections s)
 
static QDateTimeEdit::Section convertToPublic (QDateTimeParser::Section s)
 
- 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)
 

Public Variables

QStyle::StateFlag arrowState
 
bool cacheGuard
 
bool calendarPopup
 
QVariant conflictGuard
 
QString defaultDateFormat
 
QString defaultDateTimeFormat
 
QString defaultTimeFormat
 
bool formatExplicitlySet
 
bool hasHadFocus
 
QCalendarPopupmonthCalendar
 
QDateTimeEdit::Sections sections
 
QString unreversedFormat
 
- 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
 
- Public Variables inherited from QDateTimeParser
int cachedDay
 
Context context
 
int currentSectionIndex
 
QLocale defaultLocale
 
Sections display
 
QString displayFormat
 
SectionNode first
 
bool fixday
 
SectionNode last
 
SectionNode none
 
QVariant::Type parserType
 
SectionNode popup
 
QVector< SectionNodesectionNodes
 
QStringList separators
 
Qt::TimeSpec spec
 
QString text
 

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 **)
 
- Public Types inherited from QDateTimeParser
enum  {
  Neither = -1, AM = 0, PM = 1, PossibleAM = 2,
  PossiblePM = 3, PossibleBoth = 4
}
 
enum  AmPm { AmText, PmText }
 
enum  Case { UpperCase, LowerCase }
 
enum  Context { FromString, DateTimeEdit }
 
enum  FieldInfoFlag { Numeric = 0x01, FixedWidth = 0x02, AllowPartial = 0x04, Fraction = 0x08 }
 
enum  Section {
  NoSection = 0x00000, AmPmSection = 0x00001, MSecSection = 0x00002, SecondSection = 0x00004,
  MinuteSection = 0x00008, Hour12Section = 0x00010, Hour24Section = 0x00020, TimeSectionMask = (AmPmSection|MSecSection|SecondSection|MinuteSection|Hour12Section|Hour24Section),
  Internal = 0x10000, DaySection = 0x00100, MonthSection = 0x00200, YearSection = 0x00400,
  YearSection2Digits = 0x00800, DayOfWeekSection = 0x01000, DateSectionMask = (DaySection|MonthSection|YearSection|YearSection2Digits|DayOfWeekSection), FirstSection = 0x02000|Internal,
  LastSection = 0x04000|Internal, CalendarPopupSection = 0x08000|Internal, NoSectionIndex = -1, FirstSectionIndex = -2,
  LastSectionIndex = -3, CalendarPopupIndex = -4
}
 
enum  State { Invalid, Intermediate, Acceptable }
 
- 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 73 of file qdatetimeedit_p.h.

Constructors and Destructors

◆ QDateTimeEditPrivate()

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

Definition at line 1708 of file qdatetimeedit.cpp.

1710 {
1711  hasHadFocus = false;
1712  formatExplicitlySet = false;
1713  cacheGuard = false;
1714  fixday = true;
1716  sections = 0;
1717  cachedDay = -1;
1719 
1721  last.type = LastSection;
1722  none.type = NoSection;
1723  first.pos = 0;
1724  last.pos = -1;
1725  none.pos = -1;
1726  sections = 0;
1727  calendarPopup = false;
1731  monthCalendar = 0;
1733 
1734 #ifdef QT_KEYPAD_NAVIGATION
1735  focusOnButton = false;
1736 #endif
1737 }
SectionNode first
Definition: qdatetime_p.h:264
QStyle::StateFlag arrowState
#define QDATETIMEEDIT_COMPAT_DATETIME_MIN
Definition: qdatetime_p.h:73
QDateTimeEdit::Sections sections
SectionNode last
Definition: qdatetime_p.h:264
QDateTimeParser(QVariant::Type t, Context ctx)
Definition: qdatetime_p.h:119
QCalendarPopup * monthCalendar
SectionNode none
Definition: qdatetime_p.h:264
#define QDATETIMEEDIT_DATETIME_MAX
Definition: qdatetime_p.h:74

Functions

◆ _q_editorCursorPositionChanged()

void QDateTimeEditPrivate::_q_editorCursorPositionChanged ( int  oldpos,
int  newpos 
)
virtual
Warning
This function is not part of the public interface.

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 2234 of file qdatetimeedit.cpp.

2235 {
2237  return;
2238  const QString oldText = displayText();
2239  updateCache(value, oldText);
2240 
2241  const bool allowChange = !edit->hasSelectedText();
2242  const bool forward = oldpos <= newpos;
2244  int s = sectionAt(newpos);
2245  if (s == NoSectionIndex && forward && newpos > 0) {
2246  s = sectionAt(newpos - 1);
2247  }
2248 
2249  int c = newpos;
2250 
2251  const int selstart = edit->selectionStart();
2252  const int selSection = sectionAt(selstart);
2253  const int l = selSection != -1 ? sectionSize(selSection) : 0;
2254 
2255  if (s == NoSectionIndex) {
2256  if (l > 0 && selstart == sectionPos(selSection) && edit->selectedText().size() == l) {
2257  s = selSection;
2258  if (allowChange)
2259  setSelected(selSection, true);
2260  c = -1;
2261  } else {
2262  int closest = closestSection(newpos, forward);
2263  c = sectionPos(closest) + (forward ? 0 : qMax<int>(0, sectionSize(closest)));
2264 
2265  if (allowChange) {
2266  edit->setCursorPosition(c);
2267  QDTEDEBUG << c;
2268  }
2269  s = closest;
2270  }
2271  }
2272 
2273  if (allowChange && currentSectionIndex != s) {
2275  }
2276  if (c == -1) {
2277  setSelected(s, true);
2278  } else if (!edit->hasSelectedText()) {
2279  if (oldpos < newpos) {
2280  edit->setCursorPosition(displayText().size() - (oldText.size() - c));
2281  } else {
2282  edit->setCursorPosition(c);
2283  }
2284  }
2285 
2286  QDTEDEBUG << "currentSectionIndex is set to" << sectionName(sectionType(s))
2287  << oldpos << newpos
2289 
2290  currentSectionIndex = s;
2292  "QDateTimeEditPrivate::_q_editorCursorPositionChanged()",
2293  qPrintable(QString::fromAscii("Internal error (%1 %2)").
2294  arg(currentSectionIndex).
2295  arg(sectionNodes.size())));
2296 
2298 }
int selectionStart() const
selectionStart() returns the index of the first selected character in the line edit or -1 if no text ...
Definition: qlineedit.cpp:1039
unsigned char c[8]
Definition: qnumeric_p.h:62
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
void setSelected(int index, bool forward=false)
Selects the section s.
QVector< SectionNode > sectionNodes
Definition: qdatetime_p.h:263
virtual QString displayText() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define QDTEDEBUG
QString sectionName(int s) const
For debugging.
Definition: qdatetime.cpp:6044
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
int sectionSize(int index) const
Returns the size of section s.
Definition: qdatetime.cpp:4943
virtual void interpret(EmitPolicy ep)
Interprets text and emits signals.
QString selectedText
the selected text
Definition: qlineedit.h:81
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
bool hasSelectedText
whether there is any text selected
Definition: qlineedit.h:80
Section sectionType(int index) const
Definition: qdatetime.cpp:4674
QFactoryLoader * l
void setCursorPosition(int)
Definition: qlineedit.cpp:758
int sectionAt(int pos) const
Returns the section at index index or NoSection if there are no sections there.
#define qPrintable(string)
Definition: qglobal.h:1750
int sectionPos(int index) const
Returns the starting position for section s.
Definition: qdatetime.cpp:4689
bool specialValue() const
Returns true if a specialValueText has been set and the current value is minimum. ...
void updateCache(const QVariant &val, const QString &str) const
int closestSection(int index, bool forward) const
Returns the closest section of index index.

◆ _q_resetButton()

void QDateTimeEditPrivate::_q_resetButton ( )

Definition at line 2493 of file qdatetimeedit.cpp.

Referenced by cursorPosition(), and initCalendarPopup().

2494 {
2496 }
void updateArrow(QStyle::StateFlag state)

◆ absoluteIndex() [1/2]

int QDateTimeEditPrivate::absoluteIndex ( QDateTimeEdit::Section  s,
int  index 
) const

Definition at line 2397 of file qdatetimeedit.cpp.

Referenced by displayText().

2398 {
2399  for (int i=0; i<sectionNodes.size(); ++i) {
2400  if (convertToPublic(sectionNodes.at(i).type) == s && index-- == 0) {
2401  return i;
2402  }
2403  }
2404  return NoSectionIndex;
2405 }
QVector< SectionNode > sectionNodes
Definition: qdatetime_p.h:263
static QDateTimeEdit::Section convertToPublic(QDateTimeParser::Section s)
quint16 index

◆ absoluteIndex() [2/2]

int QDateTimeEditPrivate::absoluteIndex ( const SectionNode s) const

Definition at line 2407 of file qdatetimeedit.cpp.

2408 {
2409  return sectionNodes.indexOf(s);
2410 }
QVector< SectionNode > sectionNodes
Definition: qdatetime_p.h:263

◆ calendarPopupEnabled()

bool QDateTimeEditPrivate::calendarPopupEnabled ( ) const

Definition at line 2631 of file qdatetimeedit.cpp.

Referenced by cursorPosition(), newHoverControl(), and updateEditFieldGeometry().

2632 {
2633  return (calendarPopup && (sections & (DateSectionMask)));
2634 }
QDateTimeEdit::Sections sections

◆ clearCache()

void QDateTimeEditPrivate::clearCache ( ) const
virtual

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 2428 of file qdatetimeedit.cpp.

Referenced by validateAndInterpret().

2429 {
2431  cachedDay = -1;
2432 }
virtual void clearCache() const

◆ clearSection()

void QDateTimeEditPrivate::clearSection ( int  index)

Clears the text of section s.

Warning
This function is not part of the public interface.

Definition at line 1925 of file qdatetimeedit.cpp.

1926 {
1927  const QLatin1Char space(' ');
1928  int cursorPos = edit->cursorPosition();
1929  bool blocked = edit->blockSignals(true);
1930  QString t = edit->text();
1931  const int pos = sectionPos(index);
1932  if (pos == -1) {
1933  qWarning("QDateTimeEdit: Internal error (%s:%d)", __FILE__, __LINE__);
1934  return;
1935  }
1936  const int size = sectionSize(index);
1937  t.replace(pos, size, QString().fill(space, size));
1938  edit->setText(t);
1939  edit->setCursorPosition(cursorPos);
1940  QDTEDEBUG << cursorPos;
1941 
1942  edit->blockSignals(blocked);
1943 }
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
Definition: qobject.cpp:1406
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define QDTEDEBUG
int sectionSize(int index) const
Returns the size of section s.
Definition: qdatetime.cpp:4943
QString text
the line edit&#39;s text
Definition: qlineedit.h:72
Q_CORE_EXPORT void qWarning(const char *,...)
void setText(const QString &)
Definition: qlineedit.cpp:401
quint16 index
void setCursorPosition(int)
Definition: qlineedit.cpp:758
int sectionPos(int index) const
Returns the starting position for section s.
Definition: qdatetime.cpp:4689
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
int cursorPosition
the current cursor position for this line edit
Definition: qlineedit.h:77

◆ closestSection()

int QDateTimeEditPrivate::closestSection ( int  pos,
bool  forward 
) const

Returns the closest section of index index.

Warning
This function is not part of the public interface.

Searches forward for a section if forward is true. Otherwise searches backwards.

Definition at line 1859 of file qdatetimeedit.cpp.

Referenced by _q_editorCursorPositionChanged(), and displayText().

1860 {
1861  Q_ASSERT(pos >= 0);
1862  if (pos < separators.first().size()) {
1863  return forward ? 0 : FirstSectionIndex;
1864  } else if (displayText().size() - pos < separators.last().size() + 1) {
1865  return forward ? LastSectionIndex : sectionNodes.size() - 1;
1866  }
1868  for (int i=0; i<sectionNodes.size(); ++i) {
1869  const int tmp = sectionPos(sectionNodes.at(i));
1870  if (pos < tmp + sectionSize(i)) {
1871  if (pos < tmp && !forward) {
1872  return i-1;
1873  }
1874  return i;
1875  } else if (i == sectionNodes.size() - 1 && pos > tmp) {
1876  return i;
1877  }
1878  }
1879  qWarning("QDateTimeEdit: Internal Error: closestSection returned NoSection");
1880  return NoSectionIndex;
1881 }
QVector< SectionNode > sectionNodes
Definition: qdatetime_p.h:263
virtual QString displayText() const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
int sectionSize(int index) const
Returns the size of section s.
Definition: qdatetime.cpp:4943
Q_CORE_EXPORT void qWarning(const char *,...)
QStringList separators
Definition: qdatetime_p.h:265
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
int sectionPos(int index) const
Returns the starting position for section s.
Definition: qdatetime.cpp:4689
void updateCache(const QVariant &val, const QString &str) const

◆ convertSections()

QDateTimeEdit::Sections QDateTimeEditPrivate::convertSections ( QDateTimeParser::Sections  s)
static

Definition at line 2334 of file qdatetimeedit.cpp.

Referenced by cursorPosition().

2335 {
2336  QDateTimeEdit::Sections ret = 0;
2353 
2354  return ret;
2355 }

◆ convertToPublic()

QDateTimeEdit::Section QDateTimeEditPrivate::convertToPublic ( QDateTimeParser::Section  s)
static

Definition at line 2313 of file qdatetimeedit.cpp.

Referenced by absoluteIndex(), and cursorPosition().

2314 {
2315  switch (s & ~Internal) {
2320  case DayOfWeekSection:
2323  case YearSection2Digits:
2325  case Hour12Section:
2327  case FirstSection:
2328  case NoSection:
2329  case LastSection: break;
2330  }
2331  return QDateTimeEdit::NoSection;
2332 }

◆ cursorPosition()

int QDateTimeEditPrivate::cursorPosition ( ) const
inlinevirtual

Reimplemented from QDateTimeParser.

Definition at line 111 of file qdatetimeedit_p.h.

111 { return edit ? edit->cursorPosition() : -1; }
int cursorPosition
the current cursor position for this line edit
Definition: qlineedit.h:77

◆ displayText()

virtual QString QDateTimeEditPrivate::displayText ( ) const
inlinevirtual

Reimplemented from QDateTimeParser.

Definition at line 92 of file qdatetimeedit_p.h.

Referenced by _q_editorCursorPositionChanged(), closestSection(), emitSignals(), interpret(), sectionAt(), setSelected(), stepBy(), and updateEdit().

92 { return edit->text(); } // this is from QDateTimeParser
QString text
the line edit&#39;s text
Definition: qlineedit.h:72

◆ emitSignals()

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

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 2205 of file qdatetimeedit.cpp.

2206 {
2207  Q_Q(QDateTimeEdit);
2208  if (ep == NeverEmit) {
2209  return;
2210  }
2211  pendingEmit = false;
2212 
2213  const bool dodate = value.toDate().isValid() && (sections & DateSectionMask);
2214  const bool datechanged = (ep == AlwaysEmit || old.toDate() != value.toDate());
2215  const bool dotime = value.toTime().isValid() && (sections & TimeSectionMask);
2216  const bool timechanged = (ep == AlwaysEmit || old.toTime() != value.toTime());
2217 
2219 
2221  if (datechanged || timechanged)
2222  emit q->dateTimeChanged(value.toDateTime());
2223  if (dodate && datechanged)
2224  emit q->dateChanged(value.toDate());
2225  if (dotime && timechanged)
2226  emit q->timeChanged(value.toTime());
2227 
2228 }
bool isValid() const
Returns true if this date is valid; otherwise returns false.
Definition: qdatetime.cpp:340
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
QDateTimeEdit::Sections sections
virtual QString displayText() const
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2311
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2330
bool isValid() const
Returns true if the time is valid; otherwise returns false.
Definition: qdatetime.cpp:1566
void updateCache(const QVariant &val, const QString &str) const

◆ getAmPmText()

QString QDateTimeEditPrivate::getAmPmText ( AmPm  ap,
Case  cs 
) const
virtual

Reimplemented from QDateTimeParser.

Definition at line 2388 of file qdatetimeedit.cpp.

Referenced by valueToText().

2389 {
2390  if (ap == AmText) {
2391  return (cs == UpperCase ? QDateTimeEdit::tr("AM") : QDateTimeEdit::tr("am"));
2392  } else {
2393  return (cs == UpperCase ? QDateTimeEdit::tr("PM") : QDateTimeEdit::tr("pm"));
2394  }
2395 }
static QString tr(const char *sourceText, const char *comment=0, int n=-1)

◆ getMaximum()

virtual QDateTime QDateTimeEditPrivate::getMaximum ( ) const
inlinevirtual

Reimplemented from QDateTimeParser.

Definition at line 107 of file qdatetimeedit_p.h.

107 { return maximum.toDateTime(); }
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349

◆ getMinimum()

virtual QDateTime QDateTimeEditPrivate::getMinimum ( ) const
inlinevirtual

Reimplemented from QDateTimeParser.

Definition at line 106 of file qdatetimeedit_p.h.

106 { return minimum.toDateTime(); }
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349

◆ getZeroVariant()

QVariant QDateTimeEditPrivate::getZeroVariant ( ) const
virtual

Convenience function to get a variant of the right type.

Warning
This function is not part of the public interface.

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 2554 of file qdatetimeedit.cpp.

Referenced by cursorPosition(), and validateAndInterpret().

2555 {
2558 }
#define QDATETIMEEDIT_DATE_INITIAL
Definition: qdatetime_p.h:75
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QTime class provides clock time functions.
Definition: qdatetime.h:148
Qt::TimeSpec spec
Definition: qdatetime_p.h:272
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ init()

void QDateTimeEditPrivate::init ( const QVariant var)

Definition at line 2458 of file qdatetimeedit.cpp.

2459 {
2460  Q_Q(QDateTimeEdit);
2461  switch (var.type()) {
2462  case QVariant::Date:
2464  q->setDisplayFormat(defaultDateFormat);
2465  if (sectionNodes.isEmpty()) // ### safeguard for broken locale
2466  q->setDisplayFormat(QLatin1String("dd/MM/yyyy"));
2467  break;
2468  case QVariant::DateTime:
2469  value = var;
2470  q->setDisplayFormat(defaultDateTimeFormat);
2471  if (sectionNodes.isEmpty()) // ### safeguard for broken locale
2472  q->setDisplayFormat(QLatin1String("dd/MM/yyyy hh:mm:ss"));
2473  break;
2474  case QVariant::Time:
2476  q->setDisplayFormat(defaultTimeFormat);
2477  if (sectionNodes.isEmpty()) // ### safeguard for broken locale
2478  q->setDisplayFormat(QLatin1String("hh:mm:ss"));
2479  break;
2480  default:
2481  Q_ASSERT_X(0, "QDateTimeEditPrivate::init", "Internal error");
2482  break;
2483  }
2484 #ifdef QT_KEYPAD_NAVIGATION
2485  if (QApplication::keypadNavigationEnabled())
2486  q->setCalendarPopup(true);
2487 #endif
2488  updateTimeSpec();
2489  q->setInputMethodHints(Qt::ImhPreferNumbers);
2491 }
#define QDATETIMEEDIT_DATE_INITIAL
Definition: qdatetime_p.h:75
QVector< SectionNode > sectionNodes
Definition: qdatetime_p.h:263
#define QDATETIMEEDIT_TIME_MIN
Definition: qdatetime_p.h:67
void setLayoutItemMargins(int left, int top, int right, int bottom)
Definition: qwidget.cpp:12860
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2311
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2330

◆ initCalendarPopup()

void QDateTimeEditPrivate::initCalendarPopup ( QCalendarWidget cw = 0)

Definition at line 2581 of file qdatetimeedit.cpp.

Referenced by cursorPosition().

2582 {
2583  Q_Q(QDateTimeEdit);
2584  if (!monthCalendar) {
2585  monthCalendar = new QCalendarPopup(q, cw);
2586  monthCalendar->setObjectName(QLatin1String("qt_datetimedit_calendar"));
2587  QObject::connect(monthCalendar, SIGNAL(newDateSelected(QDate)), q, SLOT(setDate(QDate)));
2588  QObject::connect(monthCalendar, SIGNAL(hidingCalendar(QDate)), q, SLOT(setDate(QDate)));
2589  QObject::connect(monthCalendar, SIGNAL(activated(QDate)), q, SLOT(setDate(QDate)));
2590  QObject::connect(monthCalendar, SIGNAL(activated(QDate)), monthCalendar, SLOT(close()));
2591  QObject::connect(monthCalendar, SIGNAL(resetButton()), q, SLOT(_q_resetButton()));
2592  } else if (cw) {
2594  }
2596 }
void setCalendarWidget(QCalendarWidget *cw)
#define SLOT(a)
Definition: qobjectdefs.h:226
The QDate class provides date functions.
Definition: qdatetime.h:55
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QCalendarPopup * monthCalendar

◆ interpret()

void QDateTimeEditPrivate::interpret ( EmitPolicy  ep)
virtual

Interprets text and emits signals.

Warning
This function is not part of the public interface.

Called when the spinbox needs to interpret the text on the lineedit.

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 2412 of file qdatetimeedit.cpp.

Referenced by _q_editorCursorPositionChanged().

2413 {
2414  Q_Q(QDateTimeEdit);
2415  QString tmp = displayText();
2416  int pos = edit->cursorPosition();
2417  const QValidator::State state = q->validate(tmp, pos);
2418  if (state != QValidator::Acceptable
2421  setValue(value, ep);
2422  updateTimeSpec();
2423  } else {
2425  }
2426 }
virtual QString displayText() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483
virtual void interpret(EmitPolicy ep)
Interprets text and emits signals.
QAbstractSpinBox::CorrectionMode correctionMode
State
This enum type defines the states in which a validated string can exist.
Definition: qvalidator.h:67
void setValue(const QVariant &val, EmitPolicy ep, bool updateEdit=true)
Sets the value of the spin box to val.
FieldInfo fieldInfo(int index) const
Definition: qdatetime.cpp:5868
int cursorPosition
the current cursor position for this line edit
Definition: qlineedit.h:77

◆ isSeparatorKey()

bool QDateTimeEditPrivate::isSeparatorKey ( const QKeyEvent k) const

Definition at line 2567 of file qdatetimeedit.cpp.

Referenced by cursorPosition().

2568 {
2569  if (!ke->text().isEmpty() && currentSectionIndex + 1 < sectionNodes.size() && currentSectionIndex >= 0) {
2571  if (ke->text().at(0).isNumber())
2572  return false;
2573  } else if (ke->text().at(0).isLetterOrNumber()) {
2574  return false;
2575  }
2576  return separators.at(currentSectionIndex + 1).contains(ke->text());
2577  }
2578  return false;
2579 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
QVector< SectionNode > sectionNodes
Definition: qdatetime_p.h:263
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QStringList separators
Definition: qdatetime_p.h:265
FieldInfo fieldInfo(int index) const
Definition: qdatetime.cpp:5868

◆ locale()

virtual QLocale QDateTimeEditPrivate::locale ( ) const
inlinevirtual

Reimplemented from QDateTimeParser.

Definition at line 108 of file qdatetimeedit_p.h.

108 { return q_func()->locale(); }

◆ newHoverControl()

QStyle::SubControl QDateTimeEditPrivate::newHoverControl ( const QPoint pos)
virtual

Returns the hover control at pos.

Warning
This function is not part of the public interface.

This will update the hoverRect and hoverControl.

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 2522 of file qdatetimeedit.cpp.

Referenced by cursorPosition().

2523 {
2524  if (!calendarPopupEnabled())
2526 
2527  Q_Q(QDateTimeEdit);
2528 
2529  QStyleOptionComboBox optCombo;
2530  optCombo.init(q);
2531  optCombo.editable = true;
2532  optCombo.subControls = QStyle::SC_All;
2533  hoverControl = q->style()->hitTestComplexControl(QStyle::CC_ComboBox, &optCombo, pos, q);
2534  return hoverControl;
2535 }
virtual QStyle::SubControl newHoverControl(const QPoint &pos)
Returns the hover control at pos.
void init(const QWidget *w)
Use initFrom(widget) instead.
bool editable
whether or not the combobox is editable or not
Definition: qstyleoption.h:802
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483
QStyle::SubControl hoverControl
bool calendarPopupEnabled() const
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693

◆ nextPrevSection()

int QDateTimeEditPrivate::nextPrevSection ( int  current,
bool  forward 
) const

Returns a copy of the section that is before or after current, depending on forward.

Warning
This function is not part of the public interface.

Definition at line 1892 of file qdatetimeedit.cpp.

Referenced by displayText().

1893 {
1894  Q_Q(const QDateTimeEdit);
1895  if (q->isRightToLeft())
1896  forward = !forward;
1897 
1898  switch (current) {
1899  case FirstSectionIndex: return forward ? 0 : FirstSectionIndex;
1900  case LastSectionIndex: return (forward ? LastSectionIndex : sectionNodes.size() - 1);
1901  case NoSectionIndex: return FirstSectionIndex;
1902  default: break;
1903  }
1904  Q_ASSERT(current >= 0 && current < sectionNodes.size());
1905 
1906  current += (forward ? 1 : -1);
1907  if (current >= sectionNodes.size()) {
1908  return LastSectionIndex;
1909  } else if (current < 0) {
1910  return FirstSectionIndex;
1911  }
1912 
1913  return current;
1914 }
QVector< SectionNode > sectionNodes
Definition: qdatetime_p.h:263
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483

◆ positionCalendarPopup()

void QDateTimeEditPrivate::positionCalendarPopup ( )

Definition at line 2598 of file qdatetimeedit.cpp.

Referenced by cursorPosition().

2599 {
2600  Q_Q(QDateTimeEdit);
2601  QPoint pos = (q->layoutDirection() == Qt::RightToLeft) ? q->rect().bottomRight() : q->rect().bottomLeft();
2602  QPoint pos2 = (q->layoutDirection() == Qt::RightToLeft) ? q->rect().topRight() : q->rect().topLeft();
2603  pos = q->mapToGlobal(pos);
2604  pos2 = q->mapToGlobal(pos2);
2605  QSize size = monthCalendar->sizeHint();
2607  //handle popup falling "off screen"
2608  if (q->layoutDirection() == Qt::RightToLeft) {
2609  pos.setX(pos.x()-size.width());
2610  pos2.setX(pos2.x()-size.width());
2611  if (pos.x() < screen.left())
2612  pos.setX(qMax(pos.x(), screen.left()));
2613  else if (pos.x()+size.width() > screen.right())
2614  pos.setX(qMax(pos.x()-size.width(), screen.right()-size.width()));
2615  } else {
2616  if (pos.x()+size.width() > screen.right())
2617  pos.setX(screen.right()-size.width());
2618  pos.setX(qMax(pos.x(), screen.left()));
2619  }
2620  if (pos.y() + size.height() > screen.bottom())
2621  pos.setY(pos2.y() - size.height());
2622  else if (pos.y() < screen.top())
2623  pos.setY(screen.top());
2624  if (pos.y() < screen.top())
2625  pos.setY(screen.top());
2626  if (pos.y()+size.height() > screen.bottom())
2627  pos.setY(screen.bottom()-size.height());
2628  monthCalendar->move(pos);
2629 }
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
virtual QSize sizeHint() const
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483
int width() const
Returns the width.
Definition: qsize.h:126
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
Definition: qpoint.h:137
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QCalendarPopup * monthCalendar
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
const QRect availableGeometry(int screen=-1) const
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
Definition: qpoint.h:134
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011

◆ readLocaleSettings()

void QDateTimeEditPrivate::readLocaleSettings ( )
Warning
This function is not part of the public interface.

Try to get the format from the local settings

Definition at line 2305 of file qdatetimeedit.cpp.

Referenced by QDateTimeEditPrivate().

2306 {
2307  const QLocale loc;
2311 }
QString timeFormat(FormatType format=LongFormat) const
Returns the time format used for the current locale.
Definition: qlocale.cpp:1535
QString dateTimeFormat(FormatType format=LongFormat) const
Returns the date time format used for the current locale.
Definition: qlocale.cpp:1575
QString dateFormat(FormatType format=LongFormat) const
Returns the date format used for the current locale.
Definition: qlocale.cpp:1495

◆ sectionAt()

int QDateTimeEditPrivate::sectionAt ( int  pos) const

Returns the section at index index or NoSection if there are no sections there.

Warning
This function is not part of the public interface.

Definition at line 1828 of file qdatetimeedit.cpp.

Referenced by _q_editorCursorPositionChanged(), and displayText().

1829 {
1830  if (pos < separators.first().size()) {
1831  return (pos == 0 ? FirstSectionIndex : NoSectionIndex);
1832  } else if (displayText().size() - pos < separators.last().size() + 1) {
1833  if (separators.last().size() == 0) {
1834  return sectionNodes.count() - 1;
1835  }
1836  return (pos == displayText().size() ? LastSectionIndex : NoSectionIndex);
1837  }
1839 
1840  for (int i=0; i<sectionNodes.size(); ++i) {
1841  const int tmp = sectionPos(i);
1842  if (pos < tmp + sectionSize(i)) {
1843  return (pos < tmp ? -1 : i);
1844  }
1845  }
1846  return -1;
1847 }
QVector< SectionNode > sectionNodes
Definition: qdatetime_p.h:263
virtual QString displayText() const
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
int sectionSize(int index) const
Returns the size of section s.
Definition: qdatetime.cpp:4943
QStringList separators
Definition: qdatetime_p.h:265
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
int sectionPos(int index) const
Returns the starting position for section s.
Definition: qdatetime.cpp:4689
void updateCache(const QVariant &val, const QString &str) const

◆ setRange()

void QDateTimeEditPrivate::setRange ( const QVariant min,
const QVariant max 
)
virtual

Convenience function to set min/max values.

Warning
This function is not part of the public interface.

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 2560 of file qdatetimeedit.cpp.

Referenced by cursorPosition().

2561 {
2564 }
virtual void setRange(const QVariant &min, const QVariant &max)
Convenience function to set min/max values.

◆ setSelected()

void QDateTimeEditPrivate::setSelected ( int  sectionIndex,
bool  forward = false 
)

Selects the section s.

Warning
This function is not part of the public interface.

If forward is false selects backwards.

Definition at line 1796 of file qdatetimeedit.cpp.

Referenced by _q_editorCursorPositionChanged(), and displayText().

1797 {
1798  if (specialValue()
1799 #ifdef QT_KEYPAD_NAVIGATION
1800  || (QApplication::keypadNavigationEnabled() && !edit->hasEditFocus())
1801 #endif
1802  ) {
1803  edit->selectAll();
1804  } else {
1805  const SectionNode &node = sectionNode(sectionIndex);
1806  if (node.type == NoSection || node.type == LastSection || node.type == FirstSection)
1807  return;
1808 
1810  const int size = sectionSize(sectionIndex);
1811  if (forward) {
1812  edit->setSelection(sectionPos(node), size);
1813  } else {
1814  edit->setSelection(sectionPos(node) + size, -size);
1815  }
1816  }
1817 }
virtual QString displayText() const
int sectionSize(int index) const
Returns the size of section s.
Definition: qdatetime.cpp:4943
void setSelection(int, int)
Selects text from position start and for length characters.
Definition: qlineedit.cpp:1106
const SectionNode & sectionNode(int index) const
Returns the sectionNode for the Section s.
Definition: qdatetime.cpp:4654
void selectAll()
Selects all the text (i.e.
Definition: qlineedit.cpp:1405
int sectionPos(int index) const
Returns the starting position for section s.
Definition: qdatetime.cpp:4689
bool specialValue() const
Returns true if a specialValueText has been set and the current value is minimum. ...
void updateCache(const QVariant &val, const QString &str) const

◆ stepBy()

QDateTime QDateTimeEditPrivate::stepBy ( int  sectionIndex,
int  steps,
bool  test = false 
) const

Internal function called by QDateTimeEdit::stepBy().

Warning
This function is not part of the public interface.

Also takes a Section for which section to step on and a bool test for whether or not to modify the internal cachedDay variable. This is necessary because the function is called from the const function QDateTimeEdit::stepEnabled() as well as QDateTimeEdit::stepBy().

Definition at line 2068 of file qdatetimeedit.cpp.

Referenced by displayText().

2069 {
2070  Q_Q(const QDateTimeEdit);
2071  QDateTime v = value.toDateTime();
2072  QString str = displayText();
2073  int pos = edit->cursorPosition();
2074  const SectionNode sn = sectionNode(sectionIndex);
2075 
2076  int val;
2077  // to make sure it behaves reasonably when typing something and then stepping in non-tracking mode
2078  if (!test && pendingEmit) {
2079  if (q->validate(str, pos) != QValidator::Acceptable) {
2080  v = value.toDateTime();
2081  } else {
2082  v = q->dateTimeFromText(str);
2083  }
2084  val = getDigit(v, sectionIndex);
2085  } else {
2086  val = getDigit(v, sectionIndex);
2087  }
2088 
2089  val += steps;
2090 
2091  const int min = absoluteMin(sectionIndex);
2092  const int max = absoluteMax(sectionIndex, value.toDateTime());
2093 
2094  if (val < min) {
2095  val = (wrapping ? max - (min - val) + 1 : min);
2096  } else if (val > max) {
2097  val = (wrapping ? min + val - max - 1 : max);
2098  }
2099 
2100 
2101  const int oldDay = v.date().day();
2102 
2103  setDigit(v, sectionIndex, val);
2104  // if this sets year or month it will make
2105  // sure that days are lowered if needed.
2106 
2107  const QDateTime minimumDateTime = minimum.toDateTime();
2108  const QDateTime maximumDateTime = maximum.toDateTime();
2109  // changing one section should only modify that section, if possible
2110  if (sn.type != AmPmSection && (v < minimumDateTime || v > maximumDateTime)) {
2111  const int localmin = getDigit(minimumDateTime, sectionIndex);
2112  const int localmax = getDigit(maximumDateTime, sectionIndex);
2113 
2114  if (wrapping) {
2115  // just because we hit the roof in one direction, it
2116  // doesn't mean that we hit the floor in the other
2117  if (steps > 0) {
2118  setDigit(v, sectionIndex, min);
2119  if (!(sn.type & (DaySection|DayOfWeekSection)) && sections & DateSectionMask) {
2120  const int daysInMonth = v.date().daysInMonth();
2121  if (v.date().day() < oldDay && v.date().day() < daysInMonth) {
2122  const int adds = qMin(oldDay, daysInMonth);
2123  v = v.addDays(adds - v.date().day());
2124  }
2125  }
2126 
2127  if (v < minimumDateTime) {
2128  setDigit(v, sectionIndex, localmin);
2129  if (v < minimumDateTime)
2130  setDigit(v, sectionIndex, localmin + 1);
2131  }
2132  } else {
2133  setDigit(v, sectionIndex, max);
2134  if (!(sn.type & (DaySection|DayOfWeekSection)) && sections & DateSectionMask) {
2135  const int daysInMonth = v.date().daysInMonth();
2136  if (v.date().day() < oldDay && v.date().day() < daysInMonth) {
2137  const int adds = qMin(oldDay, daysInMonth);
2138  v = v.addDays(adds - v.date().day());
2139  }
2140  }
2141 
2142  if (v > maximumDateTime) {
2143  setDigit(v, sectionIndex, localmax);
2144  if (v > maximumDateTime)
2145  setDigit(v, sectionIndex, localmax - 1);
2146  }
2147  }
2148  } else {
2149  setDigit(v, sectionIndex, (steps > 0 ? localmax : localmin));
2150  }
2151  }
2152  if (!test && oldDay != v.date().day() && !(sn.type & (DaySection|DayOfWeekSection))) {
2153  // this should not happen when called from stepEnabled
2154  cachedDay = qMax<int>(oldDay, cachedDay);
2155  }
2156 
2157  if (v < minimumDateTime) {
2158  if (wrapping) {
2159  QDateTime t = v;
2160  setDigit(t, sectionIndex, steps < 0 ? max : min);
2161  bool mincmp = (t >= minimumDateTime);
2162  bool maxcmp = (t <= maximumDateTime);
2163  if (!mincmp || !maxcmp) {
2164  setDigit(t, sectionIndex, getDigit(steps < 0
2165  ? maximumDateTime
2166  : minimumDateTime, sectionIndex));
2167  mincmp = (t >= minimumDateTime);
2168  maxcmp = (t <= maximumDateTime);
2169  }
2170  if (mincmp && maxcmp) {
2171  v = t;
2172  }
2173  } else {
2174  v = value.toDateTime();
2175  }
2176  } else if (v > maximumDateTime) {
2177  if (wrapping) {
2178  QDateTime t = v;
2179  setDigit(t, sectionIndex, steps > 0 ? min : max);
2180  bool mincmp = (t >= minimumDateTime);
2181  bool maxcmp = (t <= maximumDateTime);
2182  if (!mincmp || !maxcmp) {
2183  setDigit(t, sectionIndex, getDigit(steps > 0 ?
2184  minimumDateTime :
2185  maximumDateTime, sectionIndex));
2186  mincmp = (t >= minimumDateTime);
2187  maxcmp = (t <= maximumDateTime);
2188  }
2189  if (mincmp && maxcmp) {
2190  v = t;
2191  }
2192  } else {
2193  v = value.toDateTime();
2194  }
2195  }
2196 
2197  const QDateTime ret = bound(v, value, steps).toDateTime().toTimeSpec(spec);
2198  return ret;
2199 }
int absoluteMin(int index) const
Definition: qdatetime.cpp:4623
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int absoluteMax(int index, const QDateTime &value=QDateTime()) const
\
Definition: qdatetime.cpp:4590
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
QDateTimeEdit::Sections sections
int day() const
Returns the day of the month (1 to 31) of this date.
Definition: qdatetime.cpp:395
virtual QString displayText() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483
const SectionNode & sectionNode(int index) const
Returns the sectionNode for the Section s.
Definition: qdatetime.cpp:4654
int getDigit(const QDateTime &dt, int index) const
Gets the digit from a datetime.
Definition: qdatetime.cpp:4469
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
int daysInMonth() const
Returns the number of days in the month (28 to 31) for this date.
Definition: qdatetime.cpp:431
Qt::TimeSpec spec
Definition: qdatetime_p.h:272
QDateTime addDays(int days) const
Returns a QDateTime object containing a datetime ndays days later than the datetime of this object (o...
Definition: qdatetime.cpp:2783
virtual QVariant bound(const QVariant &val, const QVariant &old=QVariant(), int steps=0) const
Bounds val to be within minimum and maximum.
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
bool setDigit(QDateTime &t, int index, int newval) const
Sets a digit in a datetime.
Definition: qdatetime.cpp:4520
QDateTime toTimeSpec(Qt::TimeSpec spec) const
Returns a copy of this datetime configured to use the given time specification.
Definition: qdatetime.cpp:2969
int cursorPosition
the current cursor position for this line edit
Definition: qlineedit.h:77

◆ syncCalendarWidget()

void QDateTimeEditPrivate::syncCalendarWidget ( )

Definition at line 2636 of file qdatetimeedit.cpp.

Referenced by cursorPosition(), emitSignals(), initCalendarPopup(), and setRange().

2637 {
2638  Q_Q(QDateTimeEdit);
2639  if (monthCalendar) {
2640  const bool sb = monthCalendar->blockSignals(true);
2641  monthCalendar->setDateRange(q->minimumDate(), q->maximumDate());
2642  monthCalendar->setDate(q->date());
2644  }
2645 }
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
Definition: qobject.cpp:1406
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483
void setDateRange(const QDate &min, const QDate &max)
void setDate(const QDate &date)
QCalendarPopup * monthCalendar

◆ textFromValue()

QString QDateTimeEditPrivate::textFromValue ( const QVariant f) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 2032 of file qdatetimeedit.cpp.

Referenced by updateEdit(), validateAndInterpret(), and valueToText().

2033 {
2034  Q_Q(const QDateTimeEdit);
2035  return q->textFromDateTime(f.toDateTime());
2036 }
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483

◆ updateArrow()

void QDateTimeEditPrivate::updateArrow ( QStyle::StateFlag  state)

Definition at line 2498 of file qdatetimeedit.cpp.

Referenced by _q_resetButton(), and cursorPosition().

2499 {
2500  Q_Q(QDateTimeEdit);
2501 
2502  if (arrowState == state)
2503  return;
2504  arrowState = state;
2506  buttonState |= Mouse;
2507  else {
2508  buttonState = 0;
2510  }
2511  q->update();
2512 }
QStyle::StateFlag arrowState
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483
QStyle::SubControl hoverControl

◆ updateCache()

void QDateTimeEditPrivate::updateCache ( const QVariant val,
const QString str 
) const
Warning
This function is not part of the public interface.

updates the cached values

Definition at line 1952 of file qdatetimeedit.cpp.

Referenced by _q_editorCursorPositionChanged(), closestSection(), displayText(), emitSignals(), sectionAt(), setSelected(), and validateAndInterpret().

1953 {
1954  if (val != cachedValue || str != cachedText || cacheGuard) {
1955  cacheGuard = true;
1956  QString copy = str;
1957  int unused = edit->cursorPosition();
1958  QValidator::State unusedState;
1959  validateAndInterpret(copy, unused, unusedState);
1960  cacheGuard = false;
1961  }
1962 }
QDateTime validateAndInterpret(QString &input, int &, QValidator::State &state, bool fixup=false) const
The QString class provides a Unicode character string.
Definition: qstring.h:83
void * unused
Definition: qobject_p.h:208
State
This enum type defines the states in which a validated string can exist.
Definition: qvalidator.h:67
int cursorPosition
the current cursor position for this line edit
Definition: qlineedit.h:77

◆ updateEdit()

void QDateTimeEditPrivate::updateEdit ( )
virtual

Updates the line edit to reflect the current value of the spin box.

Warning
This function is not part of the public interface.

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 1755 of file qdatetimeedit.cpp.

Referenced by displayText().

1756 {
1757  const QString newText = (specialValue() ? specialValueText : textFromValue(value));
1758  if (newText == displayText())
1759  return;
1760  int selsize = edit->selectedText().size();
1761  const bool sb = edit->blockSignals(true);
1762 
1763  edit->setText(newText);
1764 
1765  if (!specialValue()
1766 #ifdef QT_KEYPAD_NAVIGATION
1767  && !(QApplication::keypadNavigationEnabled() && !edit->hasEditFocus())
1768 #endif
1769  ) {
1770  int cursor = sectionPos(currentSectionIndex);
1771  QDTEDEBUG << "cursor is " << cursor << currentSectionIndex;
1772  cursor = qBound(0, cursor, displayText().size());
1773  QDTEDEBUG << cursor;
1774  if (selsize > 0) {
1775  edit->setSelection(cursor, selsize);
1776  QDTEDEBUG << cursor << selsize;
1777  } else {
1778  edit->setCursorPosition(cursor);
1779  QDTEDEBUG << cursor;
1780 
1781  }
1782  }
1783  edit->blockSignals(sb);
1784 }
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
Definition: qobject.cpp:1406
virtual QString displayText() const
QString textFromValue(const QVariant &f) const
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define QDTEDEBUG
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
void setSelection(int, int)
Selects text from position start and for length characters.
Definition: qlineedit.cpp:1106
void setText(const QString &)
Definition: qlineedit.cpp:401
QString selectedText
the selected text
Definition: qlineedit.h:81
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
void setCursorPosition(int)
Definition: qlineedit.cpp:758
int sectionPos(int index) const
Returns the starting position for section s.
Definition: qdatetime.cpp:4689
bool specialValue() const
Returns true if a specialValueText has been set and the current value is minimum. ...

◆ updateEditFieldGeometry()

void QDateTimeEditPrivate::updateEditFieldGeometry ( )
virtual

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 2537 of file qdatetimeedit.cpp.

Referenced by cursorPosition().

2538 {
2539  if (!calendarPopupEnabled()) {
2541  return;
2542  }
2543 
2544  Q_Q(QDateTimeEdit);
2545 
2546  QStyleOptionComboBox optCombo;
2547  optCombo.init(q);
2548  optCombo.editable = true;
2550  edit->setGeometry(q->style()->subControlRect(QStyle::CC_ComboBox, &optCombo,
2552 }
void init(const QWidget *w)
Use initFrom(widget) instead.
virtual void updateEditFieldGeometry()
bool editable
whether or not the combobox is editable or not
Definition: qstyleoption.h:802
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483
bool calendarPopupEnabled() const
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693

◆ updateTimeSpec()

void QDateTimeEditPrivate::updateTimeSpec ( )

Definition at line 1739 of file qdatetimeedit.cpp.

Referenced by displayText(), init(), and interpret().

1740 {
1744 
1745  // time zone changes can lead to 00:00:00 becomes 01:00:00 and 23:59:59 becomes 00:59:59 (invalid range)
1746  const bool dateShown = (sections & QDateTimeEdit::DateSections_Mask);
1747  if (!dateShown) {
1748  if (minimum.toTime() >= maximum.toTime()){
1751  }
1752  }
1753 }
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
QDateTimeEdit::Sections sections
#define QDATETIMEEDIT_TIME_MIN
Definition: qdatetime_p.h:67
#define QDATETIMEEDIT_TIME_MAX
Definition: qdatetime_p.h:68
Qt::TimeSpec spec
Definition: qdatetime_p.h:272
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2311
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
QDateTime toTimeSpec(Qt::TimeSpec spec) const
Returns a copy of this datetime configured to use the given time specification.
Definition: qdatetime.cpp:2969
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2330

◆ validateAndInterpret()

QDateTime QDateTimeEditPrivate::validateAndInterpret ( QString input,
int &  position,
QValidator::State state,
bool  fixup = false 
) const
Warning
This function is not part of the public interface.

parses and validates input

Definition at line 1970 of file qdatetimeedit.cpp.

Referenced by updateCache().

1972 {
1973  if (input.isEmpty()) {
1974  if (sectionNodes.size() == 1 || !specialValueText.isEmpty()) {
1975  state = QValidator::Intermediate;
1976  } else {
1977  state = QValidator::Invalid;
1978  }
1979  return getZeroVariant().toDateTime();
1980  } else if (cachedText == input && !fixup) {
1981  state = cachedState;
1982  return cachedValue.toDateTime();
1983  } else if (!specialValueText.isEmpty()) {
1984  bool changeCase = false;
1985  const int max = qMin(specialValueText.size(), input.size());
1986  int i;
1987  for (i=0; i<max; ++i) {
1988  const QChar ic = input.at(i);
1989  const QChar sc = specialValueText.at(i);
1990  if (ic != sc) {
1991  if (sc.toLower() == ic.toLower()) {
1992  changeCase = true;
1993  } else {
1994  break;
1995  }
1996  }
1997  }
1998  if (i == max) {
2000  if (changeCase) {
2001  input = specialValueText.left(max);
2002  }
2003  return minimum.toDateTime();
2004  }
2005  }
2006  StateNode tmp = parse(input, position, value.toDateTime(), fixup);
2007  input = tmp.input;
2008  state = QValidator::State(int(tmp.state));
2009  if (state == QValidator::Acceptable) {
2010  if (tmp.conflicts && conflictGuard != tmp.value) {
2011  conflictGuard = tmp.value;
2012  clearCache();
2013  input = textFromValue(tmp.value);
2014  updateCache(tmp.value, input);
2015  conflictGuard.clear();
2016  } else {
2017  cachedText = input;
2018  cachedState = state;
2019  cachedValue = tmp.value;
2020  }
2021  } else {
2022  clearCache();
2023  }
2024  return (tmp.value.isNull() ? getZeroVariant().toDateTime() : tmp.value);
2025 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
StateNode parse(QString &input, int &cursorPosition, const QDateTime &currentValue, bool fixup) const
Definition: qdatetime.cpp:5271
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
QVector< SectionNode > sectionNodes
Definition: qdatetime_p.h:263
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
QString textFromValue(const QVariant &f) const
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
virtual QVariant getZeroVariant() const
Convenience function to get a variant of the right type.
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
QValidator::State cachedState
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
void clear()
Convert this variant to type Invalid and free up any resources used.
Definition: qvariant.cpp:1993
State
This enum type defines the states in which a validated string can exist.
Definition: qvalidator.h:67
virtual void clearCache() const
QPointer< QInputContext > ic
Definition: qwidget_p.h:717
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1239
void updateCache(const QVariant &val, const QString &str) const

◆ valueFromText()

QVariant QDateTimeEditPrivate::valueFromText ( const QString f) const
virtual

This function's name is slightly confusing; it is not to be confused with QAbstractSpinBox::valueFromText().

Warning
This function is not part of the public interface.

Reimplemented from QAbstractSpinBoxPrivate.

Definition at line 2048 of file qdatetimeedit.cpp.

2049 {
2050  Q_Q(const QDateTimeEdit);
2051  return q->dateTimeFromText(f).toTimeSpec(spec);
2052 }
The QDateTimeEdit class provides a widget for editing dates and times.
Definition: qdatetimeedit.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483
Qt::TimeSpec spec
Definition: qdatetime_p.h:272

◆ valueToText()

QString QDateTimeEditPrivate::valueToText ( const QVariant var) const
inline

Definition at line 109 of file qdatetimeedit_p.h.

109 { return textFromValue(var); }
QString textFromValue(const QVariant &f) const

Properties

◆ arrowState

QStyle::StateFlag QDateTimeEditPrivate::arrowState

Definition at line 137 of file qdatetimeedit_p.h.

Referenced by QDateTimeEditPrivate(), and updateArrow().

◆ cacheGuard

bool QDateTimeEditPrivate::cacheGuard
mutable

Definition at line 132 of file qdatetimeedit_p.h.

Referenced by QDateTimeEditPrivate(), and updateCache().

◆ calendarPopup

bool QDateTimeEditPrivate::calendarPopup

Definition at line 136 of file qdatetimeedit_p.h.

Referenced by calendarPopupEnabled(), and QDateTimeEditPrivate().

◆ conflictGuard

QVariant QDateTimeEditPrivate::conflictGuard
mutable

Definition at line 135 of file qdatetimeedit_p.h.

Referenced by validateAndInterpret().

◆ defaultDateFormat

QString QDateTimeEditPrivate::defaultDateFormat

Definition at line 134 of file qdatetimeedit_p.h.

Referenced by init(), and readLocaleSettings().

◆ defaultDateTimeFormat

QString QDateTimeEditPrivate::defaultDateTimeFormat

Definition at line 134 of file qdatetimeedit_p.h.

Referenced by init(), and readLocaleSettings().

◆ defaultTimeFormat

QString QDateTimeEditPrivate::defaultTimeFormat

Definition at line 134 of file qdatetimeedit_p.h.

Referenced by init(), and readLocaleSettings().

◆ formatExplicitlySet

bool QDateTimeEditPrivate::formatExplicitlySet

Definition at line 136 of file qdatetimeedit_p.h.

Referenced by QDateTimeEditPrivate().

◆ hasHadFocus

bool QDateTimeEditPrivate::hasHadFocus

Definition at line 136 of file qdatetimeedit_p.h.

Referenced by QDateTimeEditPrivate().

◆ monthCalendar

QCalendarPopup* QDateTimeEditPrivate::monthCalendar

◆ sections

QDateTimeEdit::Sections QDateTimeEditPrivate::sections

◆ unreversedFormat

QString QDateTimeEditPrivate::unreversedFormat

Definition at line 134 of file qdatetimeedit_p.h.


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