summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show 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.cpp42
-rw-r--r--core/pim/todo/todotable.h5
5 files changed, 35 insertions, 22 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 @@
--fix the journal
+-fix the journal (wip )
-fix day wrapping update all DueDateItems
-when checking the C. box update the deadline
-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
@@ -274,7 +274,7 @@ void TodoWindow::slotNew()
e.showMaximized();
#endif
int ret = e.exec();
- qWarning("finished" );
+// qWarning("finished" );
if ( ret == QDialog::Accepted ) {
table->setPaintingEnabled( false );
todo = e.todoEntry();
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
@@ -47,7 +47,6 @@ NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent,
: NewTaskDialogBase( parent, name, modal, fl ),
todo( task )
{
- qWarning("setting category" );
todo.setCategories( task.allCategories() );
if ( todo.hasDate() )
date = todo.date();
@@ -104,7 +103,6 @@ void NewTaskDialog::init()
*/
NewTaskDialog::~NewTaskDialog()
{
- qWarning("d'tor" );
// no need to delete child widgets, Qt does it all for us
}
void NewTaskDialog::dateChanged( int y, int m, int d )
@@ -118,19 +116,16 @@ void NewTaskDialog::dateChanged( int y, int m, int d )
ToDoEvent NewTaskDialog::todoEntry()
{
- qWarning("todoEntry()" );
if( checkDate->isChecked() ){
todo.setDate( date );
todo.setHasDate( true );
}else{
todo.setHasDate( false );
}
- qWarning("todoEntry::category()" );
if ( comboCategory->currentCategory() != -1 ) {
QArray<int> arr = comboCategory->currentCategories();
QStringList list;
list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ;
- qWarning("saving category");
todo.setCategories( list );
}
todo.setPriority( comboPriority->currentItem() + 1 );
@@ -148,7 +143,6 @@ ToDoEvent NewTaskDialog::todoEntry()
void NewTaskDialog::accept()
{
- qWarning("accept" );
QString strText = txtTodo->text();
if ( strText.isEmpty() ) {
// hmm... just decline it then, the user obviously didn't care about it
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 );
+ 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;
}
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
@@ -151,13 +151,12 @@ private:
void viewportPaintEvent( QPaintEvent * );
void internalAddEntries( QList<ToDoEvent> &list);
inline void insertIntoTable( ToDoEvent *todo, int row );
- void updateJournal( const ToDoEvent &todo, journal_action action, int row = -1);
+ void updateJournal( const ToDoEvent &todo, journal_action action);
void mergeJournal();
void journalFreeReplaceEntry( const ToDoEvent &todo, int row );
void journalFreeRemoveEntry( int row );
inline void realignTable( int row );
- void loadFile( const QString &strFile, bool fromJournal = false );
- void doApply(XMLElement *el );
+ void loadFile( const QString &strFile);
private slots:
void slotClicked( int row, int col, int button, const QPoint &pos );