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
@@ -353,5 +353,5 @@ void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem )
{
int row = currentRow();
- updateJournal( todo, ACTION_REPLACE, row );
+ updateJournal( todo, ACTION_REPLACE);
if ( !fromTableItem ) {
@@ -376,5 +376,5 @@ void TodoTable::removeCurrentEntry()
realignTable( row );
updateVisible();
- updateJournal( *oldTodo, ACTION_REMOVE, row );
+ updateJournal( *oldTodo, ACTION_REMOVE);
delete oldTodo;
}
@@ -412,9 +412,9 @@ bool TodoTable::save( const QString &fn )
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);
// QTable::sortColumn(1,TRUE,TRUE);
@@ -502,6 +502,6 @@ void TodoTable::clear()
for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin();
it != todoList.end(); ++it ) {
- ToDoEvent *todo = *it;
- updateJournal( todo, ACTION_REMOVE, 0 );
+ ToDoEvent *todo = it.data();
+ updateJournal( *todo, ACTION_REMOVE );
delete todo;
}
@@ -538,5 +538,5 @@ 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 )
{
QFile f( journalFileName() );
@@ -578,5 +578,5 @@ void TodoTable::rowHeightChanged( int row )
}
-void TodoTable::loadFile( const QString &strFile, bool fromJournal )
+void TodoTable::loadFile( const QString &/*we use the standard*/ )
{
@@ -755,13 +755,33 @@ void TodoTable::applyJournal()
XMLElement *el = root->firstChild();
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();
}
QFile::remove(journalFileName()+ "_new" );
+ tododb.save();
}
}
// check Action and decide
+/*
void TodoTable::doApply(XMLElement *el )
{
@@ -785,4 +805,5 @@ void TodoTable::doApply(XMLElement *el )
}
}
+*/
namespace {
static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category )
@@ -864,5 +885,4 @@ static ToDoEvent xmlToEvent( XMLElement *element )
dumInt = dummy.toInt(&ok );
if(ok ) event.setUid( dumInt );
-
return event;
}