-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 | |||
@@ -52,325 +52,351 @@ ODateBookMonthTable::ODateBookMonthTable( QWidget *parent, const char *name, | |||
52 | : QTable( 6, 7, parent, name ), | 52 | : QTable( 6, 7, parent, name ), |
53 | db( newDb ) | 53 | db( newDb ) |
54 | { | 54 | { |
55 | d = new ODateBookMonthTablePrivate(); | 55 | d = new ODateBookMonthTablePrivate(); |
56 | selYear = -1; | 56 | selYear = -1; |
57 | selMonth = -1; | 57 | selMonth = -1; |
58 | selDay = -1; | 58 | selDay = -1; |
59 | 59 | ||
60 | /* init these as well make valgrind happy and be consistent with Qtopia1.6 -zecke */ | 60 | /* init these as well make valgrind happy and be consistent with Qtopia1.6 -zecke */ |
61 | year = -1; | 61 | year = -1; |
62 | month = -1; | 62 | month = -1; |
63 | day = -1; | 63 | day = -1; |
64 | 64 | ||
65 | Config cfg( "qpe" ); | 65 | Config cfg( "qpe" ); |
66 | cfg.setGroup( "Time" ); | 66 | cfg.setGroup( "Time" ); |
67 | d->onMonday = cfg.readBoolEntry( "MONDAY" ); | 67 | d->onMonday = cfg.readBoolEntry( "MONDAY" ); |
68 | 68 | ||
69 | horizontalHeader()->setResizeEnabled( FALSE ); | 69 | horizontalHeader()->setResizeEnabled( FALSE ); |
70 | // we have to do this here... or suffer the consequences later... | 70 | // we have to do this here... or suffer the consequences later... |
71 | for ( int i = 0; i < 7; i++ ){ | 71 | for ( int i = 0; i < 7; i++ ){ |
72 | horizontalHeader()->resizeSection( i, 30 ); | 72 | horizontalHeader()->resizeSection( i, 30 ); |
73 | setColumnStretchable( i, TRUE ); | 73 | setColumnStretchable( i, TRUE ); |
74 | } | 74 | } |
75 | setupLabels(); | 75 | setupLabels(); |
76 | 76 | ||
77 | verticalHeader()->hide(); | 77 | verticalHeader()->hide(); |
78 | setLeftMargin( 0 ); | 78 | setLeftMargin( 0 ); |
79 | for ( int i = 0; i < 6; ++i ) | 79 | for ( int i = 0; i < 6; ++i ) |
80 | setRowStretchable( i, TRUE ); | 80 | setRowStretchable( i, TRUE ); |
81 | 81 | ||
82 | setSelectionMode( NoSelection ); | 82 | setSelectionMode( NoSelection ); |
83 | 83 | ||
84 | connect( this, SIGNAL( clicked(int,int,int,const QPoint&) ), | 84 | connect( this, SIGNAL( clicked(int,int,int,const QPoint&) ), |
85 | this, SLOT( dayClicked(int,int) ) ); | 85 | this, SLOT( dayClicked(int,int) ) ); |
86 | connect( this, SIGNAL( currentChanged(int,int) ), | 86 | connect( this, SIGNAL( currentChanged(int,int) ), |
87 | this, SLOT( dragDay(int,int) ) ); | 87 | this, SLOT( dragDay(int,int) ) ); |
88 | setVScrollBarMode( AlwaysOff ); | 88 | setVScrollBarMode( AlwaysOff ); |
89 | setHScrollBarMode( AlwaysOff ); | 89 | setHScrollBarMode( AlwaysOff ); |
90 | } | 90 | } |
91 | 91 | ||
92 | ODateBookMonthTable::~ODateBookMonthTable() | 92 | ODateBookMonthTable::~ODateBookMonthTable() |
93 | { | 93 | { |
94 | monthsEvents.clear(); | 94 | monthsEvents.clear(); |
95 | delete d; | 95 | delete d; |
96 | } | 96 | } |
97 | 97 | ||
98 | void ODateBookMonthTable::setDate(int y, int m, int d) | 98 | void ODateBookMonthTable::setDate(int y, int m, int d) |
99 | { | 99 | { |
100 | if (month == m && year == y) { | 100 | if (month == m && year == y) { |
101 | if ( selYear == -1 ) | 101 | if ( selYear == -1 ) |
102 | year = selYear; | 102 | year = selYear; |
103 | if ( selMonth == -1 ) | 103 | if ( selMonth == -1 ) |
104 | month = selMonth; | 104 | month = selMonth; |
105 | int r1, c1, r2, c2; | 105 | int r1, c1, r2, c2; |
106 | findDay(selDay, r1, c1); | 106 | findDay(selDay, r1, c1); |
107 | selDay = day = d; | 107 | selDay = day = d; |
108 | findDay(selDay, r2, c2); | 108 | findDay(selDay, r2, c2); |
109 | setCurrentCell( r2, c2 ); | 109 | setCurrentCell( r2, c2 ); |
110 | //updateCell(r1,c1); | 110 | //updateCell(r1,c1); |
111 | //updateCell(r2,c2); | 111 | //updateCell(r2,c2); |
112 | } else { | 112 | } else { |
113 | selYear = year = y; | 113 | selYear = year = y; |
114 | selMonth = month = m; | 114 | selMonth = month = m; |
115 | selDay = day = d; | 115 | selDay = day = d; |
116 | setupTable(); | 116 | setupTable(); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | void ODateBookMonthTable::redraw() | 120 | void ODateBookMonthTable::redraw() |
121 | { | 121 | { |
122 | setupLabels(); | 122 | setupLabels(); |
123 | setupTable(); | 123 | setupTable(); |
124 | } | 124 | } |
125 | 125 | ||
126 | void ODateBookMonthTable::setWeekStart( bool onMonday ) | 126 | void ODateBookMonthTable::setWeekStart( bool onMonday ) |
127 | { | 127 | { |
128 | d->onMonday = onMonday; | 128 | d->onMonday = onMonday; |
129 | setupLabels(); | 129 | setupLabels(); |
130 | setupTable(); | 130 | setupTable(); |
131 | } | 131 | } |
132 | 132 | ||
133 | void ODateBookMonthTable::setupTable() | 133 | void ODateBookMonthTable::setupTable() |
134 | { | 134 | { |
135 | QValueList<Calendar::Day> days = Calendar::daysOfMonth( year, month, d->onMonday ); | 135 | QValueList<Calendar::Day> days = Calendar::daysOfMonth( year, month, d->onMonday ); |
136 | QValueList<Calendar::Day>::Iterator it = days.begin(); | 136 | QValueList<Calendar::Day>::Iterator it = days.begin(); |
137 | int row = 0, col = 0; | 137 | int row = 0, col = 0; |
138 | int crow = 0; | 138 | int crow = 0; |
139 | int ccol = 0; | 139 | int ccol = 0; |
140 | for ( ; it != days.end(); ++it ) { | 140 | for ( ; it != days.end(); ++it ) { |
141 | DayItemMonth *i = (DayItemMonth *)item( row, col ); | 141 | DayItemMonth *i = (DayItemMonth *)item( row, col ); |
142 | if ( !i ) { | 142 | if ( !i ) { |
143 | i = new DayItemMonth( this, QTableItem::Never, "" ); | 143 | i = new DayItemMonth( this, QTableItem::Never, "" ); |
144 | setItem( row, col, i ); | 144 | setItem( row, col, i ); |
145 | } | 145 | } |
146 | Calendar::Day calDay = *it; | 146 | Calendar::Day calDay = *it; |
147 | i->clearEffEvents(); | 147 | i->clearEffEvents(); |
148 | i->setDay( calDay.date ); | 148 | i->setDay( calDay.date ); |
149 | i->setType( calDay.type ); | 149 | i->setType( calDay.type ); |
150 | if ( i->day() == day && calDay.type == Calendar::Day::ThisMonth ) { | 150 | if ( i->day() == day && calDay.type == Calendar::Day::ThisMonth ) { |
151 | crow = row; | 151 | crow = row; |
152 | ccol = col; | 152 | ccol = col; |
153 | } | 153 | } |
154 | 154 | ||
155 | updateCell( row, col ); | 155 | updateCell( row, col ); |
156 | 156 | ||
157 | if ( col == 6 ) { | 157 | if ( col == 6 ) { |
158 | ++row; | 158 | ++row; |
159 | col = 0; | 159 | col = 0; |
160 | } else { | 160 | } else { |
161 | ++col; | 161 | ++col; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | setCurrentCell( crow, ccol ); | 164 | setCurrentCell( crow, ccol ); |
165 | getEvents(); | 165 | getEvents(); |
166 | } | 166 | } |
167 | 167 | ||
168 | void ODateBookMonthTable::findDay( int day, int &row, int &col ) | 168 | void ODateBookMonthTable::findDay( int day, int &row, int &col ) |
169 | { | 169 | { |
170 | QDate dtBegin( year, month, 1 ); | 170 | QDate dtBegin( year, month, 1 ); |
171 | int skips = dtBegin.dayOfWeek(); | 171 | int skips = dtBegin.dayOfWeek(); |
172 | int effective_day = day + skips - 1; // row/columns begin at 0 | 172 | int effective_day = day + skips - 1; // row/columns begin at 0 |
173 | // make an extra adjustment if we start on Mondays. | 173 | // make an extra adjustment if we start on Mondays. |
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 | ||
186 | void ODateBookMonthTable::dragDay( int row, int col ) | 202 | 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; |
239 | EffectiveEvent e = *it; | 265 | EffectiveEvent e = *it; |
240 | ++it; | 266 | ++it; |
241 | dayEvent.append( e ); | 267 | dayEvent.append( e ); |
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 | } |
255 | 281 | ||
256 | 282 | ||
257 | void ODateBookMonthTable::setupLabels() | 283 | void ODateBookMonthTable::setupLabels() |
258 | { | 284 | { |
259 | for ( int i = 0; i < 7; ++i ) { | 285 | for ( int i = 0; i < 7; ++i ) { |
260 | // horizontalHeader()->resizeSection( i, 30 ); | 286 | // horizontalHeader()->resizeSection( i, 30 ); |
261 | // setColumnStretchable( i, TRUE ); | 287 | // setColumnStretchable( i, TRUE ); |
262 | if ( d->onMonday ) | 288 | if ( d->onMonday ) |
263 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i + 1 ) ); | 289 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i + 1 ) ); |
264 | else { | 290 | else { |
265 | if ( i == 0 ) | 291 | if ( i == 0 ) |
266 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( 7 ) ); | 292 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( 7 ) ); |
267 | else | 293 | else |
268 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i ) ); | 294 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i ) ); |
269 | } | 295 | } |
270 | } | 296 | } |
271 | } | 297 | } |
272 | 298 | ||
273 | 299 | ||
274 | //--------------------------------------------------------------------------- | 300 | //--------------------------------------------------------------------------- |
275 | 301 | ||
276 | ODateBookMonth::ODateBookMonth( QWidget *parent, const char *name, bool ac, | 302 | ODateBookMonth::ODateBookMonth( QWidget *parent, const char *name, bool ac, |
277 | DateBookDBHoliday *data ) | 303 | DateBookDBHoliday *data ) |
278 | : QVBox( parent, name ), | 304 | : QVBox( parent, name ), |
279 | autoClose( ac ) | 305 | autoClose( ac ) |
280 | { | 306 | { |
281 | setFocusPolicy(StrongFocus); | 307 | setFocusPolicy(StrongFocus); |
282 | year = QDate::currentDate().year(); | 308 | year = QDate::currentDate().year(); |
283 | month = QDate::currentDate().month(); | 309 | month = QDate::currentDate().month(); |
284 | day = QDate::currentDate().day(); | 310 | day = QDate::currentDate().day(); |
285 | header = new DateBookMonthHeader( this, "DateBookMonthHeader" ); | 311 | header = new DateBookMonthHeader( this, "DateBookMonthHeader" ); |
286 | table = new ODateBookMonthTable( this, "DateBookMonthTable", data ); | 312 | table = new ODateBookMonthTable( this, "DateBookMonthTable", data ); |
287 | header->setDate( year, month ); | 313 | header->setDate( year, month ); |
288 | table->setDate( year, month, QDate::currentDate().day() ); | 314 | table->setDate( year, month, QDate::currentDate().day() ); |
289 | header->setFocusPolicy(NoFocus); | 315 | header->setFocusPolicy(NoFocus); |
290 | table->setFocusPolicy(NoFocus); | 316 | table->setFocusPolicy(NoFocus); |
291 | connect( header, SIGNAL( dateChanged(int,int) ), | 317 | connect( header, SIGNAL( dateChanged(int,int) ), |
292 | this, SLOT( setDate(int,int) ) ); | 318 | this, SLOT( setDate(int,int) ) ); |
293 | connect( table, SIGNAL( dateClicked(int,int,int) ), | 319 | connect( table, SIGNAL( dateClicked(int,int,int) ), |
294 | this, SLOT( finalDate(int,int,int) ) ); | 320 | this, SLOT( finalDate(int,int,int) ) ); |
295 | connect( qApp, SIGNAL(weekChanged(bool)), this, | 321 | connect( qApp, SIGNAL(weekChanged(bool)), this, |
296 | SLOT(slotWeekChange(bool)) ); | 322 | SLOT(slotWeekChange(bool)) ); |
297 | table->setFocus(); | 323 | table->setFocus(); |
298 | } | 324 | } |
299 | 325 | ||
300 | ODateBookMonth::~ODateBookMonth() | 326 | ODateBookMonth::~ODateBookMonth() |
301 | { | 327 | { |
302 | 328 | ||
303 | } | 329 | } |
304 | 330 | ||
305 | void ODateBookMonth::setDate( int y, int m ) | 331 | void ODateBookMonth::setDate( int y, int m ) |
306 | { | 332 | { |
307 | /* only change the date if this is a different date, | 333 | /* only change the date if this is a different date, |
308 | * other wise we may mistakenly overide the day */ | 334 | * other wise we may mistakenly overide the day */ |
309 | if ( (y != year) || (m != month) ) { | 335 | if ( (y != year) || (m != month) ) { |
310 | year = y; | 336 | year = y; |
311 | month = m; | 337 | month = m; |
312 | QDate nd( y, m, 1 ); | 338 | QDate nd( y, m, 1 ); |
313 | if ( nd.daysInMonth() < day ) | 339 | if ( nd.daysInMonth() < day ) |
314 | day = nd.daysInMonth(); | 340 | day = nd.daysInMonth(); |
315 | table->setDate( year, month, day ); | 341 | table->setDate( year, month, day ); |
316 | } | 342 | } |
317 | } | 343 | } |
318 | 344 | ||
319 | void ODateBookMonth::setDate( int y, int m, int d ) | 345 | void ODateBookMonth::setDate( int y, int m, int d ) |
320 | { | 346 | { |
321 | header->setDate( y, m); | 347 | header->setDate( y, m); |
322 | table->setDate( y, m, d); | 348 | table->setDate( y, m, d); |
323 | year = y; | 349 | year = y; |
324 | month = m; | 350 | month = m; |
325 | day = d; | 351 | day = d; |
326 | } | 352 | } |
327 | 353 | ||
328 | /* called when we wish to close or pass back the date */ | 354 | /* called when we wish to close or pass back the date */ |
329 | void ODateBookMonth::finalDate(int y, int m, int d) | 355 | void ODateBookMonth::finalDate(int y, int m, int d) |
330 | { | 356 | { |
331 | setDate( y, m, d ); | 357 | setDate( y, m, d ); |
332 | 358 | ||
333 | emit dateClicked(y, m, d); | 359 | emit dateClicked(y, m, d); |
334 | // emit dateClicked(QDate(y, m, d).toString()); | 360 | // emit dateClicked(QDate(y, m, d).toString()); |
335 | 361 | ||
336 | if ( autoClose && parentWidget() ) | 362 | if ( autoClose && parentWidget() ) |
337 | parentWidget()->close(); | 363 | parentWidget()->close(); |
338 | } | 364 | } |
339 | 365 | ||
340 | void ODateBookMonth::setDate( QDate d) | 366 | void ODateBookMonth::setDate( QDate d) |
341 | { | 367 | { |
342 | setDate(d.year(), d.month(), d.day()); | 368 | setDate(d.year(), d.month(), d.day()); |
343 | } | 369 | } |
344 | 370 | ||
345 | void ODateBookMonth::redraw() | 371 | void ODateBookMonth::redraw() |
346 | { | 372 | { |
347 | table->setDate( year, month, day ); | 373 | table->setDate( year, month, day ); |
348 | table->redraw(); | 374 | table->redraw(); |
349 | } | 375 | } |
350 | 376 | ||
351 | QDate ODateBookMonth::selectedDate() const | 377 | QDate ODateBookMonth::selectedDate() const |
352 | { | 378 | { |
353 | if ( !table ) | 379 | if ( !table ) |
354 | return QDate::currentDate(); | 380 | return QDate::currentDate(); |
355 | int y, m, d; | 381 | int y, m, d; |
356 | table->getDate( y, m, d ); | 382 | table->getDate( y, m, d ); |
357 | return QDate( y, m, d ); | 383 | return QDate( y, m, d ); |
358 | } | 384 | } |
359 | 385 | ||
360 | void ODateBookMonth::slotWeekChange( bool startOnMonday ) | 386 | void ODateBookMonth::slotWeekChange( bool startOnMonday ) |
361 | { | 387 | { |
362 | table->setWeekStart( startOnMonday ); | 388 | table->setWeekStart( startOnMonday ); |
363 | } | 389 | } |
364 | 390 | ||
365 | void ODateBookMonth::keyPressEvent( QKeyEvent *e ) | 391 | void ODateBookMonth::keyPressEvent( QKeyEvent *e ) |
366 | { | 392 | { |
367 | switch(e->key()) { | 393 | switch(e->key()) { |
368 | case Key_Up: | 394 | case Key_Up: |
369 | setDate(QDate(year, month, day).addDays(-7)); | 395 | setDate(QDate(year, month, day).addDays(-7)); |
370 | break; | 396 | break; |
371 | case Key_Down: | 397 | case Key_Down: |
372 | setDate(QDate(year, month, day).addDays(7)); | 398 | setDate(QDate(year, month, day).addDays(7)); |
373 | break; | 399 | break; |
374 | case Key_Left: | 400 | case Key_Left: |
375 | setDate(QDate(year, month, day).addDays(-1)); | 401 | setDate(QDate(year, month, day).addDays(-1)); |
376 | break; | 402 | break; |
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 | |||
@@ -1,132 +1,134 @@ | |||
1 | /* this is a straight copy of datemonthview. We can not make child of | 1 | /* this is a straight copy of datemonthview. We can not make child of |
2 | * it 'cause the origin view isn't virtual in any form. | 2 | * it 'cause the origin view isn't virtual in any form. |
3 | */ | 3 | */ |
4 | /********************************************************************** | 4 | /********************************************************************** |
5 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 5 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
6 | ** | 6 | ** |
7 | ** This file is part of the Qtopia Environment. | 7 | ** This file is part of the Qtopia Environment. |
8 | ** | 8 | ** |
9 | ** This file may be distributed and/or modified under the terms of the | 9 | ** This file may be distributed and/or modified under the terms of the |
10 | ** GNU General Public License version 2 as published by the Free Software | 10 | ** GNU General Public License version 2 as published by the Free Software |
11 | ** Foundation and appearing in the file LICENSE.GPL included in the | 11 | ** Foundation and appearing in the file LICENSE.GPL included in the |
12 | ** packaging of this file. | 12 | ** packaging of this file. |
13 | ** | 13 | ** |
14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
16 | ** | 16 | ** |
17 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 17 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
18 | ** | 18 | ** |
19 | ** Contact info@trolltech.com if any conditions of this licensing are | 19 | ** Contact info@trolltech.com if any conditions of this licensing are |
20 | ** not clear to you. | 20 | ** not clear to you. |
21 | ** | 21 | ** |
22 | **********************************************************************/ | 22 | **********************************************************************/ |
23 | #ifndef ODATEBOOKMONTH | 23 | #ifndef ODATEBOOKMONTH |
24 | #define ODATEBOOKMONTH | 24 | #define ODATEBOOKMONTH |
25 | 25 | ||
26 | #include <qtopia/private/event.h> | 26 | #include <qtopia/private/event.h> |
27 | #include <qpe/datebookmonth.h> | 27 | #include <qpe/datebookmonth.h> |
28 | 28 | ||
29 | #include <qvbox.h> | 29 | #include <qvbox.h> |
30 | #include <qhbox.h> | 30 | #include <qhbox.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qvaluelist.h> | 32 | #include <qvaluelist.h> |
33 | #include <qtable.h> | 33 | #include <qtable.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | 36 | ||
37 | #include <qpe/calendar.h> | 37 | #include <qpe/calendar.h> |
38 | #include <qpe/timestring.h> | 38 | #include <qpe/timestring.h> |
39 | 39 | ||
40 | class QToolButton; | 40 | class QToolButton; |
41 | class QComboBox; | 41 | class QComboBox; |
42 | class QSpinBox; | 42 | class QSpinBox; |
43 | class Event; | 43 | class Event; |
44 | class DateBookDB; | 44 | class DateBookDB; |
45 | class DateBookDBHoliday; | 45 | class DateBookDBHoliday; |
46 | 46 | ||
47 | class ODateBookMonthTablePrivate; | 47 | class ODateBookMonthTablePrivate; |
48 | class ODateBookMonthTable : public QTable | 48 | class ODateBookMonthTable : public QTable |
49 | { | 49 | { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | 51 | ||
52 | public: | 52 | public: |
53 | ODateBookMonthTable( QWidget *parent = 0, const char *name = 0, | 53 | ODateBookMonthTable( QWidget *parent = 0, const char *name = 0, |
54 | DateBookDBHoliday *newDb = 0 ); | 54 | DateBookDBHoliday *newDb = 0 ); |
55 | virtual ~ODateBookMonthTable(); | 55 | virtual ~ODateBookMonthTable(); |
56 | void setDate( int y, int m, int d ); | 56 | void setDate( int y, int m, int d ); |
57 | void redraw(); | 57 | void redraw(); |
58 | 58 | ||
59 | QSize minimumSizeHint() const { return sizeHint(); } | 59 | QSize minimumSizeHint() const { return sizeHint(); } |
60 | QSize minimumSize() const { return sizeHint(); } | 60 | QSize minimumSize() const { return sizeHint(); } |
61 | void getDate( int& y, int &m, int &d ) const {y=selYear;m=selMonth;d=selDay;} | 61 | void getDate( int& y, int &m, int &d ) const {y=selYear;m=selMonth;d=selDay;} |
62 | void setWeekStart( bool onMonday ); | 62 | void setWeekStart( bool onMonday ); |
63 | signals: | 63 | signals: |
64 | void dateClicked( int year, int month, int day ); | 64 | void dateClicked( int year, int month, int day ); |
65 | 65 | ||
66 | protected: | 66 | protected: |
67 | virtual void viewportMouseReleaseEvent( QMouseEvent * ); | 67 | virtual void viewportMouseReleaseEvent( QMouseEvent * ); |
68 | 68 | ||
69 | protected slots: | 69 | protected slots: |
70 | 70 | ||
71 | virtual void keyPressEvent(QKeyEvent *e ) { | 71 | virtual void keyPressEvent(QKeyEvent *e ) { |
72 | e->ignore(); | 72 | e->ignore(); |
73 | } | 73 | } |
74 | 74 | ||
75 | private slots: | 75 | private slots: |
76 | void dayClicked( int row, int col ); | 76 | void dayClicked( int row, int col ); |
77 | void dragDay( int row, int col ); | 77 | void dragDay( int row, int col ); |
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; |
92 | }; | 94 | }; |
93 | 95 | ||
94 | class ODateBookMonthPrivate; | 96 | class ODateBookMonthPrivate; |
95 | class ODateBookMonth : public QVBox | 97 | class ODateBookMonth : public QVBox |
96 | { | 98 | { |
97 | Q_OBJECT | 99 | Q_OBJECT |
98 | 100 | ||
99 | public: | 101 | public: |
100 | /* ac = Auto Close */ | 102 | /* ac = Auto Close */ |
101 | ODateBookMonth( QWidget *parent = 0, const char *name = 0, bool ac = FALSE, | 103 | ODateBookMonth( QWidget *parent = 0, const char *name = 0, bool ac = FALSE, |
102 | DateBookDBHoliday *data = 0 ); | 104 | DateBookDBHoliday *data = 0 ); |
103 | virtual ~ODateBookMonth(); | 105 | virtual ~ODateBookMonth(); |
104 | QDate selectedDate() const; | 106 | QDate selectedDate() const; |
105 | 107 | ||
106 | signals: | 108 | signals: |
107 | /* ### FIXME add a signal with QDate -zecke */ | 109 | /* ### FIXME add a signal with QDate -zecke */ |
108 | void dateClicked( int year, int month, int day ); | 110 | void dateClicked( int year, int month, int day ); |
109 | 111 | ||
110 | public slots: | 112 | public slots: |
111 | void setDate( int y, int m ); | 113 | void setDate( int y, int m ); |
112 | void setDate( int y, int m, int d ); | 114 | void setDate( int y, int m, int d ); |
113 | void setDate( QDate ); | 115 | void setDate( QDate ); |
114 | void redraw(); | 116 | void redraw(); |
115 | void slotWeekChange( bool ); | 117 | void slotWeekChange( bool ); |
116 | 118 | ||
117 | protected slots: | 119 | protected slots: |
118 | virtual void keyPressEvent(QKeyEvent *e); | 120 | virtual void keyPressEvent(QKeyEvent *e); |
119 | 121 | ||
120 | private slots: | 122 | private slots: |
121 | void forwardDateClicked( int y, int m, int d ) { emit dateClicked( y, m, d ); } | 123 | void forwardDateClicked( int y, int m, int d ) { emit dateClicked( y, m, d ); } |
122 | void finalDate(int, int, int); | 124 | void finalDate(int, int, int); |
123 | 125 | ||
124 | private: | 126 | private: |
125 | DateBookMonthHeader *header; | 127 | DateBookMonthHeader *header; |
126 | ODateBookMonthTable *table; | 128 | ODateBookMonthTable *table; |
127 | int year, month, day; | 129 | int year, month, day; |
128 | bool autoClose; | 130 | bool autoClose; |
129 | class ODateBookMonthPrivate *d; | 131 | class ODateBookMonthPrivate *d; |
130 | }; | 132 | }; |
131 | 133 | ||
132 | #endif | 134 | #endif |