src/gui/widgets/qcalendarwidget.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
--- a/src/gui/widgets/qcalendarwidget.cpp	Tue Jan 26 12:42:25 2010 +0200
+++ b/src/gui/widgets/qcalendarwidget.cpp	Tue Feb 02 00:43:10 2010 +0200
@@ -2297,7 +2297,21 @@
 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);
+    }
 }
 
 /*!