author | paule <paule> | 2007-01-31 09:30:53 (UTC) |
---|---|---|
committer | paule <paule> | 2007-01-31 09:30:53 (UTC) |
commit | 6b321230cf24e50b11783b3511a457f22ae79a58 (patch) (unidiff) | |
tree | 9d04ba6204bdc7be6b9e4ee2645b00d56a9c6f77 /core/pim/datebook/modules | |
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 | 62 | ||||
-rw-r--r-- | core/pim/datebook/modules/monthview/odatebookmonth.h | 2 |
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 | |||
@@ -174,12 +174,28 @@ void ODateBookMonthTable::findDay( int day, int &row, int &col ) | |||
174 | if ( d->onMonday ) | 174 | if ( d->onMonday ) |
175 | effective_day--; | 175 | effective_day--; |
176 | row = effective_day / 7; | 176 | row = effective_day / 7; |
177 | col = effective_day % 7; | 177 | col = effective_day % 7; |
178 | } | 178 | } |
179 | 179 | ||
180 | bool 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 | |||
180 | void ODateBookMonthTable::dayClicked( int row, int col ) | 196 | void 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 ); |
184 | } | 200 | } |
185 | 201 | ||
@@ -187,52 +203,62 @@ void ODateBookMonthTable::dragDay( int row, int col ) | |||
187 | { | 203 | { |
188 | changeDaySelection( row, col ); | 204 | changeDaySelection( row, col ); |
189 | } | 205 | } |
190 | 206 | ||
191 | void ODateBookMonthTable::changeDaySelection( int row, int col ) | 207 | void 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 | |||
215 | QDate 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 | ||
219 | void ODateBookMonthTable::viewportMouseReleaseEvent( QMouseEvent * ) | 246 | void ODateBookMonthTable::viewportMouseReleaseEvent( QMouseEvent * ) |
220 | { | 247 | { |
221 | dayClicked( currentRow(), currentColumn() ); | 248 | dayClicked( currentRow(), currentColumn() ); |
222 | } | 249 | } |
223 | 250 | ||
224 | void ODateBookMonthTable::getEvents() | 251 | 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... |
237 | while ( it != d->mMonthEvents.end() ) { | 263 | while ( it != d->mMonthEvents.end() ) { |
238 | QValueList<EffectiveEvent> dayEvent; | 264 | QValueList<EffectiveEvent> dayEvent; |
@@ -242,13 +268,13 @@ void ODateBookMonthTable::getEvents() | |||
242 | while ( it != d->mMonthEvents.end() | 268 | while ( it != d->mMonthEvents.end() |
243 | && e.date() == (*it).date() ) { | 269 | && e.date() == (*it).date() ) { |
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(); |
253 | } | 279 | } |
254 | } | 280 | } |
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 | |||
@@ -78,14 +78,16 @@ private slots: | |||
78 | 78 | ||
79 | private: | 79 | 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... |
90 | DateBookDBHoliday *db; | 92 | DateBookDBHoliday *db; |
91 | ODateBookMonthTablePrivate *d; | 93 | ODateBookMonthTablePrivate *d; |