Diffstat (limited to 'core/pim/todo/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 98 |
1 files changed, 48 insertions, 50 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index fc189bd..0613f2c 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -25,12 +25,26 @@ Boston, MA 02111-1307, USA. */ #include <unistd.h> +#include <opie2/opimrecurrence.h> +#include <opie2/opimnotifymanager.h> +#include <opie2/otodoaccessvcal.h> +#include <opie2/oapplicationfactory.h> + +#include <qpe/applnk.h> +#include <qpe/config.h> +#include <qpe/ir.h> +#include <qpe/resource.h> +#include <qpe/qpemessagebox.h> +#include <qpe/alarmserver.h> +#include <qpe/timestring.h> +#include <qpe/qpeapplication.h> + #include <qmenubar.h> #include <qmessagebox.h> #include <qtoolbar.h> #include <qpopupmenu.h> #include <qpushbutton.h> #include <qwidgetstack.h> @@ -38,28 +52,12 @@ #include <qtimer.h> #include <qvbox.h> #include <qlayout.h> #include <qlineedit.h> #include <qwhatsthis.h> -#include <qpe/applnk.h> -#include <qpe/config.h> -#include <qpe/ir.h> -#include <qpe/resource.h> -#include <qpe/qpemessagebox.h> -#include <qpe/alarmserver.h> -#include <qpe/timestring.h> -#include <qpe/qpeapplication.h> - -#include <opie/orecur.h> -#include <opie/opimnotifymanager.h> -#include <opie/otodoaccessvcal.h> -#include <opie/owidgetstack.h> - -#include <opie/oapplicationfactory.h> - #include "quickeditimpl.h" #include "todotemplatemanager.h" #include "templateeditor.h" #include "tableview.h" #include "textviewshow.h" @@ -307,16 +305,16 @@ QPopupMenu* MainWindow::options() { QPopupMenu* MainWindow::edit() { return m_edit; } QToolBar* MainWindow::toolbar() { return m_tool; } -OTodoAccess::List MainWindow::list()const { +OPimTodoAccess::List MainWindow::list()const { return m_todoMgr.list(); } -OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { +OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { int cat = 0; if ( m_curCat != QWidget::tr("All Categories") ) cat = currentCatId(); if ( m_curCat == QWidget::tr("Unfiled") ) cat = -1; @@ -328,23 +326,23 @@ OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { filter |= 4; if (m_overdue) filter |= 2; return m_todoMgr.sorted( asc, sortOrder, filter, cat ); } -OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { +OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { int cat = 0; if ( m_curCat != QWidget::tr("All Categories") ) cat = currentCatId(); if ( m_curCat == QWidget::tr("Unfiled") ) cat = -1; return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); } -OTodo MainWindow::event( int uid ) { +OPimTodo MainWindow::event( int uid ) { return m_todoMgr.event( uid ); } bool MainWindow::isSyncing()const { return m_syncing; } TemplateManager* MainWindow::templateManager() { @@ -430,20 +428,20 @@ void MainWindow::populateTemplates() { * first we get the name of the template * then we will use the TemplateManager */ void MainWindow::slotNewFromTemplate( int id ) { QString name = m_template->text( id ); - OTodo event = templateManager()->templateEvent( name ); + OPimTodo event = templateManager()->templateEvent( name ); event = currentEditor()->edit(this, event ); if ( currentEditor()->accepted() ) { /* assign new todo */ event.setUid( 1 ); - handleAlarms( OTodo(), event ); + handleAlarms( OPimTodo(), event ); m_todoMgr.add( event ); currentView()->addEvent( event ); populateCategories(); } raiseCurrentView(); @@ -454,13 +452,13 @@ void MainWindow::slotNew() { void MainWindow::slotDuplicate() { if(m_syncing) { QMessageBox::warning(this, QWidget::tr("Todo"), QWidget::tr("Data can not be edited, currently syncing")); return; } - OTodo ev = m_todoMgr.event( currentView()->current() ); + OPimTodo ev = m_todoMgr.event( currentView()->current() ); /* let's generate a new uid */ ev.setUid(1); m_todoMgr.add( ev ); currentView()->addEvent( ev ); raiseCurrentView(); @@ -475,29 +473,29 @@ void MainWindow::slotDelete() { return; } QString strName = currentView()->currentRepresentation(); if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) return; - handleAlarms( m_todoMgr.event( currentView()->current() ), OTodo() ); + handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); m_todoMgr.remove( currentView()->current() ); currentView()->removeEvent( currentView()->current() ); raiseCurrentView(); } void MainWindow::slotDelete(int uid ) { if( uid == 0 ) return; if(m_syncing) { QMessageBox::warning(this, QWidget::tr("Todo"), QWidget::tr("Data can not be edited, currently syncing")); return; } - OTodo to = m_todoMgr.event(uid); + OPimTodo to = m_todoMgr.event(uid); if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) return; - handleAlarms(to, OTodo() ); + handleAlarms(to, OPimTodo() ); m_todoMgr.remove( to.uid() ); currentView()->removeEvent( to.uid() ); raiseCurrentView(); } void MainWindow::slotDeleteAll() { if(m_syncing) { @@ -594,26 +592,26 @@ void MainWindow::slotBeam() { } void MainWindow::beamDone( Ir* ir) { delete ir; ::unlink( beamfile ); } void MainWindow::receiveFile( const QString& filename ) { - OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); + OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); - OTodoAccess acc( cal ); + OPimTodoAccess acc( cal ); acc.load(); - OTodoAccess::List list = acc.allRecords(); + OPimTodoAccess::List list = acc.allRecords(); if (list.count()){ QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); if ( QMessageBox::information(this, QWidget::tr("New Tasks"), message, QMessageBox::Ok, QMessageBox::Cancel ) == QMessageBox::Ok ) { - OTodoAccess::List::Iterator it; + OPimTodoAccess::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) m_todoMgr.add( (*it) ); currentView()->updateView(); } } @@ -705,15 +703,15 @@ void MainWindow::slotEdit( int uid ) { if(m_syncing) { QMessageBox::warning(this, QWidget::tr("Todo"), QWidget::tr("Data can't be edited, currently syncing")); return; } - OTodo old_todo = m_todoMgr.event( uid ); + OPimTodo old_todo = m_todoMgr.event( uid ); - OTodo todo = currentEditor()->edit(this, old_todo ); + OPimTodo todo = currentEditor()->edit(this, old_todo ); /* if completed */ if ( currentEditor()->accepted() ) { handleAlarms( old_todo, todo ); m_todoMgr.update( todo.uid(), todo ); currentView()->replaceEvent( todo ); @@ -725,13 +723,13 @@ void MainWindow::slotEdit( int uid ) { } /* void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { m_todoMgr.update( uid, ev ); } */ -void MainWindow::updateTodo( const OTodo& ev) { +void MainWindow::updateTodo( const OPimTodo& ev) { m_todoMgr.update( ev.uid() , ev ); } /* The view changed it's configuration * update the view menu */ void MainWindow::slotUpdate3( QWidget* ) { @@ -743,13 +741,13 @@ void MainWindow::updateList() { void MainWindow::setReadAhead( uint count ) { if (m_todoMgr.todoDB() ) m_todoMgr.todoDB()->setReadAhead( count ); } void MainWindow::slotQuickEntered() { qWarning("entered"); - OTodo todo = quickEditor()->todo(); + OPimTodo todo = quickEditor()->todo(); if (todo.isEmpty() ) return; m_todoMgr.add( todo ); currentView()->addEvent( todo ); raiseCurrentView(); @@ -757,14 +755,14 @@ void MainWindow::slotQuickEntered() { QuickEditBase* MainWindow::quickEditor() { return m_curQuick; } void MainWindow::slotComplete( int uid ) { slotComplete( event(uid) ); } -void MainWindow::slotComplete( const OTodo& todo ) { - OTodo to = todo; +void MainWindow::slotComplete( const OPimTodo& todo ) { + OPimTodo to = todo; to.setCompleted( !to.isCompleted() ); to.setCompletedDate( QDate::currentDate() ); /* * if the item does recur * we need to spin it off @@ -774,18 +772,18 @@ void MainWindow::slotComplete( const OTodo& todo ) { * recurrence. * We calculate the difference between the old due date and the * new one and add this diff to start, completed and alarm dates * -zecke */ if ( to.hasRecurrence() && to.isCompleted() ) { - OTodo to2( to ); + OPimTodo to2( to ); /* the spinned off one won't recur anymore */ - to.setRecurrence( ORecur() ); + to.setRecurrence( OPimRecurrence() ); - ORecur rec = to2.recurrence(); + OPimRecurrence rec = to2.recurrence(); rec.setStart( to.dueDate() ); to2.setRecurrence( rec ); /* * if there is a next occurence * from the duedate of the last recurrance */ @@ -822,13 +820,13 @@ void MainWindow::slotComplete( const OTodo& todo ) { for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { OPimAlarm al = (*it); al.setDateTime( al.dateTime().addDays( dayDiff ) ); als.append( al ); } to2.notifiers().setAlarms( als ); - handleAlarms( OTodo(), todo ); + handleAlarms( OPimTodo(), todo ); } to2.setCompletedDate( inval ); to2.setCompleted( false ); updateTodo( to2 ); }else @@ -852,19 +850,19 @@ int MainWindow::create() { QWidget::tr("Data can not be edited, currently syncing")); return uid; } m_todoMgr.load(); - OTodo todo = currentEditor()->newTodo( currentCatId(), + OPimTodo todo = currentEditor()->newTodo( currentCatId(), this ); if ( currentEditor()->accepted() ) { //todo.assignUid(); uid = todo.uid(); - handleAlarms( OTodo(), todo ); + handleAlarms( OPimTodo(), todo ); m_todoMgr.add( todo ); currentView()->addEvent( todo ); // I'm afraid we must call this every time now, otherwise // spend expensive time comparing all these strings... @@ -877,25 +875,25 @@ int MainWindow::create() { } /* delete it silently... */ bool MainWindow::remove( int uid ) { if (m_syncing) return false; /* argh need to get the whole OEvent... to disable alarms -zecke */ - handleAlarms( OTodo(), m_todoMgr.event( uid ) ); + handleAlarms( OPimTodo(), m_todoMgr.event( uid ) ); return m_todoMgr.remove( uid ); } void MainWindow::beam( int uid) { if( uid == 0 ) return; ::unlink( beamfile ); m_todoMgr.load(); - OTodo todo = event( uid ); - OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); - OTodoAccess acc( cal ); + OPimTodo todo = event( uid ); + OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) ); + OPimTodoAccess acc( cal ); acc.load(); acc.add( todo ); acc.save(); Ir* ir = new Ir(this ); connect(ir, SIGNAL(done(Ir*) ), this, SLOT(beamDone(Ir*) ) ); @@ -910,16 +908,16 @@ void MainWindow::show( int uid ) { } void MainWindow::edit( int uid ) { m_todoMgr.load(); slotEdit( uid ); } void MainWindow::add( const OPimRecord& rec) { - if ( rec.rtti() != OTodo::rtti() ) return; + if ( rec.rtti() != OPimTodo::rtti() ) return; m_todoMgr.load(); // might not be loaded - const OTodo& todo = static_cast<const OTodo&>(rec); + const OPimTodo& todo = static_cast<const OPimTodo&>(rec); m_todoMgr.add(todo ); currentView()->addEvent( todo ); // I'm afraid we must call this every time now, otherwise @@ -966,13 +964,13 @@ namespace { qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() ); AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); } } } -void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) { +void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) { /* * if oldTodo is not empty and has notifiers we need to find the deleted ones */ if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { OPimNotifyManager::Alarms removed; OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); @@ -994,13 +992,13 @@ void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) { } } /* we might have not loaded the db */ void MainWindow::doAlarm( const QDateTime& dt, int uid ) { m_todoMgr.load(); - OTodo todo = m_todoMgr.event( uid ); + OPimTodo todo = m_todoMgr.event( uid ); if (!todo.hasNotifiers() ) return; /* * let's find the right alarm and find out if silent * then show a richtext widget */ |