From 0762b201f248b9eaf3a08601b04484bec9a6d9a1 Mon Sep 17 00:00:00 2001 From: zecke Date: Sun, 13 Oct 2002 19:09:09 +0000 Subject: Implement beaming and adding of todos. Use the vCal resource for that --- diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index c9c43d4..2994915 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -26,6 +26,8 @@ */ +#include + #include #include #include @@ -34,11 +36,13 @@ #include #include +#include #include #include #include #include +#include #include "todotemplatemanager.h" #include "templateeditor.h" @@ -528,14 +532,50 @@ void MainWindow::slotShowCompleted( bool show) { bool MainWindow::showOverDue()const { return m_overdue; } -void MainWindow::setDocument( const QString& ) { - +void MainWindow::setDocument( const QString& fi) { + DocLnk doc(fi); + if (doc.isValid() ) + receiveFile(doc.file() ); + else + receiveFile(fi ); } -void MainWindow::slotBeam() { - -} -void MainWindow::beamDone( Ir* ) { +static const char *beamfile = "/tmp/opie-todo.vcs"; +void MainWindow::slotBeam() { + ::unlink( beamfile ); + OTodo todo = event( currentView()->current() ); + OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); + OTodoAccess acc( cal ); + acc.load(); + acc.add( todo ); + acc.save(); + Ir* ir = new Ir(this ); + connect(ir, SIGNAL(done(Ir*) ), + this, SLOT(beamDone(Ir*) ) ); + ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); + +} +void MainWindow::beamDone( Ir* ir) { + delete ir; + ::unlink( beamfile ); +} +void MainWindow::receiveFile( const QString& filename ) { + OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); + OTodoAccess acc( cal ); + acc.load(); + OTodoAccess::List list = acc.allRecords(); + + QString message = tr("

%1 new tasks arrived.

Would you like to add them to your Todolist?").arg(list.count() ); + + if ( QMessageBox::information(this, tr("New Tasks"), + message, QMessageBox::Ok, + QMessageBox::Cancel ) == QMessageBox::Ok ) { + OTodoAccess::List::Iterator it; + for ( it = list.begin(); it != list.end(); ++it ) + m_todoMgr.add( (*it) ); + + currentView()->updateView(); + } } void MainWindow::slotFlush() { diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index 598c3af..8d0c29f 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h @@ -96,6 +96,7 @@ private slots: void closeEvent( QCloseEvent* e ); private: + void receiveFile( const QString& filename ); void connectBase( ViewBase* ); void initUI(); void initActions(); diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro index 3ff78f5..f26acee 100644 --- a/core/pim/todo/todo.pro +++ b/core/pim/todo/todo.pro @@ -1,5 +1,5 @@ TEMPLATE = app -CONFIG = qt warn_on debug +CONFIG = qt warn_on release DESTDIR = $(OPIEDIR)/bin HEADERS = smalltodo.h \ -- cgit v0.9.0.2