-rw-r--r-- | core/pim/todo/mainwindow.cpp | 4 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 98 | ||||
-rw-r--r-- | core/pim/todo/todotable.h | 43 |
3 files changed, 87 insertions, 58 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 33f13aa..a34bcf2 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -112,3 +112,2 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
112 | 112 | ||
113 | /* added 20.01.2k2 by se */ | ||
114 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); | 113 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); |
@@ -183,3 +182,2 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
183 | 182 | ||
184 | /* added 20.01.2k2 by se */ | ||
185 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); | 183 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); |
@@ -366,3 +364,3 @@ void TodoWindow::populateCategories() | |||
366 | showdeadlineAction->setOn( table->showDeadline() ); | 364 | showdeadlineAction->setOn( table->showDeadline() ); |
367 | 365 | catMenu->insertSeparator(); | |
368 | int id, rememberId; | 366 | int id, rememberId; |
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index 3cd0c0e..2acd03c 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -162,5 +162,53 @@ QString ComboItem::text() const | |||
162 | } | 162 | } |
163 | 163 | DueTextItem::DueTextItem( QTable *t, ToDoEvent *ev ) | |
164 | 164 | : QTableItem(t, Never, QString::null ) | |
165 | 165 | { | |
166 | setToDoEvent( ev ); | ||
167 | } | ||
168 | QString DueTextItem::key() const | ||
169 | { | ||
170 | QString key; | ||
171 | if( m_hasDate ){ | ||
172 | if(m_off == 0 ){ | ||
173 | key.append("b"); | ||
174 | }else if( m_off > 0 ){ | ||
175 | key.append("c"); | ||
176 | }else if( m_off < 0 ){ | ||
177 | key.append("a"); | ||
178 | } | ||
179 | key.append(QString::number(m_off ) ); | ||
180 | }else{ | ||
181 | key.append("d"); | ||
182 | } | ||
183 | return key; | ||
184 | } | ||
185 | void DueTextItem::setToDoEvent( const ToDoEvent *ev ) | ||
186 | { | ||
187 | m_hasDate = ev->hasDate(); | ||
188 | m_completed = ev->isCompleted(); | ||
189 | if( ev->hasDate() ){ | ||
190 | QDate today = QDate::currentDate(); | ||
191 | m_off = today.daysTo(ev->date() ); | ||
192 | setText( QString::number(m_off) + " day(s) " ); | ||
193 | }else{ | ||
194 | setText("n.d." ); | ||
195 | m_off = 0; | ||
196 | } | ||
197 | } | ||
198 | void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ) | ||
199 | { | ||
200 | QColorGroup cg2(cg); | ||
201 | QColor text = cg.text(); | ||
202 | if( m_hasDate && !m_completed ){ | ||
203 | if( m_off < 0 ){ | ||
204 | cg2.setColor(QColorGroup::Text, QColor(red ) ); | ||
205 | }else if( m_off == 0 ){ | ||
206 | cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined | ||
207 | }else if( m_off > 0){ | ||
208 | cg2.setColor(QColorGroup::Text, QColor(green ) ); | ||
209 | } | ||
210 | } | ||
211 | QTableItem::paint(p, cg2, cr, selected ); | ||
212 | cg2.setColor(QColorGroup::Text, text ); | ||
213 | } | ||
166 | TodoTable::TodoTable( QWidget *parent, const char *name ) | 214 | TodoTable::TodoTable( QWidget *parent, const char *name ) |
@@ -249,9 +297,9 @@ void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) | |||
249 | // may as well edit it... | 297 | // may as well edit it... |
250 | menuTimer->stop(); | 298 | // menuTimer->stop(); |
251 | // emit signalEdit(); | 299 | // emit signalEdit(); |
252 | break; | 300 | // fall through |
253 | case 3: /* added 20.01.2k2 by se */ | 301 | case 3: |
254 | // may as well edit it... | 302 | // may as well edit it... |
255 | menuTimer->stop(); | 303 | menuTimer->stop(); |
256 | emit signalEdit(); | 304 | // emit signalEdit(); |
257 | break; | 305 | break; |
@@ -370,2 +418,3 @@ void TodoTable::load( const QString &fn ) | |||
370 | setCurrentCell( 0, 2 ); | 418 | setCurrentCell( 0, 2 ); |
419 | setSorting(true ); | ||
371 | } | 420 | } |
@@ -376,6 +425,3 @@ void TodoTable::updateVisible() | |||
376 | return; | 425 | return; |
377 | 426 | ||
378 | // qDebug("--> updateVisible!"); | ||
379 | |||
380 | /* added 20.01.2k2 by se */ | ||
381 | if (showDeadl){ | 427 | if (showDeadl){ |
@@ -402,3 +448,3 @@ void TodoTable::updateVisible() | |||
402 | } else { | 448 | } else { |
403 | // do some comparing, we have to reverse our idea here... | 449 | // do some comparing, we have to reverse our idea here... which idea - zecke |
404 | if ( !hide ) { | 450 | if ( !hide ) { |
@@ -468,3 +514,3 @@ void TodoTable::clear() | |||
468 | 514 | ||
469 | void TodoTable::sortColumn( int col, bool /*ascending*/, bool /*wholeRows*/ ) | 515 | void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) |
470 | { | 516 | { |
@@ -474,3 +520,3 @@ void TodoTable::sortColumn( int col, bool /*ascending*/, bool /*wholeRows*/ ) | |||
474 | // the values have a logical order. | 520 | // the values have a logical order. |
475 | QTable::sortColumn( col, TRUE, TRUE ); | 521 | QTable::sortColumn( col, ascending, TRUE ); |
476 | updateVisible(); | 522 | updateVisible(); |
@@ -499,3 +545,3 @@ void TodoTable::updateJournal( const ToDoEvent &/*todo*/, journal_action action, | |||
499 | buf += " Action=\"" + QString::number( int(action) ) + "\""; | 545 | buf += " Action=\"" + QString::number( int(action) ) + "\""; |
500 | buf += " Row=\"" + QString::number( row ) + "\""; | 546 | buf += " Row=\"" + QString::number( row ) + "\""; // better write the id |
501 | buf += "/>\n"; | 547 | buf += "/>\n"; |
@@ -543,13 +589,4 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | |||
543 | 589 | ||
544 | /* added 20.01.2k2 by se */ | ||
545 | if (showDeadl){ | 590 | if (showDeadl){ |
546 | if (todo.hasDate()){ | 591 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
547 | QDate *today = new QDate (QDate::currentDate()); | ||
548 | if (today){ | ||
549 | item (row, 3)->setText (tr ("%1").arg(today->daysTo(todo.date()))); | ||
550 | delete (today); | ||
551 | } | ||
552 | }else{ | ||
553 | item (row, 3)->setText ("n.d."); | ||
554 | } | ||
555 | } | 592 | } |
@@ -567,13 +604,4 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | |||
567 | 604 | ||
568 | /* added 20.01.2k2 by se */ | ||
569 | if (showDeadl){ | 605 | if (showDeadl){ |
570 | if (todo.hasDate()){ | 606 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
571 | QDate *today = new QDate (QDate::currentDate()); | ||
572 | if (today){ | ||
573 | item (row, 3)->setText (tr ("%1").arg(today->daysTo(todo.date()))); | ||
574 | delete (today); | ||
575 | } | ||
576 | }else{ | ||
577 | item (row, 3)->setText ("n.d."); | ||
578 | } | ||
579 | } | 607 | } |
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h index 288ff90..32df514 100644 --- a/core/pim/todo/todotable.h +++ b/core/pim/todo/todotable.h | |||
@@ -79,2 +79,15 @@ public: | |||
79 | 79 | ||
80 | class DueTextItem : public QTableItem | ||
81 | { | ||
82 | public: | ||
83 | DueTextItem( QTable *t, ToDoEvent *ev ); | ||
84 | QString key() const; | ||
85 | void setToDoEvent( const ToDoEvent *ev ); | ||
86 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); | ||
87 | private: | ||
88 | int m_off; | ||
89 | bool m_hasDate:1; | ||
90 | bool m_completed:1; | ||
91 | |||
92 | }; | ||
80 | 93 | ||
@@ -100,3 +113,2 @@ public: | |||
100 | 113 | ||
101 | /* added 20.01.2k2 by se */ | ||
102 | void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} | 114 | void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} |
@@ -165,5 +177,3 @@ private: | |||
165 | int currFindRow; | 177 | int currFindRow; |
166 | 178 | bool showDeadl:1; | |
167 | /* added 20.01.2k2 by se */ | ||
168 | bool showDeadl; | ||
169 | }; | 179 | }; |
@@ -183,15 +193,4 @@ inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) | |||
183 | 193 | ||
184 | /* added 20.01.2k2 by se */ | 194 | DueTextItem *due = new DueTextItem(this, todo ); |
185 | QTableItem *dl = NULL; | 195 | setItem( row, 3, due); |
186 | if (todo->hasDate()){ | ||
187 | QDate *today = new QDate (QDate::currentDate()); | ||
188 | if (today){ | ||
189 | dl = new TodoTextItem (this, tr ("%1"). | ||
190 | arg(today->daysTo(todo->date()))); | ||
191 | delete (today); | ||
192 | } | ||
193 | }else{ | ||
194 | dl = new TodoTextItem (this,"n.d."); | ||
195 | } | ||
196 | setItem( row, 3, dl); | ||
197 | 196 | ||
@@ -207,5 +206,6 @@ inline void TodoTable::realignTable( int row ) | |||
207 | { | 206 | { |
208 | QTableItem *ti1, | 207 | QTableItem *ti1, |
209 | *ti2, | 208 | *ti2, |
210 | *ti3; | 209 | *ti3, |
210 | *ti4; | ||
211 | int totalRows = numRows(); | 211 | int totalRows = numRows(); |
@@ -219,2 +219,3 @@ inline void TodoTable::realignTable( int row ) | |||
219 | ti3 = item( curr + 1, 2 ); | 219 | ti3 = item( curr + 1, 2 ); |
220 | ti4 = item( curr + 1, 3 ); | ||
220 | takeItem( ti1 ); | 221 | takeItem( ti1 ); |
@@ -222,2 +223,3 @@ inline void TodoTable::realignTable( int row ) | |||
222 | takeItem( ti3 ); | 223 | takeItem( ti3 ); |
224 | takeItem( ti4 ); | ||
223 | setItem( curr, 0, ti1 ); | 225 | setItem( curr, 0, ti1 ); |
@@ -225,2 +227,3 @@ inline void TodoTable::realignTable( int row ) | |||
225 | setItem( curr, 2, ti3 ); | 227 | setItem( curr, 2, ti3 ); |
228 | setItem( curr, 3, ti4 ); | ||
226 | } | 229 | } |