src/gui/widgets/qcalendarwidget.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
  2295 */
  2295 */
  2296 
  2296 
  2297 void QCalendarWidget::setCurrentPage(int year, int month)
  2297 void QCalendarWidget::setCurrentPage(int year, int month)
  2298 {
  2298 {
  2299     Q_D(QCalendarWidget);
  2299     Q_D(QCalendarWidget);
       
  2300     QDate currentDate = d->getCurrentDate();
       
  2301     int day = currentDate.day();
       
  2302     int daysInMonths = QDate(year, month, 1).daysInMonth();
       
  2303     if (day > daysInMonths)
       
  2304         day = daysInMonths;
       
  2305 
  2300     d->showMonth(year, month);
  2306     d->showMonth(year, month);
       
  2307 
       
  2308     QDate newDate(year, month, day);
       
  2309     int row = -1, col = -1;
       
  2310     d->m_model->cellForDate(newDate, &row, &col);
       
  2311     if (row != -1 && col != -1) {
       
  2312         d->m_view->selectionModel()->setCurrentIndex(d->m_model->index(row, col),
       
  2313                                                   QItemSelectionModel::NoUpdate);
       
  2314     }
  2301 }
  2315 }
  2302 
  2316 
  2303 /*!
  2317 /*!
  2304     Shows the next month relative to the currently displayed
  2318     Shows the next month relative to the currently displayed
  2305     month. Note that the selected date is not changed.
  2319     month. Note that the selected date is not changed.