summaryrefslogtreecommitdiff
path: root/core/pim/todo/todotable.cpp
authorzecke <zecke>2002-04-15 20:55:49 (UTC)
committer zecke <zecke>2002-04-15 20:55:49 (UTC)
commit943f0de13f6b017e67d0289c7273ddbf496a2cff (patch) (side-by-side diff)
treeed28fa2c3632ce672b31edff10ecf08356d35f64 /core/pim/todo/todotable.cpp
parente010d922ac415558e5efd35e69e39e45908b5501 (diff)
downloadopie-943f0de13f6b017e67d0289c7273ddbf496a2cff.zip
opie-943f0de13f6b017e67d0289c7273ddbf496a2cff.tar.gz
opie-943f0de13f6b017e67d0289c7273ddbf496a2cff.tar.bz2
journal is in place again
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
@@ -352,7 +352,7 @@ ToDoEvent TodoTable::currentEntry() const
void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem )
{
int row = currentRow();
- updateJournal( todo, ACTION_REPLACE, row );
+ updateJournal( todo, ACTION_REPLACE);
if ( !fromTableItem ) {
journalFreeReplaceEntry( todo, row );
@@ -375,7 +375,7 @@ void TodoTable::removeCurrentEntry()
oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() );
realignTable( row );
updateVisible();
- updateJournal( *oldTodo, ACTION_REMOVE, row );
+ updateJournal( *oldTodo, ACTION_REMOVE);
delete oldTodo;
}
@@ -411,11 +411,11 @@ 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);
QTable::sortColumn(0,TRUE,TRUE);
@@ -501,8 +501,8 @@ 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;
}
todoList.clear();
@@ -537,7 +537,7 @@ 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() );
if ( !f.open(IO_WriteOnly|IO_Append) )
@@ -577,7 +577,7 @@ void TodoTable::rowHeightChanged( int row )
QTable::rowHeightChanged( row );
}
-void TodoTable::loadFile( const QString &strFile, bool fromJournal )
+void TodoTable::loadFile( const QString &/*we use the standard*/ )
{
QList<ToDoEvent> list;
@@ -754,15 +754,35 @@ void TodoTable::applyJournal()
XMLElement *root = XMLElement::load(journalFileName()+ "_new");
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 )
{
QString dummy;
@@ -784,6 +804,7 @@ void TodoTable::doApply(XMLElement *el )
}
}
}
+*/
namespace {
static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category )
{
@@ -863,7 +884,6 @@ static ToDoEvent xmlToEvent( XMLElement *element )
dummy = element->attribute("Uid" );
dumInt = dummy.toInt(&ok );
if(ok ) event.setUid( dumInt );
-
return event;
}