author | zautrix <zautrix> | 2005-03-21 13:56:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-21 13:56:46 (UTC) |
commit | 41f264fea6caaf9ca0f8b34509a07157c210f851 (patch) (unidiff) | |
tree | f49b5d10db838821f79d5ae3d28b492f76663b62 /korganizer | |
parent | 098a3c6dd844a880beb2851be53314613c3a038d (diff) | |
download | kdepimpi-41f264fea6caaf9ca0f8b34509a07157c210f851.zip kdepimpi-41f264fea6caaf9ca0f8b34509a07157c210f851.tar.gz kdepimpi-41f264fea6caaf9ca0f8b34509a07157c210f851.tar.bz2 |
fixes
-rw-r--r-- | korganizer/kdatenavigator.cpp | 4 | ||||
-rw-r--r-- | korganizer/kdatenavigator.h | 2 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 8 |
3 files changed, 9 insertions, 5 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 4b50b5a..2321acb 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -127,98 +127,98 @@ QFont KDateNavigator::yourFontHint( QSize si , bool *b) | |||
127 | { | 127 | { |
128 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; | 128 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; |
129 | *b = false; | 129 | *b = false; |
130 | int fontPoint = fo.pointSize(); | 130 | int fontPoint = fo.pointSize(); |
131 | while ( fontPoint > 5 ) { | 131 | while ( fontPoint > 5 ) { |
132 | --fontPoint; | 132 | --fontPoint; |
133 | fo.setPointSize( fontPoint ); | 133 | fo.setPointSize( fontPoint ); |
134 | setFont( fo ); | 134 | setFont( fo ); |
135 | mFontChanged = true; | 135 | mFontChanged = true; |
136 | mNavigatorBar->resetFont( fo ); | 136 | mNavigatorBar->resetFont( fo ); |
137 | QSize sh = sizeHintTwoButtons(); | 137 | QSize sh = sizeHintTwoButtons(); |
138 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); | 138 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); |
139 | if ( si.width() > sh.width() && si.height() > sh.height()) { | 139 | if ( si.width() > sh.width() && si.height() > sh.height()) { |
140 | *b = true; | 140 | *b = true; |
141 | //qDebug("fooooooooooooooooooooooouuuuund "); | 141 | //qDebug("fooooooooooooooooooooooouuuuund "); |
142 | break; | 142 | break; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); | 145 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); |
146 | return fo; | 146 | return fo; |
147 | } | 147 | } |
148 | QSize KDateNavigator::sizeHint() const | 148 | QSize KDateNavigator::sizeHint() const |
149 | { | 149 | { |
150 | QFontMetrics fm ( font() ); | 150 | QFontMetrics fm ( font() ); |
151 | QSize day = daymatrix->sizeHint(); | 151 | QSize day = daymatrix->sizeHint(); |
152 | QSize nav = mNavigatorBar->sizeHint(); | 152 | QSize nav = mNavigatorBar->sizeHint(); |
153 | int wid = fm.width( "30") + day.width()+3; | 153 | int wid = fm.width( "30") + day.width()+3; |
154 | int hei = fm.height() +day.height()+nav.height()+2; | 154 | int hei = fm.height() +day.height()+nav.height()+2; |
155 | if ( wid < nav.width() ) | 155 | if ( wid < nav.width() ) |
156 | wid = nav.width() ; | 156 | wid = nav.width() ; |
157 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 157 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
158 | return QSize ( wid, hei ); | 158 | return QSize ( wid, hei ); |
159 | } | 159 | } |
160 | QSize KDateNavigator::sizeHintTwoButtons() const | 160 | QSize KDateNavigator::sizeHintTwoButtons() const |
161 | { | 161 | { |
162 | QFontMetrics fm ( font() ); | 162 | QFontMetrics fm ( font() ); |
163 | QSize day = daymatrix->sizeHint(); | 163 | QSize day = daymatrix->sizeHint(); |
164 | QSize nav = mNavigatorBar->sizeHintTwoButtons(); | 164 | QSize nav = mNavigatorBar->sizeHintTwoButtons(); |
165 | int wid = fm.width( "30") + day.width()+3; | 165 | int wid = fm.width( "30") + day.width()+3; |
166 | int hei = fm.height() +day.height()+nav.height()+2; | 166 | int hei = fm.height() +day.height()+nav.height()+2; |
167 | if ( wid < nav.width() ) | 167 | if ( wid < nav.width() ) |
168 | wid = nav.width() ; | 168 | wid = nav.width() ; |
169 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 169 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
170 | return QSize ( wid, hei ); | 170 | return QSize ( wid, hei ); |
171 | } | 171 | } |
172 | void KDateNavigator::slotMonthSelected( int m ) | 172 | void KDateNavigator::slotMonthSelected( int m ) |
173 | { | 173 | { |
174 | if ( m_MthYr.month() <= mMonthSignalOffset) | 174 | if ( m_MthYr.month() <= mMonthSignalOffset) |
175 | m += 12; | 175 | m += 12; |
176 | int mo = m - mMonthSignalOffset; | 176 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); |
177 | emit monthSelected( m - mMonthSignalOffset ); | 177 | emit monthSelected( m - mMonthSignalOffset ); |
178 | 178 | ||
179 | } | 179 | } |
180 | void KDateNavigator::setCalendar( Calendar *cal ) | 180 | void KDateNavigator::setCalendar( Calendar *cal ) |
181 | { | 181 | { |
182 | daymatrix->setCalendar( cal ); | 182 | daymatrix->setCalendar( cal ); |
183 | } | 183 | } |
184 | 184 | ||
185 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 185 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
186 | { | 186 | { |
187 | m_MthYr = date; | 187 | m_MthYr = date; |
188 | 188 | ||
189 | updateDates(); | 189 | updateDates(); |
190 | updateView(); | 190 | updateView(); |
191 | 191 | ||
192 | KCal::DateList dates; | 192 | KCal::DateList dates; |
193 | dates.append( date ); | 193 | dates.append( date ); |
194 | mNavigatorBar->selectDates( dates ); | 194 | mNavigatorBar->selectDates( dates ); |
195 | 195 | ||
196 | daymatrix->clearSelection(); | 196 | daymatrix->clearSelection(); |
197 | if ( doRepaint ) | 197 | if ( doRepaint ) |
198 | daymatrix->repaint(); | 198 | daymatrix->repaint(); |
199 | } | 199 | } |
200 | 200 | ||
201 | void KDateNavigator::enableRollover(RolloverType r) | 201 | void KDateNavigator::enableRollover(RolloverType r) |
202 | { | 202 | { |
203 | switch(r) | 203 | switch(r) |
204 | { | 204 | { |
205 | case None : | 205 | case None : |
206 | if (updateTimer) | 206 | if (updateTimer) |
207 | { | 207 | { |
208 | updateTimer->stop(); | 208 | updateTimer->stop(); |
209 | delete updateTimer; | 209 | delete updateTimer; |
210 | updateTimer=0L; | 210 | updateTimer=0L; |
211 | } | 211 | } |
212 | break; | 212 | break; |
213 | case FollowDay : | 213 | case FollowDay : |
214 | case FollowMonth : | 214 | case FollowMonth : |
215 | if (!updateTimer) | 215 | if (!updateTimer) |
216 | { | 216 | { |
217 | updateTimer = new QTimer(this); | 217 | updateTimer = new QTimer(this); |
218 | QObject::connect(updateTimer,SIGNAL(timeout()), | 218 | QObject::connect(updateTimer,SIGNAL(timeout()), |
219 | this,SLOT(possiblyPastMidnight())); | 219 | this,SLOT(possiblyPastMidnight())); |
220 | } | 220 | } |
221 | updateTimer->start(0,true); | 221 | updateTimer->start(0,true); |
222 | lastDayChecked = QDate::currentDate(); | 222 | lastDayChecked = QDate::currentDate(); |
223 | } | 223 | } |
224 | updateRollover=r; | 224 | updateRollover=r; |
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index d1f32b6..77b9b7c 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h | |||
@@ -18,97 +18,97 @@ | |||
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KDATENAVIGATOR_H | 23 | #ifndef KDATENAVIGATOR_H |
24 | #define KDATENAVIGATOR_H | 24 | #define KDATENAVIGATOR_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | 29 | ||
30 | #include <libkcal/calendar.h> | 30 | #include <libkcal/calendar.h> |
31 | 31 | ||
32 | #include "kodaymatrix.h" | 32 | #include "kodaymatrix.h" |
33 | 33 | ||
34 | class QPushButton; | 34 | class QPushButton; |
35 | class QTimer; | 35 | class QTimer; |
36 | 36 | ||
37 | class KCalendarSystem; | 37 | class KCalendarSystem; |
38 | 38 | ||
39 | class NavigatorBar; | 39 | class NavigatorBar; |
40 | 40 | ||
41 | class KDateNavigator: public QFrame | 41 | class KDateNavigator: public QFrame |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); | 45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); |
46 | ~KDateNavigator(); | 46 | ~KDateNavigator(); |
47 | 47 | ||
48 | /** The DateNavigator automatically checks for | 48 | /** The DateNavigator automatically checks for |
49 | * the passage of midnight. If rollover type is | 49 | * the passage of midnight. If rollover type is |
50 | * set to None, no signals are emitted and no | 50 | * set to None, no signals are emitted and no |
51 | * processing is done. With rollover set to | 51 | * processing is done. With rollover set to |
52 | * FollowDay, the day highlighter changes at | 52 | * FollowDay, the day highlighter changes at |
53 | * midnight and dayPassed() is emitted. | 53 | * midnight and dayPassed() is emitted. |
54 | * With FollowMonth, it has the same effect | 54 | * With FollowMonth, it has the same effect |
55 | * as FollowDay but also adjusts the month that is | 55 | * as FollowDay but also adjusts the month that is |
56 | * visible and emits monthPassed() when the month changes. | 56 | * visible and emits monthPassed() when the month changes. |
57 | */ | 57 | */ |
58 | enum RolloverType { None, FollowDay, FollowMonth } ; | 58 | enum RolloverType { None, FollowDay, FollowMonth } ; |
59 | void enableRollover( RolloverType ); | 59 | void enableRollover( RolloverType ); |
60 | 60 | ||
61 | void setShowWeekNums( bool enabled ); | 61 | void setShowWeekNums( bool enabled ); |
62 | void setCalendar( Calendar * ); | 62 | void setCalendar( Calendar * ); |
63 | void setBaseDate( const QDate & , bool doRepaint = true ); | 63 | void setBaseDate( const QDate & , bool doRepaint = true ); |
64 | KCal::DateList selectedDates() const { return mSelectedDates; } | 64 | KCal::DateList selectedDates() const { return mSelectedDates; } |
65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } | 65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } |
66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} | 66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off%12;} |
67 | QSize yourSizeHint() { return mySizeHint; } | 67 | QSize yourSizeHint() { return mySizeHint; } |
68 | QFont yourFontHint( QSize , bool * b); | 68 | QFont yourFontHint( QSize , bool * b); |
69 | bool fontChanged() {return mFontChanged; } | 69 | bool fontChanged() {return mFontChanged; } |
70 | void unsetFontChanged() { mFontChanged = false; } | 70 | void unsetFontChanged() { mFontChanged = false; } |
71 | KODayMatrix *dayMatrix() { return daymatrix ;} | 71 | KODayMatrix *dayMatrix() { return daymatrix ;} |
72 | QSize sizeHint() const; | 72 | QSize sizeHint() const; |
73 | QSize sizeHintTwoButtons() const; | 73 | QSize sizeHintTwoButtons() const; |
74 | void changeFont ( QFont fo ); | 74 | void changeFont ( QFont fo ); |
75 | public slots: | 75 | public slots: |
76 | void selectDates( const KCal::DateList & ); | 76 | void selectDates( const KCal::DateList & ); |
77 | void updateView(); | 77 | void updateView(); |
78 | void updateConfig(); | 78 | void updateConfig(); |
79 | void updateDayMatrix(); | 79 | void updateDayMatrix(); |
80 | 80 | ||
81 | signals: | 81 | signals: |
82 | void datesSelected( const KCal::DateList & ); | 82 | void datesSelected( const KCal::DateList & ); |
83 | void eventDropped( Event * ); | 83 | void eventDropped( Event * ); |
84 | void weekClicked( const QDate &); | 84 | void weekClicked( const QDate &); |
85 | 85 | ||
86 | void goPrevious(); | 86 | void goPrevious(); |
87 | void goNext(); | 87 | void goNext(); |
88 | 88 | ||
89 | void goNextMonth(); | 89 | void goNextMonth(); |
90 | void goPrevMonth(); | 90 | void goPrevMonth(); |
91 | void goNextYear(); | 91 | void goNextYear(); |
92 | void goPrevYear(); | 92 | void goPrevYear(); |
93 | void monthSelected( int ); | 93 | void monthSelected( int ); |
94 | 94 | ||
95 | // Signals emitted at midnight carrying the new date. | 95 | // Signals emitted at midnight carrying the new date. |
96 | void dayPassed( QDate ); | 96 | void dayPassed( QDate ); |
97 | void monthPassed( QDate ); | 97 | void monthPassed( QDate ); |
98 | 98 | ||
99 | protected slots: | 99 | protected slots: |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * Called regularly to see if we need to update the view | 102 | * Called regularly to see if we need to update the view |
103 | * wrt. the today box and the month box. Only important | 103 | * wrt. the today box and the month box. Only important |
104 | * if you leave KOrganizer idle for long periods of time. | 104 | * if you leave KOrganizer idle for long periods of time. |
105 | * | 105 | * |
106 | * Until we have a reliable way of setting QTimers to go | 106 | * Until we have a reliable way of setting QTimers to go |
107 | * off at a particular wall-clock time, we need this, | 107 | * off at a particular wall-clock time, we need this, |
108 | * which calls passedMidnight() at the right moments. | 108 | * which calls passedMidnight() at the right moments. |
109 | */ | 109 | */ |
110 | void possiblyPastMidnight(); | 110 | void possiblyPastMidnight(); |
111 | 111 | ||
112 | /** handles updating the view when midnight has come by due to idle time. | 112 | /** handles updating the view when midnight has come by due to idle time. |
113 | * | 113 | * |
114 | */ | 114 | */ |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 9baff20..493382d 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -366,98 +366,98 @@ void KODayMatrix::updateViewTimed() | |||
366 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 366 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
367 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 367 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
368 | !holiStr.isEmpty()) { | 368 | !holiStr.isEmpty()) { |
369 | mHolidays[i] = holiStr; | 369 | mHolidays[i] = holiStr; |
370 | } else { | 370 | } else { |
371 | mHolidays[i] = QString::null; | 371 | mHolidays[i] = QString::null; |
372 | } | 372 | } |
373 | } | 373 | } |
374 | if ( ! mPendingUpdateBeforeRepaint ) | 374 | if ( ! mPendingUpdateBeforeRepaint ) |
375 | repaint(false); | 375 | repaint(false); |
376 | } | 376 | } |
377 | void KODayMatrix::updateView(QDate actdate) | 377 | void KODayMatrix::updateView(QDate actdate) |
378 | { | 378 | { |
379 | 379 | ||
380 | if ( ! actdate.isValid() ) { | 380 | if ( ! actdate.isValid() ) { |
381 | //qDebug("date not valid "); | 381 | //qDebug("date not valid "); |
382 | return; | 382 | return; |
383 | } | 383 | } |
384 | mDayChanged = false; | 384 | mDayChanged = false; |
385 | //flag to indicate if the starting day of the matrix has changed by this call | 385 | //flag to indicate if the starting day of the matrix has changed by this call |
386 | //mDayChanged = false; | 386 | //mDayChanged = false; |
387 | // if a new startdate is to be set then apply Cornelius's calculation | 387 | // if a new startdate is to be set then apply Cornelius's calculation |
388 | // of the first day to be shown | 388 | // of the first day to be shown |
389 | if (actdate != startdate) { | 389 | if (actdate != startdate) { |
390 | // reset index of selection according to shift of starting date from startdate to actdate | 390 | // reset index of selection according to shift of starting date from startdate to actdate |
391 | if (mSelStart != NOSELECTION) { | 391 | if (mSelStart != NOSELECTION) { |
392 | int tmp = actdate.daysTo(startdate); | 392 | int tmp = actdate.daysTo(startdate); |
393 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 393 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
394 | // shift selection if new one would be visible at least partly ! | 394 | // shift selection if new one would be visible at least partly ! |
395 | 395 | ||
396 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 396 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
397 | // nested if is required for next X display pushed from a different month - correction required | 397 | // nested if is required for next X display pushed from a different month - correction required |
398 | // otherwise, for month forward and backward, it must be avoided | 398 | // otherwise, for month forward and backward, it must be avoided |
399 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 399 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
400 | mSelStart = mSelStart + tmp; | 400 | mSelStart = mSelStart + tmp; |
401 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 401 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
402 | mSelEnd = mSelEnd + tmp; | 402 | mSelEnd = mSelEnd + tmp; |
403 | } | 403 | } |
404 | } | 404 | } |
405 | startdate = actdate; | 405 | startdate = actdate; |
406 | mDayChanged = true; | 406 | mDayChanged = true; |
407 | recalculateToday(); | 407 | recalculateToday(); |
408 | } | 408 | } |
409 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 409 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
410 | if ( !isVisible() ) { | 410 | if ( !isVisible() ) { |
411 | mPendingUpdateBeforeRepaint = true; | 411 | mPendingUpdateBeforeRepaint = true; |
412 | } else { | 412 | } else { |
413 | #ifdef DESKTOP_VERSION | 413 | #ifdef DESKTOP_VERSION |
414 | //mRepaintTimer->start( 150 ); | 414 | //mRepaintTimer->start( 100 ); |
415 | mUpdateTimer->start( 150 ); | 415 | mUpdateTimer->start( 100 ); |
416 | #else | 416 | #else |
417 | mRepaintTimer->start( 350 ); | 417 | mRepaintTimer->start( 350 ); |
418 | mUpdateTimer->start( 1200 ); | 418 | mUpdateTimer->start( 1200 ); |
419 | #endif | 419 | #endif |
420 | } | 420 | } |
421 | } | 421 | } |
422 | void KODayMatrix::updateEvents() | 422 | void KODayMatrix::updateEvents() |
423 | { | 423 | { |
424 | if ( !mCalendar ) return; | 424 | if ( !mCalendar ) return; |
425 | 425 | ||
426 | for( int i = 0; i < NUMDAYS; i++ ) { | 426 | for( int i = 0; i < NUMDAYS; i++ ) { |
427 | // if events are set for the day then remember to draw it bold | 427 | // if events are set for the day then remember to draw it bold |
428 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 428 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
429 | int numEvents = eventlist.count(); | 429 | int numEvents = eventlist.count(); |
430 | Event *event; | 430 | Event *event; |
431 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 431 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
432 | ushort recurType = event->doesRecur(); | 432 | ushort recurType = event->doesRecur(); |
433 | 433 | ||
434 | if ( ( recurType == Recurrence::rDaily && | 434 | if ( ( recurType == Recurrence::rDaily && |
435 | !KOPrefs::instance()->mDailyRecur ) || | 435 | !KOPrefs::instance()->mDailyRecur ) || |
436 | ( recurType == Recurrence::rWeekly && | 436 | ( recurType == Recurrence::rWeekly && |
437 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 437 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
438 | numEvents--; | 438 | numEvents--; |
439 | } | 439 | } |
440 | } | 440 | } |
441 | events[ i ] = numEvents; | 441 | events[ i ] = numEvents; |
442 | } | 442 | } |
443 | } | 443 | } |
444 | 444 | ||
445 | const QDate& KODayMatrix::getDate(int offset) | 445 | const QDate& KODayMatrix::getDate(int offset) |
446 | { | 446 | { |
447 | if (offset < 0 || offset > NUMDAYS-1) { | 447 | if (offset < 0 || offset > NUMDAYS-1) { |
448 | qDebug("Wrong offset2 %d", offset); | 448 | qDebug("Wrong offset2 %d", offset); |
449 | return days[0]; | 449 | return days[0]; |
450 | } | 450 | } |
451 | return days[offset]; | 451 | return days[offset]; |
452 | } | 452 | } |
453 | 453 | ||
454 | QString KODayMatrix::getHolidayLabel(int offset) | 454 | QString KODayMatrix::getHolidayLabel(int offset) |
455 | { | 455 | { |
456 | if (offset < 0 || offset > NUMDAYS-1) { | 456 | if (offset < 0 || offset > NUMDAYS-1) { |
457 | qDebug("Wrong offset1 %d", offset); | 457 | qDebug("Wrong offset1 %d", offset); |
458 | return QString(); | 458 | return QString(); |
459 | } | 459 | } |
460 | return mHolidays[offset]; | 460 | return mHolidays[offset]; |
461 | } | 461 | } |
462 | 462 | ||
463 | int KODayMatrix::getDayIndexFrom(int x, int y) | 463 | int KODayMatrix::getDayIndexFrom(int x, int y) |
@@ -790,130 +790,134 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) | |||
790 | actcol = mDefaultTextColorShaded; | 790 | actcol = mDefaultTextColorShaded; |
791 | } | 791 | } |
792 | p.setPen(actcol); | 792 | p.setPen(actcol); |
793 | } | 793 | } |
794 | if (actcol == mDefaultTextColorShaded) { | 794 | if (actcol == mDefaultTextColorShaded) { |
795 | if ( ! mouseDown ) { | 795 | if ( ! mouseDown ) { |
796 | continue; | 796 | continue; |
797 | } | 797 | } |
798 | } | 798 | } |
799 | //Reset pen color after selected days block | 799 | //Reset pen color after selected days block |
800 | if (i == mSelEndT+1) { | 800 | if (i == mSelEndT+1) { |
801 | p.setPen(actcol); | 801 | p.setPen(actcol); |
802 | } | 802 | } |
803 | 803 | ||
804 | // if today then draw rectangle around day | 804 | // if today then draw rectangle around day |
805 | if (today == i) { | 805 | if (today == i) { |
806 | tmppen = p.pen(); | 806 | tmppen = p.pen(); |
807 | QPen mTodayPen(p.pen()); | 807 | QPen mTodayPen(p.pen()); |
808 | if ( daysize.width() < 20 ) | 808 | if ( daysize.width() < 20 ) |
809 | mTodayPen.setWidth(1); | 809 | mTodayPen.setWidth(1); |
810 | else | 810 | else |
811 | mTodayPen.setWidth(mTodayMarginWidth); | 811 | mTodayPen.setWidth(mTodayMarginWidth); |
812 | //draw red rectangle for holidays | 812 | //draw red rectangle for holidays |
813 | if (!mHolidays[i].isNull()) { | 813 | if (!mHolidays[i].isNull()) { |
814 | if (actcol == mDefaultTextColor) { | 814 | if (actcol == mDefaultTextColor) { |
815 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 815 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
816 | } else { | 816 | } else { |
817 | mTodayPen.setColor(mHolidayColorShaded); | 817 | mTodayPen.setColor(mHolidayColorShaded); |
818 | } | 818 | } |
819 | } | 819 | } |
820 | //draw gray rectangle for today if in selection | 820 | //draw gray rectangle for today if in selection |
821 | if (i >= mSelStartT && i <= mSelEndT) { | 821 | if (i >= mSelStartT && i <= mSelEndT) { |
822 | QColor grey("grey"); | 822 | QColor grey("grey"); |
823 | mTodayPen.setColor(grey); | 823 | mTodayPen.setColor(grey); |
824 | } | 824 | } |
825 | p.setPen(mTodayPen); | 825 | p.setPen(mTodayPen); |
826 | 826 | ||
827 | 827 | ||
828 | int addCol = 0; | 828 | int addCol = 0; |
829 | int addRow = 0; | 829 | int addRow = 0; |
830 | if (rowModulo) { | 830 | if (rowModulo) { |
831 | if ( row >= 6 - rowModulo ) | 831 | if ( row >= 6 - rowModulo ) |
832 | addRow = row - 5 + rowModulo; | 832 | addRow = row - 5 + rowModulo; |
833 | } | 833 | } |
834 | if ( colModulo ) { | 834 | if ( colModulo ) { |
835 | if ( col >= 7 - colModulo ) | 835 | if ( col >= 7 - colModulo ) |
836 | addCol = col - 6 + colModulo-1; | 836 | addCol = col - 6 + colModulo-1; |
837 | } | 837 | } |
838 | if ( col == 0 ) | ||
839 | addCol = 1; | ||
838 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); | 840 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); |
839 | p.setPen(tmppen); | 841 | p.setPen(tmppen); |
840 | } | 842 | } |
841 | 843 | ||
842 | // if any events are on that day then draw it using a bold font | 844 | // if any events are on that day then draw it using a bold font |
843 | if (events[i] > 0) { | 845 | if (events[i] > 0) { |
844 | QFont myFont = font(); | 846 | QFont myFont = font(); |
845 | myFont.setBold(true); | 847 | myFont.setBold(true); |
846 | p.setFont(myFont); | 848 | p.setFont(myFont); |
847 | } | 849 | } |
848 | 850 | ||
849 | // if it is a holiday then use the default holiday color | 851 | // if it is a holiday then use the default holiday color |
850 | if (!mHolidays[i].isNull()) { | 852 | if (!mHolidays[i].isNull()) { |
851 | if ( bDays.testBit(i) ) { | 853 | if ( bDays.testBit(i) ) { |
852 | p.setPen(Qt::green); | 854 | p.setPen(Qt::green); |
853 | } else { | 855 | } else { |
854 | if (actcol == mDefaultTextColor) { | 856 | if (actcol == mDefaultTextColor) { |
855 | p.setPen(KOPrefs::instance()->mHolidayColor); | 857 | p.setPen(KOPrefs::instance()->mHolidayColor); |
856 | } else { | 858 | } else { |
857 | p.setPen(mHolidayColorShaded); | 859 | p.setPen(mHolidayColorShaded); |
858 | } | 860 | } |
859 | } | 861 | } |
860 | } | 862 | } |
861 | 863 | ||
862 | // draw selected days with special color | 864 | // draw selected days with special color |
863 | // DO NOT specially highlight holidays in selection ! | 865 | // DO NOT specially highlight holidays in selection ! |
864 | if (i >= mSelStartT && i <= mSelEndT) { | 866 | if (i >= mSelStartT && i <= mSelEndT) { |
865 | ;//p.setPen(mSelectedDaysColor); | 867 | ;//p.setPen(mSelectedDaysColor); |
866 | } | 868 | } |
867 | 869 | ||
868 | int addCol = 0; | 870 | int addCol = 0; |
869 | int addRow = 0; | 871 | int addRow = 0; |
870 | if ( colModulo ) { | 872 | if ( colModulo ) { |
871 | if ( col >= 7 - colModulo ) | 873 | if ( col >= 7 - colModulo ) |
872 | addCol = col - 7 + colModulo; | 874 | addCol = col - 7 + colModulo; |
873 | } | 875 | } |
874 | if ( rowModulo ) { | 876 | if ( rowModulo ) { |
875 | if ( row >= 6 - rowModulo ) | 877 | if ( row >= 6 - rowModulo ) |
876 | addRow = row - 5 + rowModulo; | 878 | addRow = row - 5 + rowModulo; |
877 | } | 879 | } |
878 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); | 880 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); |
879 | ++addCol;//++addCol; | 881 | ++addCol;//++addCol; |
882 | if ( row == 0) | ||
883 | addRow = 1; | ||
880 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, | 884 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, |
881 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 885 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
882 | 886 | ||
883 | // reset color to actual color | 887 | // reset color to actual color |
884 | if (!mHolidays[i].isNull()) { | 888 | if (!mHolidays[i].isNull()) { |
885 | p.setPen(actcol); | 889 | p.setPen(actcol); |
886 | } | 890 | } |
887 | // reset bold font to plain font | 891 | // reset bold font to plain font |
888 | if (events[i] > 0) { | 892 | if (events[i] > 0) { |
889 | QFont myFont = font(); | 893 | QFont myFont = font(); |
890 | myFont.setBold(false); | 894 | myFont.setBold(false); |
891 | p.setFont(myFont); | 895 | p.setFont(myFont); |
892 | } | 896 | } |
893 | } | 897 | } |
894 | int off = xyOff; | 898 | int off = xyOff; |
895 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); | 899 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); |
896 | //qDebug("ffffffffff %d ", off); | 900 | //qDebug("ffffffffff %d ", off); |
897 | } | 901 | } |
898 | 902 | ||
899 | // ---------------------------------------------------------------------------- | 903 | // ---------------------------------------------------------------------------- |
900 | // R E SI Z E E V E N T H A N D L I N G | 904 | // R E SI Z E E V E N T H A N D L I N G |
901 | // ---------------------------------------------------------------------------- | 905 | // ---------------------------------------------------------------------------- |
902 | 906 | ||
903 | void KODayMatrix::resizeEvent(QResizeEvent *) | 907 | void KODayMatrix::resizeEvent(QResizeEvent *) |
904 | { | 908 | { |
905 | QRect sz = frameRect(); | 909 | QRect sz = frameRect(); |
906 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 910 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
907 | daysize.setWidth(sz.width() / 7); | 911 | daysize.setWidth(sz.width() / 7); |
908 | } | 912 | } |
909 | 913 | ||
910 | QSize KODayMatrix::sizeHint() const | 914 | QSize KODayMatrix::sizeHint() const |
911 | { | 915 | { |
912 | 916 | ||
913 | QFontMetrics fm ( font() ); | 917 | QFontMetrics fm ( font() ); |
914 | int wid = fm.width( "30") *7+3; | 918 | int wid = fm.width( "30") *7+3; |
915 | int hei = fm.height() * 6+3; | 919 | int hei = fm.height() * 6+3; |
916 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | 920 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); |
917 | return QSize ( wid, hei ); | 921 | return QSize ( wid, hei ); |
918 | 922 | ||
919 | } | 923 | } |