summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-07 11:29:28 (UTC)
committer zecke <zecke>2002-10-07 11:29:28 (UTC)
commit772e75ae7934325172073a09f176fbbd9b64b4e0 (patch) (unidiff)
treebaa162c1d464baeb2f6e9844ae7afedc59f4ea9c
parentd9b425252bc2d3b0d9cb848f823d8eb254f38a26 (diff)
downloadopie-772e75ae7934325172073a09f176fbbd9b64b4e0.zip
opie-772e75ae7934325172073a09f176fbbd9b64b4e0.tar.gz
opie-772e75ae7934325172073a09f176fbbd9b64b4e0.tar.bz2
make place for the new todo
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/Changes10
-rw-r--r--core/pim/todo/TODO1
-rw-r--r--core/pim/todo/main.cpp36
-rw-r--r--core/pim/todo/mainwindow.cpp634
-rw-r--r--core/pim/todo/mainwindow.h97
-rw-r--r--core/pim/todo/opie-todo.control9
-rw-r--r--core/pim/todo/todo.pro33
-rw-r--r--core/pim/todo/todoentry.ui484
-rw-r--r--core/pim/todo/todoentryimpl.cpp170
-rw-r--r--core/pim/todo/todoentryimpl.h61
-rw-r--r--core/pim/todo/todolabel.cc58
-rw-r--r--core/pim/todo/todolabel.h51
-rw-r--r--core/pim/todo/todotable.cpp949
-rw-r--r--core/pim/todo/todotable.h245
14 files changed, 0 insertions, 2838 deletions
diff --git a/core/pim/todo/Changes b/core/pim/todo/Changes
deleted file mode 100644
index 543d7dc..0000000
--- a/core/pim/todo/Changes
+++ b/dev/null
@@ -1,10 +0,0 @@
1Hi,
2We try to keep a report of what was changed from the day we forked
3
4-(re)enable sorting
5-needed to update the journal
6-ported to the ToDoDB
7-Overview Label
8-deadline
9
10- magic suprise \ No newline at end of file
diff --git a/core/pim/todo/TODO b/core/pim/todo/TODO
deleted file mode 100644
index b00450c..0000000
--- a/core/pim/todo/TODO
+++ b/dev/null
@@ -1 +0,0 @@
1-when checking the C. box update the deadline
diff --git a/core/pim/todo/main.cpp b/core/pim/todo/main.cpp
deleted file mode 100644
index 4e1c8a1..0000000
--- a/core/pim/todo/main.cpp
+++ b/dev/null
@@ -1,36 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** 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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "mainwindow.h"
22
23#include <qpe/qpeapplication.h>
24
25int main( int argc, char **argv )
26{
27 QPEApplication a( argc, argv );
28
29 TodoWindow mw;
30 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( flush() ) );
31 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( reload() ) );
32
33 a.showMainWidget(&mw);
34
35 return a.exec();
36}
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
deleted file mode 100644
index 974951e..0000000
--- a/core/pim/todo/mainwindow.cpp
+++ b/dev/null
@@ -1,634 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (C) 2002 zecke
4** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de)
5**
6** This file is part of Qtopia Environment.
7**
8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file.
12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17**
18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you.
20**
21**********************************************************************/
22
23#define QTOPIA_INTERNAL_FD
24
25#include "mainwindow.h"
26#include "todoentryimpl.h"
27#include "todotable.h"
28#include "todolabel.h"
29
30#include <opie/tododb.h>
31#include <opie/todovcalresource.h>
32#include <opie/ofontmenu.h>
33
34#include <qpe/qpeapplication.h>
35#include <qpe/config.h>
36#include <qpe/finddialog.h>
37#include <qpe/global.h>
38#include <qpe/ir.h>
39#include <qpe/qpemenubar.h>
40#include <qpe/qpemessagebox.h>
41#include <qpe/resource.h>
42//#include <qpe/task.h>
43#include <qpe/qpetoolbar.h>
44
45#include <qaction.h>
46#include <qarray.h>
47#include <qdatastream.h>
48#include <qdatetime.h>
49#include <qfile.h>
50#include <qmessagebox.h>
51#include <qpopupmenu.h>
52#include <qwidgetstack.h>
53
54#include <sys/stat.h>
55#include <sys/types.h>
56#include <fcntl.h>
57#include <unistd.h>
58
59#include <stdlib.h>
60
61static QString todolistXMLFilename()
62{
63 return Global::applicationFileName("todolist","todolist.xml");
64}
65
66static QString categoriesXMLFilename()
67{
68 return Global::applicationFileName("todolist","categories.xml");
69}
70
71TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f ) :
72 QMainWindow( parent, name, f ), syncing(FALSE)
73{
74// QTime t;
75// t.start();
76 mView = 0l;
77 mStack = new QWidgetStack(this, "main stack");
78 setCentralWidget( mStack );
79 setCaption( tr("Todo") );
80 QString str;
81 table = new TodoTable( this );
82 table->setColumnWidth( 2, 10 );
83 table->setPaintingEnabled( FALSE );
84 table->setUpdatesEnabled( FALSE );
85 table->viewport()->setUpdatesEnabled( FALSE );
86
87 {
88 str = todolistXMLFilename();
89 if ( str.isNull() )
90 QMessageBox::critical( this,
91 tr("Out of Space"),
92 tr("Unable to create startup files\n"
93 "Free up some space\n"
94 "before you enter any data") );
95 else
96 table->load( str );
97 }
98
99 // repeat for categories...
100 str = categoriesXMLFilename();
101 if ( str.isNull() )
102 QMessageBox::critical( this,
103 tr( "Out of Space" ),
104 tr( "Unable to create startup files\n"
105 "Free up some space\n"
106 "before you enter any data") );
107
108 mStack->addWidget(table, 1 );
109 mStack->raiseWidget( 1 );
110 setCentralWidget( mStack );
111 setToolBarsMovable( FALSE );
112
113// qDebug("after load: t=%d", t.elapsed() );
114
115 Config config( "todo" );
116 config.setGroup( "View" );
117 bool complete = config.readBoolEntry( "ShowComplete", true );
118 table->setShowCompleted( complete );
119
120 bool showdeadline = config.readBoolEntry("ShowDeadLine", true);
121 table->setShowDeadline (showdeadline);
122
123 QString category = config.readEntry( "Category", QString::null );
124 table->setShowCategory( category );
125
126 QPEToolBar *bar = new QPEToolBar( this );
127 bar->setHorizontalStretchable( TRUE );
128
129 QPEMenuBar *mb = new QPEMenuBar( bar );
130
131 catMenu = new QPopupMenu( this );
132 QPopupMenu *edit = new QPopupMenu( this );
133 QPopupMenu *options = new QPopupMenu(this );
134
135 contextMenu = new QPopupMenu( this );
136
137 bar = new QPEToolBar( this );
138
139 QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ),
140 QString::null, 0, this, 0 );
141 connect( a, SIGNAL( activated() ),
142 this, SLOT( slotNew() ) );
143 a->addTo( bar );
144 a->addTo( edit );
145
146 a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ),
147 QString::null, 0, this, 0 );
148 connect( a, SIGNAL( activated() ),
149 this, SLOT( slotEdit() ) );
150 a->addTo( bar );
151 a->addTo( edit );
152 a->addTo( contextMenu );
153 a->setEnabled( FALSE );
154 editAction = a;
155
156 a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
157 a->addTo( edit );
158 a->addTo( contextMenu );
159 connect( a, SIGNAL( activated() ),
160 this, SLOT(slotShowDetails() ) );
161 viewAction = a;
162
163 edit->insertSeparator();
164
165 a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ),
166 QString::null, 0, this, 0 );
167 connect( a, SIGNAL( activated() ),
168 this, SLOT( slotDelete() ) );
169 a->addTo( bar );
170 a->addTo( edit );
171 a->addTo( contextMenu );
172 a->setEnabled( FALSE );
173 deleteAction = a;
174
175 // delete All in category is missing....
176 // set All Done
177 // set All Done in category
178
179 a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 );
180 connect(a, SIGNAL( activated() ),
181 this, SLOT( slotDeleteAll() ) );
182 a->addTo(edit );
183 a->setEnabled( FALSE );
184 deleteAllAction = a;
185
186 edit->insertSeparator();
187 a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 );
188 connect(a, SIGNAL( activated() ),
189 this, SLOT( slotDuplicate() ) );
190 a->addTo(edit );
191 a->setEnabled( FALSE );
192 duplicateAction = a;
193 edit->insertSeparator();
194
195
196
197 if ( Ir::supported() ) {
198 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
199 QString::null, 0, this, 0 );
200 connect( a, SIGNAL( activated() ),
201 this, SLOT( slotBeam() ) );
202 a->addTo( edit );
203 a->addTo( bar );
204 }
205
206 a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ),
207 QString::null, 0, this, 0 );
208 connect( a, SIGNAL( activated() ),
209 this, SLOT( slotFind() ) );
210// a->addTo( bar );
211 a->addTo( options );
212 options->insertSeparator();
213
214 if ( table->numRows() )
215 a->setEnabled( TRUE );
216 else
217 a->setEnabled( FALSE );
218
219 //a->setEnabled( FALSE );
220 findAction = a;
221// qDebug("mainwindow #2: t=%d", t.elapsed() );
222
223 completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE );
224
225 showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE );
226
227 catMenu->setCheckable( true );
228 populateCategories();
229
230
231 completedAction->addTo( options );
232 completedAction->setOn( table->showCompleted() );
233 showdeadlineAction->addTo( options );
234 showdeadlineAction->setOn( table->showDeadline() );
235 options->insertSeparator( );
236 QList<QWidget> list;
237 list.append(table );
238 OFontMenu *menu = new OFontMenu(this, "menu",list );
239 menu->forceSize( table->horizontalHeader(), 10 );
240 //catMenu->insertItem(tr("Fonts"), menu );
241 list.clear();
242 options->insertItem( tr("Fonts"), menu );
243
244
245 mb->insertItem( tr( "Data" ), edit );
246 mb->insertItem( tr( "Category" ), catMenu );
247 mb->insertItem( tr( "Options"), options );
248 resize( 200, 300 );
249 if ( table->numRows() > 0 )
250 currentEntryChanged( 0, 0 );
251 connect( table, SIGNAL( signalEdit() ),
252 this, SLOT( slotEdit() ) );
253 connect( table, SIGNAL(signalShowMenu(const QPoint &)),
254 this, SLOT( slotShowPopup(const QPoint &)) );
255
256// qDebug("mainwindow #3: t=%d", t.elapsed() );
257 table->updateVisible();
258 table->setUpdatesEnabled( TRUE );
259 table->setPaintingEnabled( TRUE );
260 table->viewport()->setUpdatesEnabled( TRUE );
261
262 // Initialize the table
263 table->updateVisible();
264
265 connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) );
266 connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) );
267 connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) );
268 connect( table, SIGNAL( currentChanged( int, int ) ),
269 this, SLOT( currentEntryChanged( int, int ) ) );
270
271 connect( table, SIGNAL(showDetails(const ToDoEvent &) ),
272 this, SLOT(slotShowDetails(const ToDoEvent & ) ) );
273// qDebug("done: t=%d", t.elapsed() );
274}
275
276void TodoWindow::slotNew()
277{
278 if(syncing) {
279 QMessageBox::warning(this, tr("Todo"),
280 tr("Can not edit data, currently syncing"));
281 return;
282 }
283
284 int id;
285 id = -1;
286 QArray<int> ids;
287 ids = table->currentEntry().categories();
288 if ( ids.count() )
289 id = ids[0];
290 NewTaskDialog e( id, this, 0, TRUE );
291
292 ToDoEvent todo;
293
294#if defined(Q_WS_QWS) || defined(_WS_QWS_)
295 e.showMaximized();
296#endif
297 int ret = e.exec();
298// qWarning("finished" );
299 if ( ret == QDialog::Accepted ) {
300 table->setPaintingEnabled( false );
301 todo = e.todoEntry();
302 //todo.assignUid();
303 table->addEntry( todo );
304 table->setPaintingEnabled( true );
305 findAction->setEnabled( TRUE );
306 }
307 // I'm afraid we must call this every time now, otherwise
308 // spend expensive time comparing all these strings...
309 populateCategories();
310 mStack->raiseWidget(1 );
311}
312
313TodoWindow::~TodoWindow()
314{
315}
316
317void TodoWindow::slotDelete()
318{
319 if(syncing) {
320 QMessageBox::warning(this, tr("Todo"),
321 tr("Can not edit data, currently syncing"));
322 return;
323 }
324
325 if ( table->currentRow() == -1 )
326 return;
327
328 QString strName = table->text( table->currentRow(), 2 ).left( 30 );
329
330 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) )
331 return;
332
333
334
335 table->setPaintingEnabled( false );
336 table->removeCurrentEntry();
337 table->setPaintingEnabled( true );
338
339 if ( table->numRows() == 0 ) {
340 currentEntryChanged( -1, 0 );
341 findAction->setEnabled( FALSE );
342 }
343 mStack->raiseWidget(1);
344}
345void TodoWindow::slotDeleteAll()
346{
347 if(syncing) {
348 QMessageBox::warning(this, tr("Todo"),
349 tr("Can not edit data, currently syncing"));
350 return;
351 }
352
353 //QString strName = table->text( table->currentRow(), 2 ).left( 30 );
354
355 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks") ) )
356 return;
357
358
359
360 table->setPaintingEnabled( false );
361 table->removeAllEntries();
362 table->setPaintingEnabled( true );
363
364 if ( table->numRows() == 0 ) {
365 currentEntryChanged( -1, 0 );
366 findAction->setEnabled( FALSE );
367 }
368 mStack->raiseWidget(1 );
369}
370
371void TodoWindow::slotEdit()
372{
373 if(syncing) {
374 QMessageBox::warning(this, tr("Todo"),
375 tr("Can not edit data, currently syncing"));
376 return;
377 }
378
379 ToDoEvent todo = table->currentEntry();
380 qWarning("slotEdit" );
381 NewTaskDialog e( todo, this, 0, TRUE );
382 e.setCaption( tr( "Edit Task" ) );
383
384#if defined(Q_WS_QWS) || defined(_WS_QWS_)
385 e.showMaximized();
386#endif
387 int ret = e.exec();
388
389 if ( ret == QDialog::Accepted ) {
390 qWarning("Replacing now" );
391 table->setPaintingEnabled( false );
392 todo = e.todoEntry();
393 table->replaceCurrentEntry( todo );
394 table->setPaintingEnabled( true );
395 }
396 populateCategories();
397 mStack->raiseWidget( 1 );
398}
399void TodoWindow::slotDuplicate()
400{
401 if(syncing) {
402 QMessageBox::warning(this, tr("Todo"),
403 tr("Can not edit data, currently syncing"));
404 return;
405 }
406 ToDoEvent ev = table->currentEntry();
407 ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid
408 int uid;
409 { // uid
410 Qtopia::UidGen *uidgen = new Qtopia::UidGen();
411 uid = uidgen->generate();
412 delete uidgen;
413 }
414 ev2.setUid( uid );
415 table->setPaintingEnabled( false );
416 table->addEntry( ev2 );
417 table->setPaintingEnabled( true );
418
419 mStack->raiseWidget( 1 );
420}
421void TodoWindow::slotShowPopup( const QPoint &p )
422{
423 contextMenu->popup( p );
424}
425
426void TodoWindow::showCompleted( bool s )
427{
428 if ( !table->isUpdatesEnabled() )
429 return;
430 table->setPaintingEnabled( false );
431 table->setShowCompleted( s );
432 table->setPaintingEnabled( true );
433 mStack->raiseWidget( 1 );
434}
435
436void TodoWindow::currentEntryChanged( int r, int )
437{
438 if ( r != -1 && table->rowHeight( r ) > 0 ) {
439 editAction->setEnabled( TRUE );
440 viewAction->setEnabled( TRUE );
441 deleteAction->setEnabled( TRUE );
442 duplicateAction->setEnabled( TRUE );
443 deleteAllAction->setEnabled( TRUE );
444 } else {
445 editAction->setEnabled( FALSE );
446 viewAction->setEnabled( FALSE );
447 deleteAction->setEnabled( FALSE );
448 duplicateAction->setEnabled( FALSE );
449 deleteAllAction->setEnabled( FALSE );
450 }
451}
452
453void TodoWindow::setCategory( int c )
454{
455 if ( c <= 0 ) return;
456 if ( !table->isUpdatesEnabled() )
457 return;
458 table->setPaintingEnabled( false );
459 for ( unsigned int i = 1; i < catMenu->count(); i++ )
460 catMenu->setItemChecked( i, c == (int)i );
461 if ( c == 1 ) {
462 table->setShowCategory( QString::null );
463 setCaption( tr("Todo") + " - " + tr( "All Categories" ) );
464 } else if ( c == (int)catMenu->count() - 1 ) {
465 table->setShowCategory( tr( "Unfiled" ) );
466 setCaption( tr("Todo") + " - " + tr( "Unfiled" ) );
467 } else {
468 QString cat = table->categories()[c - 2];
469 table->setShowCategory( cat );
470 setCaption( tr("Todo") + " - " + cat );
471 }
472 table->setPaintingEnabled( true );
473
474 mStack->raiseWidget( 1 );
475}
476
477void TodoWindow::populateCategories()
478{
479 catMenu->clear();
480 int id, rememberId;
481 id = 1;
482 rememberId = 0;
483 catMenu->insertItem( tr( "All Categories" ), id++ );
484 catMenu->insertSeparator();
485 QStringList categories = table->categories();
486 categories.append( tr( "Unfiled" ) );
487 for ( QStringList::Iterator it = categories.begin();
488 it != categories.end(); ++it ) {
489 catMenu->insertItem( *it, id );
490 if ( *it == table->showCategory() )
491 rememberId = id;
492 ++id;
493 }
494 if ( table->showCategory().isEmpty() )
495 setCategory( 1 );
496 else
497 setCategory( rememberId );
498}
499
500void TodoWindow::reload()
501{
502 table->clear();
503 table->load( todolistXMLFilename() );
504 syncing = FALSE;
505}
506
507void TodoWindow::flush()
508{
509 syncing = TRUE;
510 table->save( todolistXMLFilename() );
511}
512
513void TodoWindow::closeEvent( QCloseEvent *e )
514{
515 if( mStack->visibleWidget() != table ){
516 mStack->raiseWidget( 1 );
517 e->ignore();
518 return;
519 }
520 if(syncing) {
521 /* no need to save if in the middle of syncing */
522 e->accept();
523 return;
524 }
525
526 if ( table->save( todolistXMLFilename() ) ) {
527 e->accept();
528 // repeat for categories...
529 // if writing configs fail, it will emit an
530 // error, but I feel that it is "ok" for us to exit
531 // espically since we aren't told if the write succeeded...
532 Config config( "todo" );
533 config.setGroup( "View" );
534 config.writeEntry( "ShowComplete", table->showCompleted() );
535 config.writeEntry( "Category", table->showCategory() );
536 /* added 20.01.2k2 by se */
537 config.writeEntry( "ShowDeadLine", table->showDeadline());
538 } else {
539 if ( QMessageBox::critical( this, tr("Out of space"),
540 tr("Todo was unable\n"
541 "to save your changes.\n"
542 "Free up some space\n"
543 "and try again.\n"
544 "\nQuit Anyway?"),
545 QMessageBox::Yes|QMessageBox::Escape,
546 QMessageBox::No|QMessageBox::Default)
547 != QMessageBox::No )
548 e->accept();
549 else
550 e->ignore();
551 }
552}
553
554void TodoWindow::slotFind()
555{
556 // put everything back to view all for searching...
557 mStack->raiseWidget( 1 );
558 if ( !catMenu->isItemChecked( 0 ) )
559 setCategory( 0 );
560
561 FindDialog dlg( "Todo List", this );
562 QObject::connect( &dlg,
563 SIGNAL(signalFindClicked(const QString &,
564 bool, bool, int)),
565 table,
566 SLOT(slotDoFind(const QString&, bool, bool, int)) );
567 QObject::connect( table, SIGNAL(signalNotFound()), &dlg,
568 SLOT(slotNotFound()) );
569 QObject::connect( table, SIGNAL(signalWrapAround()), &dlg,
570 SLOT(slotWrapAround()) );
571 dlg.exec();
572 if ( table->numSelections() )
573 table->clearSelection();
574 table->clearFindRow();
575}
576
577
578void TodoWindow::setDocument( const QString &filename )
579{
580 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
581
582 ToDoDB todoDB(filename, new ToDoVCalResource() );
583 QValueList<ToDoEvent> tl = todoDB.rawToDos();
584 for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
585 table->addEntry( *it );
586 }
587}
588
589static const char * beamfile = "/tmp/obex/todo.vcs";
590
591void TodoWindow::slotBeam()
592{
593 unlink( beamfile ); // delete if exists
594 ToDoEvent c = table->currentEntry();
595 mkdir("/tmp/obex/", 0755);
596 ToDoDB todoDB( beamfile, new ToDoVCalResource() );
597 todoDB.addEvent( c );
598 todoDB.save();
599 Ir *ir = new Ir( this );
600 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
601 QString description = c.summary();
602 ir->send( beamfile, description, "text/x-vCalendar" );
603}
604
605void TodoWindow::beamDone( Ir *ir )
606{
607 delete ir;
608 unlink( beamfile );
609}
610
611void TodoWindow::showDeadline( bool s )
612{
613 if ( !table->isUpdatesEnabled() )
614 return;
615 table->setPaintingEnabled( false );
616 table->setShowDeadline( s );
617 table->setPaintingEnabled( true );
618 mStack->raiseWidget( 1 );
619}
620void TodoWindow::slotShowDetails()
621{
622 ToDoEvent event = table->currentEntry();
623 slotShowDetails( event );
624}
625void TodoWindow::slotShowDetails( const ToDoEvent &event )
626{
627 if( mView == 0l ){
628 mView = new TodoLabel(mStack);
629 mStack->addWidget( mView, 2 );
630 }
631 mView->init( event );
632 mView->sync();
633 mStack->raiseWidget( 2);
634}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
deleted file mode 100644
index 7e8445c..0000000
--- a/core/pim/todo/mainwindow.h
+++ b/dev/null
@@ -1,97 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org>
3** Copyright (C) 2002 by Stefan Eilers (se, eilers.stefan@epost.de)
4** Copyright (C) 2000 Trolltech AS. All rights reserved.
5**
6** This file is part of Qtopia and Opi Environment.
7**
8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file.
12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17**
18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you.
20**
21**********************************************************************/
22
23#ifndef MAINWINDOW_H
24#define MAINWINDOW_H
25
26#include <qmainwindow.h>
27
28class TodoTable;
29class QAction;
30class QPopupMenu;
31class Ir;
32class OFontMenu;
33class TodoLabel;
34class ToDoDB;
35class QWidgetStack;
36class ToDoEvent;
37
38class TodoWindow : public QMainWindow
39{
40 Q_OBJECT
41
42public:
43 TodoWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
44 ~TodoWindow();
45
46public slots:
47 void flush();
48 void reload();
49
50protected slots:
51 void slotNew();
52 void slotDelete();
53 void slotEdit();
54 void slotShowPopup( const QPoint & );
55 void showCompleted( bool );
56
57 void showDeadline( bool );
58
59 void slotShowDetails(const ToDoEvent &event );
60 void slotShowDetails();
61
62 void currentEntryChanged( int r, int c );
63 void setCategory( int );
64 void slotFind();
65 void setDocument( const QString & );
66 void slotBeam();
67 void beamDone( Ir * );
68 void slotDeleteAll();
69 void slotDuplicate();
70
71protected:
72 void closeEvent( QCloseEvent *e );
73
74private:
75 void populateCategories();
76 //inline void switchToTable(); // move back to the normal view
77
78private:
79 TodoTable *table;
80 TodoLabel *mView;
81 QAction *editAction,
82 *viewAction,
83 *deleteAction,
84 *findAction,
85 *completedAction,
86 *showdeadlineAction,
87 *deleteAllAction,
88 *duplicateAction;
89 QPopupMenu *contextMenu, *catMenu;
90 QWidgetStack *mStack;
91
92 bool syncing;
93};
94
95#endif
96
97
diff --git a/core/pim/todo/opie-todo.control b/core/pim/todo/opie-todo.control
deleted file mode 100644
index 31fa166..0000000
--- a/core/pim/todo/opie-todo.control
+++ b/dev/null
@@ -1,9 +0,0 @@
1Files: bin/todolist apps/1Pim/todo.desktop
2Priority: optional
3Section: opie/applications
4Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org>
5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION)
8Description: TODO-list manager
9 A Todo-list manager for the Opie environment.
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro
deleted file mode 100644
index 210a70c..0000000
--- a/core/pim/todo/todo.pro
+++ b/dev/null
@@ -1,33 +0,0 @@
1 TEMPLATE= app
2 CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS= mainwindow.h \
5 todotable.h \
6 todoentryimpl.h \
7 todolabel.h
8 SOURCES= main.cpp \
9 mainwindow.cpp \
10 todotable.cpp \
11 todoentryimpl.cpp \
12 todolabel.cc
13 INTERFACES= todoentry.ui
14 TARGET = todolist
15INCLUDEPATH += $(OPIEDIR)/include
16 DEPENDPATH+= $(OPIEDIR)/include
17LIBS += -lqpe -lopie
18
19TRANSLATIONS = ../../../i18n/de/todolist.ts \
20 ../../../i18n/en/todolist.ts \
21 ../../../i18n/es/todolist.ts \
22 ../../../i18n/fr/todolist.ts \
23 ../../../i18n/hu/todolist.ts \
24 ../../../i18n/ja/todolist.ts \
25 ../../../i18n/ko/todolist.ts \
26 ../../../i18n/no/todolist.ts \
27 ../../../i18n/pl/todolist.ts \
28 ../../../i18n/pt/todolist.ts \
29 ../../../i18n/pt_BR/todolist.ts \
30 ../../../i18n/sl/todolist.ts \
31 ../../../i18n/zh_CN/todolist.ts \
32 ../../../i18n/it/todolist.ts \
33 ../../../i18n/zh_TW/todolist.ts
diff --git a/core/pim/todo/todoentry.ui b/core/pim/todo/todoentry.ui
deleted file mode 100644
index bcd1d7c..0000000
--- a/core/pim/todo/todoentry.ui
+++ b/dev/null
@@ -1,484 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>NewTaskDialogBase</class>
3<comment>*********************************************************************
4** Copyright (C) 2000 Trolltech AS. All rights reserved.
5**
6** This file is part of Qtopia Environment.
7**
8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file.
12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17**
18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you.
20**
21*********************************************************************</comment>
22<widget>
23 <class>QDialog</class>
24 <property stdset="1">
25 <name>name</name>
26 <cstring>NewTaskDialogBase</cstring>
27 </property>
28 <property stdset="1">
29 <name>geometry</name>
30 <rect>
31 <x>0</x>
32 <y>0</y>
33 <width>342</width>
34 <height>445</height>
35 </rect>
36 </property>
37 <property stdset="1">
38 <name>caption</name>
39 <string>New Task</string>
40 </property>
41 <property>
42 <name>layoutMargin</name>
43 </property>
44 <property>
45 <name>layoutSpacing</name>
46 </property>
47 <vbox>
48 <property stdset="1">
49 <name>margin</name>
50 <number>4</number>
51 </property>
52 <property stdset="1">
53 <name>spacing</name>
54 <number>4</number>
55 </property>
56 <widget>
57 <class>QLayoutWidget</class>
58 <property stdset="1">
59 <name>name</name>
60 <cstring>Layout18</cstring>
61 </property>
62 <property>
63 <name>layoutSpacing</name>
64 </property>
65 <grid>
66 <property stdset="1">
67 <name>margin</name>
68 <number>0</number>
69 </property>
70 <property stdset="1">
71 <name>spacing</name>
72 <number>4</number>
73 </property>
74 <widget row="4" column="0" >
75 <class>QLabel</class>
76 <property stdset="1">
77 <name>name</name>
78 <cstring>TextLabel1</cstring>
79 </property>
80 <property stdset="1">
81 <name>sizePolicy</name>
82 <sizepolicy>
83 <hsizetype>1</hsizetype>
84 <vsizetype>1</vsizetype>
85 </sizepolicy>
86 </property>
87 <property stdset="1">
88 <name>text</name>
89 <string>Summary:</string>
90 </property>
91 </widget>
92 <widget row="3" column="1" >
93 <class>QPushButton</class>
94 <property stdset="1">
95 <name>name</name>
96 <cstring>buttonDate</cstring>
97 </property>
98 <property stdset="1">
99 <name>enabled</name>
100 <bool>false</bool>
101 </property>
102 <property stdset="1">
103 <name>text</name>
104 <string>1 Jan 2001</string>
105 </property>
106 </widget>
107 <widget row="2" column="1" >
108 <class>QLayoutWidget</class>
109 <property stdset="1">
110 <name>name</name>
111 <cstring>Layout15</cstring>
112 </property>
113 <property>
114 <name>layoutSpacing</name>
115 </property>
116 <hbox>
117 <property stdset="1">
118 <name>margin</name>
119 <number>0</number>
120 </property>
121 <property stdset="1">
122 <name>spacing</name>
123 <number>4</number>
124 </property>
125 <widget>
126 <class>QComboBox</class>
127 <item>
128 <property>
129 <name>text</name>
130 <string>0%</string>
131 </property>
132 </item>
133 <item>
134 <property>
135 <name>text</name>
136 <string>20%</string>
137 </property>
138 </item>
139 <item>
140 <property>
141 <name>text</name>
142 <string>40%</string>
143 </property>
144 </item>
145 <item>
146 <property>
147 <name>text</name>
148 <string>60%</string>
149 </property>
150 </item>
151 <item>
152 <property>
153 <name>text</name>
154 <string>80%</string>
155 </property>
156 </item>
157 <item>
158 <property>
159 <name>text</name>
160 <string>100%</string>
161 </property>
162 </item>
163 <property stdset="1">
164 <name>name</name>
165 <cstring>cmbProg</cstring>
166 </property>
167 <property stdset="1">
168 <name>sizePolicy</name>
169 <sizepolicy>
170 <hsizetype>7</hsizetype>
171 <vsizetype>0</vsizetype>
172 </sizepolicy>
173 </property>
174 <property stdset="1">
175 <name>maximumSize</name>
176 <size>
177 <width>32767</width>
178 <height>32767</height>
179 </size>
180 </property>
181 </widget>
182 <widget>
183 <class>QCheckBox</class>
184 <property stdset="1">
185 <name>name</name>
186 <cstring>checkCompleted</cstring>
187 </property>
188 <property stdset="1">
189 <name>text</name>
190 <string>&amp;Completed</string>
191 </property>
192 </widget>
193 </hbox>
194 </widget>
195 <widget row="4" column="1" >
196 <class>QLayoutWidget</class>
197 <property stdset="1">
198 <name>name</name>
199 <cstring>Layout17</cstring>
200 </property>
201 <property>
202 <name>layoutSpacing</name>
203 </property>
204 <hbox>
205 <property stdset="1">
206 <name>margin</name>
207 <number>0</number>
208 </property>
209 <property stdset="1">
210 <name>spacing</name>
211 <number>4</number>
212 </property>
213 <widget>
214 <class>QLineEdit</class>
215 <property stdset="1">
216 <name>name</name>
217 <cstring>lneSum</cstring>
218 </property>
219 </widget>
220 <widget>
221 <class>OClickableLabel</class>
222 <property stdset="1">
223 <name>name</name>
224 <cstring>lblDown</cstring>
225 </property>
226 <property stdset="1">
227 <name>sizePolicy</name>
228 <sizepolicy>
229 <hsizetype>0</hsizetype>
230 <vsizetype>0</vsizetype>
231 </sizepolicy>
232 </property>
233 <property stdset="1">
234 <name>minimumSize</name>
235 <size>
236 <width>20</width>
237 <height>20</height>
238 </size>
239 </property>
240 <property stdset="1">
241 <name>maximumSize</name>
242 <size>
243 <width>20</width>
244 <height>20</height>
245 </size>
246 </property>
247 </widget>
248 </hbox>
249 </widget>
250 <widget row="0" column="1" >
251 <class>QComboBox</class>
252 <item>
253 <property>
254 <name>text</name>
255 <string>1 - Very High</string>
256 </property>
257 </item>
258 <item>
259 <property>
260 <name>text</name>
261 <string>2 - High</string>
262 </property>
263 </item>
264 <item>
265 <property>
266 <name>text</name>
267 <string>3 - Normal</string>
268 </property>
269 </item>
270 <item>
271 <property>
272 <name>text</name>
273 <string>4 - Low</string>
274 </property>
275 </item>
276 <item>
277 <property>
278 <name>text</name>
279 <string>5 - Very Low</string>
280 </property>
281 </item>
282 <property stdset="1">
283 <name>name</name>
284 <cstring>comboPriority</cstring>
285 </property>
286 <property stdset="1">
287 <name>sizePolicy</name>
288 <sizepolicy>
289 <hsizetype>1</hsizetype>
290 <vsizetype>0</vsizetype>
291 </sizepolicy>
292 </property>
293 <property stdset="1">
294 <name>currentItem</name>
295 <number>2</number>
296 </property>
297 </widget>
298 <widget row="0" column="0" >
299 <class>QLabel</class>
300 <property stdset="1">
301 <name>name</name>
302 <cstring>TextLabel2</cstring>
303 </property>
304 <property stdset="1">
305 <name>sizePolicy</name>
306 <sizepolicy>
307 <hsizetype>1</hsizetype>
308 <vsizetype>1</vsizetype>
309 </sizepolicy>
310 </property>
311 <property stdset="1">
312 <name>text</name>
313 <string>Priority:</string>
314 </property>
315 </widget>
316 <widget row="2" column="0" >
317 <class>QLabel</class>
318 <property stdset="1">
319 <name>name</name>
320 <cstring>txtProg</cstring>
321 </property>
322 <property stdset="1">
323 <name>sizePolicy</name>
324 <sizepolicy>
325 <hsizetype>1</hsizetype>
326 <vsizetype>1</vsizetype>
327 </sizepolicy>
328 </property>
329 <property stdset="1">
330 <name>frameShape</name>
331 <enum>MShape</enum>
332 </property>
333 <property stdset="1">
334 <name>frameShadow</name>
335 <enum>MShadow</enum>
336 </property>
337 <property stdset="1">
338 <name>text</name>
339 <string>Progress:</string>
340 </property>
341 </widget>
342 <widget row="3" column="0" >
343 <class>QCheckBox</class>
344 <property stdset="1">
345 <name>name</name>
346 <cstring>checkDate</cstring>
347 </property>
348 <property stdset="1">
349 <name>text</name>
350 <string>D&amp;ue</string>
351 </property>
352 </widget>
353 <widget row="1" column="0" >
354 <class>QLabel</class>
355 <property stdset="1">
356 <name>name</name>
357 <cstring>TextLabel3</cstring>
358 </property>
359 <property stdset="1">
360 <name>sizePolicy</name>
361 <sizepolicy>
362 <hsizetype>1</hsizetype>
363 <vsizetype>1</vsizetype>
364 </sizepolicy>
365 </property>
366 <property stdset="1">
367 <name>frameShape</name>
368 <enum>NoFrame</enum>
369 </property>
370 <property stdset="1">
371 <name>text</name>
372 <string>Category:</string>
373 </property>
374 </widget>
375 <widget row="1" column="1" >
376 <class>CategorySelect</class>
377 <property stdset="1">
378 <name>name</name>
379 <cstring>comboCategory</cstring>
380 </property>
381 <property stdset="1">
382 <name>sizePolicy</name>
383 <sizepolicy>
384 <hsizetype>7</hsizetype>
385 <vsizetype>0</vsizetype>
386 </sizepolicy>
387 </property>
388 <property stdset="1">
389 <name>minimumSize</name>
390 <size>
391 <width>60</width>
392 <height>20</height>
393 </size>
394 </property>
395 </widget>
396 </grid>
397 </widget>
398 <widget>
399 <class>QMultiLineEdit</class>
400 <property stdset="1">
401 <name>name</name>
402 <cstring>txtTodo</cstring>
403 </property>
404 <property stdset="1">
405 <name>sizePolicy</name>
406 <sizepolicy>
407 <hsizetype>7</hsizetype>
408 <vsizetype>7</vsizetype>
409 </sizepolicy>
410 </property>
411 <property stdset="1">
412 <name>wordWrap</name>
413 <enum>WidgetWidth</enum>
414 </property>
415 </widget>
416 </vbox>
417</widget>
418<customwidgets>
419 <customwidget>
420 <class>CategorySelect</class>
421 <header location="global">qpe/categoryselect.h</header>
422 <sizehint>
423 <width>-1</width>
424 <height>-1</height>
425 </sizehint>
426 <container>0</container>
427 <sizepolicy>
428 <hordata>7</hordata>
429 <verdata>1</verdata>
430 </sizepolicy>
431 <pixmap>image0</pixmap>
432 </customwidget>
433 <customwidget>
434 <class>OClickableLabel</class>
435 <header location="global">opie/oclickablelabel.h</header>
436 <sizehint>
437 <width>-1</width>
438 <height>-1</height>
439 </sizehint>
440 <container>0</container>
441 <sizepolicy>
442 <hordata>5</hordata>
443 <verdata>5</verdata>
444 </sizepolicy>
445 <pixmap>image0</pixmap>
446 <signal>clicked()</signal>
447 <signal>toggled(bool)</signal>
448 <slot access="public">slotOn(bool)</slot>
449 </customwidget>
450</customwidgets>
451<images>
452 <image>
453 <name>image0</name>
454 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
455 </image>
456</images>
457<connections>
458 <connection>
459 <sender>checkDate</sender>
460 <signal>toggled(bool)</signal>
461 <receiver>buttonDate</receiver>
462 <slot>setEnabled(bool)</slot>
463 </connection>
464 <connection>
465 <sender>lblDown</sender>
466 <signal>clicked()</signal>
467 <receiver>NewTaskDialogBase</receiver>
468 <slot>slotCopy()</slot>
469 </connection>
470 <slot access="protected">dateChanged( const QString &amp; )</slot>
471 <slot access="protected">dateChanged( int, int, int )</slot>
472 <slot access="protected">slotCopy()</slot>
473</connections>
474<tabstops>
475 <tabstop>comboPriority</tabstop>
476 <tabstop>checkCompleted</tabstop>
477 <tabstop>checkDate</tabstop>
478 <tabstop>buttonDate</tabstop>
479 <tabstop>cmbProg</tabstop>
480 <tabstop>comboCategory</tabstop>
481 <tabstop>lneSum</tabstop>
482 <tabstop>txtTodo</tabstop>
483</tabstops>
484</UI>
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp
deleted file mode 100644
index af47665..0000000
--- a/core/pim/todo/todoentryimpl.cpp
+++ b/dev/null
@@ -1,170 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (C) 2002 zecke
4**
5** This file is part of Qtopia Environment.
6**
7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file.
11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16**
17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you.
19**
20**********************************************************************/
21
22#include "todoentryimpl.h"
23
24#include <opie/oclickablelabel.h>
25#include <opie/todoevent.h>
26#include <opie/tododb.h>
27
28#include <qpe/categoryselect.h>
29#include <qpe/datebookmonth.h>
30#include <qpe/global.h>
31#include <qpe/resource.h>
32#include <qpe/imageedit.h>
33#include <qpe/timestring.h>
34#include <qpe/palmtoprecord.h>
35
36#include <qlayout.h>
37#include <qmessagebox.h>
38#include <qpopupmenu.h>
39#include <qtoolbutton.h>
40#include <qcombobox.h>
41#include <qcheckbox.h>
42#include <qlineedit.h>
43#include <qmultilineedit.h>
44#include <qlabel.h>
45#include <qtimer.h>
46#include <qapplication.h>
47
48
49NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent,
50 const char *name, bool modal, WFlags fl )
51 : NewTaskDialogBase( parent, name, modal, fl ),
52 todo( task )
53{
54 todo.setCategories( task.allCategories() );
55 if ( todo.hasDate() )
56 date = todo.date();
57 else
58 date = QDate::currentDate();
59
60 init();
61 comboPriority->setCurrentItem( task.priority() - 1 );
62
63 checkCompleted->setChecked( task.isCompleted() );
64 checkDate->setChecked( task.hasDate() );
65 buttonDate->setText( TimeString::longDateString( date ) );
66
67 txtTodo->setText( task.description() );
68 lneSum->setText( task.summary() );
69 cmbProg->setCurrentItem( task.progress()/20 );
70}
71
72/*
73 * Constructs a NewTaskDialog which is a child of 'parent', with the
74 * name 'name' and widget flags set to 'f'
75 *
76 * The dialog will by default be modeless, unless you set 'modal' to
77 * TRUE to construct a modal dialog.
78 */
79NewTaskDialog::NewTaskDialog( int id, QWidget* parent, const char* name, bool modal,
80 WFlags fl )
81 : NewTaskDialogBase( parent, name, modal, fl ),
82 date( QDate::currentDate() )
83{
84 if ( id != -1 ) {
85 QArray<int> ids( 1 );
86 ids[0] = id;
87 todo.setCategory( Qtopia::Record::idsToString( ids ) );
88 }
89 init();
90}
91
92void NewTaskDialog::init()
93{
94 if( layout() != 0 ){
95 layout()->setMargin( 2 );
96 }
97 QPopupMenu *m1 = new QPopupMenu( this );
98 picker = new DateBookMonth( m1, 0, TRUE );
99 m1->insertItem( picker );
100 buttonDate->setPopup( m1 );
101 comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") );
102
103 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
104 this, SLOT( dateChanged( int, int, int ) ) );
105
106 buttonDate->setText( TimeString::longDateString( date ) );
107 picker->setDate( date.year(), date.month(), date.day() );
108 lblDown->setPixmap(Resource::loadPixmap("down") );
109}
110
111/*
112 * Destroys the object and frees any allocated resources
113 */
114NewTaskDialog::~NewTaskDialog()
115{
116 // no need to delete child widgets, Qt does it all for us
117}
118void NewTaskDialog::dateChanged( int y, int m, int d )
119{
120 date = QDate( y, m, d );
121 buttonDate->setText( TimeString::longDateString( date ) );
122}
123
124/*!
125*/
126
127ToDoEvent NewTaskDialog::todoEntry()
128{
129 if( checkDate->isChecked() ){
130 todo.setDate( date );
131 todo.setHasDate( true );
132 }else{
133 todo.setHasDate( false );
134 }
135 if ( comboCategory->currentCategory() != -1 ) {
136 QArray<int> arr = comboCategory->currentCategories();
137 QStringList list;
138 list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ;
139 todo.setCategories( list );
140 }
141 todo.setPriority( comboPriority->currentItem() + 1 );
142 todo.setCompleted( checkCompleted->isChecked() );
143
144 todo.setDescription( txtTodo->text() );
145 todo.setSummary( lneSum->text() );
146 QString text = cmbProg->currentText();
147 todo.setProgress( text.remove( text.length()-1, 1 ).toUShort() );
148 return todo;
149}
150void NewTaskDialog::slotCopy()
151{
152 txtTodo->clear();
153 txtTodo->setText( lneSum->text() );
154}
155
156/*!
157
158*/
159
160void NewTaskDialog::accept()
161{
162 QString strText = txtTodo->text();
163 QString strSumm = lneSum->text();
164 if ( strSumm.isEmpty() && strText.isEmpty() ) {
165 // hmm... just decline it then, the user obviously didn't care about it
166 QDialog::reject();
167 return;
168 }
169 QDialog::accept();
170}
diff --git a/core/pim/todo/todoentryimpl.h b/core/pim/todo/todoentryimpl.h
deleted file mode 100644
index 49d1274..0000000
--- a/core/pim/todo/todoentryimpl.h
+++ b/dev/null
@@ -1,61 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** 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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef NEWTASKDIALOG_H
22#define NEWTASKDIALOG_H
23
24#include "todoentry.h"
25
26#include <opie/todoevent.h>
27
28#include <qdatetime.h>
29#include <qpalette.h>
30
31class QLabel;
32class QTimer;
33class DateBookMonth;
34
35class NewTaskDialog : public NewTaskDialogBase
36{
37 Q_OBJECT
38
39public:
40 NewTaskDialog( const ToDoEvent &task, QWidget *parent = 0, const char* name = 0,
41 bool modal = FALSE, WFlags fl = 0 );
42 NewTaskDialog( int id, QWidget* parent = 0, const char* name = 0,
43 bool modal = FALSE, WFlags fl = 0 );
44 ~NewTaskDialog();
45
46 ToDoEvent todoEntry();
47
48protected slots:
49 void dateChanged( int y, int m, int d );
50 void slotCopy();
51protected:
52 virtual void accept();
53
54private:
55 void init();
56 ToDoEvent todo;
57 QDate date;
58 DateBookMonth *picker;
59};
60
61#endif // NEWTASKDIALOG_H
diff --git a/core/pim/todo/todolabel.cc b/core/pim/todo/todolabel.cc
deleted file mode 100644
index 4ce3499..0000000
--- a/core/pim/todo/todolabel.cc
+++ b/dev/null
@@ -1,58 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2002 by Stefan Eilers (se, eilers.stefan@epost.de)
3** Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org>
4** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
5**
6** This file is part of the Qtopia Environment.
7**
8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file.
12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17**
18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you.
20**
21**********************************************************************/
22
23
24
25#include <qpe/stringutil.h>
26
27#include <qregexp.h>
28#include <qstylesheet.h>
29
30
31#include "todolabel.h"
32
33TodoLabel::TodoLabel( QWidget *parent, const char *name )
34 : QTextView( parent, name )
35{
36}
37
38TodoLabel::~TodoLabel()
39{
40}
41
42void TodoLabel::init( const ToDoEvent &item )
43{
44 m_item = item;
45}
46
47void TodoLabel::sync()
48{
49 QString text = m_item.richText();
50 setText( text );
51}
52
53void TodoLabel::keyPressEvent( QKeyEvent *e )
54{
55 if ( e->key() == Qt::Key_F33 ) {
56 emit okPressed();
57 }
58}
diff --git a/core/pim/todo/todolabel.h b/core/pim/todo/todolabel.h
deleted file mode 100644
index b6d67af..0000000
--- a/core/pim/todo/todolabel.h
+++ b/dev/null
@@ -1,51 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2002 by Stefan Eilers (se, eilers.stefan@epost.de)
3** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
4**
5** This file is part of the Qtopia Environment.
6**
7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file.
11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16**
17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you.
19**
20**********************************************************************/
21#ifndef TODOLABEL_H
22#define TODOLABEL_H
23
24#include <opie/todoevent.h>
25
26#include <qtextview.h>
27
28class TodoLabel : public QTextView
29{
30 Q_OBJECT
31
32public:
33 TodoLabel( QWidget *parent, const char *name = 0 );
34 ~TodoLabel();
35
36public slots:
37 void init( const ToDoEvent &item);
38 void sync();
39
40signals:
41 void okPressed();
42
43protected:
44 void keyPressEvent( QKeyEvent * );
45
46private:
47 ToDoEvent m_item;
48
49};
50
51#endif
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp
deleted file mode 100644
index 15f733b..0000000
--- a/core/pim/todo/todotable.cpp
+++ b/dev/null
@@ -1,949 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** 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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20/* Show Deadline was added by Stefan Eilers (se, eilers.stefan@epost.de)
21 */
22#include "todotable.h"
23
24#include <opie/tododb.h>
25#include <opie/xmltree.h>
26
27#include <qpe/categoryselect.h>
28#include <qpe/xmlreader.h>
29
30#include <qasciidict.h>
31#include <qcombobox.h>
32#include <qfile.h>
33#include <qpainter.h>
34#include <qtextcodec.h>
35#include <qtimer.h>
36#include <qdatetime.h>
37#include <qtextstream.h>
38
39#include <qcursor.h>
40#include <qregexp.h>
41
42#include <errno.h>
43#include <stdlib.h>
44
45#include <stdio.h>
46
47using namespace Opie;
48
49namespace {
50
51 static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category );
52 static QString journalFileName();
53 static ToDoEvent xmlToEvent( XMLElement *ev );
54}
55CheckItem::CheckItem( QTable *t, const QString &key )
56 : QTableItem( t, Never, "" ), checked( FALSE ), sortKey( key )
57{
58}
59
60QString CheckItem::key() const
61{
62 return sortKey;
63}
64
65void CheckItem::setChecked( bool b )
66{
67 checked = b;
68 table()->updateCell( row(), col() );
69}
70
71void CheckItem::toggle()
72{
73 TodoTable *parent = static_cast<TodoTable*>(table());
74 ToDoEvent newTodo = parent->currentEntry();
75 checked = !checked;
76 newTodo.setCompleted( checked );
77 table()->updateCell( row(), col() );
78 parent->replaceCurrentEntry( newTodo, true );
79}
80
81bool CheckItem::isChecked() const
82{
83 return checked;
84}
85
86static const int BoxSize = 10;
87
88void CheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr,
89 bool )
90{
91 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
92
93 int marg = ( cr.width() - BoxSize ) / 2;
94 int x = 0;
95 int y = ( cr.height() - BoxSize ) / 2;
96 p->setPen( QPen( cg.text() ) );
97 p->drawRect( x + marg, y, BoxSize, BoxSize );
98 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
99 p->setPen( darkGreen );
100 x += 1;
101 y += 1;
102 if ( checked ) {
103 QPointArray a( 7*2 );
104 int i, xx, yy;
105 xx = x+1+marg;
106 yy = y+2;
107 for ( i=0; i<3; i++ ) {
108 a.setPoint( 2*i, xx, yy );
109 a.setPoint( 2*i+1, xx, yy+2 );
110 xx++; yy++;
111 }
112 yy -= 2;
113 for ( i=3; i<7; i++ ) {
114 a.setPoint( 2*i, xx, yy );
115 a.setPoint( 2*i+1, xx, yy+2 );
116 xx++; yy--;
117 }
118 p->drawLineSegments( a );
119 }
120}
121
122
123ComboItem::ComboItem( QTable *t, EditType et )
124 : QTableItem( t, et, "3" ), cb( 0 )
125{
126 setReplaceable( FALSE );
127}
128
129QWidget *ComboItem::createEditor() const
130{
131 QString txt = text();
132 ( (ComboItem*)this )->cb = new QComboBox( table()->viewport() );
133 cb->insertItem( "1" );
134 cb->insertItem( "2" );
135 cb->insertItem( "3" );
136 cb->insertItem( "4" );
137 cb->insertItem( "5" );
138 cb->setCurrentItem( txt.toInt() - 1 );
139 return cb;
140}
141
142void ComboItem::setContentFromEditor( QWidget *w )
143{
144 TodoTable *parent = static_cast<TodoTable*>(table());
145 ToDoEvent newTodo = parent->currentEntry();
146
147 if ( w->inherits( "QComboBox" ) )
148 setText( ( (QComboBox*)w )->currentText() );
149 else
150 QTableItem::setContentFromEditor( w );
151 newTodo.setPriority( text().toInt() );
152 parent->replaceCurrentEntry( newTodo, true );
153}
154
155void ComboItem::setText( const QString &s )
156{
157 if ( cb )
158 cb->setCurrentItem( s.toInt() - 1 );
159 QTableItem::setText( s );
160}
161
162QString ComboItem::text() const
163{
164 if ( cb )
165 return cb->currentText();
166 return QTableItem::text();
167}
168DueTextItem::DueTextItem( QTable *t, ToDoEvent *ev )
169 : QTableItem(t, Never, QString::null )
170{
171 setToDoEvent( ev );
172}
173QString DueTextItem::key() const
174{
175 QString key;
176 if( m_hasDate ){
177 if(m_off == 0 ){
178 key.append("b");
179 }else if( m_off > 0 ){
180 key.append("c");
181 }else if( m_off < 0 ){
182 key.append("a");
183 }
184 key.append(QString::number(m_off ) );
185 }else{
186 key.append("d");
187 }
188 return key;
189}
190void DueTextItem::setToDoEvent( const ToDoEvent *ev )
191{
192 m_hasDate = ev->hasDate();
193 m_completed = ev->isCompleted();
194 if( ev->hasDate() ){
195 QDate today = QDate::currentDate();
196 m_off = today.daysTo(ev->date() );
197 //qWarning("DueText m_off=%d", m_off );
198 setText( QString::number(m_off) + " day(s) " );
199 }else{
200 setText("n.d." );
201 m_off = 0;
202 }
203 //qWarning("m_off=%d", m_off );
204}
205void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected )
206{
207 //qWarning ("paint m_off=%d", m_off );
208 QColorGroup cg2(cg);
209 QColor text = cg.text();
210 if( m_hasDate && !m_completed ){
211 if( m_off < 0 ){
212 cg2.setColor(QColorGroup::Text, QColor(red ) );
213 }else if( m_off == 0 ){
214 cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined
215 }else if( m_off > 0){
216 cg2.setColor(QColorGroup::Text, QColor(green ) );
217 }
218 }
219 QTableItem::paint(p, cg2, cr, selected );
220 cg2.setColor(QColorGroup::Text, text );
221}
222TodoTable::TodoTable( QWidget *parent, const char *name )
223// #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR
224// : QTable( 0, 3, parent, name, TRUE ),
225// #else
226 : QTable( 0, 4, parent, name ),
227// #endif
228 showComp( true ),
229 enablePainting( true ),
230 mCat( 0 ),
231 currFindRow( -2 ),
232 showDeadl( true)
233{
234 setNumRows(0);
235 mCat.load( categoryFileName() );
236 setSorting( TRUE );
237 setSelectionMode( NoSelection );
238 setColumnStretchable( 2, TRUE );
239 setColumnWidth( 0, 20 );
240 setColumnWidth( 1, 35 );
241
242 setLeftMargin( 0 );
243 verticalHeader()->hide();
244 horizontalHeader()->setLabel( 0, tr( "C." ) );
245 horizontalHeader()->setLabel( 1, tr( "Prior." ) );
246 horizontalHeader()->setLabel( 2, tr( "Description" ) );
247
248 setColumnStretchable( 3, FALSE );
249 setColumnWidth( 3, 20 );
250 horizontalHeader()->setLabel( 3, tr( "Deadline" ) );
251
252 if (showDeadl){
253 showColumn (3);
254 }else{
255 hideColumn (3);
256 }
257
258 connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ),
259 this, SLOT( slotClicked( int, int, int, const QPoint & ) ) );
260 connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ),
261 this, SLOT( slotPressed( int, int, int, const QPoint & ) ) );
262 connect( this, SIGNAL( valueChanged( int, int ) ),
263 this, SLOT( slotCheckPriority( int, int ) ) );
264 connect( this, SIGNAL( currentChanged( int, int ) ),
265 this, SLOT( slotCurrentChanged( int, int ) ) );
266
267 menuTimer = new QTimer( this );
268 connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) );
269
270 mDayTimer = new QTimer( this );
271 connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) );
272 mDay = QDate::currentDate();
273}
274
275void TodoTable::addEntry( const ToDoEvent &todo )
276{
277 int row = numRows();
278 setNumRows( row + 1 );
279 updateJournal( todo, ACTION_ADD );
280 insertIntoTable( new ToDoEvent(todo), row );
281 setCurrentCell(row, currentColumn());
282 updateVisible();
283}
284
285void TodoTable::slotClicked( int row, int col, int, const QPoint &pos )
286{
287 if ( !cellGeometry( row, col ).contains(pos) )
288 return;
289 // let's switch on the column number...
290 switch ( col )
291 {
292 case 0: {
293 CheckItem *i = static_cast<CheckItem*>(item( row, col ));
294 if ( i ) {
295 int x = pos.x() - columnPos( col );
296 int y = pos.y() - rowPos( row );
297 int w = columnWidth( col );
298 int h = rowHeight( row );
299 if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize &&
300 y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) {
301 i->toggle();
302 }
303 emit signalDoneChanged( i->isChecked() );
304 }
305 }
306 break;
307 case 1:
308 break;
309 case 2:
310 // Show detailed view of the selected entry
311 {
312 menuTimer->stop();
313 ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))];
314 emit showDetails( *todo );
315 }
316 break;
317 case 3:
318 // may as well edit it...
319 menuTimer->stop();
320 emit signalEdit();
321 break;
322 }
323}
324
325void TodoTable::slotPressed( int row, int col, int, const QPoint &pos )
326{
327 if ( col == 2 && cellGeometry( row, col ).contains(pos) )
328 menuTimer->start( 750, TRUE );
329}
330
331void TodoTable::slotShowMenu()
332{
333 emit signalShowMenu( QCursor::pos() );
334}
335
336void TodoTable::slotCurrentChanged( int, int )
337{
338 menuTimer->stop();
339}
340
341void TodoTable::internalAddEntries( QList<ToDoEvent> &list )
342{
343 setNumRows( list.count() );
344 int row = 0;
345 ToDoEvent *it;
346 for ( it = list.first(); it; it = list.next() )
347 insertIntoTable( it, row++ );
348}
349
350
351ToDoEvent TodoTable::currentEntry() const
352{
353 //qWarning ("in currentEntry\n");
354
355 QTableItem *i = item( currentRow(), 0 );
356 if ( !i || rowHeight( currentRow() ) <= 0 )
357 return ToDoEvent();
358 ToDoEvent *todo = todoList[(CheckItem*)i];
359 todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() );
360 todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() );
361 return *todo;
362}
363
364void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem )
365{
366 int row = currentRow();
367 updateJournal( todo, ACTION_REPLACE);
368
369 if ( !fromTableItem ) {
370 journalFreeReplaceEntry( todo, row );
371 updateVisible();
372 }
373}
374
375void TodoTable::removeCurrentEntry()
376{
377 ToDoEvent *oldTodo;
378 int row = currentRow();
379 CheckItem *chk;
380
381 chk = static_cast<CheckItem*>(item(row, 0 ));
382 if ( !chk )
383 return;
384 oldTodo = todoList[chk];
385 todoList.remove( chk );
386 oldTodo->setCompleted( chk->isChecked() );
387 oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() );
388 realignTable( row );
389 updateVisible();
390 updateJournal( *oldTodo, ACTION_REMOVE);
391 delete oldTodo;
392}
393
394
395bool TodoTable::save( const QString &fn )
396{
397 QString strNewFile = fn + ".new";
398 QFile::remove( strNewFile ); // just to be sure
399 ToDoDB todoDB( strNewFile );
400 for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin();
401 it != todoList.end(); ++it ) {
402 if ( !item( it.key()->row(), 0 ) )
403 continue;
404 ToDoEvent *todo = *it;
405 // sync item with table
406 todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() );
407 todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() );
408 todoDB.addEvent( *todo );
409 }
410 if(!todoDB.save() ){
411 QFile::remove( strNewFile );
412 return false;
413 };
414 // now do the rename
415 if ( ::rename( strNewFile, fn ) < 0 )
416 qWarning( "problem renaming file %s to %s errno %d",
417 strNewFile.latin1(), fn.latin1(), errno );
418
419 // remove the journal
420 QFile::remove( journalFileName() );
421 return true;
422}
423
424void TodoTable::load( const QString &fn )
425{
426 if ( QFile::exists(journalFileName()) ) {
427 applyJournal();
428 QFile::remove(journalFileName() );
429 }
430 loadFile( fn );
431// QTable::sortColumn(2,TRUE,TRUE);
432// QTable::sortColumn(1,TRUE,TRUE);
433 QTable::sortColumn(0,TRUE,TRUE);
434 setCurrentCell( 0, 2 );
435 setSorting(true );
436 mDayTimer->start( 60 * 1000 ); // gone in 60 seconds?
437}
438void TodoTable::updateVisible()
439{
440 if ( !isUpdatesEnabled() )
441 return;
442
443 if (showDeadl){
444 showColumn (3);
445 adjustColumn(3);
446 }else{
447 hideColumn (3);
448 adjustColumn(2);
449 }
450
451 int visible = 0;
452 int id = mCat.id( "Todo List", showCat );
453 for ( int row = 0; row < numRows(); row++ ) {
454 CheckItem *ci = (CheckItem *)item( row, 0 );
455 ToDoEvent *t = todoList[ci];
456 if (!t)
457 continue;
458
459 QArray<int> vlCats = t->categories();
460 bool hide = false;
461 if ( !showComp && ci->isChecked() )
462 hide = true;
463 if ( !showCat.isEmpty() ) {
464 if ( showCat == tr( "Unfiled" ) ) {
465 if ( vlCats.count() > 0 )
466 hide = true;
467 } else {
468 // do some comparing, we have to reverse our idea here... which idea? - zecke
469 if ( !hide ) {
470 hide = true;
471 for ( uint it = 0; it < vlCats.count(); ++it ) {
472 if ( vlCats[it] == id ) {
473 hide = false;
474 break;
475 }
476 }
477 }
478 }
479 }
480 if ( hide ) {
481 if ( currentRow() == row )
482 setCurrentCell( -1, 0 );
483 if ( rowHeight( row ) > 0 )
484 hideRow( row );
485 } else {
486 if ( rowHeight( row ) == 0 ) {
487 showRow( row );
488 adjustRow( row );
489 }
490 visible++;
491 }
492 }
493 if ( !visible )
494 setCurrentCell( -1, 0 );
495}
496
497void TodoTable::viewportPaintEvent( QPaintEvent *pe )
498{
499 if ( enablePainting )
500 QTable::viewportPaintEvent( pe );
501}
502
503void TodoTable::setPaintingEnabled( bool e )
504{
505 if ( e != enablePainting ) {
506 if ( !enablePainting ) {
507 enablePainting = true;
508 rowHeightChanged( 0 );
509 viewport()->update();
510 } else {
511 enablePainting = false;
512 }
513 }
514}
515
516void TodoTable::clear()
517{
518 for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin();
519 it != todoList.end(); ++it ) {
520 ToDoEvent *todo = it.data();
521 updateJournal( *todo, ACTION_REMOVE );
522 delete todo;
523 }
524 todoList.clear();
525 for ( int r = 0; r < numRows(); ++r ) {
526 for ( int c = 0; c < numCols(); ++c ) {
527 if ( cellWidget( r, c ) )
528 clearCellWidget( r, c );
529 clearCell( r, c );
530 }
531 }
532 setNumRows( 0 );
533}
534
535void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ )
536{
537 // The default for wholeRows is false, however
538 // for this todo table we want to exchange complete
539 // rows when sorting. Also, we always want ascending, since
540 // the values have a logical order.
541 QTable::sortColumn( col, ascending, TRUE );
542 updateVisible();
543}
544
545void TodoTable::slotCheckPriority(int row, int col )
546{
547 // kludgey work around to make forward along the updated priority...
548 if ( col == 1 ) {
549 // let everyone know!!
550 ComboItem* i = static_cast<ComboItem*>( item( row, col ) );
551 emit signalPriorityChanged( i->text().toInt() );
552 }
553}
554
555
556void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action )
557{
558 QFile f( journalFileName() );
559 if ( !f.open(IO_WriteOnly|IO_Append) )
560 return;
561 QString buf;
562 QCString str;
563 buf = "<Task";
564 // todo.save( buf );
565 buf += " Action=\"" + QString::number( int(action) ) + "\"";
566 buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id
567 buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\"";
568 buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\"";
569 buf += " Priority=\"" + QString::number( todo.priority() ) + "\"";
570 QArray<int> arrat = todo.categories();
571 QString attr;
572 for(uint i=0; i < arrat.count(); i++ ){
573 attr.append(QString::number(arrat[i])+";" );
574 }
575 if(!attr.isEmpty() ) // remove the last ;
576 attr.remove(attr.length()-1, 1 );
577 buf += " Categories=\"" + attr + "\"";
578 buf += " Description=\"" + todo.description() + "\"";
579 buf += " Summary=\"" + todo.summary() + "\"";
580 if(todo.hasDate() ) {
581 buf += " DateYear=\""+QString::number( todo.date().year() ) + "\"";
582 buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\"";
583 buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\"";
584 }
585 buf += "/>\n";
586 str = buf.utf8();
587 f.writeBlock( str.data(), str.length() );
588 f.close();
589}
590
591void TodoTable::rowHeightChanged( int row )
592{
593 if ( enablePainting )
594 QTable::rowHeightChanged( row );
595}
596
597void TodoTable::loadFile( const QString &/*we use the standard*/ )
598{
599
600 QList<ToDoEvent> list;
601 ToDoDB todoDB;
602 QValueList<ToDoEvent> vaList = todoDB.rawToDos();
603 for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){
604 ToDoEvent *event = new ToDoEvent( (*it) );
605 list.append( event );
606 }
607 vaList.clear();
608 // qDebug("parsing done=%d", t.elapsed() );
609 if ( list.count() > 0 ) {
610 internalAddEntries( list );
611 list.clear();
612 }
613// qDebug("loading done: t=%d", t.elapsed() );
614}
615
616void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row )
617{
618 QString strTodo = todo.summary();
619 if( strTodo.isEmpty() ){
620 strTodo = todo.description().left(40).simplifyWhiteSpace();
621 //todo.setSummary(strTodo );
622 }
623 if ( row == -1 ) {
624 QMapIterator<CheckItem*, ToDoEvent *> it;
625 for ( it = todoList.begin(); it != todoList.end(); ++it ) {
626 if ( *(*it) == todo ) {
627 row = it.key()->row();
628 it.key()->setChecked( todo.isCompleted() );
629 static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) );
630 item( row, 2 )->setText( strTodo );
631
632 if (showDeadl){
633 static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo );
634 }
635
636 *(*it) = todo;
637 }
638 }
639 } else {
640 ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))];
641 todoList.remove( static_cast<CheckItem*>(item(row, 0)) );
642 delete t;
643 static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() );
644 static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) );
645 item( row, 2 )->setText( strTodo );
646
647 if (showDeadl){
648 static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo );
649 }
650 todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) );
651 }
652}
653
654void TodoTable::journalFreeRemoveEntry( int row )
655{
656 CheckItem *chk;
657 chk = static_cast<CheckItem*>(item(row, 0 ));
658 if ( !chk )
659 return;
660 todoList.remove( chk );
661
662 realignTable( row );
663}
664
665void TodoTable::keyPressEvent( QKeyEvent *e )
666{
667 if ( e->key() == Key_Space || e->key() == Key_Return ) {
668 switch ( currentColumn() ) {
669 case 0: {
670 CheckItem *i = static_cast<CheckItem*>(item(currentRow(),
671 currentColumn()));
672 if ( i )
673 i->toggle();
674 break;
675 }
676 case 1:
677 break;
678 case 2:{
679 ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(currentRow(), 0))];
680 emit showDetails(*todo);
681 break;
682 }
683 case 3:
684 // Future: Let us change the dueDate directly...
685 emit signalEdit();
686 default:
687 break;
688 }
689 } else
690 QTable::keyPressEvent( e );
691}
692
693
694QStringList TodoTable::categories()
695{
696 // This is called seldom, so calling a load in here
697 // should be fine.
698 mCat.load( categoryFileName() );
699 QStringList categoryList = mCat.labels( "Todo List" );
700 return categoryList;
701}
702
703void TodoTable::slotDoFind( const QString &findString, bool caseSensitive,
704 bool backwards, int category )
705{
706 // we have to iterate through the table, this gives the illusion that
707 // sorting is actually being used.
708 if ( currFindRow < -1 )
709 currFindRow = currentRow() - 1;
710 clearSelection( TRUE );
711 int rows,
712 row;
713 CheckItem *chk;
714 QRegExp r( findString );
715
716 r.setCaseSensitive( caseSensitive );
717 rows = numRows();
718 static bool wrapAround = true;
719
720 if ( !backwards ) {
721 for ( row = currFindRow + 1; row < rows; row++ ) {
722 chk = static_cast<CheckItem*>( item(row, 0) );
723 if ( taskCompare(*(todoList[chk]), r, category) )
724 break;
725 }
726 } else {
727 for ( row = currFindRow - 1; row > -1; row-- ) {
728 chk = static_cast<CheckItem*>( item(row, 0) );
729 if ( taskCompare(*(todoList[chk]), r, category) )
730 break;
731 }
732 }
733 if ( row >= rows || row < 0 ) {
734 if ( row < 0 )
735 currFindRow = rows;
736 else
737 currFindRow = -1;
738 if ( wrapAround )
739 emit signalWrapAround();
740 else
741 emit signalNotFound();
742 wrapAround = !wrapAround;
743 } else {
744 currFindRow = row;
745 QTableSelection foundSelection;
746 foundSelection.init( currFindRow, 0 );
747 foundSelection.expandTo( currFindRow, numCols() - 1 );
748 addSelection( foundSelection );
749 setCurrentCell( currFindRow, numCols() - 1 );
750 // we should always be able to wrap around and find this again,
751 // so don't give confusing not found message...
752 wrapAround = true;
753 }
754}
755
756int TodoTable::showCategoryId() const
757{
758 int id;
759 id = -1;
760 // if allcategories are selected, you get unfiled...
761 if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) )
762 id = mCat.id( "Todo List", showCat );
763 return id;
764}
765void TodoTable::applyJournal()
766{
767 // we need to hack
768 QFile file( journalFileName() );
769 if( file.open(IO_ReadOnly ) ) {
770 QByteArray ar = file.readAll();
771 file.close();
772 QFile file2( journalFileName() + "_new" );
773 if( file2.open(IO_WriteOnly ) ){
774 QTextStream str(&file2 );
775 str << QString::fromLatin1("<Tasks>") << endl;
776 str << ar.data();
777 str << QString::fromLatin1("</Tasks>") << endl;
778 file2.close();
779 }
780 XMLElement *root = XMLElement::load(journalFileName()+ "_new");
781 XMLElement *el = root->firstChild();
782 el = el->firstChild();
783 ToDoDB tododb; // allready loaded ;)
784 bool ok;
785 int action;
786 QString dummy;
787 while( el ){
788 dummy = el->attribute("Action" );
789 action = dummy.toInt(&ok );
790 ToDoEvent ev = xmlToEvent( el );
791 if(ok ){
792 switch( action){
793 case ACTION_ADD:
794 tododb.addEvent(ev );
795 break;
796 case ACTION_REMOVE:
797 tododb.removeEvent( ev );
798 break;
799 case ACTION_REPLACE:
800 tododb.replaceEvent( ev );
801 break;
802 }
803 }
804 el = el->nextChild();
805 }
806 QFile::remove(journalFileName()+ "_new" );
807 tododb.save();
808 }
809}
810void TodoTable::slotCheckDay()
811{
812 QDate date = QDate::currentDate();
813 if( mDay.daysTo(date )!= 0 ){
814 setPaintingEnabled( FALSE );
815 for(int i=0; i < numRows(); i++ ){
816 ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))];
817 static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t );
818
819 }
820 setPaintingEnabled( TRUE );
821 mDay = date;
822 }
823 mDayTimer->start( 60 * 1000 ); // 60 seconds
824}
825// check Action and decide
826/*
827void TodoTable::doApply(XMLElement *el )
828{
829 QString dummy;
830 bool ok;
831 int action;
832 dummy = el->attribute("Action" );
833 action = dummy.toInt(&ok );
834 ToDoEvent ev = xmlToEvent( el );
835 if( ok ){
836 switch( action ){
837 case ACTION_ADD:
838 addEntry( ev );
839 break;
840 case ACTION_REMOVE:{ // find an entry with the same uid and remove it then
841 break;
842 }
843 case ACTION_REPLACE:
844 break;
845 }
846 }
847}
848*/
849namespace {
850static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category )
851{
852 bool returnMe;
853 QArray<int> cats;
854 cats = task.categories();
855
856 returnMe = false;
857 if ( (category == -1 && cats.count() == 0) || category == -2 )
858 returnMe = task.match( r );
859 else {
860 int i;
861 for ( i = 0; i < int(cats.count()); i++ ) {
862 if ( cats[i] == category ) {
863 returnMe = task.match( r );
864 break;
865 }
866 }
867 }
868 return returnMe;
869}
870
871static QString journalFileName()
872{
873 QString str;
874 str = getenv( "HOME" );
875 str += "/.opie_todojournal";
876 return str;
877}
878static ToDoEvent xmlToEvent( XMLElement *element )
879{
880 QString dummy;
881 ToDoEvent event;
882 bool ok;
883 int dumInt;
884 // completed
885 dummy = element->attribute("Completed" );
886 dumInt = dummy.toInt(&ok );
887 if(ok ) event.setCompleted( dumInt == 0 ? false : true );
888 // hasDate
889 dummy = element->attribute("HasDate" );
890 dumInt = dummy.toInt(&ok );
891 if(ok ) event.setHasDate( dumInt == 0 ? false: true );
892 // set the date
893 bool hasDa = dumInt;
894 if ( hasDa ) { //parse the date
895 int year, day, month = 0;
896 year = day = month;
897 // year
898 dummy = element->attribute("DateYear" );
899 dumInt = dummy.toInt(&ok );
900 if( ok ) year = dumInt;
901 // month
902 dummy = element->attribute("DateMonth" );
903 dumInt = dummy.toInt(&ok );
904 if(ok ) month = dumInt;
905 dummy = element->attribute("DateDay" );
906 dumInt = dummy.toInt(&ok );
907 if(ok ) day = dumInt;
908 // set the date
909 QDate date( year, month, day );
910 event.setDate( date);
911 }
912 dummy = element->attribute("Priority" );
913 dumInt = dummy.toInt(&ok );
914 if(!ok ) dumInt = ToDoEvent::NORMAL;
915 event.setPriority( dumInt );
916 //description
917 dummy = element->attribute("Description" );
918 event.setDescription( dummy );
919 // summary
920 dummy = element->attribute("Summary" );
921 event.setSummary( dummy );
922 // category
923 dummy = element->attribute("Categories" );
924 QStringList ids = QStringList::split(";", dummy );
925 event.setCategories( ids );
926
927 //uid
928 dummy = element->attribute("Uid" );
929 dumInt = dummy.toInt(&ok );
930 if(ok ) event.setUid( dumInt );
931 return event;
932}
933
934}
935// int TodoTable::rowHeight( int ) const
936// {
937// return 18;
938// }
939
940// int TodoTable::rowPos( int row ) const
941// {
942// return 18*row;
943// }
944
945// int TodoTable::rowAt( int pos ) const
946// {
947// return QMIN( pos/18, numRows()-1 );
948// }
949
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h
deleted file mode 100644
index 387dddb..0000000
--- a/core/pim/todo/todotable.h
+++ b/dev/null
@@ -1,245 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** 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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef TODOTABLE_H
22#define TODOTABLE_H
23
24#include <qpe/categories.h>
25#include <qpe/stringutil.h>
26//#include <qpe/task.h>
27#include <opie/todoevent.h>
28
29#include <qtable.h>
30#include <qmap.h>
31#include <qguardedptr.h>
32
33class Node;
34class QComboBox;
35class QTimer;
36
37class CheckItem : public QTableItem
38{
39public:
40 CheckItem( QTable *t, const QString &sortkey );
41
42 void setChecked( bool b );
43 void toggle();
44 bool isChecked() const;
45 void setKey( const QString &key ) { sortKey = key; }
46 QString key() const;
47
48 void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected );
49
50private:
51 bool checked;
52 QString sortKey;
53};
54
55class ComboItem : public QTableItem
56{
57public:
58 ComboItem( QTable *t, EditType et );
59 QWidget *createEditor() const;
60 void setContentFromEditor( QWidget *w );
61 void setText( const QString &s );
62 int alignment() const { return Qt::AlignCenter; }
63
64 QString text() const;
65
66private:
67 QGuardedPtr<QComboBox> cb;
68
69};
70
71class TodoTextItem : public QTableItem
72{
73public:
74 TodoTextItem( QTable *t, const QString & str )
75 :QTableItem( t, QTableItem::Never, str ) {}
76
77 QString key () const { return Qtopia::buildSortKey( text() ); }
78};
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};
93
94
95enum journal_action { ACTION_ADD=0, ACTION_REMOVE, ACTION_REPLACE };
96
97namespace Opie
98{
99class XMLElement;
100};
101
102class TodoTable : public QTable
103{
104 Q_OBJECT
105
106public:
107 TodoTable( QWidget *parent = 0, const char * name = 0 );
108 void addEntry( const ToDoEvent &todo );
109 void clearFindRow() { currFindRow = -2; }
110
111 ToDoEvent currentEntry() const;
112 void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false );
113
114 QStringList categories();
115
116 void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); }
117 bool showCompleted() const { return showComp; }
118
119 void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();}
120 bool showDeadline() const { return showDeadl;}
121
122 void setShowCategory( const QString &c ) { showCat = c; updateVisible(); }
123 const QString &showCategory() const { return showCat; }
124 int showCategoryId() const;
125
126 bool save( const QString &fn );
127 void load( const QString &fn );
128 void applyJournal( );
129 void clear();
130 void removeCurrentEntry();
131 void removeAllEntries() { clear(); };
132 //void removeAllEntriesInCategory(const QString &category );
133
134 void setPaintingEnabled( bool e );
135
136 virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ );
137
138// int rowHeight( int ) const;
139// int rowPos( int row ) const;
140// virtual int rowAt( int pos ) const;
141
142signals:
143 void signalEdit();
144 void signalDoneChanged( bool b );
145 void signalPriorityChanged( int i );
146 void signalShowMenu( const QPoint & );
147 void signalNotFound();
148 void signalWrapAround();
149 void showDetails( const ToDoEvent & );
150protected:
151 void keyPressEvent( QKeyEvent *e );
152
153private:
154 void updateVisible();
155 void viewportPaintEvent( QPaintEvent * );
156 void internalAddEntries( QList<ToDoEvent> &list);
157 inline void insertIntoTable( ToDoEvent *todo, int row );
158 void updateJournal( const ToDoEvent &todo, journal_action action);
159 void mergeJournal();
160 void journalFreeReplaceEntry( const ToDoEvent &todo, int row );
161 void journalFreeRemoveEntry( int row );
162 inline void realignTable( int row );
163 void loadFile( const QString &strFile);
164
165private slots:
166 void slotClicked( int row, int col, int button, const QPoint &pos );
167 void slotPressed( int row, int col, int button, const QPoint &pos );
168 void slotCheckPriority(int row, int col );
169 void slotCurrentChanged(int row, int col );
170 void slotDoFind( const QString &findString, bool caseSensetive,
171 bool backwards, int category );
172 void slotShowMenu();
173 void rowHeightChanged( int row );
174 void slotCheckDay(); // check the day
175
176private:
177 friend class TodoWindow;
178
179 QMap<CheckItem*, ToDoEvent *> todoList;
180 QStringList categoryList;
181 bool showComp;
182 QString showCat;
183 QTimer *menuTimer;
184 QDate mDay;
185 QTimer *mDayTimer; // see if the day changed
186 bool enablePainting;
187 Categories mCat;
188 int currFindRow;
189 bool showDeadl:1;
190};
191
192
193inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
194{
195 QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A')
196 + todo->priority() )
197 + Qtopia::buildSortKey( todo->description() );
198 CheckItem *chk = new CheckItem( this, sortKey );
199 chk->setChecked( todo->isCompleted() );
200 ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent );
201 cmb->setText( QString::number( todo->priority() ) );
202 QString sum = todo->summary();
203 QTableItem *ti = new TodoTextItem( this, sum.isEmpty() ? todo->description().left(40).simplifyWhiteSpace() : sum );
204 ti->setReplaceable( false );
205
206 DueTextItem *due = new DueTextItem(this, todo );
207 setItem( row, 3, due);
208
209 setItem( row, 0, chk );
210 setItem( row, 1, cmb );
211 setItem( row, 2, ti );
212
213
214 todoList.insert( chk, todo );
215}
216
217inline void TodoTable::realignTable( int row )
218{
219 QTableItem *ti1,
220 *ti2,
221 *ti3,
222 *ti4;
223 int totalRows = numRows();
224 for ( int curr = row; curr < totalRows - 1; curr++ ) {
225 // this is bad, we must take the item out and then
226 // set it. In the end, it behaves no worse (time wise)
227 // then the old way of saving the entries to file, clearing
228 // the table re-reading in the file and resetting the table
229 ti1 = item( curr + 1, 0 );
230 ti2 = item( curr + 1, 1 );
231 ti3 = item( curr + 1, 2 );
232 ti4 = item( curr + 1, 3 );
233 takeItem( ti1 );
234 takeItem( ti2 );
235 takeItem( ti3 );
236 takeItem( ti4 );
237 setItem( curr, 0, ti1 );
238 setItem( curr, 1, ti2 );
239 setItem( curr, 2, ti3 );
240 setItem( curr, 3, ti4 );
241 }
242 setNumRows( totalRows - 1 );
243}
244
245#endif