From 6b321230cf24e50b11783b3511a457f22ae79a58 Mon Sep 17 00:00:00 2001 From: paule Date: Wed, 31 Jan 2007 09:30:53 +0000 Subject: Show events on all visible days in the month view, not just those within the current month. Fixes bug #1351. --- (limited to 'core') 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 @@ -177,6 +177,22 @@ void ODateBookMonthTable::findDay( int day, int &row, int &col ) col = effective_day % 7; } +bool ODateBookMonthTable::findDate( QDate date, int &row, int &col ) +{ + int rows = numRows(); + int cols = numCols(); + for(int r=0;rtype() ) { 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--; + } + else if ( itemMonth > 12 ) { + itemMonth = 1; + itemYear++; } - selDay = i->day(); -} + return QDate( itemYear, itemMonth, i->day()); +} void ODateBookMonthTable::viewportMouseReleaseEvent( QMouseEvent * ) { @@ -226,10 +253,9 @@ void ODateBookMonthTable::getEvents() if ( !db ) return; - 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 it = d->mMonthEvents.begin(); // now that the events are sorted, basically go through the list, make // a small list for every day and set it for each item... @@ -245,7 +271,7 @@ void ODateBookMonthTable::getEvents() ++it; } int row, col; - findDay( e.date().day(), row, col ); + findDate( e.date(), row, col ); DayItemMonth* w = static_cast( item( row, col ) ); w->setEvents( dayEvent ); updateCell( 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 @@ -81,8 +81,10 @@ private: void setupLabels(); 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 ); int year, month, day; int selYear, selMonth, selDay; -- cgit v0.9.0.2