summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qdatetimeedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/qdatetimeedit.cpp')
-rw-r--r--src/gui/widgets/qdatetimeedit.cpp51
1 files changed, 22 insertions, 29 deletions
diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp
index d0a90a0..e875701 100644
--- a/src/gui/widgets/qdatetimeedit.cpp
+++ b/src/gui/widgets/qdatetimeedit.cpp
@@ -1,4 +1,4 @@
-/****************************************************************************)
+/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
@@ -75,7 +75,7 @@ QT_BEGIN_NAMESPACE
\brief The QDateTimeEdit class provides a widget for editing dates and times.
\ingroup basicwidgets
- \mainclass
+
QDateTimeEdit allows the user to edit dates by using the keyboard or
the arrow keys to increase and decrease date and time values. The
@@ -220,6 +220,9 @@ QDateTimeEdit::QDateTimeEdit(const QVariant &var, QVariant::Type parserType, QWi
\property QDateTimeEdit::dateTime
\brief the QDateTime that is set in the QDateTimeEdit
+ When setting this property the timespec of the QDateTimeEdit remains the same
+ and the timespec of the new QDateTime is ignored.
+
By default, this property contains a date that refers to January 1,
2000 and a time of 00:00:00 and 0 milliseconds.
@@ -239,7 +242,7 @@ void QDateTimeEdit::setDateTime(const QDateTime &datetime)
d->clearCache();
if (!(d->sections & DateSections_Mask))
setDateRange(datetime.date(), datetime.date());
- d->setValue(QVariant(datetime), EmitIfChanged);
+ d->setValue(QDateTime(datetime.date(), datetime.time(), d->spec), EmitIfChanged);
}
}
@@ -932,9 +935,6 @@ void QDateTimeEdit::setCalendarPopup(bool enable)
\property QDateTimeEdit::timeSpec
\brief the current timespec used by the date time edit.
\since 4.4
-
- All dates/passed to the date time edit will be converted to this
- timespec.
*/
Qt::TimeSpec QDateTimeEdit::timeSpec() const
@@ -1086,10 +1086,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event)
//hide cursor
d->edit->d_func()->setCursorVisible(false);
- if (d->edit->d_func()->cursorTimer > 0)
- killTimer(d->edit->d_func()->cursorTimer);
- d->edit->d_func()->cursorTimer = 0;
-
+ d->edit->d_func()->control->setCursorBlinkPeriod(0);
d->setSelected(0);
}
}
@@ -1110,10 +1107,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event)
//hide cursor
d->edit->d_func()->setCursorVisible(false);
- if (d->edit->d_func()->cursorTimer > 0)
- killTimer(d->edit->d_func()->cursorTimer);
- d->edit->d_func()->cursorTimer = 0;
-
+ d->edit->d_func()->control->setCursorBlinkPeriod(0);
d->setSelected(0);
oldCurrent = 0;
}
@@ -1126,23 +1120,25 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event)
case Qt::Key_Left:
case Qt::Key_Right:
if (event->key() == Qt::Key_Left || event->key() == Qt::Key_Right) {
+ if (
#ifdef QT_KEYPAD_NAVIGATION
- if (!QApplication::keypadNavigationEnabled() || !hasEditFocus()) {
- select = false;
- break;
- }
-#else
- if (!(event->modifiers() & Qt::ControlModifier)) {
+ QApplication::keypadNavigationEnabled() && !hasEditFocus()
+ || !QApplication::keypadNavigationEnabled() &&
+#endif
+ !(event->modifiers() & Qt::ControlModifier)) {
select = false;
break;
}
#ifdef Q_WS_MAC
- else {
+ else
+#ifdef QT_KEYPAD_NAVIGATION
+ if (!QApplication::keypadNavigationEnabled())
+#endif
+ {
select = (event->modifiers() & Qt::ShiftModifier);
break;
}
#endif
-#endif // QT_KEYPAD_NAVIGATION
}
// else fall through
case Qt::Key_Backtab:
@@ -1510,7 +1506,7 @@ void QDateTimeEdit::mousePressEvent(QMouseEvent *event)
the QDateTimeEdit widget.
\ingroup basicwidgets
- \mainclass
+
Many of the properties and functions provided by QTimeEdit are implemented in
QDateTimeEdit. The following properties are most relevant to users of this
@@ -1572,7 +1568,7 @@ QTimeEdit::QTimeEdit(const QTime &time, QWidget *parent)
the QDateTimeEdit widget.
\ingroup basicwidgets
- \mainclass
+
Many of the properties and functions provided by QDateEdit are implemented in
QDateTimeEdit. The following properties are most relevant to users of this
@@ -1647,7 +1643,6 @@ QDateTimeEditPrivate::QDateTimeEditPrivate()
cachedDay = -1;
currentSectionIndex = FirstSectionIndex;
- layoutDirection = QApplication::layoutDirection();
first.type = FirstSection;
last.type = LastSection;
none.type = NoSection;
@@ -1934,7 +1929,6 @@ QDateTime QDateTimeEditPrivate::validateAndInterpret(QString &input, int &positi
/*!
\internal
- \reimp
*/
QString QDateTimeEditPrivate::textFromValue(const QVariant &f) const
@@ -1945,7 +1939,6 @@ QString QDateTimeEditPrivate::textFromValue(const QVariant &f) const
/*!
\internal
- \reimp
This function's name is slightly confusing; it is not to be confused
with QAbstractSpinBox::valueFromText().
@@ -2103,7 +2096,6 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c
/*!
\internal
- \reimp
*/
void QDateTimeEditPrivate::emitSignals(EmitPolicy ep, const QVariant &old)
@@ -2133,7 +2125,6 @@ void QDateTimeEditPrivate::emitSignals(EmitPolicy ep, const QVariant &old)
/*!
\internal
- \reimp
*/
void QDateTimeEditPrivate::_q_editorCursorPositionChanged(int oldpos, int newpos)
@@ -2278,6 +2269,7 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event)
optCombo.init(this);
optCombo.editable = true;
+ optCombo.frame = opt.frame;
optCombo.subControls = opt.subControls;
optCombo.activeSubControls = opt.activeSubControls;
optCombo.state = opt.state;
@@ -2390,6 +2382,7 @@ void QDateTimeEditPrivate::init(const QVariant &var)
q->setCalendarPopup(true);
#endif
updateTimeSpec();
+ q->setInputMethodHints(Qt::ImhPreferNumbers);
setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem);
}