summaryrefslogtreecommitdiff
path: root/core/pim/todo/todotable.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/todo/todotable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/todotable.cpp48
1 files changed, 34 insertions, 14 deletions
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
@@ -354,3 +354,3 @@ void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem )
int row = currentRow();
- updateJournal( todo, ACTION_REPLACE, row );
+ updateJournal( todo, ACTION_REPLACE);
@@ -377,3 +377,3 @@ void TodoTable::removeCurrentEntry()
updateVisible();
- updateJournal( *oldTodo, ACTION_REMOVE, row );
+ updateJournal( *oldTodo, ACTION_REMOVE);
delete oldTodo;
@@ -413,7 +413,7 @@ void TodoTable::load( const QString &fn )
{
- loadFile( fn, false );
- if ( QFile::exists(journalFileName()) ) {
- applyJournal( );
- save( fn );
- }
+ if ( QFile::exists(journalFileName()) ) {
+ applyJournal();
+ QFile::remove(journalFileName() );
+ }
+ loadFile( fn );
// QTable::sortColumn(2,TRUE,TRUE);
@@ -503,4 +503,4 @@ void TodoTable::clear()
it != todoList.end(); ++it ) {
- ToDoEvent *todo = *it;
- updateJournal( todo, ACTION_REMOVE, 0 );
+ ToDoEvent *todo = it.data();
+ updateJournal( *todo, ACTION_REMOVE );
delete todo;
@@ -539,3 +539,3 @@ void TodoTable::slotCheckPriority(int row, int col )
-void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action, int row )
+void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action )
{
@@ -579,3 +579,3 @@ void TodoTable::rowHeightChanged( int row )
-void TodoTable::loadFile( const QString &strFile, bool fromJournal )
+void TodoTable::loadFile( const QString &/*we use the standard*/ )
{
@@ -756,5 +756,23 @@ void TodoTable::applyJournal()
el = el->firstChild();
+ ToDoDB tododb; // allready loaded ;)
+ bool ok;
+ int action;
+ QString dummy;
while( el ){
- qWarning("journal: %s %s", el->attribute("Uid" ).latin1(), el->tagName().latin1() );
- doApply( el );
+ dummy = el->attribute("Action" );
+ action = dummy.toInt(&ok );
+ ToDoEvent ev = xmlToEvent( el );
+ if(ok ){
+ switch( action){
+ case ACTION_ADD:
+ tododb.addEvent(ev );
+ break;
+ case ACTION_REMOVE:
+ tododb.removeEvent( ev );
+ break;
+ case ACTION_REPLACE:
+ tododb.replaceEvent( ev );
+ break;
+ }
+ }
el = el->nextChild();
@@ -762,2 +780,3 @@ void TodoTable::applyJournal()
QFile::remove(journalFileName()+ "_new" );
+ tododb.save();
}
@@ -765,2 +784,3 @@ void TodoTable::applyJournal()
// check Action and decide
+/*
void TodoTable::doApply(XMLElement *el )
@@ -786,2 +806,3 @@ void TodoTable::doApply(XMLElement *el )
}
+*/
namespace {
@@ -865,3 +886,2 @@ static ToDoEvent xmlToEvent( XMLElement *element )
if(ok ) event.setUid( dumInt );
-
return event;