summaryrefslogtreecommitdiff
path: root/core/pim/todo/todotable.h
Unidiff
Diffstat (limited to 'core/pim/todo/todotable.h') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/todotable.h43
1 files changed, 23 insertions, 20 deletions
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
@@ -74,12 +74,25 @@ public:
74 TodoTextItem( QTable *t, const QString & str ) 74 TodoTextItem( QTable *t, const QString & str )
75 :QTableItem( t, QTableItem::Never, str ) {} 75 :QTableItem( t, QTableItem::Never, str ) {}
76 76
77 QString key () const { return Qtopia::buildSortKey( text() ); } 77 QString key () const { return Qtopia::buildSortKey( text() ); }
78}; 78};
79 79
80class 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
81 94
82enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; 95enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
83 96
84class TodoTable : public QTable 97class TodoTable : public QTable
85{ 98{
@@ -95,13 +108,12 @@ public:
95 108
96 QStringList categories(); 109 QStringList categories();
97 110
98 void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } 111 void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); }
99 bool showCompleted() const { return showComp; } 112 bool showCompleted() const { return showComp; }
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();}
103 bool showDeadline() const { return showDeadl;} 115 bool showDeadline() const { return showDeadl;}
104 116
105 void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } 117 void setShowCategory( const QString &c ) { showCat = c; updateVisible(); }
106 const QString &showCategory() const { return showCat; } 118 const QString &showCategory() const { return showCat; }
107 int showCategoryId() const; 119 int showCategoryId() const;
@@ -160,15 +172,13 @@ private:
160 bool showComp; 172 bool showComp;
161 QString showCat; 173 QString showCat;
162 QTimer *menuTimer; 174 QTimer *menuTimer;
163 bool enablePainting; 175 bool enablePainting;
164 Categories mCat; 176 Categories mCat;
165 int currFindRow; 177 int currFindRow;
166 178 bool showDeadl:1;
167 /* added 20.01.2k2 by se */
168 bool showDeadl;
169}; 179};
170 180
171 181
172inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) 182inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
173{ 183{
174 QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') 184 QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A')
@@ -178,53 +188,46 @@ inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
178 chk->setChecked( todo->isCompleted() ); 188 chk->setChecked( todo->isCompleted() );
179 ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); 189 ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent );
180 cmb->setText( QString::number( todo->priority() ) ); 190 cmb->setText( QString::number( todo->priority() ) );
181 QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); 191 QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() );
182 ti->setReplaceable( false ); 192 ti->setReplaceable( false );
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
198 setItem( row, 0, chk ); 197 setItem( row, 0, chk );
199 setItem( row, 1, cmb ); 198 setItem( row, 1, cmb );
200 setItem( row, 2, ti ); 199 setItem( row, 2, ti );
201 200
202 201
203 todoList.insert( chk, todo ); 202 todoList.insert( chk, todo );
204} 203}
205 204
206inline void TodoTable::realignTable( int row ) 205inline 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();
212 for ( int curr = row; curr < totalRows - 1; curr++ ) { 212 for ( int curr = row; curr < totalRows - 1; curr++ ) {
213 // this is bad, we must take the item out and then 213 // this is bad, we must take the item out and then
214 // set it. In the end, it behaves no worse (time wise) 214 // set it. In the end, it behaves no worse (time wise)
215 // then the old way of saving the entries to file, clearing 215 // then the old way of saving the entries to file, clearing
216 // the table re-reading in the file and resetting the table 216 // the table re-reading in the file and resetting the table
217 ti1 = item( curr + 1, 0 ); 217 ti1 = item( curr + 1, 0 );
218 ti2 = item( curr + 1, 1 ); 218 ti2 = item( curr + 1, 1 );
219 ti3 = item( curr + 1, 2 ); 219 ti3 = item( curr + 1, 2 );
220 ti4 = item( curr + 1, 3 );
220 takeItem( ti1 ); 221 takeItem( ti1 );
221 takeItem( ti2 ); 222 takeItem( ti2 );
222 takeItem( ti3 ); 223 takeItem( ti3 );
224 takeItem( ti4 );
223 setItem( curr, 0, ti1 ); 225 setItem( curr, 0, ti1 );
224 setItem( curr, 1, ti2 ); 226 setItem( curr, 1, ti2 );
225 setItem( curr, 2, ti3 ); 227 setItem( curr, 2, ti3 );
228 setItem( curr, 3, ti4 );
226 } 229 }
227 setNumRows( totalRows - 1 ); 230 setNumRows( totalRows - 1 );
228} 231}
229 232
230#endif 233#endif