author | zautrix <zautrix> | 2005-03-19 19:11:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-19 19:11:16 (UTC) |
commit | 414b033f0c39b5122fd4899408a7045a6c29d7c9 (patch) (unidiff) | |
tree | 802d40e62d1b55e9b3a2daca2ba74fc47af15137 /korganizer/kodaymatrix.cpp | |
parent | 0aa5a7dce6ac1224395f7cb3fae488ba566f0e38 (diff) | |
download | kdepimpi-414b033f0c39b5122fd4899408a7045a6c29d7c9.zip kdepimpi-414b033f0c39b5122fd4899408a7045a6c29d7c9.tar.gz kdepimpi-414b033f0c39b5122fd4899408a7045a6c29d7c9.tar.bz2 |
dnc
-rw-r--r-- | korganizer/kodaymatrix.cpp | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 989f758..a886f4a 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -84,16 +84,21 @@ void DynamicTip::maybeTip( const QPoint &pos ) | |||
84 | // K O D A Y M A T R I X | 84 | // K O D A Y M A T R I X |
85 | // ============================================================================ | 85 | // ============================================================================ |
86 | 86 | ||
87 | const int KODayMatrix::NOSELECTION = -1000; | 87 | const int KODayMatrix::NOSELECTION = -1000; |
88 | const int KODayMatrix::NUMDAYS = 42; | 88 | const int KODayMatrix::NUMDAYS = 42; |
89 | 89 | ||
90 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | ||
91 | : QFrame( parent, name ), mCalendar( 0 ) | ||
92 | |||
93 | #if 0 | ||
90 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 94 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
91 | QFrame(parent, name) | 95 | QFrame(parent, name) |
96 | #endif | ||
92 | { | 97 | { |
93 | mCalendar = calendar; | 98 | |
94 | mPendingUpdateBeforeRepaint = false; | 99 | mPendingUpdateBeforeRepaint = false; |
95 | 100 | ||
96 | // initialize dynamic arrays | 101 | // initialize dynamic arrays |
97 | days = new QDate[NUMDAYS]; | 102 | days = new QDate[NUMDAYS]; |
98 | daylbls = new QString[NUMDAYS]; | 103 | daylbls = new QString[NUMDAYS]; |
99 | events = new int[NUMDAYS]; | 104 | events = new int[NUMDAYS]; |
@@ -115,12 +120,20 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const | |||
115 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 120 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
116 | mRepaintTimer = new QTimer( this ); | 121 | mRepaintTimer = new QTimer( this ); |
117 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 122 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
118 | mDayChanged = false; | 123 | mDayChanged = false; |
119 | updateView(); | 124 | updateView(); |
120 | } | 125 | } |
126 | void KODayMatrix::setCalendar( Calendar *cal ) | ||
127 | { | ||
128 | mCalendar = cal; | ||
129 | |||
130 | setAcceptDrops( mCalendar ); | ||
131 | |||
132 | updateEvents(); | ||
133 | } | ||
121 | 134 | ||
122 | QColor KODayMatrix::getShadedColor(QColor color) | 135 | QColor KODayMatrix::getShadedColor(QColor color) |
123 | { | 136 | { |
124 | QColor shaded; | 137 | QColor shaded; |
125 | int h=0; | 138 | int h=0; |
126 | int s=0; | 139 | int s=0; |
@@ -183,12 +196,16 @@ void KODayMatrix::addSelectedDaysTo(DateList& selDays) | |||
183 | 196 | ||
184 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 197 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
185 | { | 198 | { |
186 | mSelStart = startdate.daysTo(start); | 199 | mSelStart = startdate.daysTo(start); |
187 | mSelEnd = startdate.daysTo(end); | 200 | mSelEnd = startdate.daysTo(end); |
188 | } | 201 | } |
202 | void KODayMatrix::clearSelection() | ||
203 | { | ||
204 | mSelEnd = mSelStart = NOSELECTION; | ||
205 | } | ||
189 | 206 | ||
190 | 207 | ||
191 | void KODayMatrix::recalculateToday() | 208 | void KODayMatrix::recalculateToday() |
192 | { | 209 | { |
193 | today = -1; | 210 | today = -1; |
194 | for (int i=0; i<NUMDAYS; i++) { | 211 | for (int i=0; i<NUMDAYS; i++) { |
@@ -214,14 +231,18 @@ void KODayMatrix::repaintViewTimed() | |||
214 | { | 231 | { |
215 | mRepaintTimer->stop(); | 232 | mRepaintTimer->stop(); |
216 | repaint(false); | 233 | repaint(false); |
217 | } | 234 | } |
218 | void KODayMatrix::updateViewTimed() | 235 | void KODayMatrix::updateViewTimed() |
219 | { | 236 | { |
220 | |||
221 | mUpdateTimer->stop(); | 237 | mUpdateTimer->stop(); |
238 | if ( !mCalendar ) { | ||
239 | qDebug("NOT CAL "); | ||
240 | return; | ||
241 | } | ||
242 | //qDebug("KODayMatrix::updateViewTimed "); | ||
222 | for(int i = 0; i < NUMDAYS; i++) { | 243 | for(int i = 0; i < NUMDAYS; i++) { |
223 | // if events are set for the day then remember to draw it bold | 244 | // if events are set for the day then remember to draw it bold |
224 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 245 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
225 | Event *event; | 246 | Event *event; |
226 | int numEvents = eventlist.count(); | 247 | int numEvents = eventlist.count(); |
227 | QString holiStr = ""; | 248 | QString holiStr = ""; |
@@ -291,12 +312,34 @@ void KODayMatrix::updateView(QDate actdate) | |||
291 | #else | 312 | #else |
292 | mRepaintTimer->start( 350 ); | 313 | mRepaintTimer->start( 350 ); |
293 | mUpdateTimer->start( 2000 ); | 314 | mUpdateTimer->start( 2000 ); |
294 | #endif | 315 | #endif |
295 | } | 316 | } |
296 | } | 317 | } |
318 | void KODayMatrix::updateEvents() | ||
319 | { | ||
320 | if ( !mCalendar ) return; | ||
321 | |||
322 | for( int i = 0; i < NUMDAYS; i++ ) { | ||
323 | // if events are set for the day then remember to draw it bold | ||
324 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | ||
325 | int numEvents = eventlist.count(); | ||
326 | Event *event; | ||
327 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | ||
328 | ushort recurType = event->doesRecur(); | ||
329 | |||
330 | if ( ( recurType == Recurrence::rDaily && | ||
331 | !KOPrefs::instance()->mDailyRecur ) || | ||
332 | ( recurType == Recurrence::rWeekly && | ||
333 | !KOPrefs::instance()->mWeeklyRecur ) ) { | ||
334 | numEvents--; | ||
335 | } | ||
336 | } | ||
337 | events[ i ] = numEvents; | ||
338 | } | ||
339 | } | ||
297 | 340 | ||
298 | const QDate& KODayMatrix::getDate(int offset) | 341 | const QDate& KODayMatrix::getDate(int offset) |
299 | { | 342 | { |
300 | if (offset < 0 || offset > NUMDAYS-1) { | 343 | if (offset < 0 || offset > NUMDAYS-1) { |
301 | qDebug("Wrong offset2 "); | 344 | qDebug("Wrong offset2 "); |
302 | return days[0]; | 345 | return days[0]; |
@@ -425,13 +468,13 @@ void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | |||
425 | 468 | ||
426 | void KODayMatrix::dropEvent(QDropEvent *e) | 469 | void KODayMatrix::dropEvent(QDropEvent *e) |
427 | { | 470 | { |
428 | #ifndef KORG_NODND | 471 | #ifndef KORG_NODND |
429 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 472 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
430 | 473 | ||
431 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 474 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
432 | e->ignore(); | 475 | e->ignore(); |
433 | return; | 476 | return; |
434 | } | 477 | } |
435 | 478 | ||
436 | DndFactory factory( mCalendar ); | 479 | DndFactory factory( mCalendar ); |
437 | Event *event = factory.createDrop(e); | 480 | Event *event = factory.createDrop(e); |