-rw-r--r-- | core/pim/todo/mainwindow.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 6709811..f3afa5f 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -19,25 +19,28 @@ **********************************************************************/ #define QTOPIA_INTERNAL_FD #include "mainwindow.h" #include "todoentryimpl.h" #include "todotable.h" +#include <opie/tododb.h> +#include <opie/todovcalresource.h> + #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/finddialog.h> #include <qpe/global.h> #include <qpe/ir.h> #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> -#include <qpe/task.h> +//#include <qpe/task.h> #include <qpe/qpetoolbar.h> #include <qaction.h> #include <qarray.h> #include <qdatastream.h> #include <qdatetime.h> #include <qfile.h> #include <qmessagebox.h> @@ -210,27 +213,27 @@ void TodoWindow::slotNew() int id; id = -1; QArray<int> ids; ids = table->currentEntry().categories(); if ( ids.count() ) id = ids[0]; NewTaskDialog e( id, this, 0, TRUE ); - Task todo; + ToDoEvent todo; #if defined(Q_WS_QWS) || defined(_WS_QWS_) e.showMaximized(); #endif int ret = e.exec(); - + qWarning("finished" ); if ( ret == QDialog::Accepted ) { table->setPaintingEnabled( false ); todo = e.todoEntry(); - todo.assignUid(); + //todo.assignUid(); table->addEntry( todo ); table->setPaintingEnabled( true ); findAction->setEnabled( TRUE ); } // I'm afraid we must call this every time now, otherwise // spend expensive time comparing all these strings... populateCategories(); } @@ -270,17 +273,17 @@ void TodoWindow::slotDelete() void TodoWindow::slotEdit() { if(syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } - Task todo = table->currentEntry(); + ToDoEvent todo = table->currentEntry(); NewTaskDialog e( todo, this, 0, TRUE ); e.setCaption( tr( "Edit Task" ) ); #if defined(Q_WS_QWS) || defined(_WS_QWS_) e.showMaximized(); #endif int ret = e.exec(); @@ -344,18 +347,17 @@ void TodoWindow::setCategory( int c ) void TodoWindow::populateCategories() { catMenu->clear(); completedAction->addTo( catMenu ); completedAction->setOn( table->showCompleted() ); - int id, - rememberId; + int id, rememberId; id = 1; catMenu->insertItem( tr( "All Categories" ), id++ ); // catMenu->insertSeparator(); QStringList categories = table->categories(); categories.append( tr( "Unfiled" ) ); for ( QStringList::Iterator it = categories.begin(); it != categories.end(); ++it ) { catMenu->insertItem( *it, id ); @@ -438,30 +440,33 @@ void TodoWindow::slotFind() table->clearFindRow(); } void TodoWindow::setDocument( const QString &filename ) { if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; - QValueList<Task> tl = Task::readVCalendar( filename ); - for( QValueList<Task>::Iterator it = tl.begin(); it != tl.end(); ++it ) { + ToDoDB todoDB(filename, new ToDoVCalResource() ); + QValueList<ToDoEvent> tl = todoDB.rawToDos(); + for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) { table->addEntry( *it ); } } static const char * beamfile = "/tmp/obex/todo.vcs"; void TodoWindow::slotBeam() { unlink( beamfile ); // delete if exists - Task c = table->currentEntry(); + ToDoEvent c = table->currentEntry(); mkdir("/tmp/obex/", 0755); - Task::writeVCalendar( beamfile, c ); + ToDoDB todoDB( beamfile, new ToDoVCalResource() ); + todoDB.addEvent( c ); + todoDB.save(); Ir *ir = new Ir( this ); connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); QString description = c.description(); ir->send( beamfile, description, "text/x-vCalendar" ); } void TodoWindow::beamDone( Ir *ir ) { |