author | zautrix <zautrix> | 2005-04-01 18:10:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-01 18:10:09 (UTC) |
commit | edc032c21ae3788d02a632ea8066e4ac5a4feedb (patch) (unidiff) | |
tree | 8e59c8dcf1cc3021694025627d36e152f7adc389 /korganizer/kodaymatrix.cpp | |
parent | 5d88f92b76a760f100384ea5fa6ed143088d19bb (diff) | |
download | kdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.zip kdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.tar.gz kdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.tar.bz2 |
fixes
-rw-r--r-- | korganizer/kodaymatrix.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index dfc6af7..c55f7d7 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -243,97 +243,98 @@ KODayMatrix::~KODayMatrix() | |||
243 | // delete mKODaymatrixWhatsThis; | 243 | // delete mKODaymatrixWhatsThis; |
244 | delete [] days; | 244 | delete [] days; |
245 | delete [] daylbls; | 245 | delete [] daylbls; |
246 | //delete [] events; | 246 | //delete [] events; |
247 | delete mToolTip; | 247 | delete mToolTip; |
248 | } | 248 | } |
249 | 249 | ||
250 | /* | 250 | /* |
251 | void KODayMatrix::setStartDate(QDate start) | 251 | void KODayMatrix::setStartDate(QDate start) |
252 | { | 252 | { |
253 | updateView(start); | 253 | updateView(start); |
254 | } | 254 | } |
255 | */ | 255 | */ |
256 | 256 | ||
257 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 257 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
258 | { | 258 | { |
259 | 259 | ||
260 | if (mSelStart == NOSELECTION) { | 260 | if (mSelStart == NOSELECTION) { |
261 | return; | 261 | return; |
262 | } | 262 | } |
263 | 263 | ||
264 | //cope with selection being out of matrix limits at top (< 0) | 264 | //cope with selection being out of matrix limits at top (< 0) |
265 | int i0 = mSelStart; | 265 | int i0 = mSelStart; |
266 | if (i0 < 0) { | 266 | if (i0 < 0) { |
267 | for (int i = i0; i < 0; i++) { | 267 | for (int i = i0; i < 0; i++) { |
268 | selDays.append(days[0].addDays(i)); | 268 | selDays.append(days[0].addDays(i)); |
269 | } | 269 | } |
270 | i0 = 0; | 270 | i0 = 0; |
271 | } | 271 | } |
272 | 272 | ||
273 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 273 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
274 | if (mSelEnd > NUMDAYS-1) { | 274 | if (mSelEnd > NUMDAYS-1) { |
275 | for (int i = i0; i <= NUMDAYS-1; i++) { | 275 | for (int i = i0; i <= NUMDAYS-1; i++) { |
276 | selDays.append(days[i]); | 276 | selDays.append(days[i]); |
277 | } | 277 | } |
278 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 278 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
279 | selDays.append(days[0].addDays(i)); | 279 | selDays.append(days[0].addDays(i)); |
280 | } | 280 | } |
281 | 281 | ||
282 | // apply normal routine to selection being entirely within matrix limits | 282 | // apply normal routine to selection being entirely within matrix limits |
283 | } else { | 283 | } else { |
284 | for (int i = i0; i <= mSelEnd; i++) { | 284 | for (int i = i0; i <= mSelEnd; i++) { |
285 | selDays.append(days[i]); | 285 | selDays.append(days[i]); |
286 | } | 286 | } |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 290 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
291 | { | 291 | { |
292 | mRedrawNeeded = true; | ||
292 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); | 293 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); |
293 | mSelStart = startdate.daysTo(start); | 294 | mSelStart = startdate.daysTo(start); |
294 | if ( mSelStart < 0 ) | 295 | if ( mSelStart < 0 ) |
295 | mSelStart = 0; | 296 | mSelStart = 0; |
296 | mSelEnd = startdate.daysTo(end); | 297 | mSelEnd = startdate.daysTo(end); |
297 | if ( mSelEnd > NUMDAYS-1 ) | 298 | if ( mSelEnd > NUMDAYS-1 ) |
298 | mSelEnd = NUMDAYS-1; | 299 | mSelEnd = NUMDAYS-1; |
299 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { | 300 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { |
300 | clearSelection(); | 301 | clearSelection(); |
301 | if ( noSel ) | 302 | if ( noSel ) |
302 | return false; | 303 | return false; |
303 | } | 304 | } |
304 | 305 | ||
305 | return true; | 306 | return true; |
306 | } | 307 | } |
307 | void KODayMatrix::clearSelection() | 308 | void KODayMatrix::clearSelection() |
308 | { | 309 | { |
309 | mSelEnd = mSelStart = NOSELECTION; | 310 | mSelEnd = mSelStart = NOSELECTION; |
310 | } | 311 | } |
311 | 312 | ||
312 | 313 | ||
313 | void KODayMatrix::recalculateToday() | 314 | void KODayMatrix::recalculateToday() |
314 | { | 315 | { |
315 | today = -1; | 316 | today = -1; |
316 | for (int i=0; i<NUMDAYS; i++) { | 317 | for (int i=0; i<NUMDAYS; i++) { |
317 | //events[i] = 0; | 318 | //events[i] = 0; |
318 | days[i] = startdate.addDays(i); | 319 | days[i] = startdate.addDays(i); |
319 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 320 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
320 | 321 | ||
321 | // if today is in the currently displayed month, hilight today | 322 | // if today is in the currently displayed month, hilight today |
322 | if (days[i].year() == QDate::currentDate().year() && | 323 | if (days[i].year() == QDate::currentDate().year() && |
323 | days[i].month() == QDate::currentDate().month() && | 324 | days[i].month() == QDate::currentDate().month() && |
324 | days[i].day() == QDate::currentDate().day()) { | 325 | days[i].day() == QDate::currentDate().day()) { |
325 | today = i; | 326 | today = i; |
326 | } | 327 | } |
327 | } | 328 | } |
328 | // qDebug(QString("Today is visible at %1.").arg(today)); | 329 | // qDebug(QString("Today is visible at %1.").arg(today)); |
329 | } | 330 | } |
330 | 331 | ||
331 | void KODayMatrix::updateView() | 332 | void KODayMatrix::updateView() |
332 | { | 333 | { |
333 | updateView(startdate); | 334 | updateView(startdate); |
334 | } | 335 | } |
335 | void KODayMatrix::repaintViewTimed() | 336 | void KODayMatrix::repaintViewTimed() |
336 | { | 337 | { |
337 | mRepaintTimer->stop(); | 338 | mRepaintTimer->stop(); |
338 | repaint(false); | 339 | repaint(false); |
339 | } | 340 | } |
@@ -465,142 +466,145 @@ void KODayMatrix::updateEvents() | |||
465 | } | 466 | } |
466 | 467 | ||
467 | const QDate& KODayMatrix::getDate(int offset) | 468 | const QDate& KODayMatrix::getDate(int offset) |
468 | { | 469 | { |
469 | if (offset < 0 || offset > NUMDAYS-1) { | 470 | if (offset < 0 || offset > NUMDAYS-1) { |
470 | qDebug("Wrong offset2 %d", offset); | 471 | qDebug("Wrong offset2 %d", offset); |
471 | return days[0]; | 472 | return days[0]; |
472 | } | 473 | } |
473 | return days[offset]; | 474 | return days[offset]; |
474 | } | 475 | } |
475 | 476 | ||
476 | QString KODayMatrix::getHolidayLabel(int offset) | 477 | QString KODayMatrix::getHolidayLabel(int offset) |
477 | { | 478 | { |
478 | if (offset < 0 || offset > NUMDAYS-1) { | 479 | if (offset < 0 || offset > NUMDAYS-1) { |
479 | qDebug("Wrong offset1 %d", offset); | 480 | qDebug("Wrong offset1 %d", offset); |
480 | return QString(); | 481 | return QString(); |
481 | } | 482 | } |
482 | return mHolidays[offset]; | 483 | return mHolidays[offset]; |
483 | } | 484 | } |
484 | 485 | ||
485 | int KODayMatrix::getDayIndexFrom(int x, int y) | 486 | int KODayMatrix::getDayIndexFrom(int x, int y) |
486 | { | 487 | { |
487 | int colModulo = (width()-2) % 7; | 488 | int colModulo = (width()-2) % 7; |
488 | int rowModulo = (height()-2) % 6; | 489 | int rowModulo = (height()-2) % 6; |
489 | #if 0 | 490 | #if 0 |
490 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 491 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
491 | 6 - x/daysize.width() : x/daysize.width()); | 492 | 6 - x/daysize.width() : x/daysize.width()); |
492 | #endif | 493 | #endif |
493 | int xVal = (x-colModulo/2-2)/daysize.width(); | 494 | int xVal = (x-colModulo/2-2)/daysize.width(); |
494 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 495 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
495 | 496 | ||
496 | 497 | ||
497 | return 7*(yVal) + xVal; | 498 | return 7*(yVal) + xVal; |
498 | 499 | ||
499 | } | 500 | } |
500 | 501 | ||
501 | // ---------------------------------------------------------------------------- | 502 | // ---------------------------------------------------------------------------- |
502 | // M O U S E E V E N T H A N D L I N G | 503 | // M O U S E E V E N T H A N D L I N G |
503 | // ---------------------------------------------------------------------------- | 504 | // ---------------------------------------------------------------------------- |
504 | 505 | ||
505 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 506 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
506 | { | 507 | { |
507 | 508 | ||
508 | if ( e->button() == LeftButton ) | 509 | if ( e->button() == LeftButton ) |
509 | mouseDown = true; | 510 | mouseDown = true; |
510 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 511 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
511 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 512 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
512 | mSelInit = mSelStart; | 513 | mSelInit = mSelStart; |
513 | mSelEnd = mSelStart; | 514 | mSelEnd = mSelStart; |
515 | mRedrawNeeded = true; | ||
514 | repaint(false); | 516 | repaint(false); |
515 | } | 517 | } |
516 | 518 | ||
517 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 519 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
518 | { | 520 | { |
521 | mRedrawNeeded = true; | ||
519 | if ( e->button() == LeftButton ) | 522 | if ( e->button() == LeftButton ) |
520 | if ( ! mouseDown ) { | 523 | if ( ! mouseDown ) { |
521 | return; | 524 | return; |
522 | } | 525 | } |
523 | else | 526 | else |
524 | mouseDown = false; | 527 | mouseDown = false; |
525 | int tmp = getDayIndexFrom(e->x(), e->y()); | 528 | int tmp = getDayIndexFrom(e->x(), e->y()); |
526 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 529 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
527 | 530 | ||
528 | if (mSelInit > tmp) { | 531 | if (mSelInit > tmp) { |
529 | mSelEnd = mSelInit; | 532 | mSelEnd = mSelInit; |
530 | if (tmp != mSelStart) { | 533 | if (tmp != mSelStart) { |
531 | mSelStart = tmp; | 534 | mSelStart = tmp; |
532 | repaint(false); | 535 | repaint(false); |
533 | } | 536 | } |
534 | } else { | 537 | } else { |
535 | mSelStart = mSelInit; | 538 | mSelStart = mSelInit; |
536 | 539 | ||
537 | //repaint only if selection has changed | 540 | //repaint only if selection has changed |
538 | if (tmp != mSelEnd) { | 541 | if (tmp != mSelEnd) { |
539 | mSelEnd = tmp; | 542 | mSelEnd = tmp; |
540 | repaint(false); | 543 | repaint(false); |
541 | } | 544 | } |
542 | } | 545 | } |
543 | 546 | ||
544 | DateList daylist; | 547 | DateList daylist; |
545 | if ( mSelStart < 0 ) | 548 | if ( mSelStart < 0 ) |
546 | mSelStart = 0; | 549 | mSelStart = 0; |
547 | for (int i = mSelStart; i <= mSelEnd; i++) { | 550 | for (int i = mSelStart; i <= mSelEnd; i++) { |
548 | daylist.append(days[i]); | 551 | daylist.append(days[i]); |
549 | } | 552 | } |
550 | emit selected((const DateList)daylist); | 553 | emit selected((const DateList)daylist); |
551 | 554 | ||
552 | } | 555 | } |
553 | 556 | ||
554 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 557 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
555 | { | 558 | { |
556 | if ( ! mouseDown ) { | 559 | if ( ! mouseDown ) { |
557 | return; | 560 | return; |
558 | } | 561 | } |
562 | mRedrawNeeded = true; | ||
559 | int tmp = getDayIndexFrom(e->x(), e->y()); | 563 | int tmp = getDayIndexFrom(e->x(), e->y()); |
560 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 564 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
561 | 565 | ||
562 | if (mSelInit > tmp) { | 566 | if (mSelInit > tmp) { |
563 | mSelEnd = mSelInit; | 567 | mSelEnd = mSelInit; |
564 | if (tmp != mSelStart) { | 568 | if (tmp != mSelStart) { |
565 | mSelStart = tmp; | 569 | mSelStart = tmp; |
566 | repaint(false); | 570 | repaint(false); |
567 | } | 571 | } |
568 | } else { | 572 | } else { |
569 | mSelStart = mSelInit; | 573 | mSelStart = mSelInit; |
570 | 574 | ||
571 | //repaint only if selection has changed | 575 | //repaint only if selection has changed |
572 | if (tmp != mSelEnd) { | 576 | if (tmp != mSelEnd) { |
573 | mSelEnd = tmp; | 577 | mSelEnd = tmp; |
574 | repaint(false); | 578 | repaint(false); |
575 | } | 579 | } |
576 | } | 580 | } |
577 | } | 581 | } |
578 | 582 | ||
579 | // ---------------------------------------------------------------------------- | 583 | // ---------------------------------------------------------------------------- |
580 | // D R A G ' N D R O P H A N D L I N G | 584 | // D R A G ' N D R O P H A N D L I N G |
581 | // ---------------------------------------------------------------------------- | 585 | // ---------------------------------------------------------------------------- |
582 | 586 | ||
583 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 587 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
584 | { | 588 | { |
585 | #ifndef KORG_NODND | 589 | #ifndef KORG_NODND |
586 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 590 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
587 | e->ignore(); | 591 | e->ignore(); |
588 | return; | 592 | return; |
589 | } | 593 | } |
590 | 594 | ||
591 | // some visual feedback | 595 | // some visual feedback |
592 | // oldPalette = palette(); | 596 | // oldPalette = palette(); |
593 | // setPalette(my_HilitePalette); | 597 | // setPalette(my_HilitePalette); |
594 | // update(); | 598 | // update(); |
595 | #endif | 599 | #endif |
596 | } | 600 | } |
597 | 601 | ||
598 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 602 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
599 | { | 603 | { |
600 | #ifndef KORG_NODND | 604 | #ifndef KORG_NODND |
601 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 605 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
602 | e->ignore(); | 606 | e->ignore(); |
603 | return; | 607 | return; |
604 | } | 608 | } |
605 | 609 | ||
606 | e->accept(); | 610 | e->accept(); |