summaryrefslogtreecommitdiff
authorpaule <paule>2007-01-31 09:30:53 (UTC)
committer paule <paule>2007-01-31 09:30:53 (UTC)
commit6b321230cf24e50b11783b3511a457f22ae79a58 (patch) (unidiff)
tree9d04ba6204bdc7be6b9e4ee2645b00d56a9c6f77
parente9c5c237e27d908c890779215b19c22a3706b614 (diff)
downloadopie-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.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/modules/monthview/odatebookmonth.cpp62
-rw-r--r--core/pim/datebook/modules/monthview/odatebookmonth.h2
2 files changed, 46 insertions, 18 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
@@ -176,8 +176,24 @@ void ODateBookMonthTable::findDay( int day, int &row, int &col )
176 row = effective_day / 7; 176 row = effective_day / 7;
177 col = effective_day % 7; 177 col = effective_day % 7;
178} 178}
179 179
180bool ODateBookMonthTable::findDate( QDate date, int &row, int &col )
181{
182 int rows = numRows();
183 int cols = numCols();
184 for(int r=0;r<rows;r++) {
185 for(int c=0;c<cols;c++) {
186 if(getDateAt(r, c) == date) {
187 row = r;
188 col = c;
189 return true;
190 }
191 }
192 }
193 return false;
194}
195
180void ODateBookMonthTable::dayClicked( int row, int col ) 196void ODateBookMonthTable::dayClicked( int row, int col )
181{ 197{
182 changeDaySelection( row, col ); 198 changeDaySelection( row, col );
183 emit dateClicked( selYear, selMonth, selDay ); 199 emit dateClicked( selYear, selMonth, selDay );
@@ -189,33 +205,44 @@ void ODateBookMonthTable::dragDay( int row, int col )
189} 205}
190 206
191void ODateBookMonthTable::changeDaySelection( int row, int col ) 207void ODateBookMonthTable::changeDaySelection( int row, int col )
192{ 208{
209 QDate selDate = getDateAt( row, col );
210 selYear = selDate.year();
211 selMonth = selDate.month();
212 selDay = selDate.day();
213}
214
215QDate ODateBookMonthTable::getDateAt( int row, int col )
216{
217 int itemMonth, itemYear;
218
193 DayItemMonth *i = (DayItemMonth*)item( row, col ); 219 DayItemMonth *i = (DayItemMonth*)item( row, col );
194 if ( !i ) 220 if ( !i )
195 return; 221 return QDate(1900, 1, 1);
196 switch ( i->type() ) { 222 switch ( i->type() ) {
197 case Calendar::Day::ThisMonth: 223 case Calendar::Day::ThisMonth:
198 selMonth = month; 224 itemMonth = month;
199 break; 225 break;
200 case Calendar::Day::PrevMonth: 226 case Calendar::Day::PrevMonth:
201 selMonth = month-1; 227 itemMonth = month-1;
202 break; 228 break;
203 default: 229 default:
204 selMonth = month+1; 230 itemMonth = month+1;
205 } 231 }
206 232
207 selYear = year; 233 itemYear = year;
208 if ( selMonth <= 0 ) { 234 if ( itemMonth <= 0 ) {
209 selMonth = 12; 235 itemMonth = 12;
210 selYear--; 236 itemYear--;
211 } else if ( selMonth > 12 ) { 237 }
212 selMonth = 1; 238 else if ( itemMonth > 12 ) {
213 selYear++; 239 itemMonth = 1;
240 itemYear++;
214 } 241 }
215 selDay = i->day();
216}
217 242
243 return QDate( itemYear, itemMonth, i->day());
244}
218 245
219void ODateBookMonthTable::viewportMouseReleaseEvent( QMouseEvent * ) 246void ODateBookMonthTable::viewportMouseReleaseEvent( QMouseEvent * )
220{ 247{
221 dayClicked( currentRow(), currentColumn() ); 248 dayClicked( currentRow(), currentColumn() );
@@ -225,12 +252,11 @@ void ODateBookMonthTable::getEvents()
225{ 252{
226 if ( !db ) 253 if ( !db )
227 return; 254 return;
228 255
229 QDate dtStart( year, month, 1 ); 256 QDate dtStart = getDateAt(0,0);
230 d->mMonthEvents = db->getEffectiveEvents( dtStart, 257 QDate dtEnd = getDateAt(numRows()-1, numCols()-1);
231 QDate( year, month, 258 d->mMonthEvents = db->getEffectiveEvents( dtStart, dtEnd);
232 dtStart.daysInMonth() ) );
233 QValueListIterator<EffectiveEvent> it = d->mMonthEvents.begin(); 259 QValueListIterator<EffectiveEvent> it = d->mMonthEvents.begin();
234 // now that the events are sorted, basically go through the list, make 260 // now that the events are sorted, basically go through the list, make
235 // a small list for every day and set it for each item... 261 // a small list for every day and set it for each item...
236 // clear all the items... 262 // clear all the items...
@@ -244,9 +270,9 @@ void ODateBookMonthTable::getEvents()
244 dayEvent.append( *it ); 270 dayEvent.append( *it );
245 ++it; 271 ++it;
246 } 272 }
247 int row, col; 273 int row, col;
248 findDay( e.date().day(), row, col ); 274 findDate( e.date(), row, col );
249 DayItemMonth* w = static_cast<DayItemMonth*>( item( row, col ) ); 275 DayItemMonth* w = static_cast<DayItemMonth*>( item( row, col ) );
250 w->setEvents( dayEvent ); 276 w->setEvents( dayEvent );
251 updateCell( row, col ); 277 updateCell( row, col );
252 dayEvent.clear(); 278 dayEvent.clear();
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
@@ -80,10 +80,12 @@ private:
80 void setupTable(); 80 void setupTable();
81 void setupLabels(); 81 void setupLabels();
82 82
83 void findDay( int day, int &row, int &col ); 83 void findDay( int day, int &row, int &col );
84 bool findDate( QDate date, int &row, int &col );
84 void getEvents(); 85 void getEvents();
85 void changeDaySelection( int row, int col ); 86 void changeDaySelection( int row, int col );
87 QDate getDateAt( int row, int col );
86 88
87 int year, month, day; 89 int year, month, day;
88 int selYear, selMonth, selDay; 90 int selYear, selMonth, selDay;
89 QValueList<Event> monthsEvents; // not used anymore... 91 QValueList<Event> monthsEvents; // not used anymore...