QCalendarWidget: Add reset functions for minimum/maximumDate
QDateTimeEdit has such reset functions for the minimum/maximum range properties, this makes QCalendarWidget consistent with the simpler editors. Fixes: QTBUG-62448 Change-Id: Iabb89f599e4996f00488a885a5b8a009471838b3 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
e3458aac64
commit
51272017a7
@ -2513,6 +2513,11 @@ void QCalendarWidget::setMinimumDate(QDate date)
|
||||
}
|
||||
}
|
||||
|
||||
void QCalendarWidget::clearMinimumDate()
|
||||
{
|
||||
setMinimumDate(QDate::fromJulianDay(1));
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QCalendarWidget::maximumDate
|
||||
\brief the maximum date of the currently specified date range.
|
||||
@ -2564,6 +2569,11 @@ void QCalendarWidget::setMaximumDate(QDate date)
|
||||
}
|
||||
}
|
||||
|
||||
void QCalendarWidget::clearMaximumDate()
|
||||
{
|
||||
setMaximumDate(QDate(9999, 12, 31));
|
||||
}
|
||||
|
||||
/*!
|
||||
Defines a date range by setting the minimumDate and maximumDate
|
||||
properties.
|
||||
|
@ -21,8 +21,8 @@ class Q_WIDGETS_EXPORT QCalendarWidget : public QWidget
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Qt::DayOfWeek)
|
||||
Q_PROPERTY(QDate selectedDate READ selectedDate WRITE setSelectedDate)
|
||||
Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate)
|
||||
Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate)
|
||||
Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate RESET clearMinimumDate)
|
||||
Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate RESET clearMaximumDate)
|
||||
Q_PROPERTY(Qt::DayOfWeek firstDayOfWeek READ firstDayOfWeek WRITE setFirstDayOfWeek)
|
||||
Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible)
|
||||
Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
|
||||
@ -68,9 +68,11 @@ public:
|
||||
|
||||
QDate minimumDate() const;
|
||||
void setMinimumDate(QDate date);
|
||||
void clearMinimumDate();
|
||||
|
||||
QDate maximumDate() const;
|
||||
void setMaximumDate(QDate date);
|
||||
void clearMaximumDate();
|
||||
|
||||
Qt::DayOfWeek firstDayOfWeek() const;
|
||||
void setFirstDayOfWeek(Qt::DayOfWeek dayOfWeek);
|
||||
|
@ -110,11 +110,19 @@ void tst_QCalendarWidget::getSetCheck()
|
||||
object.setSelectedDate(selectedDate);
|
||||
QCOMPARE(minDate, object.selectedDate());
|
||||
QVERIFY(selectedDate != object.selectedDate());
|
||||
object.clearMinimumDate();
|
||||
object.setSelectedDate(selectedDate);
|
||||
QCOMPARE(selectedDate, object.selectedDate());
|
||||
|
||||
//date should not go beyond the maximum.
|
||||
selectedDate = maxDate.addDays(10);
|
||||
object.setSelectedDate(selectedDate);
|
||||
QCOMPARE(maxDate, object.selectedDate());
|
||||
QVERIFY(selectedDate != object.selectedDate());
|
||||
object.clearMaximumDate();
|
||||
object.setSelectedDate(selectedDate);
|
||||
QCOMPARE(selectedDate, object.selectedDate());
|
||||
|
||||
//show today
|
||||
QDate today = QDate::currentDate();
|
||||
object.showToday();
|
||||
|
Loading…
Reference in New Issue
Block a user