author | paule <paule> | 2007-01-31 09:30:53 (UTC) |
---|---|---|
committer | paule <paule> | 2007-01-31 09:30:53 (UTC) |
commit | 6b321230cf24e50b11783b3511a457f22ae79a58 (patch) (side-by-side diff) | |
tree | 9d04ba6204bdc7be6b9e4ee2645b00d56a9c6f77 | |
parent | e9c5c237e27d908c890779215b19c22a3706b614 (diff) | |
download | opie-6b321230cf24e50b11783b3511a457f22ae79a58.zip opie-6b321230cf24e50b11783b3511a457f22ae79a58.tar.gz opie-6b321230cf24e50b11783b3511a457f22ae79a58.tar.bz2 |
Show events on all visible days in the month view, not just those within the current month. Fixes bug #1351.
-rw-r--r-- | core/pim/datebook/modules/monthview/odatebookmonth.cpp | 60 | ||||
-rw-r--r-- | core/pim/datebook/modules/monthview/odatebookmonth.h | 2 |
2 files changed, 45 insertions, 17 deletions
diff --git a/core/pim/datebook/modules/monthview/odatebookmonth.cpp b/core/pim/datebook/modules/monthview/odatebookmonth.cpp index d52a092..e4de279 100644 --- a/core/pim/datebook/modules/monthview/odatebookmonth.cpp +++ b/core/pim/datebook/modules/monthview/odatebookmonth.cpp @@ -179,2 +179,18 @@ void ODateBookMonthTable::findDay( int day, int &row, int &col ) +bool ODateBookMonthTable::findDate( QDate date, int &row, int &col ) +{ + int rows = numRows(); + int cols = numCols(); + for(int r=0;r<rows;r++) { + for(int c=0;c<cols;c++) { + if(getDateAt(r, c) == date) { + row = r; + col = c; + return true; + } + } + } + return false; +} + void ODateBookMonthTable::dayClicked( int row, int col ) @@ -192,27 +208,38 @@ void ODateBookMonthTable::changeDaySelection( int row, int col ) { + QDate selDate = getDateAt( row, col ); + selYear = selDate.year(); + selMonth = selDate.month(); + selDay = selDate.day(); +} + +QDate ODateBookMonthTable::getDateAt( int row, int col ) +{ + int itemMonth, itemYear; + DayItemMonth *i = (DayItemMonth*)item( row, col ); if ( !i ) - return; + return QDate(1900, 1, 1); switch ( i->type() ) { case Calendar::Day::ThisMonth: - selMonth = month; + itemMonth = month; break; case Calendar::Day::PrevMonth: - selMonth = month-1; + itemMonth = month-1; break; default: - selMonth = month+1; + itemMonth = month+1; } - selYear = year; - if ( selMonth <= 0 ) { - selMonth = 12; - selYear--; - } else if ( selMonth > 12 ) { - selMonth = 1; - selYear++; + itemYear = year; + if ( itemMonth <= 0 ) { + itemMonth = 12; + itemYear--; } - selDay = i->day(); + else if ( itemMonth > 12 ) { + itemMonth = 1; + itemYear++; } + return QDate( itemYear, itemMonth, i->day()); +} @@ -228,6 +255,5 @@ void ODateBookMonthTable::getEvents() - QDate dtStart( year, month, 1 ); - d->mMonthEvents = db->getEffectiveEvents( dtStart, - QDate( year, month, - dtStart.daysInMonth() ) ); + QDate dtStart = getDateAt(0,0); + QDate dtEnd = getDateAt(numRows()-1, numCols()-1); + d->mMonthEvents = db->getEffectiveEvents( dtStart, dtEnd); QValueListIterator<EffectiveEvent> it = d->mMonthEvents.begin(); @@ -247,3 +273,3 @@ void ODateBookMonthTable::getEvents() int row, col; - findDay( e.date().day(), row, col ); + findDate( e.date(), row, col ); DayItemMonth* w = static_cast<DayItemMonth*>( item( row, col ) ); diff --git a/core/pim/datebook/modules/monthview/odatebookmonth.h b/core/pim/datebook/modules/monthview/odatebookmonth.h index e967abe..a81a161 100644 --- a/core/pim/datebook/modules/monthview/odatebookmonth.h +++ b/core/pim/datebook/modules/monthview/odatebookmonth.h @@ -83,4 +83,6 @@ private: void findDay( int day, int &row, int &col ); + bool findDate( QDate date, int &row, int &col ); void getEvents(); void changeDaySelection( int row, int col ); + QDate getDateAt( int row, int col ); |