-rw-r--r-- | microkde/kdatetbl.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp index 146291b..508ce31 100644 --- a/microkde/kdatetbl.cpp +++ b/microkde/kdatetbl.cpp | |||
@@ -323,60 +323,63 @@ KDateTable::contentsMousePressEvent(QMouseEvent *e) | |||
323 | { | 323 | { |
324 | if(e->type()!=QEvent::MouseButtonPress) | 324 | if(e->type()!=QEvent::MouseButtonPress) |
325 | { // the KDatePicker only reacts on mouse press events: | 325 | { // the KDatePicker only reacts on mouse press events: |
326 | return; | 326 | return; |
327 | } | 327 | } |
328 | if(!isEnabled()) | 328 | if(!isEnabled()) |
329 | { | 329 | { |
330 | KNotifyClient::beep(); | 330 | KNotifyClient::beep(); |
331 | return; | 331 | return; |
332 | } | 332 | } |
333 | 333 | ||
334 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | 334 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; |
335 | // ----- | 335 | // ----- |
336 | int row, col, pos, temp; | 336 | int row, col, pos, temp; |
337 | QPoint mouseCoord; | 337 | QPoint mouseCoord; |
338 | // ----- | 338 | // ----- |
339 | mouseCoord = e->pos(); | 339 | mouseCoord = e->pos(); |
340 | row=rowAt(mouseCoord.y()); | 340 | row=rowAt(mouseCoord.y()); |
341 | col=columnAt(mouseCoord.x()); | 341 | col=columnAt(mouseCoord.x()); |
342 | if(row<0 || col<0) | 342 | if(row<0 || col<0) |
343 | { // the user clicked on the frame of the table | 343 | { // the user clicked on the frame of the table |
344 | return; | 344 | return; |
345 | } | 345 | } |
346 | pos=7*(row-1)+col+1; | 346 | pos=7*(row-1)+col+1; |
347 | #if 0 | ||
347 | if(pos+dayoff<=firstday) | 348 | if(pos+dayoff<=firstday) |
348 | { // this day is in the previous month | 349 | { // this day is in the previous month |
349 | KNotifyClient::beep(); | 350 | KNotifyClient::beep(); |
350 | return; | 351 | return; |
351 | } | 352 | } |
352 | if(firstday+numdays<pos+dayoff) | 353 | if(firstday+numdays<pos+dayoff) |
353 | { // this date is in the next month | 354 | { // this date is in the next month |
354 | KNotifyClient::beep(); | 355 | KNotifyClient::beep(); |
355 | return; | 356 | return; |
356 | } | 357 | } |
358 | #endif | ||
357 | temp=firstday+date.day()-dayoff-1; | 359 | temp=firstday+date.day()-dayoff-1; |
358 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); | 360 | QDate da = QDate(date.year(), date.month(),1); |
361 | setDate(da.addDays( pos-firstday+dayoff-1)); | ||
359 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | 362 | updateCell(temp/7+1, temp%7); // Update the previously selected cell |
360 | updateCell(row, col); // Update the selected cell | 363 | updateCell(row, col); // Update the selected cell |
361 | // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | 364 | // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); |
362 | emit(tableClicked()); | 365 | emit(tableClicked()); |
363 | } | 366 | } |
364 | 367 | ||
365 | bool | 368 | bool |
366 | KDateTable::setDate(const QDate& date_) | 369 | KDateTable::setDate(const QDate& date_) |
367 | { | 370 | { |
368 | bool changed=false; | 371 | bool changed=false; |
369 | QDate temp; | 372 | QDate temp; |
370 | mMarkCurrent = false; | 373 | mMarkCurrent = false; |
371 | // ----- | 374 | // ----- |
372 | if(!date_.isValid()) | 375 | if(!date_.isValid()) |
373 | { | 376 | { |
374 | kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; | 377 | kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; |
375 | return false; | 378 | return false; |
376 | } | 379 | } |
377 | if(date!=date_) | 380 | if(date!=date_) |
378 | { | 381 | { |
379 | date=date_; | 382 | date=date_; |
380 | changed=true; | 383 | changed=true; |
381 | } | 384 | } |
382 | mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); | 385 | mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); |