author | zecke <zecke> | 2002-04-13 16:28:40 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-13 16:28:40 (UTC) |
commit | 1eb54898047fab3963debe51fa3e570b361a1215 (patch) (unidiff) | |
tree | 7ba017af1f2807d9710577817e4a13876900a0a7 | |
parent | def870c6fcccf2b20d7ce3821055391b18243a24 (diff) | |
download | opie-1eb54898047fab3963debe51fa3e570b361a1215.zip opie-1eb54898047fab3963debe51fa3e570b361a1215.tar.gz opie-1eb54898047fab3963debe51fa3e570b361a1215.tar.bz2 |
move to multiple categories + patch from Stefan Eilers to show the due date
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 23 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 9 | ||||
-rw-r--r-- | core/pim/todo/todoentryimpl.cpp | 8 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 68 | ||||
-rw-r--r-- | core/pim/todo/todotable.h | 22 |
5 files changed, 120 insertions, 10 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index f3afa5f..33f13aa 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,5 +1,7 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | Copyright (C) 2002 zecke | ||
4 | Copyright (C) 2002 Stefan Eilers | ||
3 | ** | 5 | ** |
4 | ** This file is part of Qtopia Environment. | 6 | ** This file is part of Qtopia Environment. |
5 | ** | 7 | ** |
@@ -107,6 +109,11 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
107 | config.setGroup( "View" ); | 109 | config.setGroup( "View" ); |
108 | bool complete = config.readBoolEntry( "ShowComplete", true ); | 110 | bool complete = config.readBoolEntry( "ShowComplete", true ); |
109 | table->setShowCompleted( complete ); | 111 | table->setShowCompleted( complete ); |
112 | |||
113 | /* added 20.01.2k2 by se */ | ||
114 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); | ||
115 | table->setShowDeadline (showdeadline); | ||
116 | |||
110 | QString category = config.readEntry( "Category", QString::null ); | 117 | QString category = config.readEntry( "Category", QString::null ); |
111 | table->setShowCategory( category ); | 118 | table->setShowCategory( category ); |
112 | 119 | ||
@@ -174,6 +181,9 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
174 | 181 | ||
175 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); | 182 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); |
176 | 183 | ||
184 | /* added 20.01.2k2 by se */ | ||
185 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); | ||
186 | |||
177 | catMenu->setCheckable( true ); | 187 | catMenu->setCheckable( true ); |
178 | populateCategories(); | 188 | populateCategories(); |
179 | 189 | ||
@@ -195,6 +205,7 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
195 | table->viewport()->setUpdatesEnabled( TRUE ); | 205 | table->viewport()->setUpdatesEnabled( TRUE ); |
196 | 206 | ||
197 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); | 207 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); |
208 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); | ||
198 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); | 209 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); |
199 | connect( table, SIGNAL( currentChanged( int, int ) ), | 210 | connect( table, SIGNAL( currentChanged( int, int ) ), |
200 | this, SLOT( currentEntryChanged( int, int ) ) ); | 211 | this, SLOT( currentEntryChanged( int, int ) ) ); |
@@ -351,6 +362,8 @@ void TodoWindow::populateCategories() | |||
351 | 362 | ||
352 | completedAction->addTo( catMenu ); | 363 | completedAction->addTo( catMenu ); |
353 | completedAction->setOn( table->showCompleted() ); | 364 | completedAction->setOn( table->showCompleted() ); |
365 | showdeadlineAction->addTo( catMenu ); | ||
366 | showdeadlineAction->setOn( table->showDeadline() ); | ||
354 | 367 | ||
355 | int id, rememberId; | 368 | int id, rememberId; |
356 | id = 1; | 369 | id = 1; |
@@ -402,6 +415,8 @@ void TodoWindow::closeEvent( QCloseEvent *e ) | |||
402 | config.setGroup( "View" ); | 415 | config.setGroup( "View" ); |
403 | config.writeEntry( "ShowComplete", table->showCompleted() ); | 416 | config.writeEntry( "ShowComplete", table->showCompleted() ); |
404 | config.writeEntry( "Category", table->showCategory() ); | 417 | config.writeEntry( "Category", table->showCategory() ); |
418 | /* added 20.01.2k2 by se */ | ||
419 | config.writeEntry( "ShowDeadLine", table->showDeadline()); | ||
405 | } else { | 420 | } else { |
406 | if ( QMessageBox::critical( this, tr("Out of space"), | 421 | if ( QMessageBox::critical( this, tr("Out of space"), |
407 | tr("Todo was unable\n" | 422 | tr("Todo was unable\n" |
@@ -473,3 +488,11 @@ void TodoWindow::beamDone( Ir *ir ) | |||
473 | delete ir; | 488 | delete ir; |
474 | unlink( beamfile ); | 489 | unlink( beamfile ); |
475 | } | 490 | } |
491 | |||
492 | /* added 20.01.2k2 by se */ | ||
493 | void TodoWindow::showDeadline( bool s ) | ||
494 | { | ||
495 | table->setPaintingEnabled( false ); | ||
496 | table->setShowDeadline( s ); | ||
497 | table->setPaintingEnabled( true ); | ||
498 | } | ||
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index 856dcb4..a81c27c 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h | |||
@@ -47,6 +47,10 @@ protected slots: | |||
47 | void slotEdit(); | 47 | void slotEdit(); |
48 | void slotShowPopup( const QPoint & ); | 48 | void slotShowPopup( const QPoint & ); |
49 | void showCompleted( bool ); | 49 | void showCompleted( bool ); |
50 | |||
51 | /* added 20.01.2k2 by se */ | ||
52 | void showDeadline( bool ); | ||
53 | |||
50 | void currentEntryChanged( int r, int c ); | 54 | void currentEntryChanged( int r, int c ); |
51 | void setCategory( int ); | 55 | void setCategory( int ); |
52 | void slotFind(); | 56 | void slotFind(); |
@@ -64,8 +68,9 @@ private: | |||
64 | TodoTable *table; | 68 | TodoTable *table; |
65 | QAction *editAction, | 69 | QAction *editAction, |
66 | *deleteAction, | 70 | *deleteAction, |
67 | *findAction, | 71 | *findAction, |
68 | * completedAction; | 72 | * completedAction, |
73 | *showdeadlineAction ; | ||
69 | QPopupMenu *contextMenu, *catMenu; | 74 | QPopupMenu *contextMenu, *catMenu; |
70 | 75 | ||
71 | bool syncing; | 76 | bool syncing; |
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp index 1dc1d44..f938d61 100644 --- a/core/pim/todo/todoentryimpl.cpp +++ b/core/pim/todo/todoentryimpl.cpp | |||
@@ -48,7 +48,7 @@ NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent, | |||
48 | todo( task ) | 48 | todo( task ) |
49 | { | 49 | { |
50 | qWarning("setting category" ); | 50 | qWarning("setting category" ); |
51 | todo.setCategory( task.category() ); | 51 | todo.setCategories( task.allCategories() ); |
52 | if ( todo.hasDate() ) | 52 | if ( todo.hasDate() ) |
53 | date = todo.date(); | 53 | date = todo.date(); |
54 | else | 54 | else |
@@ -128,10 +128,10 @@ ToDoEvent NewTaskDialog::todoEntry() | |||
128 | qWarning("todoEntry::category()" ); | 128 | qWarning("todoEntry::category()" ); |
129 | if ( comboCategory->currentCategory() != -1 ) { | 129 | if ( comboCategory->currentCategory() != -1 ) { |
130 | QArray<int> arr = comboCategory->currentCategories(); | 130 | QArray<int> arr = comboCategory->currentCategories(); |
131 | int id = arr[0]; | 131 | QStringList list; |
132 | qWarning("id 0: %d",id ); | 132 | list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ; |
133 | todo.setCategory( Qtopia::Record::idsToString( arr ) ); | ||
134 | qWarning("saving category"); | 133 | qWarning("saving category"); |
134 | todo.setCategories( list ); | ||
135 | } | 135 | } |
136 | todo.setPriority( comboPriority->currentItem() + 1 ); | 136 | todo.setPriority( comboPriority->currentItem() + 1 ); |
137 | todo.setCompleted( checkCompleted->isChecked() ); | 137 | todo.setCompleted( checkCompleted->isChecked() ); |
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index 2bb95a2..3cd0c0e 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -17,7 +17,8 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | /* Show Deadline was added by Stefan Eilers (se, eilers.stefan@epost.de) | |
21 | */ | ||
21 | #include "todotable.h" | 22 | #include "todotable.h" |
22 | 23 | ||
23 | #include <opie/tododb.h> | 24 | #include <opie/tododb.h> |
@@ -38,6 +39,8 @@ | |||
38 | #include <errno.h> | 39 | #include <errno.h> |
39 | #include <stdlib.h> | 40 | #include <stdlib.h> |
40 | 41 | ||
42 | #include <stdio.h> | ||
43 | |||
41 | 44 | ||
42 | 45 | ||
43 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ); | 46 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ); |
@@ -164,12 +167,13 @@ TodoTable::TodoTable( QWidget *parent, const char *name ) | |||
164 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR | 167 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR |
165 | // : QTable( 0, 3, parent, name, TRUE ), | 168 | // : QTable( 0, 3, parent, name, TRUE ), |
166 | // #else | 169 | // #else |
167 | : QTable( 0, 3, parent, name ), | 170 | : QTable( 0, 4, parent, name ), |
168 | // #endif | 171 | // #endif |
169 | showComp( true ), | 172 | showComp( true ), |
170 | enablePainting( true ), | 173 | enablePainting( true ), |
171 | mCat( 0 ), | 174 | mCat( 0 ), |
172 | currFindRow( -2 ) | 175 | currFindRow( -2 ), |
176 | showDeadl( true) | ||
173 | { | 177 | { |
174 | mCat.load( categoryFileName() ); | 178 | mCat.load( categoryFileName() ); |
175 | setSorting( TRUE ); | 179 | setSorting( TRUE ); |
@@ -177,11 +181,23 @@ TodoTable::TodoTable( QWidget *parent, const char *name ) | |||
177 | setColumnStretchable( 2, TRUE ); | 181 | setColumnStretchable( 2, TRUE ); |
178 | setColumnWidth( 0, 20 ); | 182 | setColumnWidth( 0, 20 ); |
179 | setColumnWidth( 1, 35 ); | 183 | setColumnWidth( 1, 35 ); |
184 | |||
180 | setLeftMargin( 0 ); | 185 | setLeftMargin( 0 ); |
181 | verticalHeader()->hide(); | 186 | verticalHeader()->hide(); |
182 | horizontalHeader()->setLabel( 0, tr( "C." ) ); | 187 | horizontalHeader()->setLabel( 0, tr( "C." ) ); |
183 | horizontalHeader()->setLabel( 1, tr( "Prior." ) ); | 188 | horizontalHeader()->setLabel( 1, tr( "Prior." ) ); |
184 | horizontalHeader()->setLabel( 2, tr( "Description" ) ); | 189 | horizontalHeader()->setLabel( 2, tr( "Description" ) ); |
190 | |||
191 | setColumnStretchable( 3, FALSE ); | ||
192 | setColumnWidth( 3, 20 ); | ||
193 | horizontalHeader()->setLabel( 3, tr( "Deadline" ) ); | ||
194 | |||
195 | if (showDeadl){ | ||
196 | showColumn (3); | ||
197 | }else{ | ||
198 | hideColumn (3); | ||
199 | } | ||
200 | |||
185 | connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), | 201 | connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), |
186 | this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); | 202 | this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); |
187 | connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), | 203 | connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), |
@@ -234,6 +250,11 @@ void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) | |||
234 | menuTimer->stop(); | 250 | menuTimer->stop(); |
235 | // emit signalEdit(); | 251 | // emit signalEdit(); |
236 | break; | 252 | break; |
253 | case 3: /* added 20.01.2k2 by se */ | ||
254 | // may as well edit it... | ||
255 | menuTimer->stop(); | ||
256 | emit signalEdit(); | ||
257 | break; | ||
237 | } | 258 | } |
238 | } | 259 | } |
239 | 260 | ||
@@ -265,6 +286,8 @@ void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) | |||
265 | 286 | ||
266 | ToDoEvent TodoTable::currentEntry() const | 287 | ToDoEvent TodoTable::currentEntry() const |
267 | { | 288 | { |
289 | printf ("in currentEntry\n"); | ||
290 | |||
268 | QTableItem *i = item( currentRow(), 0 ); | 291 | QTableItem *i = item( currentRow(), 0 ); |
269 | if ( !i || rowHeight( currentRow() ) <= 0 ) | 292 | if ( !i || rowHeight( currentRow() ) <= 0 ) |
270 | return ToDoEvent(); | 293 | return ToDoEvent(); |
@@ -354,6 +377,15 @@ void TodoTable::updateVisible() | |||
354 | 377 | ||
355 | // qDebug("--> updateVisible!"); | 378 | // qDebug("--> updateVisible!"); |
356 | 379 | ||
380 | /* added 20.01.2k2 by se */ | ||
381 | if (showDeadl){ | ||
382 | showColumn (3); | ||
383 | adjustColumn(3); | ||
384 | }else{ | ||
385 | hideColumn (3); | ||
386 | adjustColumn(2); | ||
387 | } | ||
388 | |||
357 | int visible = 0; | 389 | int visible = 0; |
358 | int id = mCat.id( "Todo List", showCat ); | 390 | int id = mCat.id( "Todo List", showCat ); |
359 | for ( int row = 0; row < numRows(); row++ ) { | 391 | for ( int row = 0; row < numRows(); row++ ) { |
@@ -455,7 +487,7 @@ void TodoTable::slotCheckPriority(int row, int col ) | |||
455 | } | 487 | } |
456 | 488 | ||
457 | 489 | ||
458 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action, int row ) | 490 | void TodoTable::updateJournal( const ToDoEvent &/*todo*/, journal_action action, int row ) |
459 | { | 491 | { |
460 | QFile f( journalFileName() ); | 492 | QFile f( journalFileName() ); |
461 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 493 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
@@ -508,6 +540,20 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | |||
508 | it.key()->setChecked( todo.isCompleted() ); | 540 | it.key()->setChecked( todo.isCompleted() ); |
509 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 541 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
510 | item( row, 2 )->setText( strTodo ); | 542 | item( row, 2 )->setText( strTodo ); |
543 | |||
544 | /* added 20.01.2k2 by se */ | ||
545 | if (showDeadl){ | ||
546 | if (todo.hasDate()){ | ||
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 | } | ||
556 | |||
511 | *(*it) = todo; | 557 | *(*it) = todo; |
512 | } | 558 | } |
513 | } | 559 | } |
@@ -518,6 +564,20 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | |||
518 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); | 564 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); |
519 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 565 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
520 | item( row, 2 )->setText( strTodo ); | 566 | item( row, 2 )->setText( strTodo ); |
567 | |||
568 | /* added 20.01.2k2 by se */ | ||
569 | if (showDeadl){ | ||
570 | if (todo.hasDate()){ | ||
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 | } | ||
580 | |||
521 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); | 581 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); |
522 | } | 582 | } |
523 | } | 583 | } |
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h index 2746ce7..288ff90 100644 --- a/core/pim/todo/todotable.h +++ b/core/pim/todo/todotable.h | |||
@@ -98,6 +98,10 @@ public: | |||
98 | void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } | 98 | void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } |
99 | bool showCompleted() const { return showComp; } | 99 | bool showCompleted() const { return showComp; } |
100 | 100 | ||
101 | /* added 20.01.2k2 by se */ | ||
102 | void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} | ||
103 | bool showDeadline() const { return showDeadl;} | ||
104 | |||
101 | void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } | 105 | void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } |
102 | const QString &showCategory() const { return showCat; } | 106 | const QString &showCategory() const { return showCat; } |
103 | int showCategoryId() const; | 107 | int showCategoryId() const; |
@@ -159,6 +163,9 @@ private: | |||
159 | bool enablePainting; | 163 | bool enablePainting; |
160 | Categories mCat; | 164 | Categories mCat; |
161 | int currFindRow; | 165 | int currFindRow; |
166 | |||
167 | /* added 20.01.2k2 by se */ | ||
168 | bool showDeadl; | ||
162 | }; | 169 | }; |
163 | 170 | ||
164 | 171 | ||
@@ -174,10 +181,25 @@ inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) | |||
174 | QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); | 181 | QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); |
175 | ti->setReplaceable( false ); | 182 | ti->setReplaceable( false ); |
176 | 183 | ||
184 | /* added 20.01.2k2 by se */ | ||
185 | QTableItem *dl = NULL; | ||
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 | |||
177 | setItem( row, 0, chk ); | 198 | setItem( row, 0, chk ); |
178 | setItem( row, 1, cmb ); | 199 | setItem( row, 1, cmb ); |
179 | setItem( row, 2, ti ); | 200 | setItem( row, 2, ti ); |
180 | 201 | ||
202 | |||
181 | todoList.insert( chk, todo ); | 203 | todoList.insert( chk, todo ); |
182 | } | 204 | } |
183 | 205 | ||