summaryrefslogtreecommitdiff
authorzecke <zecke>2002-04-15 20:55:49 (UTC)
committer zecke <zecke>2002-04-15 20:55:49 (UTC)
commit943f0de13f6b017e67d0289c7273ddbf496a2cff (patch) (unidiff)
treeed28fa2c3632ce672b31edff10ecf08356d35f64
parente010d922ac415558e5efd35e69e39e45908b5501 (diff)
downloadopie-943f0de13f6b017e67d0289c7273ddbf496a2cff.zip
opie-943f0de13f6b017e67d0289c7273ddbf496a2cff.tar.gz
opie-943f0de13f6b017e67d0289c7273ddbf496a2cff.tar.bz2
journal is in place again
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/TODO2
-rw-r--r--core/pim/todo/mainwindow.cpp2
-rw-r--r--core/pim/todo/todoentryimpl.cpp6
-rw-r--r--core/pim/todo/todotable.cpp48
-rw-r--r--core/pim/todo/todotable.h5
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
@@ -273,9 +273,9 @@ void TodoWindow::slotNew()
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();
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
@@ -46,9 +46,8 @@ 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
@@ -103,9 +102,8 @@ void NewTaskDialog::init()
103 * Destroys the object and frees any allocated resources 102 * Destroys the object and frees any allocated resources
104 */ 103 */
105NewTaskDialog::~NewTaskDialog() 104NewTaskDialog::~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}
110void NewTaskDialog::dateChanged( int y, int m, int d ) 108void NewTaskDialog::dateChanged( int y, int m, int d )
111{ 109{
@@ -117,21 +115,18 @@ void NewTaskDialog::dateChanged( int y, int m, int d )
117*/ 115*/
118 116
119ToDoEvent NewTaskDialog::todoEntry() 117ToDoEvent 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() );
@@ -147,9 +142,8 @@ ToDoEvent NewTaskDialog::todoEntry()
147*/ 142*/
148 143
149void NewTaskDialog::accept() 144void 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();
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
@@ -351,9 +351,9 @@ ToDoEvent TodoTable::currentEntry() const
351 351
352void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) 352void 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();
@@ -374,9 +374,9 @@ void TodoTable::removeCurrentEntry()
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
@@ -410,13 +410,13 @@ bool TodoTable::save( const QString &fn )
410} 410}
411 411
412void TodoTable::load( const QString &fn ) 412void 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 );
@@ -500,10 +500,10 @@ void TodoTable::setPaintingEnabled( bool e )
500void TodoTable::clear() 500void 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 ) {
@@ -536,9 +536,9 @@ void TodoTable::slotCheckPriority(int row, int col )
536 } 536 }
537} 537}
538 538
539 539
540void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action, int row ) 540void 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;
@@ -576,9 +576,9 @@ void TodoTable::rowHeightChanged( int row )
576 if ( enablePainting ) 576 if ( enablePainting )
577 QTable::rowHeightChanged( row ); 577 QTable::rowHeightChanged( row );
578} 578}
579 579
580void TodoTable::loadFile( const QString &strFile, bool fromJournal ) 580void 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;
@@ -753,17 +753,37 @@ void TodoTable::applyJournal()
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/*
766void TodoTable::doApply(XMLElement *el ) 786void TodoTable::doApply(XMLElement *el )
767{ 787{
768 QString dummy; 788 QString dummy;
769 bool ok; 789 bool ok;
@@ -783,8 +803,9 @@ void TodoTable::doApply(XMLElement *el )
783 break; 803 break;
784 } 804 }
785 } 805 }
786} 806}
807*/
787namespace { 808namespace {
788static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ) 809static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category )
789{ 810{
790 bool returnMe; 811 bool returnMe;
@@ -862,9 +883,8 @@ static ToDoEvent xmlToEvent( XMLElement *element )
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}
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
@@ -150,15 +150,14 @@ 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
162private slots: 161private 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 );