author | eilers <eilers> | 2004-04-28 09:23:28 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-04-28 09:23:28 (UTC) |
commit | 8af6d533817ddc490c9d19344c7f0fa83239831e (patch) (side-by-side diff) | |
tree | e25fcc93a4949f32e389aad8212051c093108b1a | |
parent | 134b7accd6bdc8fbc160a42f7c52c585e73f4add (diff) | |
download | opie-8af6d533817ddc490c9d19344c7f0fa83239831e.zip opie-8af6d533817ddc490c9d19344c7f0fa83239831e.tar.gz opie-8af6d533817ddc490c9d19344c7f0fa83239831e.tar.bz2 |
Removed static cast which is not working with the new modifications of
the opie-pim api
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 924fde1..2002e87 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -721,321 +721,322 @@ void MainWindow::slotEdit( int uid ) { raiseCurrentView(); } /* void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { m_todoMgr.update( uid, 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* ) { } void MainWindow::updateList() { m_todoMgr.updateList(); } void MainWindow::setReadAhead( uint count ) { if (m_todoMgr.todoDB() ) m_todoMgr.todoDB()->setReadAhead( count ); } void MainWindow::slotQuickEntered() { owarn << "entered" << oendl; OPimTodo todo = quickEditor()->todo(); if (todo.isEmpty() ) return; m_todoMgr.add( todo ); currentView()->addEvent( todo ); raiseCurrentView(); } QuickEditBase* MainWindow::quickEditor() { return m_curQuick; } void MainWindow::slotComplete( int uid ) { slotComplete( event(uid) ); } 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 * and update the items duedate to the next * possible recurrance of this item... * the spinned off one will loose the * 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() ) { OPimTodo to2( to ); /* the spinned off one won't recur anymore */ to.setRecurrence( OPimRecurrence() ); OPimRecurrence rec = to2.recurrence(); rec.setStart( to.dueDate() ); to2.setRecurrence( rec ); /* * if there is a next occurence * from the duedate of the last recurrance */ QDate date; if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { int dayDiff = to.dueDate().daysTo( date ); owarn << "day diff is " << dayDiff << oendl; QDate inval; /* generate a new uid for the old record */ to.setUid( 1 ); /* add the old one cause it has a new UID here cause it was spin off */ m_todoMgr.add( to ); /* * update the due date * start date * and complete date */ to2.setDueDate( date ); rec.setStart( date ); to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week /* move start date */ if (to2.hasStartDate() ) to2.setStartDate( to2.startDate().addDays( dayDiff ) ); /* now the alarms */ if (to2.hasNotifiers() ) { OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); OPimNotifyManager::Alarms als; /* for every alarm move the day */ 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( OPimTodo(), todo ); } to2.setCompletedDate( inval ); to2.setCompleted( false ); updateTodo( to2 ); }else updateTodo( to ); }else updateTodo( to ); currentView()->updateView(); raiseCurrentView(); } void MainWindow::flush() { slotFlush(); } void MainWindow::reload() { slotReload(); } int MainWindow::create() { int uid = 0; if(m_syncing) { QMessageBox::warning(this, QWidget::tr("Todo"), QWidget::tr("Data can not be edited, currently syncing")); return uid; } m_todoMgr.load(); OPimTodo todo = currentEditor()->newTodo( currentCatId(), this ); if ( currentEditor()->accepted() ) { //todo.assignUid(); uid = todo.uid(); 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... // but only call if we changed something -zecke populateCategories(); } raiseCurrentView( ); return uid; } /* 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( OPimTodo(), m_todoMgr.event( uid ) ); return m_todoMgr.remove( uid ); } void MainWindow::beam( int uid) { if( uid == 0 ) return; ::unlink( beamfile ); m_todoMgr.load(); 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*) ) ); ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); } void MainWindow::show( int uid ) { m_todoMgr.load(); // might not be loaded yet m_showing = true; slotShow( uid ); raise(); QPEApplication::setKeepRunning(); } void MainWindow::edit( int uid ) { m_todoMgr.load(); slotEdit( uid ); } void MainWindow::add( const OPimRecord& rec) { - if ( rec.rtti() != OPimTodo::rtti() ) return; + OPimTodo test; + if ( rec.rtti() != test.rtti() ) return; m_todoMgr.load(); // might not be loaded 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 // spend expensive time comparing all these strings... // but only call if we changed something -zecke populateCategories(); } void MainWindow::slotReturnFromView() { m_showing = false; raiseCurrentView(); } namespace { OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, const OPimNotifyManager::Alarms& newAls ) { OPimNotifyManager::Alarms nonMatching; OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); OPimNotifyManager::Alarms::ConstIterator newIt; for ( ; oldIt != oldAls.end(); ++oldIt ) { bool found = false; QDateTime oldDt = (*oldIt).dateTime(); for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { if ( oldDt == (*newIt).dateTime() ) { found = true; break; } } if (!found) nonMatching.append( (*oldIt) ); } return nonMatching; } void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { OPimNotifyManager::Alarms::ConstIterator it; for ( it = als.begin(); it != als.end(); ++it ) { owarn << "Adding alarm for " << (*it).dateTime().toString() << oendl; AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); } } void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { OPimNotifyManager::Alarms::ConstIterator it; for ( it = als.begin(); it != als.end(); ++it ) { owarn << "Removinf alarm for " << (*it).dateTime().toString() << oendl; AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); } } } 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(); if (!newTodo.hasNotifiers() ) removed = oldAls; else removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); removeAlarms( removed, oldTodo.uid() ); } if ( newTodo.hasNotifiers() ) { OPimNotifyManager::Alarms added; if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) added = newTodo.notifiers().alarms(); else added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); addAlarms( added, newTodo.uid() ); } } /* we might have not loaded the db */ void MainWindow::doAlarm( const QDateTime& dt, int uid ) { m_todoMgr.load(); 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 */ bool loud = false; OPimNotifyManager::Alarms als = todo.notifiers().alarms(); OPimNotifyManager::Alarms::Iterator it; for ( it = als.begin(); it != als.end(); ++it ) { if ( (*it).dateTime() == dt ) { loud = ( (*it).sound() == OPimAlarm::Loud ); break; } } if (loud) startAlarm(); QDialog dlg(this, 0, TRUE ); QVBoxLayout* lay = new QVBoxLayout( &dlg ); QTextView* view = new QTextView( &dlg ); lay->addWidget( view ); QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); lay->addWidget( btnOk ); QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); text += todo.toRichText(); view->setText( text ); bool needToStay = QPEApplication::execDialog( &dlg ); if (loud) killAlarm(); if (needToStay) { // showMaximized(); // raise(); QPEApplication::setKeepRunning(); // setActiveWindow(); } } |