-rw-r--r-- | core/pim/todo/TODO | 2 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 2 | ||||
-rw-r--r-- | core/pim/todo/todoentryimpl.cpp | 6 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 48 | ||||
-rw-r--r-- | core/pim/todo/todotable.h | 5 |
5 files changed, 38 insertions, 25 deletions
diff --git a/core/pim/todo/TODO b/core/pim/todo/TODO index 040f163..7601dd2 100644 --- a/core/pim/todo/TODO +++ b/core/pim/todo/TODO | |||
@@ -1,4 +1,4 @@ | |||
1 | -fix the journal | 1 | -fix the journal (wip ) |
2 | -fix day wrapping update all DueDateItems | 2 | -fix day wrapping update all DueDateItems |
3 | -when checking the C. box update the deadline | 3 | -when checking the C. box update the deadline |
4 | -TodoLabel : public TextView | 4 | -TodoLabel : public TextView |
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 883d78c..fc17c5f 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -261,33 +261,33 @@ void TodoWindow::slotNew() | |||
261 | } | 261 | } |
262 | 262 | ||
263 | int id; | 263 | int id; |
264 | id = -1; | 264 | id = -1; |
265 | QArray<int> ids; | 265 | QArray<int> ids; |
266 | ids = table->currentEntry().categories(); | 266 | ids = table->currentEntry().categories(); |
267 | if ( ids.count() ) | 267 | if ( ids.count() ) |
268 | id = ids[0]; | 268 | id = ids[0]; |
269 | NewTaskDialog e( id, this, 0, TRUE ); | 269 | NewTaskDialog e( id, this, 0, TRUE ); |
270 | 270 | ||
271 | ToDoEvent todo; | 271 | ToDoEvent todo; |
272 | 272 | ||
273 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 273 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
274 | e.showMaximized(); | 274 | e.showMaximized(); |
275 | #endif | 275 | #endif |
276 | int ret = e.exec(); | 276 | int ret = e.exec(); |
277 | qWarning("finished" ); | 277 | // qWarning("finished" ); |
278 | if ( ret == QDialog::Accepted ) { | 278 | if ( ret == QDialog::Accepted ) { |
279 | table->setPaintingEnabled( false ); | 279 | table->setPaintingEnabled( false ); |
280 | todo = e.todoEntry(); | 280 | todo = e.todoEntry(); |
281 | //todo.assignUid(); | 281 | //todo.assignUid(); |
282 | table->addEntry( todo ); | 282 | table->addEntry( todo ); |
283 | table->setPaintingEnabled( true ); | 283 | table->setPaintingEnabled( true ); |
284 | findAction->setEnabled( TRUE ); | 284 | findAction->setEnabled( TRUE ); |
285 | } | 285 | } |
286 | // I'm afraid we must call this every time now, otherwise | 286 | // I'm afraid we must call this every time now, otherwise |
287 | // spend expensive time comparing all these strings... | 287 | // spend expensive time comparing all these strings... |
288 | populateCategories(); | 288 | populateCategories(); |
289 | } | 289 | } |
290 | 290 | ||
291 | TodoWindow::~TodoWindow() | 291 | TodoWindow::~TodoWindow() |
292 | { | 292 | { |
293 | } | 293 | } |
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp index f938d61..26a685c 100644 --- a/core/pim/todo/todoentryimpl.cpp +++ b/core/pim/todo/todoentryimpl.cpp | |||
@@ -34,33 +34,32 @@ | |||
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtoolbutton.h> | 35 | #include <qtoolbutton.h> |
36 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
37 | #include <qcheckbox.h> | 37 | #include <qcheckbox.h> |
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
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 | ||
45 | NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent, | 45 | NewTaskDialog::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" ); | ||
51 | todo.setCategories( task.allCategories() ); | 50 | todo.setCategories( task.allCategories() ); |
52 | if ( todo.hasDate() ) | 51 | if ( todo.hasDate() ) |
53 | date = todo.date(); | 52 | date = todo.date(); |
54 | else | 53 | else |
55 | date = QDate::currentDate(); | 54 | date = QDate::currentDate(); |
56 | 55 | ||
57 | init(); | 56 | init(); |
58 | comboPriority->setCurrentItem( task.priority() - 1 ); | 57 | comboPriority->setCurrentItem( task.priority() - 1 ); |
59 | 58 | ||
60 | checkCompleted->setChecked( task.isCompleted() ); | 59 | checkCompleted->setChecked( task.isCompleted() ); |
61 | checkDate->setChecked( task.hasDate() ); | 60 | checkDate->setChecked( task.hasDate() ); |
62 | buttonDate->setText( TimeString::longDateString( date ) ); | 61 | buttonDate->setText( TimeString::longDateString( date ) ); |
63 | 62 | ||
64 | txtTodo->setText( task.description() ); | 63 | txtTodo->setText( task.description() ); |
65 | } | 64 | } |
66 | 65 | ||
@@ -91,69 +90,64 @@ void NewTaskDialog::init() | |||
91 | m1->insertItem( picker ); | 90 | m1->insertItem( picker ); |
92 | buttonDate->setPopup( m1 ); | 91 | buttonDate->setPopup( m1 ); |
93 | comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); | 92 | comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); |
94 | 93 | ||
95 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | 94 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), |
96 | this, SLOT( dateChanged( int, int, int ) ) ); | 95 | this, SLOT( dateChanged( int, int, int ) ) ); |
97 | 96 | ||
98 | buttonDate->setText( TimeString::longDateString( date ) ); | 97 | buttonDate->setText( TimeString::longDateString( date ) ); |
99 | picker->setDate( date.year(), date.month(), date.day() ); | 98 | picker->setDate( date.year(), date.month(), date.day() ); |
100 | } | 99 | } |
101 | 100 | ||
102 | /* | 101 | /* |
103 | * Destroys the object and frees any allocated resources | 102 | * Destroys the object and frees any allocated resources |
104 | */ | 103 | */ |
105 | NewTaskDialog::~NewTaskDialog() | 104 | NewTaskDialog::~NewTaskDialog() |
106 | { | 105 | { |
107 | qWarning("d'tor" ); | ||
108 | // no need to delete child widgets, Qt does it all for us | 106 | // no need to delete child widgets, Qt does it all for us |
109 | } | 107 | } |
110 | void NewTaskDialog::dateChanged( int y, int m, int d ) | 108 | void NewTaskDialog::dateChanged( int y, int m, int d ) |
111 | { | 109 | { |
112 | date = QDate( y, m, d ); | 110 | date = QDate( y, m, d ); |
113 | buttonDate->setText( TimeString::longDateString( date ) ); | 111 | buttonDate->setText( TimeString::longDateString( date ) ); |
114 | } | 112 | } |
115 | 113 | ||
116 | /*! | 114 | /*! |
117 | */ | 115 | */ |
118 | 116 | ||
119 | ToDoEvent NewTaskDialog::todoEntry() | 117 | ToDoEvent NewTaskDialog::todoEntry() |
120 | { | 118 | { |
121 | qWarning("todoEntry()" ); | ||
122 | if( checkDate->isChecked() ){ | 119 | if( checkDate->isChecked() ){ |
123 | todo.setDate( date ); | 120 | todo.setDate( date ); |
124 | todo.setHasDate( true ); | 121 | todo.setHasDate( true ); |
125 | }else{ | 122 | }else{ |
126 | todo.setHasDate( false ); | 123 | todo.setHasDate( false ); |
127 | } | 124 | } |
128 | qWarning("todoEntry::category()" ); | ||
129 | if ( comboCategory->currentCategory() != -1 ) { | 125 | if ( comboCategory->currentCategory() != -1 ) { |
130 | QArray<int> arr = comboCategory->currentCategories(); | 126 | QArray<int> arr = comboCategory->currentCategories(); |
131 | QStringList list; | 127 | QStringList list; |
132 | list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ; | 128 | list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ; |
133 | qWarning("saving category"); | ||
134 | todo.setCategories( list ); | 129 | todo.setCategories( list ); |
135 | } | 130 | } |
136 | todo.setPriority( comboPriority->currentItem() + 1 ); | 131 | todo.setPriority( comboPriority->currentItem() + 1 ); |
137 | todo.setCompleted( checkCompleted->isChecked() ); | 132 | todo.setCompleted( checkCompleted->isChecked() ); |
138 | 133 | ||
139 | todo.setDescription( txtTodo->text() ); | 134 | todo.setDescription( txtTodo->text() ); |
140 | 135 | ||
141 | return todo; | 136 | return todo; |
142 | } | 137 | } |
143 | 138 | ||
144 | 139 | ||
145 | /*! | 140 | /*! |
146 | 141 | ||
147 | */ | 142 | */ |
148 | 143 | ||
149 | void NewTaskDialog::accept() | 144 | void NewTaskDialog::accept() |
150 | { | 145 | { |
151 | qWarning("accept" ); | ||
152 | QString strText = txtTodo->text(); | 146 | QString strText = txtTodo->text(); |
153 | if ( strText.isEmpty() ) { | 147 | if ( strText.isEmpty() ) { |
154 | // hmm... just decline it then, the user obviously didn't care about it | 148 | // hmm... just decline it then, the user obviously didn't care about it |
155 | QDialog::reject(); | 149 | QDialog::reject(); |
156 | return; | 150 | return; |
157 | } | 151 | } |
158 | QDialog::accept(); | 152 | QDialog::accept(); |
159 | } | 153 | } |
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index 401d2c8..96cd860 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -339,56 +339,56 @@ void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) | |||
339 | ToDoEvent TodoTable::currentEntry() const | 339 | ToDoEvent TodoTable::currentEntry() const |
340 | { | 340 | { |
341 | printf ("in currentEntry\n"); | 341 | printf ("in currentEntry\n"); |
342 | 342 | ||
343 | QTableItem *i = item( currentRow(), 0 ); | 343 | QTableItem *i = item( currentRow(), 0 ); |
344 | if ( !i || rowHeight( currentRow() ) <= 0 ) | 344 | if ( !i || rowHeight( currentRow() ) <= 0 ) |
345 | return ToDoEvent(); | 345 | return ToDoEvent(); |
346 | ToDoEvent *todo = todoList[(CheckItem*)i]; | 346 | ToDoEvent *todo = todoList[(CheckItem*)i]; |
347 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); | 347 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); |
348 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); | 348 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); |
349 | return *todo; | 349 | return *todo; |
350 | } | 350 | } |
351 | 351 | ||
352 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) | 352 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) |
353 | { | 353 | { |
354 | int row = currentRow(); | 354 | int row = currentRow(); |
355 | updateJournal( todo, ACTION_REPLACE, row ); | 355 | updateJournal( todo, ACTION_REPLACE); |
356 | 356 | ||
357 | if ( !fromTableItem ) { | 357 | if ( !fromTableItem ) { |
358 | journalFreeReplaceEntry( todo, row ); | 358 | journalFreeReplaceEntry( todo, row ); |
359 | updateVisible(); | 359 | updateVisible(); |
360 | } | 360 | } |
361 | } | 361 | } |
362 | 362 | ||
363 | void TodoTable::removeCurrentEntry() | 363 | void TodoTable::removeCurrentEntry() |
364 | { | 364 | { |
365 | ToDoEvent *oldTodo; | 365 | ToDoEvent *oldTodo; |
366 | int row = currentRow(); | 366 | int row = currentRow(); |
367 | CheckItem *chk; | 367 | CheckItem *chk; |
368 | 368 | ||
369 | chk = static_cast<CheckItem*>(item(row, 0 )); | 369 | chk = static_cast<CheckItem*>(item(row, 0 )); |
370 | if ( !chk ) | 370 | if ( !chk ) |
371 | return; | 371 | return; |
372 | oldTodo = todoList[chk]; | 372 | oldTodo = todoList[chk]; |
373 | todoList.remove( chk ); | 373 | todoList.remove( chk ); |
374 | oldTodo->setCompleted( chk->isChecked() ); | 374 | oldTodo->setCompleted( chk->isChecked() ); |
375 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); | 375 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); |
376 | realignTable( row ); | 376 | realignTable( row ); |
377 | updateVisible(); | 377 | updateVisible(); |
378 | updateJournal( *oldTodo, ACTION_REMOVE, row ); | 378 | updateJournal( *oldTodo, ACTION_REMOVE); |
379 | delete oldTodo; | 379 | delete oldTodo; |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | bool TodoTable::save( const QString &fn ) | 383 | bool TodoTable::save( const QString &fn ) |
384 | { | 384 | { |
385 | QString strNewFile = fn + ".new"; | 385 | QString strNewFile = fn + ".new"; |
386 | QFile::remove( strNewFile ); // just to be sure | 386 | QFile::remove( strNewFile ); // just to be sure |
387 | ToDoDB todoDB( strNewFile ); | 387 | ToDoDB todoDB( strNewFile ); |
388 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 388 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
389 | it != todoList.end(); ++it ) { | 389 | it != todoList.end(); ++it ) { |
390 | if ( !item( it.key()->row(), 0 ) ) | 390 | if ( !item( it.key()->row(), 0 ) ) |
391 | continue; | 391 | continue; |
392 | ToDoEvent *todo = *it; | 392 | ToDoEvent *todo = *it; |
393 | // sync item with table | 393 | // sync item with table |
394 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); | 394 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); |
@@ -398,37 +398,37 @@ bool TodoTable::save( const QString &fn ) | |||
398 | if(!todoDB.save() ){ | 398 | if(!todoDB.save() ){ |
399 | QFile::remove( strNewFile ); | 399 | QFile::remove( strNewFile ); |
400 | return false; | 400 | return false; |
401 | }; | 401 | }; |
402 | // now do the rename | 402 | // now do the rename |
403 | if ( ::rename( strNewFile, fn ) < 0 ) | 403 | if ( ::rename( strNewFile, fn ) < 0 ) |
404 | qWarning( "problem renaming file %s to %s errno %d", | 404 | qWarning( "problem renaming file %s to %s errno %d", |
405 | strNewFile.latin1(), fn.latin1(), errno ); | 405 | strNewFile.latin1(), fn.latin1(), errno ); |
406 | 406 | ||
407 | // remove the journal | 407 | // remove the journal |
408 | QFile::remove( journalFileName() ); | 408 | QFile::remove( journalFileName() ); |
409 | return true; | 409 | return true; |
410 | } | 410 | } |
411 | 411 | ||
412 | void TodoTable::load( const QString &fn ) | 412 | void TodoTable::load( const QString &fn ) |
413 | { | 413 | { |
414 | loadFile( fn, false ); | 414 | if ( QFile::exists(journalFileName()) ) { |
415 | if ( QFile::exists(journalFileName()) ) { | 415 | applyJournal(); |
416 | applyJournal( ); | 416 | QFile::remove(journalFileName() ); |
417 | save( fn ); | 417 | } |
418 | } | 418 | loadFile( fn ); |
419 | // QTable::sortColumn(2,TRUE,TRUE); | 419 | // QTable::sortColumn(2,TRUE,TRUE); |
420 | // QTable::sortColumn(1,TRUE,TRUE); | 420 | // QTable::sortColumn(1,TRUE,TRUE); |
421 | QTable::sortColumn(0,TRUE,TRUE); | 421 | QTable::sortColumn(0,TRUE,TRUE); |
422 | setCurrentCell( 0, 2 ); | 422 | setCurrentCell( 0, 2 ); |
423 | setSorting(true ); | 423 | setSorting(true ); |
424 | } | 424 | } |
425 | void TodoTable::updateVisible() | 425 | void TodoTable::updateVisible() |
426 | { | 426 | { |
427 | if ( !isUpdatesEnabled() ) | 427 | if ( !isUpdatesEnabled() ) |
428 | return; | 428 | return; |
429 | 429 | ||
430 | if (showDeadl){ | 430 | if (showDeadl){ |
431 | showColumn (3); | 431 | showColumn (3); |
432 | adjustColumn(3); | 432 | adjustColumn(3); |
433 | }else{ | 433 | }else{ |
434 | hideColumn (3); | 434 | hideColumn (3); |
@@ -488,34 +488,34 @@ void TodoTable::setPaintingEnabled( bool e ) | |||
488 | { | 488 | { |
489 | if ( e != enablePainting ) { | 489 | if ( e != enablePainting ) { |
490 | if ( !enablePainting ) { | 490 | if ( !enablePainting ) { |
491 | enablePainting = true; | 491 | enablePainting = true; |
492 | rowHeightChanged( 0 ); | 492 | rowHeightChanged( 0 ); |
493 | viewport()->update(); | 493 | viewport()->update(); |
494 | } else { | 494 | } else { |
495 | enablePainting = false; | 495 | enablePainting = false; |
496 | } | 496 | } |
497 | } | 497 | } |
498 | } | 498 | } |
499 | 499 | ||
500 | void TodoTable::clear() | 500 | void TodoTable::clear() |
501 | { | 501 | { |
502 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 502 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
503 | it != todoList.end(); ++it ) { | 503 | it != todoList.end(); ++it ) { |
504 | ToDoEvent *todo = *it; | 504 | ToDoEvent *todo = it.data(); |
505 | updateJournal( todo, ACTION_REMOVE, 0 ); | 505 | updateJournal( *todo, ACTION_REMOVE ); |
506 | delete todo; | 506 | delete todo; |
507 | } | 507 | } |
508 | todoList.clear(); | 508 | todoList.clear(); |
509 | for ( int r = 0; r < numRows(); ++r ) { | 509 | for ( int r = 0; r < numRows(); ++r ) { |
510 | for ( int c = 0; c < numCols(); ++c ) { | 510 | for ( int c = 0; c < numCols(); ++c ) { |
511 | if ( cellWidget( r, c ) ) | 511 | if ( cellWidget( r, c ) ) |
512 | clearCellWidget( r, c ); | 512 | clearCellWidget( r, c ); |
513 | clearCell( r, c ); | 513 | clearCell( r, c ); |
514 | } | 514 | } |
515 | } | 515 | } |
516 | setNumRows( 0 ); | 516 | setNumRows( 0 ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) | 519 | void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) |
520 | { | 520 | { |
521 | // The default for wholeRows is false, however | 521 | // The default for wholeRows is false, however |
@@ -524,33 +524,33 @@ void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) | |||
524 | // the values have a logical order. | 524 | // the values have a logical order. |
525 | QTable::sortColumn( col, ascending, TRUE ); | 525 | QTable::sortColumn( col, ascending, TRUE ); |
526 | updateVisible(); | 526 | updateVisible(); |
527 | } | 527 | } |
528 | 528 | ||
529 | void TodoTable::slotCheckPriority(int row, int col ) | 529 | void TodoTable::slotCheckPriority(int row, int col ) |
530 | { | 530 | { |
531 | // kludgey work around to make forward along the updated priority... | 531 | // kludgey work around to make forward along the updated priority... |
532 | if ( col == 1 ) { | 532 | if ( col == 1 ) { |
533 | // let everyone know!! | 533 | // let everyone know!! |
534 | ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); | 534 | ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); |
535 | emit signalPriorityChanged( i->text().toInt() ); | 535 | emit signalPriorityChanged( i->text().toInt() ); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | 538 | ||
539 | 539 | ||
540 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action, int row ) | 540 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) |
541 | { | 541 | { |
542 | QFile f( journalFileName() ); | 542 | QFile f( journalFileName() ); |
543 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 543 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
544 | return; | 544 | return; |
545 | QString buf; | 545 | QString buf; |
546 | QCString str; | 546 | QCString str; |
547 | buf = "<Task"; | 547 | buf = "<Task"; |
548 | // todo.save( buf ); | 548 | // todo.save( buf ); |
549 | buf += " Action=\"" + QString::number( int(action) ) + "\""; | 549 | buf += " Action=\"" + QString::number( int(action) ) + "\""; |
550 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id | 550 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id |
551 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; | 551 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; |
552 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; | 552 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; |
553 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; | 553 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; |
554 | QArray<int> arrat = todo.categories(); | 554 | QArray<int> arrat = todo.categories(); |
555 | QString attr; | 555 | QString attr; |
556 | for(uint i=0; i < arrat.count(); i++ ){ | 556 | for(uint i=0; i < arrat.count(); i++ ){ |
@@ -564,33 +564,33 @@ void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action, int | |||
564 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; | 564 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; |
565 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; | 565 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; |
566 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; | 566 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; |
567 | } | 567 | } |
568 | buf += "/>\n"; | 568 | buf += "/>\n"; |
569 | str = buf.utf8(); | 569 | str = buf.utf8(); |
570 | f.writeBlock( str.data(), str.length() ); | 570 | f.writeBlock( str.data(), str.length() ); |
571 | f.close(); | 571 | f.close(); |
572 | } | 572 | } |
573 | 573 | ||
574 | void TodoTable::rowHeightChanged( int row ) | 574 | void TodoTable::rowHeightChanged( int row ) |
575 | { | 575 | { |
576 | if ( enablePainting ) | 576 | if ( enablePainting ) |
577 | QTable::rowHeightChanged( row ); | 577 | QTable::rowHeightChanged( row ); |
578 | } | 578 | } |
579 | 579 | ||
580 | void TodoTable::loadFile( const QString &strFile, bool fromJournal ) | 580 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) |
581 | { | 581 | { |
582 | 582 | ||
583 | QList<ToDoEvent> list; | 583 | QList<ToDoEvent> list; |
584 | ToDoDB todoDB; | 584 | ToDoDB todoDB; |
585 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); | 585 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); |
586 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ | 586 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ |
587 | list.append( new ToDoEvent( (*it) ) ); | 587 | list.append( new ToDoEvent( (*it) ) ); |
588 | } | 588 | } |
589 | vaList.clear(); | 589 | vaList.clear(); |
590 | // qDebug("parsing done=%d", t.elapsed() ); | 590 | // qDebug("parsing done=%d", t.elapsed() ); |
591 | if ( list.count() > 0 ) { | 591 | if ( list.count() > 0 ) { |
592 | internalAddEntries( list ); | 592 | internalAddEntries( list ); |
593 | list.clear(); | 593 | list.clear(); |
594 | } | 594 | } |
595 | // qDebug("loading done: t=%d", t.elapsed() ); | 595 | // qDebug("loading done: t=%d", t.elapsed() ); |
596 | } | 596 | } |
@@ -741,62 +741,83 @@ void TodoTable::applyJournal() | |||
741 | // we need to hack | 741 | // we need to hack |
742 | QFile file( journalFileName() ); | 742 | QFile file( journalFileName() ); |
743 | if( file.open(IO_ReadOnly ) ) { | 743 | if( file.open(IO_ReadOnly ) ) { |
744 | QByteArray ar = file.readAll(); | 744 | QByteArray ar = file.readAll(); |
745 | file.close(); | 745 | file.close(); |
746 | QFile file2( journalFileName() + "_new" ); | 746 | QFile file2( journalFileName() + "_new" ); |
747 | if( file2.open(IO_WriteOnly ) ){ | 747 | if( file2.open(IO_WriteOnly ) ){ |
748 | QTextStream str(&file2 ); | 748 | QTextStream str(&file2 ); |
749 | str << QString::fromLatin1("<Tasks>") << endl; | 749 | str << QString::fromLatin1("<Tasks>") << endl; |
750 | str << ar.data(); | 750 | str << ar.data(); |
751 | str << QString::fromLatin1("</Tasks>") << endl; | 751 | str << QString::fromLatin1("</Tasks>") << endl; |
752 | file2.close(); | 752 | file2.close(); |
753 | } | 753 | } |
754 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); | 754 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); |
755 | XMLElement *el = root->firstChild(); | 755 | XMLElement *el = root->firstChild(); |
756 | el = el->firstChild(); | 756 | el = el->firstChild(); |
757 | ToDoDB tododb; // allready loaded ;) | ||
758 | bool ok; | ||
759 | int action; | ||
760 | QString dummy; | ||
757 | while( el ){ | 761 | while( el ){ |
758 | qWarning("journal: %s %s", el->attribute("Uid" ).latin1(), el->tagName().latin1() ); | 762 | dummy = el->attribute("Action" ); |
759 | doApply( el ); | 763 | action = dummy.toInt(&ok ); |
764 | ToDoEvent ev = xmlToEvent( el ); | ||
765 | if(ok ){ | ||
766 | switch( action){ | ||
767 | case ACTION_ADD: | ||
768 | tododb.addEvent(ev ); | ||
769 | break; | ||
770 | case ACTION_REMOVE: | ||
771 | tododb.removeEvent( ev ); | ||
772 | break; | ||
773 | case ACTION_REPLACE: | ||
774 | tododb.replaceEvent( ev ); | ||
775 | break; | ||
776 | } | ||
777 | } | ||
760 | el = el->nextChild(); | 778 | el = el->nextChild(); |
761 | } | 779 | } |
762 | QFile::remove(journalFileName()+ "_new" ); | 780 | QFile::remove(journalFileName()+ "_new" ); |
781 | tododb.save(); | ||
763 | } | 782 | } |
764 | } | 783 | } |
765 | // check Action and decide | 784 | // check Action and decide |
785 | /* | ||
766 | void TodoTable::doApply(XMLElement *el ) | 786 | void TodoTable::doApply(XMLElement *el ) |
767 | { | 787 | { |
768 | QString dummy; | 788 | QString dummy; |
769 | bool ok; | 789 | bool ok; |
770 | int action; | 790 | int action; |
771 | dummy = el->attribute("Action" ); | 791 | dummy = el->attribute("Action" ); |
772 | action = dummy.toInt(&ok ); | 792 | action = dummy.toInt(&ok ); |
773 | ToDoEvent ev = xmlToEvent( el ); | 793 | ToDoEvent ev = xmlToEvent( el ); |
774 | if( ok ){ | 794 | if( ok ){ |
775 | switch( action ){ | 795 | switch( action ){ |
776 | case ACTION_ADD: | 796 | case ACTION_ADD: |
777 | addEntry( ev ); | 797 | addEntry( ev ); |
778 | break; | 798 | break; |
779 | case ACTION_REMOVE:{ // find an entry with the same uid and remove it then | 799 | case ACTION_REMOVE:{ // find an entry with the same uid and remove it then |
780 | break; | 800 | break; |
781 | } | 801 | } |
782 | case ACTION_REPLACE: | 802 | case ACTION_REPLACE: |
783 | break; | 803 | break; |
784 | } | 804 | } |
785 | } | 805 | } |
786 | } | 806 | } |
807 | */ | ||
787 | namespace { | 808 | namespace { |
788 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ) | 809 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ) |
789 | { | 810 | { |
790 | bool returnMe; | 811 | bool returnMe; |
791 | QArray<int> cats; | 812 | QArray<int> cats; |
792 | cats = task.categories(); | 813 | cats = task.categories(); |
793 | 814 | ||
794 | returnMe = false; | 815 | returnMe = false; |
795 | if ( (category == -1 && cats.count() == 0) || category == -2 ) | 816 | if ( (category == -1 && cats.count() == 0) || category == -2 ) |
796 | returnMe = task.match( r ); | 817 | returnMe = task.match( r ); |
797 | else { | 818 | else { |
798 | int i; | 819 | int i; |
799 | for ( i = 0; i < int(cats.count()); i++ ) { | 820 | for ( i = 0; i < int(cats.count()); i++ ) { |
800 | if ( cats[i] == category ) { | 821 | if ( cats[i] == category ) { |
801 | returnMe = task.match( r ); | 822 | returnMe = task.match( r ); |
802 | break; | 823 | break; |
@@ -850,33 +871,32 @@ static ToDoEvent xmlToEvent( XMLElement *element ) | |||
850 | dummy = element->attribute("Priority" ); | 871 | dummy = element->attribute("Priority" ); |
851 | dumInt = dummy.toInt(&ok ); | 872 | dumInt = dummy.toInt(&ok ); |
852 | if(!ok ) dumInt = ToDoEvent::NORMAL; | 873 | if(!ok ) dumInt = ToDoEvent::NORMAL; |
853 | event.setPriority( dumInt ); | 874 | event.setPriority( dumInt ); |
854 | //description | 875 | //description |
855 | dummy = element->attribute("Description" ); | 876 | dummy = element->attribute("Description" ); |
856 | event.setDescription( dummy ); | 877 | event.setDescription( dummy ); |
857 | // category | 878 | // category |
858 | dummy = element->attribute("Categories" ); | 879 | dummy = element->attribute("Categories" ); |
859 | QStringList ids = QStringList::split(";", dummy ); | 880 | QStringList ids = QStringList::split(";", dummy ); |
860 | event.setCategories( ids ); | 881 | event.setCategories( ids ); |
861 | 882 | ||
862 | //uid | 883 | //uid |
863 | dummy = element->attribute("Uid" ); | 884 | dummy = element->attribute("Uid" ); |
864 | dumInt = dummy.toInt(&ok ); | 885 | dumInt = dummy.toInt(&ok ); |
865 | if(ok ) event.setUid( dumInt ); | 886 | if(ok ) event.setUid( dumInt ); |
866 | |||
867 | return event; | 887 | return event; |
868 | } | 888 | } |
869 | 889 | ||
870 | } | 890 | } |
871 | // int TodoTable::rowHeight( int ) const | 891 | // int TodoTable::rowHeight( int ) const |
872 | // { | 892 | // { |
873 | // return 18; | 893 | // return 18; |
874 | // } | 894 | // } |
875 | 895 | ||
876 | // int TodoTable::rowPos( int row ) const | 896 | // int TodoTable::rowPos( int row ) const |
877 | // { | 897 | // { |
878 | // return 18*row; | 898 | // return 18*row; |
879 | // } | 899 | // } |
880 | 900 | ||
881 | // int TodoTable::rowAt( int pos ) const | 901 | // int TodoTable::rowAt( int pos ) const |
882 | // { | 902 | // { |
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h index 6917e04..6e371e8 100644 --- a/core/pim/todo/todotable.h +++ b/core/pim/todo/todotable.h | |||
@@ -138,39 +138,38 @@ public: | |||
138 | signals: | 138 | signals: |
139 | void signalEdit(); | 139 | void signalEdit(); |
140 | void signalDoneChanged( bool b ); | 140 | void signalDoneChanged( bool b ); |
141 | void signalPriorityChanged( int i ); | 141 | void signalPriorityChanged( int i ); |
142 | void signalShowMenu( const QPoint & ); | 142 | void signalShowMenu( const QPoint & ); |
143 | void signalNotFound(); | 143 | void signalNotFound(); |
144 | void signalWrapAround(); | 144 | void signalWrapAround(); |
145 | 145 | ||
146 | protected: | 146 | protected: |
147 | void keyPressEvent( QKeyEvent *e ); | 147 | void keyPressEvent( QKeyEvent *e ); |
148 | 148 | ||
149 | private: | 149 | private: |
150 | void updateVisible(); | 150 | void updateVisible(); |
151 | void viewportPaintEvent( QPaintEvent * ); | 151 | void viewportPaintEvent( QPaintEvent * ); |
152 | void internalAddEntries( QList<ToDoEvent> &list); | 152 | void internalAddEntries( QList<ToDoEvent> &list); |
153 | inline void insertIntoTable( ToDoEvent *todo, int row ); | 153 | inline void insertIntoTable( ToDoEvent *todo, int row ); |
154 | void updateJournal( const ToDoEvent &todo, journal_action action, int row = -1); | 154 | void updateJournal( const ToDoEvent &todo, journal_action action); |
155 | void mergeJournal(); | 155 | void mergeJournal(); |
156 | void journalFreeReplaceEntry( const ToDoEvent &todo, int row ); | 156 | void journalFreeReplaceEntry( const ToDoEvent &todo, int row ); |
157 | void journalFreeRemoveEntry( int row ); | 157 | void journalFreeRemoveEntry( int row ); |
158 | inline void realignTable( int row ); | 158 | inline void realignTable( int row ); |
159 | void loadFile( const QString &strFile, bool fromJournal = false ); | 159 | void loadFile( const QString &strFile); |
160 | void doApply(XMLElement *el ); | ||
161 | 160 | ||
162 | private slots: | 161 | private slots: |
163 | void slotClicked( int row, int col, int button, const QPoint &pos ); | 162 | void slotClicked( int row, int col, int button, const QPoint &pos ); |
164 | void slotPressed( int row, int col, int button, const QPoint &pos ); | 163 | void slotPressed( int row, int col, int button, const QPoint &pos ); |
165 | void slotCheckPriority(int row, int col ); | 164 | void slotCheckPriority(int row, int col ); |
166 | void slotCurrentChanged(int row, int col ); | 165 | void slotCurrentChanged(int row, int col ); |
167 | void slotDoFind( const QString &findString, bool caseSensetive, | 166 | void slotDoFind( const QString &findString, bool caseSensetive, |
168 | bool backwards, int category ); | 167 | bool backwards, int category ); |
169 | void slotShowMenu(); | 168 | void slotShowMenu(); |
170 | void rowHeightChanged( int row ); | 169 | void rowHeightChanged( int row ); |
171 | 170 | ||
172 | private: | 171 | private: |
173 | friend class TodoWindow; | 172 | friend class TodoWindow; |
174 | 173 | ||
175 | QMap<CheckItem*, ToDoEvent *> todoList; | 174 | QMap<CheckItem*, ToDoEvent *> todoList; |
176 | QStringList categoryList; | 175 | QStringList categoryList; |