author | zautrix <zautrix> | 2005-01-31 09:21:57 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-31 09:21:57 (UTC) |
commit | 1c5f4d993bf5eeb4a21bacf61671a1a08ed1f3cd (patch) (unidiff) | |
tree | dd55b89fd37ffb8a880c175c5237f5ca57ca6d4c /korganizer | |
parent | 9b13105b4cc0ede4ca2d01a3d998fdb90bf67b58 (diff) | |
download | kdepimpi-1c5f4d993bf5eeb4a21bacf61671a1a08ed1f3cd.zip kdepimpi-1c5f4d993bf5eeb4a21bacf61671a1a08ed1f3cd.tar.gz kdepimpi-1c5f4d993bf5eeb4a21bacf61671a1a08ed1f3cd.tar.bz2 |
fix
-rw-r--r-- | korganizer/kodaymatrix.cpp | 12 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 9812321..ca896b5 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -119,278 +119,278 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const | |||
119 | updateView(); | 119 | updateView(); |
120 | } | 120 | } |
121 | 121 | ||
122 | QColor KODayMatrix::getShadedColor(QColor color) | 122 | QColor KODayMatrix::getShadedColor(QColor color) |
123 | { | 123 | { |
124 | QColor shaded; | 124 | QColor shaded; |
125 | int h=0; | 125 | int h=0; |
126 | int s=0; | 126 | int s=0; |
127 | int v=0; | 127 | int v=0; |
128 | color.hsv(&h,&s,&v); | 128 | color.hsv(&h,&s,&v); |
129 | s = s/4; | 129 | s = s/4; |
130 | v = 192+v/4; | 130 | v = 192+v/4; |
131 | shaded.setHsv(h,s,v); | 131 | shaded.setHsv(h,s,v); |
132 | 132 | ||
133 | return shaded; | 133 | return shaded; |
134 | } | 134 | } |
135 | 135 | ||
136 | KODayMatrix::~KODayMatrix() | 136 | KODayMatrix::~KODayMatrix() |
137 | { | 137 | { |
138 | delete [] days; | 138 | delete [] days; |
139 | delete [] daylbls; | 139 | delete [] daylbls; |
140 | delete [] events; | 140 | delete [] events; |
141 | delete mToolTip; | 141 | delete mToolTip; |
142 | } | 142 | } |
143 | 143 | ||
144 | /* | 144 | /* |
145 | void KODayMatrix::setStartDate(QDate start) | 145 | void KODayMatrix::setStartDate(QDate start) |
146 | { | 146 | { |
147 | updateView(start); | 147 | updateView(start); |
148 | } | 148 | } |
149 | */ | 149 | */ |
150 | 150 | ||
151 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 151 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
152 | { | 152 | { |
153 | 153 | ||
154 | if (mSelStart == NOSELECTION) { | 154 | if (mSelStart == NOSELECTION) { |
155 | return; | 155 | return; |
156 | } | 156 | } |
157 | 157 | ||
158 | //cope with selection being out of matrix limits at top (< 0) | 158 | //cope with selection being out of matrix limits at top (< 0) |
159 | int i0 = mSelStart; | 159 | int i0 = mSelStart; |
160 | if (i0 < 0) { | 160 | if (i0 < 0) { |
161 | for (int i = i0; i < 0; i++) { | 161 | for (int i = i0; i < 0; i++) { |
162 | selDays.append(days[0].addDays(i)); | 162 | selDays.append(days[0].addDays(i)); |
163 | } | 163 | } |
164 | i0 = 0; | 164 | i0 = 0; |
165 | } | 165 | } |
166 | 166 | ||
167 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 167 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
168 | if (mSelEnd > NUMDAYS-1) { | 168 | if (mSelEnd > NUMDAYS-1) { |
169 | for (int i = i0; i <= NUMDAYS-1; i++) { | 169 | for (int i = i0; i <= NUMDAYS-1; i++) { |
170 | selDays.append(days[i]); | 170 | selDays.append(days[i]); |
171 | } | 171 | } |
172 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 172 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
173 | selDays.append(days[0].addDays(i)); | 173 | selDays.append(days[0].addDays(i)); |
174 | } | 174 | } |
175 | 175 | ||
176 | // apply normal routine to selection being entirely within matrix limits | 176 | // apply normal routine to selection being entirely within matrix limits |
177 | } else { | 177 | } else { |
178 | for (int i = i0; i <= mSelEnd; i++) { | 178 | for (int i = i0; i <= mSelEnd; i++) { |
179 | selDays.append(days[i]); | 179 | selDays.append(days[i]); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 184 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
185 | { | 185 | { |
186 | mSelStart = startdate.daysTo(start); | 186 | mSelStart = startdate.daysTo(start); |
187 | mSelEnd = startdate.daysTo(end); | 187 | mSelEnd = startdate.daysTo(end); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | void KODayMatrix::recalculateToday() | 191 | void KODayMatrix::recalculateToday() |
192 | { | 192 | { |
193 | today = -1; | 193 | today = -1; |
194 | for (int i=0; i<NUMDAYS; i++) { | 194 | for (int i=0; i<NUMDAYS; i++) { |
195 | events[i] = 0; | 195 | events[i] = 0; |
196 | days[i] = startdate.addDays(i); | 196 | days[i] = startdate.addDays(i); |
197 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 197 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
198 | 198 | ||
199 | // if today is in the currently displayed month, hilight today | 199 | // if today is in the currently displayed month, hilight today |
200 | if (days[i].year() == QDate::currentDate().year() && | 200 | if (days[i].year() == QDate::currentDate().year() && |
201 | days[i].month() == QDate::currentDate().month() && | 201 | days[i].month() == QDate::currentDate().month() && |
202 | days[i].day() == QDate::currentDate().day()) { | 202 | days[i].day() == QDate::currentDate().day()) { |
203 | today = i; | 203 | today = i; |
204 | } | 204 | } |
205 | } | 205 | } |
206 | // qDebug(QString("Today is visible at %1.").arg(today)); | 206 | // qDebug(QString("Today is visible at %1.").arg(today)); |
207 | } | 207 | } |
208 | 208 | ||
209 | void KODayMatrix::updateView() | 209 | void KODayMatrix::updateView() |
210 | { | 210 | { |
211 | updateView(startdate); | 211 | updateView(startdate); |
212 | } | 212 | } |
213 | void KODayMatrix::repaintViewTimed() | 213 | void KODayMatrix::repaintViewTimed() |
214 | { | 214 | { |
215 | //qDebug("KODayMatrix::repaintViewTimed "); | 215 | qDebug("KODayMatrix::repaintViewTimed "); |
216 | mRepaintTimer->stop(); | 216 | mRepaintTimer->stop(); |
217 | repaint(false); | 217 | repaint(false); |
218 | } | 218 | } |
219 | void KODayMatrix::updateViewTimed() | 219 | void KODayMatrix::updateViewTimed() |
220 | { | 220 | { |
221 | 221 | ||
222 | mUpdateTimer->stop(); | 222 | mUpdateTimer->stop(); |
223 | //qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii ); | 223 | qDebug("KODayMatrix::updateView(QDate actdate)"); |
224 | for(int i = 0; i < NUMDAYS; i++) { | 224 | for(int i = 0; i < NUMDAYS; i++) { |
225 | 225 | ||
226 | // if events are set for the day then remember to draw it bold | 226 | // if events are set for the day then remember to draw it bold |
227 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 227 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
228 | Event *event; | 228 | Event *event; |
229 | int numEvents = eventlist.count(); | 229 | int numEvents = eventlist.count(); |
230 | 230 | ||
231 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 231 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
232 | ushort recurType = event->recurrence()->doesRecur(); | 232 | ushort recurType = event->recurrence()->doesRecur(); |
233 | 233 | ||
234 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 234 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
235 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 235 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
236 | numEvents--; | 236 | numEvents--; |
237 | } | 237 | } |
238 | } | 238 | } |
239 | events[i] = numEvents; | 239 | events[i] = numEvents; |
240 | 240 | ||
241 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 241 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
242 | #ifndef KORG_NOPLUGINS | 242 | #ifndef KORG_NOPLUGINS |
243 | QString holiStr = KOCore::self()->holiday(days[i]); | 243 | QString holiStr = KOCore::self()->holiday(days[i]); |
244 | #else | 244 | #else |
245 | QString holiStr = QString::null; | 245 | QString holiStr = QString::null; |
246 | #endif | 246 | #endif |
247 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 247 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
248 | !holiStr.isEmpty()) { | 248 | !holiStr.isEmpty()) { |
249 | if (holiStr.isNull()) holiStr = ""; | 249 | if (holiStr.isNull()) holiStr = ""; |
250 | mHolidays[i] = holiStr; | 250 | mHolidays[i] = holiStr; |
251 | 251 | ||
252 | } else { | 252 | } else { |
253 | mHolidays[i] = QString::null; | 253 | mHolidays[i] = QString::null; |
254 | } | 254 | } |
255 | } | 255 | } |
256 | if ( ! mPendingUpdateBeforeRepaint ) | 256 | if ( ! mPendingUpdateBeforeRepaint ) |
257 | repaint(false); | 257 | repaint(false); |
258 | } | 258 | } |
259 | void KODayMatrix::updateView(QDate actdate) | 259 | void KODayMatrix::updateView(QDate actdate) |
260 | { | 260 | { |
261 | 261 | ||
262 | if ( ! actdate.isValid() ) { | 262 | if ( ! actdate.isValid() ) { |
263 | //qDebug("date not valid "); | 263 | //qDebug("date not valid "); |
264 | return; | 264 | return; |
265 | } | 265 | } |
266 | mDayChanged = false; | 266 | mDayChanged = false; |
267 | //flag to indicate if the starting day of the matrix has changed by this call | 267 | //flag to indicate if the starting day of the matrix has changed by this call |
268 | //mDayChanged = false; | 268 | //mDayChanged = false; |
269 | // if a new startdate is to be set then apply Cornelius's calculation | 269 | // if a new startdate is to be set then apply Cornelius's calculation |
270 | // of the first day to be shown | 270 | // of the first day to be shown |
271 | if (actdate != startdate) { | 271 | if (actdate != startdate) { |
272 | // reset index of selection according to shift of starting date from startdate to actdate | 272 | // reset index of selection according to shift of starting date from startdate to actdate |
273 | if (mSelStart != NOSELECTION) { | 273 | if (mSelStart != NOSELECTION) { |
274 | int tmp = actdate.daysTo(startdate); | 274 | int tmp = actdate.daysTo(startdate); |
275 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 275 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
276 | // shift selection if new one would be visible at least partly ! | 276 | // shift selection if new one would be visible at least partly ! |
277 | 277 | ||
278 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 278 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
279 | // nested if is required for next X display pushed from a different month - correction required | 279 | // nested if is required for next X display pushed from a different month - correction required |
280 | // otherwise, for month forward and backward, it must be avoided | 280 | // otherwise, for month forward and backward, it must be avoided |
281 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 281 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
282 | mSelStart = mSelStart + tmp; | 282 | mSelStart = mSelStart + tmp; |
283 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 283 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
284 | mSelEnd = mSelEnd + tmp; | 284 | mSelEnd = mSelEnd + tmp; |
285 | } | 285 | } |
286 | } | 286 | } |
287 | startdate = actdate; | 287 | startdate = actdate; |
288 | mDayChanged = true; | 288 | mDayChanged = true; |
289 | recalculateToday(); | 289 | recalculateToday(); |
290 | } | 290 | } |
291 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 291 | qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
292 | if ( !isVisible() ) { | 292 | if ( !isVisible() ) { |
293 | mPendingUpdateBeforeRepaint = true; | 293 | mPendingUpdateBeforeRepaint = true; |
294 | } else { | 294 | } else { |
295 | #ifdef DESKTOP_VERSION | 295 | #ifdef DESKTOP_VERSION |
296 | mRepaintTimer->start( 250 ); | 296 | //mRepaintTimer->start( 250 ); |
297 | mUpdateTimer->start( 2000 ); | 297 | mUpdateTimer->start( 250 ); |
298 | #else | 298 | #else |
299 | mRepaintTimer->start( 350 ); | 299 | mRepaintTimer->start( 350 ); |
300 | mUpdateTimer->start( 4000 ); | 300 | mUpdateTimer->start( 2000 ); |
301 | #endif | 301 | #endif |
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
305 | const QDate& KODayMatrix::getDate(int offset) | 305 | const QDate& KODayMatrix::getDate(int offset) |
306 | { | 306 | { |
307 | if (offset < 0 || offset > NUMDAYS-1) { | 307 | if (offset < 0 || offset > NUMDAYS-1) { |
308 | qDebug("Wrong offset2 "); | 308 | qDebug("Wrong offset2 "); |
309 | return days[0]; | 309 | return days[0]; |
310 | } | 310 | } |
311 | return days[offset]; | 311 | return days[offset]; |
312 | } | 312 | } |
313 | 313 | ||
314 | QString KODayMatrix::getHolidayLabel(int offset) | 314 | QString KODayMatrix::getHolidayLabel(int offset) |
315 | { | 315 | { |
316 | if (offset < 0 || offset > NUMDAYS-1) { | 316 | if (offset < 0 || offset > NUMDAYS-1) { |
317 | qDebug("Wrong offset1 "); | 317 | qDebug("Wrong offset1 "); |
318 | return 0; | 318 | return 0; |
319 | } | 319 | } |
320 | return mHolidays[offset]; | 320 | return mHolidays[offset]; |
321 | } | 321 | } |
322 | 322 | ||
323 | int KODayMatrix::getDayIndexFrom(int x, int y) | 323 | int KODayMatrix::getDayIndexFrom(int x, int y) |
324 | { | 324 | { |
325 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 325 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
326 | 6 - x/daysize.width() : x/daysize.width()); | 326 | 6 - x/daysize.width() : x/daysize.width()); |
327 | } | 327 | } |
328 | 328 | ||
329 | // ---------------------------------------------------------------------------- | 329 | // ---------------------------------------------------------------------------- |
330 | // M O U S E E V E N T H A N D L I N G | 330 | // M O U S E E V E N T H A N D L I N G |
331 | // ---------------------------------------------------------------------------- | 331 | // ---------------------------------------------------------------------------- |
332 | 332 | ||
333 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 333 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
334 | { | 334 | { |
335 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 335 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
336 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 336 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
337 | mSelInit = mSelStart; | 337 | mSelInit = mSelStart; |
338 | } | 338 | } |
339 | 339 | ||
340 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 340 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
341 | { | 341 | { |
342 | 342 | ||
343 | int tmp = getDayIndexFrom(e->x(), e->y()); | 343 | int tmp = getDayIndexFrom(e->x(), e->y()); |
344 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 344 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
345 | 345 | ||
346 | if (mSelInit > tmp) { | 346 | if (mSelInit > tmp) { |
347 | mSelEnd = mSelInit; | 347 | mSelEnd = mSelInit; |
348 | if (tmp != mSelStart) { | 348 | if (tmp != mSelStart) { |
349 | mSelStart = tmp; | 349 | mSelStart = tmp; |
350 | repaint(); | 350 | repaint(); |
351 | } | 351 | } |
352 | } else { | 352 | } else { |
353 | mSelStart = mSelInit; | 353 | mSelStart = mSelInit; |
354 | 354 | ||
355 | //repaint only if selection has changed | 355 | //repaint only if selection has changed |
356 | if (tmp != mSelEnd) { | 356 | if (tmp != mSelEnd) { |
357 | mSelEnd = tmp; | 357 | mSelEnd = tmp; |
358 | repaint(); | 358 | repaint(); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | DateList daylist; | 362 | DateList daylist; |
363 | if ( mSelStart < 0 ) | 363 | if ( mSelStart < 0 ) |
364 | mSelStart = 0; | 364 | mSelStart = 0; |
365 | for (int i = mSelStart; i <= mSelEnd; i++) { | 365 | for (int i = mSelStart; i <= mSelEnd; i++) { |
366 | daylist.append(days[i]); | 366 | daylist.append(days[i]); |
367 | } | 367 | } |
368 | emit selected((const DateList)daylist); | 368 | emit selected((const DateList)daylist); |
369 | 369 | ||
370 | } | 370 | } |
371 | 371 | ||
372 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 372 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
373 | { | 373 | { |
374 | int tmp = getDayIndexFrom(e->x(), e->y()); | 374 | int tmp = getDayIndexFrom(e->x(), e->y()); |
375 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 375 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
376 | 376 | ||
377 | if (mSelInit > tmp) { | 377 | if (mSelInit > tmp) { |
378 | mSelEnd = mSelInit; | 378 | mSelEnd = mSelInit; |
379 | if (tmp != mSelStart) { | 379 | if (tmp != mSelStart) { |
380 | mSelStart = tmp; | 380 | mSelStart = tmp; |
381 | repaint(); | 381 | repaint(); |
382 | } | 382 | } |
383 | } else { | 383 | } else { |
384 | mSelStart = mSelInit; | 384 | mSelStart = mSelInit; |
385 | 385 | ||
386 | //repaint only if selection has changed | 386 | //repaint only if selection has changed |
387 | if (tmp != mSelEnd) { | 387 | if (tmp != mSelEnd) { |
388 | mSelEnd = tmp; | 388 | mSelEnd = tmp; |
389 | repaint(); | 389 | repaint(); |
390 | } | 390 | } |
391 | } | 391 | } |
392 | } | 392 | } |
393 | 393 | ||
394 | // ---------------------------------------------------------------------------- | 394 | // ---------------------------------------------------------------------------- |
395 | // D R A G ' N D R O P H A N D L I N G | 395 | // D R A G ' N D R O P H A N D L I N G |
396 | // ---------------------------------------------------------------------------- | 396 | // ---------------------------------------------------------------------------- |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 1edddac..6bdee18 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -115,192 +115,196 @@ void KOTodoViewItem::construct() | |||
115 | setSortKey(3,keyd); | 115 | setSortKey(3,keyd); |
116 | setSortKey(4,keyt); | 116 | setSortKey(4,keyt); |
117 | 117 | ||
118 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); | 118 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); |
119 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 119 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | if (mTodo->hasStartDate()) { | 123 | if (mTodo->hasStartDate()) { |
124 | setText(5, mTodo->dtStartDateStr()); | 124 | setText(5, mTodo->dtStartDateStr()); |
125 | QDate d = mTodo->dtStart().date(); | 125 | QDate d = mTodo->dtStart().date(); |
126 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 126 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
127 | 127 | ||
128 | if (mTodo->doesFloat()) { | 128 | if (mTodo->doesFloat()) { |
129 | setText(6,""); | 129 | setText(6,""); |
130 | } | 130 | } |
131 | else { | 131 | else { |
132 | setText(6,mTodo->dtStartTimeStr()); | 132 | setText(6,mTodo->dtStartTimeStr()); |
133 | QTime t = mTodo->dtStart().time(); | 133 | QTime t = mTodo->dtStart().time(); |
134 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 134 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
135 | 135 | ||
136 | } | 136 | } |
137 | } else { | 137 | } else { |
138 | setText(5,""); | 138 | setText(5,""); |
139 | setText(6,""); | 139 | setText(6,""); |
140 | } | 140 | } |
141 | setSortKey(5,skeyd); | 141 | setSortKey(5,skeyd); |
142 | setSortKey(6,skeyt); | 142 | setSortKey(6,skeyt); |
143 | 143 | ||
144 | setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); | 144 | setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); |
145 | setText(8,mTodo->categoriesStr()); | 145 | setText(8,mTodo->categoriesStr()); |
146 | 146 | ||
147 | #if 0 | 147 | #if 0 |
148 | // Find sort id in description. It's the text behind the last '#' character | 148 | // Find sort id in description. It's the text behind the last '#' character |
149 | // found in the description. White spaces are removed from beginning and end | 149 | // found in the description. White spaces are removed from beginning and end |
150 | // of sort id. | 150 | // of sort id. |
151 | int pos = mTodo->description().findRev('#'); | 151 | int pos = mTodo->description().findRev('#'); |
152 | if (pos < 0) { | 152 | if (pos < 0) { |
153 | setText(6,""); | 153 | setText(6,""); |
154 | } else { | 154 | } else { |
155 | QString str = mTodo->description().mid(pos+1); | 155 | QString str = mTodo->description().mid(pos+1); |
156 | str.stripWhiteSpace(); | 156 | str.stripWhiteSpace(); |
157 | setText(6,str); | 157 | setText(6,str); |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
160 | 160 | ||
161 | m_known = false; | 161 | m_known = false; |
162 | m_init = false; | 162 | m_init = false; |
163 | 163 | ||
164 | setMyPixmap(); | 164 | setMyPixmap(); |
165 | 165 | ||
166 | } | 166 | } |
167 | void KOTodoViewItem::setMyPixmap() | 167 | void KOTodoViewItem::setMyPixmap() |
168 | { | 168 | { |
169 | int size = 5; | 169 | int size = 5; |
170 | QPixmap pixi = QPixmap( 1, 1 ); | 170 | QPixmap pixi = QPixmap( 1, 1 ); |
171 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 171 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
172 | // pixi = SmallIcon("redcross16"); | 172 | // pixi = SmallIcon("redcross16"); |
173 | // } else { | 173 | // } else { |
174 | QPainter p; | 174 | QPainter p; |
175 | 175 | ||
176 | int pixSize = 0; | 176 | int pixSize = 0; |
177 | QPixmap pPix = QPixmap( size, size ); | 177 | QPixmap pPix = QPixmap( size, size ); |
178 | if ( mTodo->description().length() > 0 ) { | 178 | if ( mTodo->description().length() > 0 ) { |
179 | pixi.resize(size, pixSize+size); | 179 | pixi.resize(size, pixSize+size); |
180 | pPix.fill( Qt::darkGreen ); | 180 | pPix.fill( Qt::darkGreen ); |
181 | p.begin( &pixi ); | 181 | p.begin( &pixi ); |
182 | p. drawPixmap ( 0, pixSize, pPix); | 182 | p. drawPixmap ( 0, pixSize, pPix); |
183 | p.end(); | 183 | p.end(); |
184 | pixSize += size; | 184 | pixSize += size; |
185 | } | 185 | } |
186 | if ( mTodo->isAlarmEnabled() ) { | 186 | if ( mTodo->isAlarmEnabled() ) { |
187 | pixi.resize(size, pixSize+size); | 187 | pixi.resize(size, pixSize+size); |
188 | pPix.fill( Qt::red ); | 188 | pPix.fill( Qt::red ); |
189 | p.begin( &pixi ); | 189 | p.begin( &pixi ); |
190 | p. drawPixmap ( 0, pixSize, pPix); | 190 | p. drawPixmap ( 0, pixSize, pPix); |
191 | p.end(); | 191 | p.end(); |
192 | pixSize += size; | 192 | pixSize += size; |
193 | } | 193 | } |
194 | // } | 194 | // } |
195 | if ( pixi.width() > 1 ) { | 195 | if ( pixi.width() > 1 ) { |
196 | setPixmap ( 0,pixi ) ; | 196 | setPixmap ( 0,pixi ) ; |
197 | } else { | 197 | } else { |
198 | setPixmap ( 0,QPixmap() ) ; | 198 | setPixmap ( 0,QPixmap() ) ; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | void KOTodoViewItem::stateChange(bool state) | 201 | void KOTodoViewItem::stateChange(bool state) |
202 | { | 202 | { |
203 | // qDebug("KOTodoViewItem::stateChange "); | 203 | // qDebug("KOTodoViewItem::stateChange "); |
204 | // do not change setting on startup | 204 | // do not change setting on startup |
205 | if ( m_init ) return; | 205 | if ( m_init ) return; |
206 | if (isOn()!=state) { | 206 | if (isOn()!=state) { |
207 | setOn(state); | 207 | setOn(state); |
208 | //qDebug("SETON "); | 208 | //qDebug("SETON "); |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | if ( mTodo->isCompleted() == state ) { | ||
212 | //qDebug("STATECHANGE:nothing to do "); | ||
213 | return; | ||
214 | } | ||
211 | QString keyd = "=="; | 215 | QString keyd = "=="; |
212 | QString keyt = "=="; | 216 | QString keyt = "=="; |
213 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); | 217 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); |
214 | mTodo->setCompleted(state); | 218 | mTodo->setCompleted(state); |
215 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); | 219 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); |
216 | 220 | ||
217 | if (mTodo->hasDueDate()) { | 221 | if (mTodo->hasDueDate()) { |
218 | setText(3, mTodo->dtDueDateStr()); | 222 | setText(3, mTodo->dtDueDateStr()); |
219 | QDate d = mTodo->dtDue().date(); | 223 | QDate d = mTodo->dtDue().date(); |
220 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 224 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
221 | setSortKey(3,keyd); | 225 | setSortKey(3,keyd); |
222 | if (mTodo->doesFloat()) { | 226 | if (mTodo->doesFloat()) { |
223 | setText(4,""); | 227 | setText(4,""); |
224 | } | 228 | } |
225 | else { | 229 | else { |
226 | setText(4,mTodo->dtDueTimeStr()); | 230 | setText(4,mTodo->dtDueTimeStr()); |
227 | QTime t = mTodo->dtDue().time(); | 231 | QTime t = mTodo->dtDue().time(); |
228 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 232 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
229 | setSortKey(4,keyt); | 233 | setSortKey(4,keyt); |
230 | } | 234 | } |
231 | } | 235 | } |
232 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 236 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
233 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 237 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
234 | 238 | ||
235 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 239 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
236 | if (mTodo->percentComplete()<100) { | 240 | if (mTodo->percentComplete()<100) { |
237 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 241 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
238 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 242 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
239 | } | 243 | } |
240 | else { | 244 | else { |
241 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 245 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
242 | else setSortKey(2,QString::number(99)); | 246 | else setSortKey(2,QString::number(99)); |
243 | } | 247 | } |
244 | if ( state ) { | 248 | if ( state ) { |
245 | QListViewItem * myChild = firstChild(); | 249 | QListViewItem * myChild = firstChild(); |
246 | KOTodoViewItem *item; | 250 | KOTodoViewItem *item; |
247 | while( myChild ) { | 251 | while( myChild ) { |
248 | //qDebug("stateCH "); | 252 | //qDebug("stateCH "); |
249 | item = static_cast<KOTodoViewItem*>(myChild); | 253 | item = static_cast<KOTodoViewItem*>(myChild); |
250 | item->stateChange(state); | 254 | item->stateChange(state); |
251 | myChild = myChild->nextSibling(); | 255 | myChild = myChild->nextSibling(); |
252 | } | 256 | } |
253 | } else { | 257 | } else { |
254 | QListViewItem * myChild = parent(); | 258 | QListViewItem * myChild = parent(); |
255 | if ( myChild ) | 259 | if ( myChild ) |
256 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); | 260 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); |
257 | } | 261 | } |
258 | mTodoView->modified(true); | 262 | mTodoView->modified(true); |
259 | setMyPixmap(); | 263 | setMyPixmap(); |
260 | mTodoView->setTodoModified( mTodo ); | 264 | mTodoView->setTodoModified( mTodo ); |
261 | } | 265 | } |
262 | 266 | ||
263 | bool KOTodoViewItem::isAlternate() | 267 | bool KOTodoViewItem::isAlternate() |
264 | { | 268 | { |
265 | #ifndef KORG_NOLVALTERNATION | 269 | #ifndef KORG_NOLVALTERNATION |
266 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 270 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
267 | if (lv && lv->alternateBackground().isValid()) | 271 | if (lv && lv->alternateBackground().isValid()) |
268 | { | 272 | { |
269 | KOTodoViewItem *above = 0; | 273 | KOTodoViewItem *above = 0; |
270 | above = dynamic_cast<KOTodoViewItem *>(itemAbove()); | 274 | above = dynamic_cast<KOTodoViewItem *>(itemAbove()); |
271 | m_known = above ? above->m_known : true; | 275 | m_known = above ? above->m_known : true; |
272 | if (m_known) | 276 | if (m_known) |
273 | { | 277 | { |
274 | m_odd = above ? !above->m_odd : false; | 278 | m_odd = above ? !above->m_odd : false; |
275 | } | 279 | } |
276 | else | 280 | else |
277 | { | 281 | { |
278 | KOTodoViewItem *item; | 282 | KOTodoViewItem *item; |
279 | bool previous = true; | 283 | bool previous = true; |
280 | if (QListViewItem::parent()) | 284 | if (QListViewItem::parent()) |
281 | { | 285 | { |
282 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); | 286 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); |
283 | if (item) | 287 | if (item) |
284 | previous = item->m_odd; | 288 | previous = item->m_odd; |
285 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); | 289 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); |
286 | } | 290 | } |
287 | else | 291 | else |
288 | { | 292 | { |
289 | item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); | 293 | item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); |
290 | } | 294 | } |
291 | 295 | ||
292 | while(item) | 296 | while(item) |
293 | { | 297 | { |
294 | item->m_odd = previous = !previous; | 298 | item->m_odd = previous = !previous; |
295 | item->m_known = true; | 299 | item->m_known = true; |
296 | item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); | 300 | item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); |
297 | } | 301 | } |
298 | } | 302 | } |
299 | return m_odd; | 303 | return m_odd; |
300 | } | 304 | } |
301 | return false; | 305 | return false; |
302 | #else | 306 | #else |
303 | return false; | 307 | return false; |
304 | #endif | 308 | #endif |
305 | } | 309 | } |
306 | 310 | ||