summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-20 01:37:34 (UTC)
committer zautrix <zautrix>2005-03-20 01:37:34 (UTC)
commit1ebfa83d28d9eb3f48d8240e65212bbe22defb3c (patch) (unidiff)
treec82bb3fb86c4d5494edb8d0b512f08e9e1339a24 /korganizer
parent0ef9fe870982bd005806d7f51898a740cd52fec8 (diff)
downloadkdepimpi-1ebfa83d28d9eb3f48d8240e65212bbe22defb3c.zip
kdepimpi-1ebfa83d28d9eb3f48d8240e65212bbe22defb3c.tar.gz
kdepimpi-1ebfa83d28d9eb3f48d8240e65212bbe22defb3c.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp2
-rw-r--r--korganizer/kodaymatrix.cpp58
2 files changed, 45 insertions, 15 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index d09f484..b9bd1b9 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -123,49 +123,49 @@ void DateNavigatorContainer::updateConfig()
123 } 123 }
124} 124}
125 125
126void DateNavigatorContainer::selectDates( const DateList &dateList ) 126void DateNavigatorContainer::selectDates( const DateList &dateList )
127{ 127{
128 mNavigatorView->selectDates( dateList ); 128 mNavigatorView->selectDates( dateList );
129 setBaseDates(); 129 setBaseDates();
130 if ( mExtraViews.count() ) { 130 if ( mExtraViews.count() ) {
131 KDateNavigator *view = mExtraViews.at( 0 ); 131 KDateNavigator *view = mExtraViews.at( 0 );
132 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 132 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
133 view->dayMatrix()->repaint(); 133 view->dayMatrix()->repaint();
134 } 134 }
135} 135}
136 136
137void DateNavigatorContainer::setBaseDates() 137void DateNavigatorContainer::setBaseDates()
138{ 138{
139 KCal::DateList dateList = mNavigatorView->selectedDates(); 139 KCal::DateList dateList = mNavigatorView->selectedDates();
140 if ( dateList.isEmpty() ) { 140 if ( dateList.isEmpty() ) {
141 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; 141 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl;
142 } 142 }
143 QDate baseDate = dateList.first(); 143 QDate baseDate = dateList.first();
144 KDateNavigator *n; 144 KDateNavigator *n;
145 bool doRepaint = false; // skip first repaint 145 bool doRepaint = false; // skip first repaint
146 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 146 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
147 baseDate = baseDate.addDays( baseDate.daysInMonth () ); 147 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
148 n->setBaseDate( baseDate, doRepaint ); 148 n->setBaseDate( baseDate, doRepaint );
149 doRepaint = true; 149 doRepaint = true;
150 } 150 }
151} 151}
152 152
153void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 153void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
154{ 154{
155#if 0 155#if 0
156 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; 156 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl;
157 kdDebug(5850) << " CURRENT SIZE: " << size() << endl; 157 kdDebug(5850) << " CURRENT SIZE: " << size() << endl;
158 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; 158 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl;
159 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; 159 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl;
160 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; 160 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl;
161#endif 161#endif
162 QSize minSize = mNavigatorView->yourSizeHint(); 162 QSize minSize = mNavigatorView->yourSizeHint();
163 163
164// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; 164// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl;
165 165
166 int verticalCount = size().height() / minSize.height(); 166 int verticalCount = size().height() / minSize.height();
167 int horizontalCount = size().width() / minSize.width(); 167 int horizontalCount = size().width() / minSize.width();
168 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); 168 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
169 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 169 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
170 if ( horizontalCount != mHorizontalCount || 170 if ( horizontalCount != mHorizontalCount ||
171 verticalCount != mVerticalCount ) { 171 verticalCount != mVerticalCount ) {
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 1cde616..619ae39 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -250,49 +250,53 @@ void KODayMatrix::addSelectedDaysTo(DateList& selDays)
250 } 250 }
251 i0 = 0; 251 i0 = 0;
252 } 252 }
253 253
254 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 254 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
255 if (mSelEnd > NUMDAYS-1) { 255 if (mSelEnd > NUMDAYS-1) {
256 for (int i = i0; i <= NUMDAYS-1; i++) { 256 for (int i = i0; i <= NUMDAYS-1; i++) {
257 selDays.append(days[i]); 257 selDays.append(days[i]);
258 } 258 }
259 for (int i = NUMDAYS; i < mSelEnd; i++) { 259 for (int i = NUMDAYS; i < mSelEnd; i++) {
260 selDays.append(days[0].addDays(i)); 260 selDays.append(days[0].addDays(i));
261 } 261 }
262 262
263 // apply normal routine to selection being entirely within matrix limits 263 // apply normal routine to selection being entirely within matrix limits
264 } else { 264 } else {
265 for (int i = i0; i <= mSelEnd; i++) { 265 for (int i = i0; i <= mSelEnd; i++) {
266 selDays.append(days[i]); 266 selDays.append(days[i]);
267 } 267 }
268 } 268 }
269} 269}
270 270
271void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 271void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
272{ 272{
273 mSelStart = startdate.daysTo(start); 273 mSelStart = startdate.daysTo(start);
274 if ( mSelStart < 0 )
275 mSelStart = 0;
274 mSelEnd = startdate.daysTo(end); 276 mSelEnd = startdate.daysTo(end);
277 if ( mSelEnd < 0 )
278 clearSelection();
275} 279}
276void KODayMatrix::clearSelection() 280void KODayMatrix::clearSelection()
277{ 281{
278 mSelEnd = mSelStart = NOSELECTION; 282 mSelEnd = mSelStart = NOSELECTION;
279} 283}
280 284
281 285
282void KODayMatrix::recalculateToday() 286void KODayMatrix::recalculateToday()
283{ 287{
284 today = -1; 288 today = -1;
285 for (int i=0; i<NUMDAYS; i++) { 289 for (int i=0; i<NUMDAYS; i++) {
286 events[i] = 0; 290 events[i] = 0;
287 days[i] = startdate.addDays(i); 291 days[i] = startdate.addDays(i);
288 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 292 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
289 293
290 // if today is in the currently displayed month, hilight today 294 // if today is in the currently displayed month, hilight today
291 if (days[i].year() == QDate::currentDate().year() && 295 if (days[i].year() == QDate::currentDate().year() &&
292 days[i].month() == QDate::currentDate().month() && 296 days[i].month() == QDate::currentDate().month() &&
293 days[i].day() == QDate::currentDate().day()) { 297 days[i].day() == QDate::currentDate().day()) {
294 today = i; 298 today = i;
295 } 299 }
296 } 300 }
297 // qDebug(QString("Today is visible at %1.").arg(today)); 301 // qDebug(QString("Today is visible at %1.").arg(today));
298} 302}
@@ -617,146 +621,172 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
617{ 621{
618 if ( width() <= 0 || height() <= 0 ) 622 if ( width() <= 0 || height() <= 0 )
619 return; 623 return;
620 if ( mPendingUpdateBeforeRepaint ) { 624 if ( mPendingUpdateBeforeRepaint ) {
621 updateViewTimed(); 625 updateViewTimed();
622 mPendingUpdateBeforeRepaint = false; 626 mPendingUpdateBeforeRepaint = false;
623 } 627 }
624 if ( myPix.width() != width() || myPix.height()!=height() ) { 628 if ( myPix.width() != width() || myPix.height()!=height() ) {
625 myPix.resize(size() ); 629 myPix.resize(size() );
626 } 630 }
627 QPainter p(&myPix); 631 QPainter p(&myPix);
628 p.setFont(font()); 632 p.setFont(font());
629 633
630 QRect sz = frameRect(); 634 QRect sz = frameRect();
631 int dheight = daysize.height(); 635 int dheight = daysize.height();
632 int dwidth = daysize.width(); 636 int dwidth = daysize.width();
633 int row,col; 637 int row,col;
634 int selw, selh; 638 int selw, selh;
635 bool isRTL = KOGlobals::self()->reverseLayout(); 639 bool isRTL = KOGlobals::self()->reverseLayout();
636 640
637 // draw background and topleft frame 641 // draw background and topleft frame
638 p.fillRect(pevent->rect(), mDefaultBackColor); 642 p.fillRect(pevent->rect(), mDefaultBackColor);
639 p.setPen(mDefaultTextColor); 643 p.setPen(mDefaultTextColor);
640 p.drawRect(0, 0, sz.width()+1, sz.height()+1); 644 p.drawRect(0, 0, sz.width()+1, sz.height()+1);
641 645 int mSelStartT = mSelStart;
646 int mSelEndT = mSelEnd;
647 if ( mSelEndT >= NUMDAYS )
648 mSelEndT = NUMDAYS-1;
642 // draw selected days with highlighted background color 649 // draw selected days with highlighted background color
643 if (mSelStart != NOSELECTION) { 650 if (mSelStart != NOSELECTION) {
644 651 bool skip = false;
645 row = mSelStart/7; 652 if ( ! mouseDown ) {
646 col = mSelStart -row*7; 653 int mo = days[20].month();
654 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
655 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
656 if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) {
657 skip = true;
658 } else {
659 if ( days[mSelStartT].month() != mo ) {
660 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
661 mSelStartT += add +1;
662 }
663 if ( days[mSelEndT].month() != mo ) {
664 int sub = days[mSelEndT].day();
665 mSelEndT -= sub ;
666 }
667 }
668 }
669 if ( ! skip ) {
670 row = mSelStartT/7;
671 col = mSelStartT -row*7;
647 QColor selcol = KOPrefs::instance()->mHighlightColor; 672 QColor selcol = KOPrefs::instance()->mHighlightColor;
648 673
649 if (row == mSelEnd/7) { 674 if (row == mSelEndT/7) {
650 // Single row selection 675 // Single row selection
651 p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, 676 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth,
652 row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); 677 row*dheight, (mSelEndT-mSelStartT+1)*dwidth, dheight, selcol);
653 } else { 678 } else {
654 // draw first row to the right 679 // draw first row to the right
655 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, 680 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth,
656 dheight, selcol); 681 dheight, selcol);
657 // draw full block till last line 682 // draw full block till last line
658 selh = mSelEnd/7-row; 683 selh = mSelEndT/7-row;
659 if (selh > 1) { 684 if (selh > 1) {
660 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); 685 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol);
661 } 686 }
662 // draw last block from left to mSelEnd 687 // draw last block from left to mSelEndT
663 selw = mSelEnd-7*(mSelEnd/7)+1; 688 selw = mSelEndT-7*(mSelEndT/7)+1;
664 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, 689 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight,
665 selw*dwidth, dheight, selcol); 690 selw*dwidth, dheight, selcol);
666 } 691 }
692 }
667 } 693 }
668 694
669 // iterate over all days in the matrix and draw the day label in appropriate colors 695 // iterate over all days in the matrix and draw the day label in appropriate colors
670 QColor actcol = mDefaultTextColorShaded; 696 QColor actcol = mDefaultTextColorShaded;
671 p.setPen(actcol); 697 p.setPen(actcol);
672 QPen tmppen; 698 QPen tmppen;
673 for(int i = 0; i < NUMDAYS; i++) { 699 for(int i = 0; i < NUMDAYS; i++) {
674 row = i/7; 700 row = i/7;
675 col = isRTL ? 6-(i-row*7) : i-row*7; 701 col = isRTL ? 6-(i-row*7) : i-row*7;
676 702
677 // if it is the first day of a month switch color from normal to shaded and vice versa 703 // if it is the first day of a month switch color from normal to shaded and vice versa
678 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 704 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
679 if (actcol == mDefaultTextColorShaded) { 705 if (actcol == mDefaultTextColorShaded) {
680 actcol = mDefaultTextColor; 706 actcol = mDefaultTextColor;
681 } else { 707 } else {
682 actcol = mDefaultTextColorShaded; 708 actcol = mDefaultTextColorShaded;
683 } 709 }
684 p.setPen(actcol); 710 p.setPen(actcol);
685 } 711 }
686 712 if (actcol == mDefaultTextColorShaded) {
713 if ( ! mouseDown ) {
714 continue;
715 }
716 }
687 //Reset pen color after selected days block 717 //Reset pen color after selected days block
688 if (i == mSelEnd+1) { 718 if (i == mSelEndT+1) {
689 p.setPen(actcol); 719 p.setPen(actcol);
690 } 720 }
691 721
692 // if today then draw rectangle around day 722 // if today then draw rectangle around day
693 if (today == i) { 723 if (today == i) {
694 tmppen = p.pen(); 724 tmppen = p.pen();
695 QPen mTodayPen(p.pen()); 725 QPen mTodayPen(p.pen());
696 726
697 mTodayPen.setWidth(mTodayMarginWidth); 727 mTodayPen.setWidth(mTodayMarginWidth);
698 //draw red rectangle for holidays 728 //draw red rectangle for holidays
699 if (!mHolidays[i].isNull()) { 729 if (!mHolidays[i].isNull()) {
700 if (actcol == mDefaultTextColor) { 730 if (actcol == mDefaultTextColor) {
701 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 731 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
702 } else { 732 } else {
703 mTodayPen.setColor(mHolidayColorShaded); 733 mTodayPen.setColor(mHolidayColorShaded);
704 } 734 }
705 } 735 }
706 //draw gray rectangle for today if in selection 736 //draw gray rectangle for today if in selection
707 if (i >= mSelStart && i <= mSelEnd) { 737 if (i >= mSelStartT && i <= mSelEndT) {
708 QColor grey("grey"); 738 QColor grey("grey");
709 mTodayPen.setColor(grey); 739 mTodayPen.setColor(grey);
710 } 740 }
711 p.setPen(mTodayPen); 741 p.setPen(mTodayPen);
712 p.drawRect(col*dwidth, row*dheight, dwidth, dheight); 742 p.drawRect(col*dwidth, row*dheight, dwidth, dheight);
713 p.setPen(tmppen); 743 p.setPen(tmppen);
714 } 744 }
715 745
716 // if any events are on that day then draw it using a bold font 746 // if any events are on that day then draw it using a bold font
717 if (events[i] > 0) { 747 if (events[i] > 0) {
718 QFont myFont = font(); 748 QFont myFont = font();
719 myFont.setBold(true); 749 myFont.setBold(true);
720 p.setFont(myFont); 750 p.setFont(myFont);
721 } 751 }
722 752
723 // if it is a holiday then use the default holiday color 753 // if it is a holiday then use the default holiday color
724 if (!mHolidays[i].isNull()) { 754 if (!mHolidays[i].isNull()) {
725 if ( bDays.testBit(i) ) { 755 if ( bDays.testBit(i) ) {
726 p.setPen(Qt::green); 756 p.setPen(Qt::green);
727 } else { 757 } else {
728 if (actcol == mDefaultTextColor) { 758 if (actcol == mDefaultTextColor) {
729 p.setPen(KOPrefs::instance()->mHolidayColor); 759 p.setPen(KOPrefs::instance()->mHolidayColor);
730 } else { 760 } else {
731 p.setPen(mHolidayColorShaded); 761 p.setPen(mHolidayColorShaded);
732 } 762 }
733 } 763 }
734 } 764 }
735 765
736 // draw selected days with special color 766 // draw selected days with special color
737 // DO NOT specially highlight holidays in selection ! 767 // DO NOT specially highlight holidays in selection !
738 if (i >= mSelStart && i <= mSelEnd) { 768 if (i >= mSelStartT && i <= mSelEndT) {
739 ;//p.setPen(mSelectedDaysColor); 769 ;//p.setPen(mSelectedDaysColor);
740 } 770 }
741 771
742 p.drawText(col*dwidth, row*dheight, dwidth, dheight, 772 p.drawText(col*dwidth, row*dheight, dwidth, dheight,
743 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 773 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
744 774
745 // reset color to actual color 775 // reset color to actual color
746 if (!mHolidays[i].isNull()) { 776 if (!mHolidays[i].isNull()) {
747 p.setPen(actcol); 777 p.setPen(actcol);
748 } 778 }
749 // reset bold font to plain font 779 // reset bold font to plain font
750 if (events[i] > 0) { 780 if (events[i] > 0) {
751 QFont myFont = font(); 781 QFont myFont = font();
752 myFont.setBold(false); 782 myFont.setBold(false);
753 p.setFont(myFont); 783 p.setFont(myFont);
754 } 784 }
755 } 785 }
756 bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); 786 bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
757} 787}
758 788
759// ---------------------------------------------------------------------------- 789// ----------------------------------------------------------------------------
760// R E SI Z E E V E N T H A N D L I N G 790// R E SI Z E E V E N T H A N D L I N G
761// ---------------------------------------------------------------------------- 791// ----------------------------------------------------------------------------
762 792