summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp23
-rw-r--r--core/pim/todo/mainwindow.h9
-rw-r--r--core/pim/todo/todoentryimpl.cpp8
-rw-r--r--core/pim/todo/todotable.cpp68
-rw-r--r--core/pim/todo/todotable.h22
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,14 +1,16 @@
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**
6** This file may be distributed and/or modified under the terms of the 8** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 9** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 10** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 11** packaging of this file.
10** 12**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 15**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 16** See http://www.trolltech.com/gpl/ for GPL licensing information.
@@ -98,24 +100,29 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
98 "Free up some space\n" 100 "Free up some space\n"
99 "before you enter any data") ); 101 "before you enter any data") );
100 102
101 setCentralWidget( table ); 103 setCentralWidget( table );
102 setToolBarsMovable( FALSE ); 104 setToolBarsMovable( FALSE );
103 105
104// qDebug("after load: t=%d", t.elapsed() ); 106// qDebug("after load: t=%d", t.elapsed() );
105 107
106 Config config( "todo" ); 108 Config config( "todo" );
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
113 QPEToolBar *bar = new QPEToolBar( this ); 120 QPEToolBar *bar = new QPEToolBar( this );
114 bar->setHorizontalStretchable( TRUE ); 121 bar->setHorizontalStretchable( TRUE );
115 122
116 QPEMenuBar *mb = new QPEMenuBar( bar ); 123 QPEMenuBar *mb = new QPEMenuBar( bar );
117 124
118 catMenu = new QPopupMenu( this ); 125 catMenu = new QPopupMenu( this );
119 QPopupMenu *edit = new QPopupMenu( this ); 126 QPopupMenu *edit = new QPopupMenu( this );
120 contextMenu = new QPopupMenu( this ); 127 contextMenu = new QPopupMenu( this );
121 128
@@ -165,45 +172,49 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
165 a->addTo( edit ); 172 a->addTo( edit );
166 if ( table->numRows() ) 173 if ( table->numRows() )
167 a->setEnabled( TRUE ); 174 a->setEnabled( TRUE );
168 else 175 else
169 a->setEnabled( FALSE ); 176 a->setEnabled( FALSE );
170 177
171 //a->setEnabled( FALSE ); 178 //a->setEnabled( FALSE );
172 findAction = a; 179 findAction = a;
173// qDebug("mainwindow #2: t=%d", t.elapsed() ); 180// qDebug("mainwindow #2: t=%d", t.elapsed() );
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
180 mb->insertItem( tr( "Task" ), edit ); 190 mb->insertItem( tr( "Task" ), edit );
181 mb->insertItem( tr( "View" ), catMenu ); 191 mb->insertItem( tr( "View" ), catMenu );
182 192
183 resize( 200, 300 ); 193 resize( 200, 300 );
184 if ( table->numRows() > 0 ) 194 if ( table->numRows() > 0 )
185 currentEntryChanged( 0, 0 ); 195 currentEntryChanged( 0, 0 );
186 connect( table, SIGNAL( signalEdit() ), 196 connect( table, SIGNAL( signalEdit() ),
187 this, SLOT( slotEdit() ) ); 197 this, SLOT( slotEdit() ) );
188 connect( table, SIGNAL(signalShowMenu(const QPoint &)), 198 connect( table, SIGNAL(signalShowMenu(const QPoint &)),
189 this, SLOT( slotShowPopup(const QPoint &)) ); 199 this, SLOT( slotShowPopup(const QPoint &)) );
190 200
191// qDebug("mainwindow #3: t=%d", t.elapsed() ); 201// qDebug("mainwindow #3: t=%d", t.elapsed() );
192 table->updateVisible(); 202 table->updateVisible();
193 table->setUpdatesEnabled( TRUE ); 203 table->setUpdatesEnabled( TRUE );
194 table->setPaintingEnabled( TRUE ); 204 table->setPaintingEnabled( TRUE );
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 ) ) );
201 212
202// qDebug("done: t=%d", t.elapsed() ); 213// qDebug("done: t=%d", t.elapsed() );
203} 214}
204 215
205void TodoWindow::slotNew() 216void TodoWindow::slotNew()
206{ 217{
207 if(syncing) { 218 if(syncing) {
208 QMessageBox::warning(this, tr("Todo"), 219 QMessageBox::warning(this, tr("Todo"),
209 tr("Can not edit data, currently syncing")); 220 tr("Can not edit data, currently syncing"));
@@ -342,24 +353,26 @@ void TodoWindow::setCategory( int c )
342 table->setShowCategory( cat ); 353 table->setShowCategory( cat );
343 setCaption( tr("Todo") + " - " + cat ); 354 setCaption( tr("Todo") + " - " + cat );
344 } 355 }
345 table->setPaintingEnabled( true ); 356 table->setPaintingEnabled( true );
346} 357}
347 358
348void TodoWindow::populateCategories() 359void TodoWindow::populateCategories()
349{ 360{
350 catMenu->clear(); 361 catMenu->clear();
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;
357 catMenu->insertItem( tr( "All Categories" ), id++ ); 370 catMenu->insertItem( tr( "All Categories" ), id++ );
358// catMenu->insertSeparator(); 371// catMenu->insertSeparator();
359 QStringList categories = table->categories(); 372 QStringList categories = table->categories();
360 categories.append( tr( "Unfiled" ) ); 373 categories.append( tr( "Unfiled" ) );
361 for ( QStringList::Iterator it = categories.begin(); 374 for ( QStringList::Iterator it = categories.begin();
362 it != categories.end(); ++it ) { 375 it != categories.end(); ++it ) {
363 catMenu->insertItem( *it, id ); 376 catMenu->insertItem( *it, id );
364 if ( *it == table->showCategory() ) 377 if ( *it == table->showCategory() )
365 rememberId = id; 378 rememberId = id;
@@ -393,24 +406,26 @@ void TodoWindow::closeEvent( QCloseEvent *e )
393 } 406 }
394 407
395 if ( table->save( todolistXMLFilename() ) ) { 408 if ( table->save( todolistXMLFilename() ) ) {
396 e->accept(); 409 e->accept();
397 // repeat for categories... 410 // repeat for categories...
398 // if writing configs fail, it will emit an 411 // if writing configs fail, it will emit an
399 // error, but I feel that it is "ok" for us to exit 412 // error, but I feel that it is "ok" for us to exit
400 // espically since we aren't told if the write succeeded... 413 // espically since we aren't told if the write succeeded...
401 Config config( "todo" ); 414 Config config( "todo" );
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"
408 "to save your changes.\n" 423 "to save your changes.\n"
409 "Free up some space\n" 424 "Free up some space\n"
410 "and try again.\n" 425 "and try again.\n"
411 "\nQuit Anyway?"), 426 "\nQuit Anyway?"),
412 QMessageBox::Yes|QMessageBox::Escape, 427 QMessageBox::Yes|QMessageBox::Escape,
413 QMessageBox::No|QMessageBox::Default) 428 QMessageBox::No|QMessageBox::Default)
414 != QMessageBox::No ) 429 != QMessageBox::No )
415 e->accept(); 430 e->accept();
416 else 431 else
@@ -464,12 +479,20 @@ void TodoWindow::slotBeam()
464 todoDB.save(); 479 todoDB.save();
465 Ir *ir = new Ir( this ); 480 Ir *ir = new Ir( this );
466 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 481 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
467 QString description = c.description(); 482 QString description = c.description();
468 ir->send( beamfile, description, "text/x-vCalendar" ); 483 ir->send( beamfile, description, "text/x-vCalendar" );
469} 484}
470 485
471void TodoWindow::beamDone( Ir *ir ) 486void TodoWindow::beamDone( Ir *ir )
472{ 487{
473 delete ir; 488 delete ir;
474 unlink( beamfile ); 489 unlink( beamfile );
475} 490}
491
492/* added 20.01.2k2 by se */
493void 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
@@ -38,37 +38,42 @@ public:
38 ~TodoWindow(); 38 ~TodoWindow();
39 39
40public slots: 40public slots:
41 void flush(); 41 void flush();
42 void reload(); 42 void reload();
43 43
44protected slots: 44protected slots:
45 void slotNew(); 45 void slotNew();
46 void slotDelete(); 46 void slotDelete();
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();
53 void setDocument( const QString & ); 57 void setDocument( const QString & );
54 void slotBeam(); 58 void slotBeam();
55 void beamDone( Ir * ); 59 void beamDone( Ir * );
56 60
57protected: 61protected:
58 void closeEvent( QCloseEvent *e ); 62 void closeEvent( QCloseEvent *e );
59 63
60private: 64private:
61 void populateCategories(); 65 void populateCategories();
62 66
63private: 67private:
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;
72}; 77};
73 78
74#endif 79#endif
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
@@ -39,25 +39,25 @@
39#include <qmultilineedit.h> 39#include <qmultilineedit.h>
40#include <qlabel.h> 40#include <qlabel.h>
41#include <qtimer.h> 41#include <qtimer.h>
42#include <qapplication.h> 42#include <qapplication.h>
43 43
44 44
45NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent, 45NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent,
46 const char *name, bool modal, WFlags fl ) 46 const char *name, bool modal, WFlags fl )
47 : NewTaskDialogBase( parent, name, modal, fl ), 47 : NewTaskDialogBase( parent, name, modal, fl ),
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
55 date = QDate::currentDate(); 55 date = QDate::currentDate();
56 56
57 init(); 57 init();
58 comboPriority->setCurrentItem( task.priority() - 1 ); 58 comboPriority->setCurrentItem( task.priority() - 1 );
59 59
60 checkCompleted->setChecked( task.isCompleted() ); 60 checkCompleted->setChecked( task.isCompleted() );
61 checkDate->setChecked( task.hasDate() ); 61 checkDate->setChecked( task.hasDate() );
62 buttonDate->setText( TimeString::longDateString( date ) ); 62 buttonDate->setText( TimeString::longDateString( date ) );
63 63
@@ -119,28 +119,28 @@ void NewTaskDialog::dateChanged( int y, int m, int d )
119ToDoEvent NewTaskDialog::todoEntry() 119ToDoEvent NewTaskDialog::todoEntry()
120{ 120{
121 qWarning("todoEntry()" ); 121 qWarning("todoEntry()" );
122 if( checkDate->isChecked() ){ 122 if( checkDate->isChecked() ){
123 todo.setDate( date ); 123 todo.setDate( date );
124 todo.setHasDate( true ); 124 todo.setHasDate( true );
125 }else{ 125 }else{
126 todo.setHasDate( false ); 126 todo.setHasDate( false );
127 } 127 }
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() );
138 138
139 todo.setDescription( txtTodo->text() ); 139 todo.setDescription( txtTodo->text() );
140 140
141 return todo; 141 return todo;
142} 142}
143 143
144 144
145/*! 145/*!
146 146
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
@@ -8,45 +8,48 @@
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
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>
24#include <qpe/categoryselect.h> 25#include <qpe/categoryselect.h>
25#include <qpe/xmlreader.h> 26#include <qpe/xmlreader.h>
26 27
27#include <qasciidict.h> 28#include <qasciidict.h>
28#include <qcombobox.h> 29#include <qcombobox.h>
29#include <qfile.h> 30#include <qfile.h>
30#include <qpainter.h> 31#include <qpainter.h>
31#include <qtextcodec.h> 32#include <qtextcodec.h>
32#include <qtimer.h> 33#include <qtimer.h>
33#include <qdatetime.h> 34#include <qdatetime.h>
34 35
35#include <qcursor.h> 36#include <qcursor.h>
36#include <qregexp.h> 37#include <qregexp.h>
37 38
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
43static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ); 46static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category );
44 47
45static QString journalFileName(); 48static QString journalFileName();
46 49
47CheckItem::CheckItem( QTable *t, const QString &key ) 50CheckItem::CheckItem( QTable *t, const QString &key )
48 : QTableItem( t, Never, "" ), checked( FALSE ), sortKey( key ) 51 : QTableItem( t, Never, "" ), checked( FALSE ), sortKey( key )
49{ 52{
50} 53}
51 54
52QString CheckItem::key() const 55QString CheckItem::key() const
@@ -155,42 +158,55 @@ QString ComboItem::text() const
155{ 158{
156 if ( cb ) 159 if ( cb )
157 return cb->currentText(); 160 return cb->currentText();
158 return QTableItem::text(); 161 return QTableItem::text();
159} 162}
160 163
161 164
162 165
163TodoTable::TodoTable( QWidget *parent, const char *name ) 166TodoTable::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 );
176 setSelectionMode( NoSelection ); 180 setSelectionMode( NoSelection );
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 & ) ),
188 this, SLOT( slotPressed( int, int, int, const QPoint & ) ) ); 204 this, SLOT( slotPressed( int, int, int, const QPoint & ) ) );
189 connect( this, SIGNAL( valueChanged( int, int ) ), 205 connect( this, SIGNAL( valueChanged( int, int ) ),
190 this, SLOT( slotCheckPriority( int, int ) ) ); 206 this, SLOT( slotCheckPriority( int, int ) ) );
191 connect( this, SIGNAL( currentChanged( int, int ) ), 207 connect( this, SIGNAL( currentChanged( int, int ) ),
192 this, SLOT( slotCurrentChanged( int, int ) ) ); 208 this, SLOT( slotCurrentChanged( int, int ) ) );
193 209
194 menuTimer = new QTimer( this ); 210 menuTimer = new QTimer( this );
195 connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); 211 connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) );
196} 212}
@@ -225,24 +241,29 @@ void TodoTable::slotClicked( int row, int col, int, const QPoint &pos )
225 } 241 }
226 emit signalDoneChanged( i->isChecked() ); 242 emit signalDoneChanged( i->isChecked() );
227 } 243 }
228 } 244 }
229 break; 245 break;
230 case 1: 246 case 1:
231 break; 247 break;
232 case 2: 248 case 2:
233 // may as well edit it... 249 // may as well edit it...
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
240void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) 261void TodoTable::slotPressed( int row, int col, int, const QPoint &pos )
241{ 262{
242 if ( col == 2 && cellGeometry( row, col ).contains(pos) ) 263 if ( col == 2 && cellGeometry( row, col ).contains(pos) )
243 menuTimer->start( 750, TRUE ); 264 menuTimer->start( 750, TRUE );
244} 265}
245 266
246void TodoTable::slotShowMenu() 267void TodoTable::slotShowMenu()
247{ 268{
248 emit signalShowMenu( QCursor::pos() ); 269 emit signalShowMenu( QCursor::pos() );
@@ -256,24 +277,26 @@ void TodoTable::slotCurrentChanged( int, int )
256void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) 277void TodoTable::internalAddEntries( QList<ToDoEvent> &list )
257{ 278{
258 setNumRows( list.count() ); 279 setNumRows( list.count() );
259 int row = 0; 280 int row = 0;
260 ToDoEvent *it; 281 ToDoEvent *it;
261 for ( it = list.first(); it; it = list.next() ) 282 for ( it = list.first(); it; it = list.next() )
262 insertIntoTable( it, row++ ); 283 insertIntoTable( it, row++ );
263} 284}
264 285
265 286
266ToDoEvent TodoTable::currentEntry() const 287ToDoEvent 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();
271 ToDoEvent *todo = todoList[(CheckItem*)i]; 294 ToDoEvent *todo = todoList[(CheckItem*)i];
272 todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); 295 todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() );
273 todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); 296 todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() );
274 return *todo; 297 return *todo;
275} 298}
276 299
277void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) 300void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem )
278{ 301{
279 int row = currentRow(); 302 int row = currentRow();
@@ -345,24 +368,33 @@ void TodoTable::load( const QString &fn )
345// QTable::sortColumn(1,TRUE,TRUE); 368// QTable::sortColumn(1,TRUE,TRUE);
346 QTable::sortColumn(0,TRUE,TRUE); 369 QTable::sortColumn(0,TRUE,TRUE);
347 setCurrentCell( 0, 2 ); 370 setCurrentCell( 0, 2 );
348} 371}
349 372
350void TodoTable::updateVisible() 373void TodoTable::updateVisible()
351{ 374{
352 if ( !isUpdatesEnabled() ) 375 if ( !isUpdatesEnabled() )
353 return; 376 return;
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++ ) {
360 CheckItem *ci = (CheckItem *)item( row, 0 ); 392 CheckItem *ci = (CheckItem *)item( row, 0 );
361 ToDoEvent *t = todoList[ci]; 393 ToDoEvent *t = todoList[ci];
362 QArray<int> vlCats = t->categories(); 394 QArray<int> vlCats = t->categories();
363 bool hide = false; 395 bool hide = false;
364 if ( !showComp && ci->isChecked() ) 396 if ( !showComp && ci->isChecked() )
365 hide = true; 397 hide = true;
366 if ( !showCat.isEmpty() ) { 398 if ( !showCat.isEmpty() ) {
367 if ( showCat == tr( "Unfiled" ) ) { 399 if ( showCat == tr( "Unfiled" ) ) {
368 if ( vlCats.count() > 0 ) 400 if ( vlCats.count() > 0 )
@@ -446,25 +478,25 @@ void TodoTable::sortColumn( int col, bool /*ascending*/, bool /*wholeRows*/ )
446 478
447void TodoTable::slotCheckPriority(int row, int col ) 479void TodoTable::slotCheckPriority(int row, int col )
448{ 480{
449 // kludgey work around to make forward along the updated priority... 481 // kludgey work around to make forward along the updated priority...
450 if ( col == 1 ) { 482 if ( col == 1 ) {
451 // let everyone know!! 483 // let everyone know!!
452 ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); 484 ComboItem* i = static_cast<ComboItem*>( item( row, col ) );
453 emit signalPriorityChanged( i->text().toInt() ); 485 emit signalPriorityChanged( i->text().toInt() );
454 } 486 }
455} 487}
456 488
457 489
458void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action, int row ) 490void 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) )
462 return; 494 return;
463 QString buf; 495 QString buf;
464 QCString str; 496 QCString str;
465 buf = "<Task"; 497 buf = "<Task";
466 // todo.save( buf ); 498 // todo.save( buf );
467 buf += " Action=\"" + QString::number( int(action) ) + "\""; 499 buf += " Action=\"" + QString::number( int(action) ) + "\"";
468 buf += " Row=\"" + QString::number( row ) + "\""; 500 buf += " Row=\"" + QString::number( row ) + "\"";
469 buf += "/>\n"; 501 buf += "/>\n";
470 str = buf.utf8(); 502 str = buf.utf8();
@@ -499,34 +531,62 @@ void TodoTable::loadFile( const QString &strFile, bool fromJournal )
499void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) 531void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row )
500{ 532{
501 QString strTodo; 533 QString strTodo;
502 strTodo = todo.description().left(40).simplifyWhiteSpace(); 534 strTodo = todo.description().left(40).simplifyWhiteSpace();
503 if ( row == -1 ) { 535 if ( row == -1 ) {
504 QMapIterator<CheckItem*, ToDoEvent *> it; 536 QMapIterator<CheckItem*, ToDoEvent *> it;
505 for ( it = todoList.begin(); it != todoList.end(); ++it ) { 537 for ( it = todoList.begin(); it != todoList.end(); ++it ) {
506 if ( *(*it) == todo ) { 538 if ( *(*it) == todo ) {
507 row = it.key()->row(); 539 row = it.key()->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 }
514 } else { 560 } else {
515 ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; 561 ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))];
516 todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); 562 todoList.remove( static_cast<CheckItem*>(item(row, 0)) );
517 delete t; 563 delete t;
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}
524 584
525void TodoTable::journalFreeRemoveEntry( int row ) 585void TodoTable::journalFreeRemoveEntry( int row )
526{ 586{
527 CheckItem *chk; 587 CheckItem *chk;
528 chk = static_cast<CheckItem*>(item(row, 0 )); 588 chk = static_cast<CheckItem*>(item(row, 0 ));
529 if ( !chk ) 589 if ( !chk )
530 return; 590 return;
531 todoList.remove( chk ); 591 todoList.remove( chk );
532 592
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
@@ -89,24 +89,28 @@ public:
89 TodoTable( QWidget *parent = 0, const char * name = 0 ); 89 TodoTable( QWidget *parent = 0, const char * name = 0 );
90 void addEntry( const ToDoEvent &todo ); 90 void addEntry( const ToDoEvent &todo );
91 void clearFindRow() { currFindRow = -2; } 91 void clearFindRow() { currFindRow = -2; }
92 92
93 ToDoEvent currentEntry() const; 93 ToDoEvent currentEntry() const;
94 void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false ); 94 void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false );
95 95
96 QStringList categories(); 96 QStringList categories();
97 97
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;
104 108
105 bool save( const QString &fn ); 109 bool save( const QString &fn );
106 void load( const QString &fn ); 110 void load( const QString &fn );
107 void clear(); 111 void clear();
108 void removeCurrentEntry(); 112 void removeCurrentEntry();
109 113
110 void setPaintingEnabled( bool e ); 114 void setPaintingEnabled( bool e );
111 115
112 virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ ); 116 virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ );
@@ -150,43 +154,61 @@ private slots:
150 154
151private: 155private:
152 friend class TodoWindow; 156 friend class TodoWindow;
153 157
154 QMap<CheckItem*, ToDoEvent *> todoList; 158 QMap<CheckItem*, ToDoEvent *> todoList;
155 QStringList categoryList; 159 QStringList categoryList;
156 bool showComp; 160 bool showComp;
157 QString showCat; 161 QString showCat;
158 QTimer *menuTimer; 162 QTimer *menuTimer;
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
165inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) 172inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
166{ 173{
167 QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') 174 QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A')
168 + todo->priority() ) 175 + todo->priority() )
169 + Qtopia::buildSortKey( todo->description() ); 176 + Qtopia::buildSortKey( todo->description() );
170 CheckItem *chk = new CheckItem( this, sortKey ); 177 CheckItem *chk = new CheckItem( this, sortKey );
171 chk->setChecked( todo->isCompleted() ); 178 chk->setChecked( todo->isCompleted() );
172 ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); 179 ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent );
173 cmb->setText( QString::number( todo->priority() ) ); 180 cmb->setText( QString::number( todo->priority() ) );
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
184inline void TodoTable::realignTable( int row ) 206inline void TodoTable::realignTable( int row )
185{ 207{
186 QTableItem *ti1, 208 QTableItem *ti1,
187 *ti2, 209 *ti2,
188 *ti3; 210 *ti3;
189 int totalRows = numRows(); 211 int totalRows = numRows();
190 for ( int curr = row; curr < totalRows - 1; curr++ ) { 212 for ( int curr = row; curr < totalRows - 1; curr++ ) {
191 // this is bad, we must take the item out and then 213 // this is bad, we must take the item out and then
192 // set it. In the end, it behaves no worse (time wise) 214 // set it. In the end, it behaves no worse (time wise)