summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-21 18:04:19 (UTC)
committer zautrix <zautrix>2005-03-21 18:04:19 (UTC)
commit8888389a4511e0bda23774b993dcfdeb7f837c31 (patch) (unidiff)
treecb45be3b62f2255f69cee92e358380cc76d3ad30 /korganizer
parent3c5d7b484e6ab263ab4091f22815770ea8da6c9c (diff)
downloadkdepimpi-8888389a4511e0bda23774b993dcfdeb7f837c31.zip
kdepimpi-8888389a4511e0bda23774b993dcfdeb7f837c31.tar.gz
kdepimpi-8888389a4511e0bda23774b993dcfdeb7f837c31.tar.bz2
nf
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 36cd990..120bc89 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -601,193 +601,193 @@ void KODayMatrix::dropEvent(QDropEvent *e)
601// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 601// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
602 602
603 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 603 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
604 e->ignore(); 604 e->ignore();
605 return; 605 return;
606 } 606 }
607 607
608 DndFactory factory( mCalendar ); 608 DndFactory factory( mCalendar );
609 Event *event = factory.createDrop(e); 609 Event *event = factory.createDrop(e);
610 610
611 if (event) { 611 if (event) {
612 e->acceptAction(); 612 e->acceptAction();
613 613
614 Event *existingEvent = mCalendar->event(event->uid()); 614 Event *existingEvent = mCalendar->event(event->uid());
615 615
616 if(existingEvent) { 616 if(existingEvent) {
617 // uniquify event 617 // uniquify event
618 event->recreate(); 618 event->recreate();
619/* 619/*
620 KMessageBox::sorry(this, 620 KMessageBox::sorry(this,
621 i18n("Event already exists in this calendar."), 621 i18n("Event already exists in this calendar."),
622 i18n("Drop Event")); 622 i18n("Drop Event"));
623 delete event; 623 delete event;
624 return; 624 return;
625*/ 625*/
626 } 626 }
627// kdDebug() << "Drop new Event" << endl; 627// kdDebug() << "Drop new Event" << endl;
628 // Adjust date 628 // Adjust date
629 QDateTime start = event->dtStart(); 629 QDateTime start = event->dtStart();
630 QDateTime end = event->dtEnd(); 630 QDateTime end = event->dtEnd();
631 int duration = start.daysTo(end); 631 int duration = start.daysTo(end);
632 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 632 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
633 633
634 start.setDate(days[idx]); 634 start.setDate(days[idx]);
635 end.setDate(days[idx].addDays(duration)); 635 end.setDate(days[idx].addDays(duration));
636 636
637 event->setDtStart(start); 637 event->setDtStart(start);
638 event->setDtEnd(end); 638 event->setDtEnd(end);
639 mCalendar->addEvent(event); 639 mCalendar->addEvent(event);
640 640
641 emit eventDropped(event); 641 emit eventDropped(event);
642 } else { 642 } else {
643// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 643// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
644 e->ignore(); 644 e->ignore();
645 } 645 }
646#endif 646#endif
647} 647}
648 648
649// ---------------------------------------------------------------------------- 649// ----------------------------------------------------------------------------
650// P A I N T E V E N T H A N D L I N G 650// P A I N T E V E N T H A N D L I N G
651// ---------------------------------------------------------------------------- 651// ----------------------------------------------------------------------------
652 652
653void KODayMatrix::paintEvent(QPaintEvent * pevent) 653void KODayMatrix::paintEvent(QPaintEvent * pevent)
654{ 654{
655 QRect sz = frameRect(); 655 QRect sz = frameRect();
656 if ( sz.width() <= 0 || sz.height() <= 0 ) 656 if ( sz.width() <= 0 || sz.height() <= 0 )
657 return; 657 return;
658 if ( mPendingUpdateBeforeRepaint ) { 658 if ( mPendingUpdateBeforeRepaint ) {
659 updateViewTimed(); 659 updateViewTimed();
660 mPendingUpdateBeforeRepaint = false; 660 mPendingUpdateBeforeRepaint = false;
661 } 661 }
662 if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { 662 if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) {
663 myPix.resize(sz.size() ); 663 myPix.resize(sz.size() );
664 } 664 }
665 QPainter p(&myPix); 665 QPainter p(&myPix);
666 p.setFont(font()); 666 p.setFont(font());
667 667
668 668
669 int dheight = daysize.height(); 669 int dheight = daysize.height();
670 int dwidth = daysize.width(); 670 int dwidth = daysize.width();
671 int row,col; 671 int row,col;
672 int selw, selh; 672 int selw, selh;
673 int xyOff = frameWidth(); 673 int xyOff = frameWidth();
674 int colModulo = sz.width() % 7; 674 int colModulo = sz.width() % 7;
675 int rowModulo = sz.height() % 6; 675 int rowModulo = sz.height() % 6;
676 //qDebug("col %d row %d ",colModulo,rowModulo ); 676 //qDebug("col %d row %d ",colModulo,rowModulo );
677 677
678 bool isRTL = KOGlobals::self()->reverseLayout(); 678 bool isRTL = KOGlobals::self()->reverseLayout();
679 679
680 // draw background and topleft frame 680 // draw background and topleft frame
681 p.fillRect(pevent->rect(), mDefaultBackColor); 681 p.fillRect(pevent->rect(), mDefaultBackColor);
682 p.setPen(mDefaultTextColor); 682 p.setPen(mDefaultTextColor);
683 p.drawRect(0, 0, sz.width()+1, sz.height()+1); 683 p.drawRect(0, 0, sz.width()+1, sz.height()+1);
684 int mSelStartT = mSelStart; 684 int mSelStartT = mSelStart;
685 int mSelEndT = mSelEnd; 685 int mSelEndT = mSelEnd;
686 if ( mSelEndT >= NUMDAYS ) 686 if ( mSelEndT >= NUMDAYS )
687 mSelEndT = NUMDAYS-1; 687 mSelEndT = NUMDAYS-1;
688 // draw selected days with highlighted background color 688 // draw selected days with highlighted background color
689 if (mSelStart != NOSELECTION) { 689 if (mSelStart != NOSELECTION) {
690 bool skip = false; 690 bool skip = false;
691 if ( ! mouseDown ) { 691 if ( ! mouseDown ) {
692 int mo = days[20].month(); 692 int mo = days[20].month();
693 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 693 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
694 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); 694 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
695 int startMo = days[mSelStartT].month(); 695 int startMo = days[mSelStartT].month();
696 int endMo = days[mSelEndT].month(); 696 int endMo = days[mSelEndT].month();
697 if ( startMo == 12 && mo == 1 && endMo == 1 ) 697 if ( startMo == 12 && mo == 1 && endMo <= 2 )
698 startMo = 1; 698 startMo = 1;
699 if ( endMo == 1 && mo == 12 ) 699 if ( endMo == 1 && mo == 12 )
700 endMo = 12; 700 endMo = 12;
701 if ( (startMo > mo || endMo < mo) ) { 701 if ( (startMo > mo || endMo < mo) ) {
702 skip = true; 702 skip = true;
703 } else { 703 } else {
704 if ( days[mSelStartT].month() != mo ) { 704 if ( days[mSelStartT].month() != mo ) {
705 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 705 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
706 mSelStartT += add +1; 706 mSelStartT += add +1;
707 } 707 }
708 if ( days[mSelEndT].month() != mo ) { 708 if ( days[mSelEndT].month() != mo ) {
709 int sub = days[mSelEndT].day(); 709 int sub = days[mSelEndT].day();
710 mSelEndT -= sub ; 710 mSelEndT -= sub ;
711 } 711 }
712 } 712 }
713 } 713 }
714 if ( ! skip ) { 714 if ( ! skip ) {
715 row = mSelStartT/7; 715 row = mSelStartT/7;
716 col = mSelStartT -row*7; 716 col = mSelStartT -row*7;
717 QColor selcol = KOPrefs::instance()->mHighlightColor; 717 QColor selcol = KOPrefs::instance()->mHighlightColor;
718 int addCol = 0; 718 int addCol = 0;
719 int addRow = 0; 719 int addRow = 0;
720 int addRow2 = 0; 720 int addRow2 = 0;
721 int addCol2 = 0; 721 int addCol2 = 0;
722 if (row == mSelEndT/7) { 722 if (row == mSelEndT/7) {
723 if ( rowModulo ) { 723 if ( rowModulo ) {
724 if ( row >= 6 - rowModulo ) 724 if ( row >= 6 - rowModulo )
725 addRow = row - 5 + rowModulo; 725 addRow = row - 5 + rowModulo;
726 } 726 }
727 if ( colModulo ) { 727 if ( colModulo ) {
728 int colt1 = mSelEndT%7; 728 int colt1 = mSelEndT%7;
729 //qDebug("colt1 %d ", colt1 ); 729 //qDebug("colt1 %d ", colt1 );
730 if ( colt1 >= 7 - colModulo ) 730 if ( colt1 >= 7 - colModulo )
731 addCol = colt1 - 7 + colModulo+1; 731 addCol = colt1 - 7 + colModulo+1;
732 int colt = mSelStartT%7; 732 int colt = mSelStartT%7;
733 if ( colt >= 7 - colModulo ) 733 if ( colt >= 7 - colModulo )
734 addCol2 = colt - 7 + colModulo; 734 addCol2 = colt - 7 + colModulo;
735 addCol -= addCol2; 735 addCol -= addCol2;
736 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); 736 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
737 } 737 }
738 // Single row selection 738 // Single row selection
739 if ( row == 0) 739 if ( row == 0)
740 addRow = 1; 740 addRow = 1;
741 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, 741 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
742 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 742 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
743 } else { 743 } else {
744 // draw first row to the right 744 // draw first row to the right
745 if ( colModulo ) { 745 if ( colModulo ) {
746 if ( col >= 7 - colModulo ) 746 if ( col >= 7 - colModulo )
747 addCol2 = col - 7 + colModulo; 747 addCol2 = col - 7 + colModulo;
748 } 748 }
749 if ( rowModulo ) { 749 if ( rowModulo ) {
750 if ( row >= 6 - rowModulo ) 750 if ( row >= 6 - rowModulo )
751 addRow = row - 5 + rowModulo; 751 addRow = row - 5 + rowModulo;
752 } 752 }
753 if ( row == 0) 753 if ( row == 0)
754 addRow = 1; 754 addRow = 1;
755 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, 755 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo,
756 dheight+1, selcol); 756 dheight+1, selcol);
757 // draw full block till last line 757 // draw full block till last line
758 selh = mSelEndT/7-row; 758 selh = mSelEndT/7-row;
759 addRow = 0; 759 addRow = 0;
760 if ( rowModulo ) { 760 if ( rowModulo ) {
761 if ( mSelEndT/7 >= 6 - rowModulo ) 761 if ( mSelEndT/7 >= 6 - rowModulo )
762 addRow = mSelEndT/7 - 5 + rowModulo; 762 addRow = mSelEndT/7 - 5 + rowModulo;
763 } 763 }
764 if (selh > 1) { 764 if (selh > 1) {
765 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 765 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
766 } 766 }
767 // draw last block from left to mSelEndT 767 // draw last block from left to mSelEndT
768 selw = mSelEndT-7*(mSelEndT/7)+1; 768 selw = mSelEndT-7*(mSelEndT/7)+1;
769 //qDebug("esl %d ",selw ); 769 //qDebug("esl %d ",selw );
770 int add = 0; 770 int add = 0;
771 if ( colModulo ) { 771 if ( colModulo ) {
772 add = 7 - colModulo; 772 add = 7 - colModulo;
773 if ( selw > add ) 773 if ( selw > add )
774 add = selw - add; 774 add = selw - add;
775 else 775 else
776 add = 0; 776 add = 0;
777 } 777 }
778 //qDebug("add %d ", add); 778 //qDebug("add %d ", add);
779 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, 779 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
780 selw*dwidth+add, dheight+1, selcol); 780 selw*dwidth+add, dheight+1, selcol);
781 } 781 }
782 } 782 }
783 } 783 }
784 784
785 // iterate over all days in the matrix and draw the day label in appropriate colors 785 // iterate over all days in the matrix and draw the day label in appropriate colors
786 QColor actcol = mDefaultTextColorShaded; 786 QColor actcol = mDefaultTextColorShaded;
787 p.setPen(actcol); 787 p.setPen(actcol);
788 QPen tmppen; 788 QPen tmppen;
789 for(int i = 0; i < NUMDAYS; i++) { 789 for(int i = 0; i < NUMDAYS; i++) {
790 row = i/7; 790 row = i/7;
791 col = isRTL ? 6-(i-row*7) : i-row*7; 791 col = isRTL ? 6-(i-row*7) : i-row*7;
792 792
793 // if it is the first day of a month switch color from normal to shaded and vice versa 793 // if it is the first day of a month switch color from normal to shaded and vice versa