author | zautrix <zautrix> | 2005-07-09 23:58:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-09 23:58:28 (UTC) |
commit | 2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b (patch) (unidiff) | |
tree | e57782981707d6932940d0489fc942bfeab40dd6 /korganizer/kotodoviewitem.cpp | |
parent | 47370b5d0dea0f29bb929ba13cf45186095c762d (diff) | |
download | kdepimpi-2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b.zip kdepimpi-2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b.tar.gz kdepimpi-2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b.tar.bz2 |
fixxx
Diffstat (limited to 'korganizer/kotodoviewitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 66 |
1 files changed, 58 insertions, 8 deletions
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 0cf6e4c..bdef94c 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -108,100 +108,116 @@ void KOTodoViewItem::construct() | |||
108 | QTime t = mTodo->dtDue().time(); | 108 | QTime t = mTodo->dtDue().time(); |
109 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 109 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
110 | //setSortKey(4,keyt); | 110 | //setSortKey(4,keyt); |
111 | } | 111 | } |
112 | } else { | 112 | } else { |
113 | setText(3,""); | 113 | setText(3,""); |
114 | setText(4,""); | 114 | setText(4,""); |
115 | } | 115 | } |
116 | setSortKey(3,keyd); | 116 | setSortKey(3,keyd); |
117 | setSortKey(4,keyt); | 117 | setSortKey(4,keyt); |
118 | 118 | ||
119 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); | 119 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); |
120 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 120 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
121 | 121 | ||
122 | 122 | ||
123 | 123 | ||
124 | keyd = ""; | 124 | keyd = ""; |
125 | keyt = ""; | 125 | keyt = ""; |
126 | 126 | ||
127 | if (mTodo->isRunning() ) { | 127 | if (mTodo->isRunning() ) { |
128 | QDate d = mTodo->runStart().date(); | 128 | QDate d = mTodo->runStart().date(); |
129 | QTime t = mTodo->runStart().time(); | 129 | QTime t = mTodo->runStart().time(); |
130 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 130 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
131 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 131 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
132 | keyd = KGlobal::locale()->formatDate( d , true); | 132 | keyd = KGlobal::locale()->formatDate( d , true); |
133 | keyt = KGlobal::locale()->formatTime( t ); | 133 | keyt = KGlobal::locale()->formatTime( t ); |
134 | 134 | ||
135 | } else { | 135 | } else { |
136 | 136 | ||
137 | if (mTodo->hasStartDate()) { | 137 | if (mTodo->hasStartDate()) { |
138 | keyd = mTodo->dtStartDateStr(); | 138 | keyd = mTodo->dtStartDateStr(); |
139 | QDate d = mTodo->dtStart().date(); | 139 | QDate d = mTodo->dtStart().date(); |
140 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 140 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
141 | 141 | ||
142 | if ( !mTodo->doesFloat()) { | 142 | if ( !mTodo->doesFloat()) { |
143 | keyt = mTodo->dtStartTimeStr(); | 143 | keyt = mTodo->dtStartTimeStr(); |
144 | QTime t = mTodo->dtStart().time(); | 144 | QTime t = mTodo->dtStart().time(); |
145 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 145 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
146 | 146 | ||
147 | } | 147 | } |
148 | 148 | ||
149 | } | 149 | } |
150 | } | 150 | } |
151 | setText(5,keyd); | 151 | setText(5,keyd); |
152 | setText(6,keyt); | 152 | setText(6,keyt); |
153 | setSortKey(5,skeyd); | 153 | setSortKey(5,skeyd); |
154 | setSortKey(6,skeyt); | 154 | setSortKey(6,skeyt); |
155 | 155 | ||
156 | setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); | 156 | //setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); |
157 | setText(8,mTodo->categoriesStr()); | 157 | setText(7,mTodo->categoriesStr()); |
158 | setText(9,KOPrefs::instance()->calName( mTodo->calID())); | 158 | setText(8,KOPrefs::instance()->calName( mTodo->calID())); |
159 | 159 | setText(9, KGlobal::locale()->formatDateTime( mTodo->lastModified(), true, true )); | |
160 | setText(10, KGlobal::locale()->formatDateTime( mTodo->created(), true, true )); | ||
161 | setText(11, KGlobal::locale()->formatDateTime( mTodo->lastModifiedSub(), true, true )); | ||
162 | QString key; | ||
163 | QDate d = mTodo->lastModified().date(); | ||
164 | QTime t = mTodo->lastModified().time(); | ||
165 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); | ||
166 | setSortKey(9,key); | ||
167 | d = mTodo->created().date(); | ||
168 | t = mTodo->created().time(); | ||
169 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); | ||
170 | setSortKey(10,key); | ||
171 | d = mTodo->lastModifiedSub().date(); | ||
172 | t = mTodo->lastModifiedSub().time(); | ||
173 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); | ||
174 | setSortKey(11,key); | ||
175 | |||
160 | #if 0 | 176 | #if 0 |
161 | // Find sort id in description. It's the text behind the last '#' character | 177 | // Find sort id in description. It's the text behind the last '#' character |
162 | // found in the description. White spaces are removed from beginning and end | 178 | // found in the description. White spaces are removed from beginning and end |
163 | // of sort id. | 179 | // of sort id. |
164 | int pos = mTodo->description().findRev('#'); | 180 | int pos = mTodo->description().findRev('#'); |
165 | if (pos < 0) { | 181 | if (pos < 0) { |
166 | setText(6,""); | 182 | setText(6,""); |
167 | } else { | 183 | } else { |
168 | QString str = mTodo->description().mid(pos+1); | 184 | QString str = mTodo->description().mid(pos+1); |
169 | str.stripWhiteSpace(); | 185 | str.stripWhiteSpace(); |
170 | setText(6,str); | 186 | setText(6,str); |
171 | } | 187 | } |
172 | #endif | 188 | #endif |
173 | 189 | ||
174 | m_known = false; | 190 | m_known = false; |
175 | m_init = false; | 191 | m_init = false; |
176 | 192 | ||
177 | setMyPixmap(); | 193 | setMyPixmap(); |
178 | 194 | ||
179 | } | 195 | } |
180 | void KOTodoViewItem::setMyPixmap() | 196 | void KOTodoViewItem::setMyPixmap() |
181 | { | 197 | { |
182 | int size = 5; | 198 | int size = 5; |
183 | QPixmap pixi = QPixmap( 1, 1 ); | 199 | QPixmap pixi = QPixmap( 1, 1 ); |
184 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 200 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
185 | // pixi = SmallIcon("redcross16"); | 201 | // pixi = SmallIcon("redcross16"); |
186 | // } else { | 202 | // } else { |
187 | QPainter p; | 203 | QPainter p; |
188 | 204 | ||
189 | int pixSize = 0; | 205 | int pixSize = 0; |
190 | QPixmap pPix = QPixmap( size, size ); | 206 | QPixmap pPix = QPixmap( size, size ); |
191 | if ( mTodo->description().length() > 0 ) { | 207 | if ( mTodo->description().length() > 0 ) { |
192 | pixi.resize(size, pixSize+size); | 208 | pixi.resize(size, pixSize+size); |
193 | pPix.fill( Qt::darkGreen ); | 209 | pPix.fill( Qt::darkGreen ); |
194 | p.begin( &pixi ); | 210 | p.begin( &pixi ); |
195 | p. drawPixmap ( 0, pixSize, pPix); | 211 | p. drawPixmap ( 0, pixSize, pPix); |
196 | p.end(); | 212 | p.end(); |
197 | pixSize += size; | 213 | pixSize += size; |
198 | } | 214 | } |
199 | if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { | 215 | if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { |
200 | pixi.resize(size, pixSize+size); | 216 | pixi.resize(size, pixSize+size); |
201 | pPix.fill( Qt::red ); | 217 | pPix.fill( Qt::red ); |
202 | p.begin( &pixi ); | 218 | p.begin( &pixi ); |
203 | p. drawPixmap ( 0, pixSize, pPix); | 219 | p. drawPixmap ( 0, pixSize, pPix); |
204 | p.end(); | 220 | p.end(); |
205 | pixSize += size; | 221 | pixSize += size; |
206 | } | 222 | } |
207 | if ( mTodo->doesRecur() ) { | 223 | if ( mTodo->doesRecur() ) { |
@@ -272,133 +288,167 @@ void KOTodoViewItem::stateChange(bool state) | |||
272 | QDate d = mTodo->dtStart().date(); | 288 | QDate d = mTodo->dtStart().date(); |
273 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 289 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
274 | 290 | ||
275 | if (mTodo->doesFloat()) { | 291 | if (mTodo->doesFloat()) { |
276 | setText(6,""); | 292 | setText(6,""); |
277 | } | 293 | } |
278 | else { | 294 | else { |
279 | setText(6,mTodo->dtStartTimeStr()); | 295 | setText(6,mTodo->dtStartTimeStr()); |
280 | QTime t = mTodo->dtStart().time(); | 296 | QTime t = mTodo->dtStart().time(); |
281 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 297 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
282 | 298 | ||
283 | } | 299 | } |
284 | setSortKey(5,skeyd); | 300 | setSortKey(5,skeyd); |
285 | setSortKey(6,skeyt); | 301 | setSortKey(6,skeyt); |
286 | } | 302 | } |
287 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 303 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
288 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 304 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
289 | 305 | ||
290 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 306 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
291 | if (mTodo->percentComplete()<100) { | 307 | if (mTodo->percentComplete()<100) { |
292 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 308 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
293 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 309 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
294 | } | 310 | } |
295 | else { | 311 | else { |
296 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 312 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
297 | else setSortKey(2,QString::number(99)); | 313 | else setSortKey(2,QString::number(99)); |
298 | } | 314 | } |
299 | if ( state ) { | 315 | if ( state ) { |
300 | QListViewItem * myChild = firstChild(); | 316 | QListViewItem * myChild = firstChild(); |
301 | KOTodoViewItem *item; | 317 | KOTodoViewItem *item; |
302 | while( myChild ) { | 318 | while( myChild ) { |
303 | //qDebug("stateCH "); | 319 | //qDebug("stateCH "); |
304 | item = static_cast<KOTodoViewItem*>(myChild); | 320 | item = static_cast<KOTodoViewItem*>(myChild); |
305 | item->stateChange(state); | 321 | item->stateChange(state); |
306 | myChild = myChild->nextSibling(); | 322 | myChild = myChild->nextSibling(); |
307 | } | 323 | } |
308 | } else { | 324 | } else { |
309 | QListViewItem * myChild = parent(); | 325 | QListViewItem * myChild = parent(); |
310 | if ( myChild ) | 326 | if ( myChild ) |
311 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); | 327 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); |
312 | } | 328 | } |
313 | mTodoView->modified(true); | 329 | mTodoView->modified(true); |
314 | setMyPixmap(); | 330 | setMyPixmap(); |
315 | mTodoView->setTodoModified( mTodo ); | 331 | mTodoView->setTodoModified( mTodo ); |
316 | } | 332 | } |
317 | 333 | ||
318 | bool KOTodoViewItem::isAlternate() | 334 | bool KOTodoViewItem::isAlternate() |
319 | { | 335 | { |
320 | 336 | #if 0 | |
337 | //if ( m_known ) return m_odd; | ||
338 | //qDebug("test "); | ||
339 | KOTodoViewItem *item = static_cast<KOTodoViewItem *>(itemAbove()); | ||
340 | if ( item ) { | ||
341 | m_known = item->m_known; | ||
342 | if ( m_known ) { | ||
343 | m_odd = !item->m_odd ; | ||
344 | return m_odd; | ||
345 | } | ||
346 | } else { | ||
347 | item = static_cast<KOTodoViewItem *>(itemBelow()); | ||
348 | if ( item ) { | ||
349 | m_known = item->m_known; | ||
350 | if ( m_known ) { | ||
351 | m_odd = !item->m_odd ; | ||
352 | return m_odd; | ||
353 | } | ||
354 | } | ||
355 | } | ||
321 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 356 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
322 | if (lv && lv->alternateBackground().isValid()) | 357 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); |
358 | bool previous = true; | ||
359 | qDebug("WHILE "); | ||
360 | while ( item ) { | ||
361 | item->m_odd = !previous; | ||
362 | item->m_known = true; | ||
363 | previous = !previous; | ||
364 | item = static_cast<KOTodoViewItem *>(item->itemBelow()); | ||
365 | } | ||
366 | return m_odd; | ||
367 | |||
368 | #else | ||
369 | |||
370 | //KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | ||
371 | //if (lv && lv->alternateBackground().isValid()) | ||
323 | { | 372 | { |
324 | KOTodoViewItem *above = 0; | 373 | KOTodoViewItem *above = static_cast<KOTodoViewItem *>(itemAbove()); |
325 | above = static_cast<KOTodoViewItem *>(itemAbove()); | ||
326 | m_known = above ? above->m_known : true; | 374 | m_known = above ? above->m_known : true; |
327 | if (m_known) | 375 | if (m_known) |
328 | { | 376 | { |
329 | m_odd = above ? !above->m_odd : false; | 377 | m_odd = above ? !above->m_odd : false; |
330 | } | 378 | } |
331 | else | 379 | else |
332 | { | 380 | { |
333 | KOTodoViewItem *item; | 381 | KOTodoViewItem *item; |
334 | bool previous = true; | 382 | bool previous = true; |
335 | if (QListViewItem::parent()) | 383 | if (QListViewItem::parent()) |
336 | { | 384 | { |
337 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); | 385 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); |
338 | if (item) | 386 | if (item) |
339 | previous = item->m_odd; | 387 | previous = item->m_odd; |
340 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); | 388 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); |
341 | } | 389 | } |
342 | else | 390 | else |
343 | { | 391 | { |
392 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | ||
344 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); | 393 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); |
345 | } | 394 | } |
346 | 395 | ||
347 | while(item) | 396 | while(item) |
348 | { | 397 | { |
349 | item->m_odd = previous = !previous; | 398 | item->m_odd = previous = !previous; |
350 | item->m_known = true; | 399 | item->m_known = true; |
351 | item = static_cast<KOTodoViewItem *>(item->nextSibling()); | 400 | item = static_cast<KOTodoViewItem *>(item->nextSibling()); |
352 | } | 401 | } |
353 | } | 402 | } |
354 | return m_odd; | 403 | return m_odd; |
355 | } | 404 | } |
356 | return false; | 405 | return false; |
406 | #endif | ||
357 | } | 407 | } |
358 | 408 | ||
359 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 409 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
360 | { | 410 | { |
361 | QColorGroup _cg = cg; | 411 | QColorGroup _cg = cg; |
362 | QColorGroup::ColorRole role; | 412 | QColorGroup::ColorRole role; |
363 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning()) | 413 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning()) |
364 | role = QColorGroup::Text; | 414 | role = QColorGroup::Text; |
365 | else | 415 | else |
366 | role = QColorGroup::Base; | 416 | role = QColorGroup::Base; |
367 | //#ifndef KORG_NOLVALTERNATION | 417 | //#ifndef KORG_NOLVALTERNATION |
368 | if (isAlternate()) | 418 | if (isAlternate()) |
369 | _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); | 419 | _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); |
370 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; | 420 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; |
371 | QColor colorToSet; | 421 | QColor colorToSet; |
372 | if ( column == 0 && mTodo->calID() > 1 ) { | 422 | if ( column == 0 && mTodo->calID() > 1 ) { |
373 | setColor = true; | 423 | setColor = true; |
374 | colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() ); | 424 | colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() ); |
375 | } else if ( setColor ) { | 425 | } else if ( setColor ) { |
376 | QStringList categories = mTodo->categories(); | 426 | QStringList categories = mTodo->categories(); |
377 | QString cat = categories.first(); | 427 | QString cat = categories.first(); |
378 | if ( !cat.isEmpty()) { | 428 | if ( !cat.isEmpty()) { |
379 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); | 429 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); |
380 | } else | 430 | } else |
381 | setColor = false; | 431 | setColor = false; |
382 | } | 432 | } |
383 | bool openMode = !isOpen(); | 433 | bool openMode = !isOpen(); |
384 | // maybe we are in flat-display-mode | 434 | // maybe we are in flat-display-mode |
385 | if ( !firstChild() ) | 435 | if ( !firstChild() ) |
386 | openMode = false; | 436 | openMode = false; |
387 | bool colorRunning = mTodo->isRunning(); | 437 | bool colorRunning = mTodo->isRunning(); |
388 | if ( ! colorRunning && openMode ) | 438 | if ( ! colorRunning && openMode ) |
389 | colorRunning = mTodo->hasRunningSub(); | 439 | colorRunning = mTodo->hasRunningSub(); |
390 | if ( colorRunning ) { | 440 | if ( colorRunning ) { |
391 | setColor = true; | 441 | setColor = true; |
392 | colorToSet = KOPrefs::instance()->mTodoRunColor; | 442 | colorToSet = KOPrefs::instance()->mTodoRunColor; |
393 | } else { | 443 | } else { |
394 | int odue = mTodo->hasDueSubTodo( openMode ); | 444 | int odue = mTodo->hasDueSubTodo( openMode ); |
395 | if (odue == 2) { | 445 | if (odue == 2) { |
396 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; | 446 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; |
397 | setColor = true; | 447 | setColor = true; |
398 | } else if ( odue == 1 ) { | 448 | } else if ( odue == 1 ) { |
399 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; | 449 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; |
400 | setColor = true; | 450 | setColor = true; |
401 | } | 451 | } |
402 | } | 452 | } |
403 | 453 | ||
404 | 454 | ||