summaryrefslogtreecommitdiff
path: root/src/gui/widgets/qcalendarwidget.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-13 10:08:26 +0100
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-13 10:41:07 +0100
commitf5c5cc585cef8d2d2f77e7d83d7a07c6d70f0d09 (patch)
treece447fc2dabf3640b24acce666a7f44508ba39dd /src/gui/widgets/qcalendarwidget.cpp
parent671fb279defa0a97c38c28dded767f58c67f9dac (diff)
downloadqt4-tools-f5c5cc585cef8d2d2f77e7d83d7a07c6d70f0d09.tar.gz
Fixed: QCalendarWidget::showNextMonth() followed by a click on the navigation button causes it to go to the first possible month
QCalendarWidget::setCurrentPage did not set the current index on the model. This is required in order to get QCalendarWidgetPrivate::getCurrentDate working. (and this is used by the calendar widget to navigate) This intentionaly do not check if the date is inside the minimumDate or maximumDate range. This was possible before, and the autotests tests that behaviour. Task-number: QTBUG-4058 Reviewed-by: Prasanth Ullattil
Diffstat (limited to 'src/gui/widgets/qcalendarwidget.cpp')
-rw-r--r--src/gui/widgets/qcalendarwidget.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/gui/widgets/qcalendarwidget.cpp b/src/gui/widgets/qcalendarwidget.cpp
index 08ed7f6a22..ee536ee43c 100644
--- a/src/gui/widgets/qcalendarwidget.cpp
+++ b/src/gui/widgets/qcalendarwidget.cpp
@@ -2297,7 +2297,21 @@ int QCalendarWidget::monthShown() const
void QCalendarWidget::setCurrentPage(int year, int month)
{
Q_D(QCalendarWidget);
+ QDate currentDate = d->getCurrentDate();
+ int day = currentDate.day();
+ int daysInMonths = QDate(year, month, 1).daysInMonth();
+ if (day > daysInMonths)
+ day = daysInMonths;
+
d->showMonth(year, month);
+
+ QDate newDate(year, month, day);
+ int row = -1, col = -1;
+ d->m_model->cellForDate(newDate, &row, &col);
+ if (row != -1 && col != -1) {
+ d->m_view->selectionModel()->setCurrentIndex(d->m_model->index(row, col),
+ QItemSelectionModel::NoUpdate);
+ }
}
/*!