summaryrefslogtreecommitdiff
path: root/core/pim/todo/mainwindow.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/todo/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp136
1 files changed, 110 insertions, 26 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 5119ae0..6725951 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -73,2 +73,3 @@ MainWindow::MainWindow( QWidget* parent,
m_syncing = false;
+ m_showing = false;
m_counter = 0;
@@ -163,2 +164,3 @@ void MainWindow::initActions() {
+#if 0
// Options menu
@@ -170,3 +172,5 @@ void MainWindow::initActions() {
+
m_options->insertSeparator();
+#endif
@@ -354,2 +358,3 @@ void MainWindow::closeEvent( QCloseEvent* e ) {
if (m_stack->visibleWidget() == currentShow()->widget() ) {
+ m_showing = false;
raiseCurrentView();
@@ -411,3 +416,3 @@ void MainWindow::populateTemplates() {
* We use the edit widget to do
- * the config but we setUid(-1)
+ * the config but we setUid(1)
* to get a new uid
@@ -427,5 +432,6 @@ void MainWindow::slotNewFromTemplate( int id ) {
/* assign new todo */
- event.setUid( -1 );
- currentView()->addEvent( event );
+ event.setUid( 1 );
+ handleAlarms( OTodo(), event );
m_todoMgr.add( event );
+ currentView()->addEvent( event );
@@ -433,2 +439,3 @@ void MainWindow::slotNewFromTemplate( int id ) {
}
+ raiseCurrentView();
}
@@ -440,3 +447,3 @@ void MainWindow::slotDuplicate() {
QMessageBox::warning(this, QWidget::tr("Todo"),
- QWidget::tr("Can not edit data, currently syncing"));
+ QWidget::tr("Data can not be edited, currently syncing"));
return;
@@ -445,3 +452,3 @@ void MainWindow::slotDuplicate() {
/* let's generate a new uid */
- ev.setUid(-1);
+ ev.setUid(1);
m_todoMgr.add( ev );
@@ -457,3 +464,3 @@ void MainWindow::slotDelete() {
QMessageBox::warning(this, QWidget::tr("Todo"),
- QWidget::tr("Can not edit data, currently syncing"));
+ QWidget::tr("Data can not be edited, currently syncing"));
return;
@@ -464,3 +471,3 @@ void MainWindow::slotDelete() {
- handleAlarms( OTodo(), m_todoMgr.event( currentView()->current() ) );
+ handleAlarms( m_todoMgr.event( currentView()->current() ), OTodo() );
m_todoMgr.remove( currentView()->current() );
@@ -469,2 +476,18 @@ void MainWindow::slotDelete() {
}
+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);
+ if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) )
+ return;
+
+ handleAlarms(to, OTodo() );
+ m_todoMgr.remove( to.uid() );
+ currentView()->removeEvent( to.uid() );
+ raiseCurrentView();
+}
void MainWindow::slotDeleteAll() {
@@ -472,3 +495,3 @@ void MainWindow::slotDeleteAll() {
QMessageBox::warning(this, QWidget::tr("Todo"),
- QWidget::tr("Can not edit data, currently syncing"));
+ QWidget::tr("Data can not be edited, currently syncing"));
return;
@@ -488,3 +511,3 @@ void MainWindow::slotDeleteCompleted() {
QMessageBox::warning(this, QWidget::tr("Todo"),
- QWidget::tr("Can not edit data, currently syncing"));
+ QWidget::tr("Data can not be edited, currently syncing"));
return;
@@ -568,2 +591,3 @@ void MainWindow::receiveFile( const QString& filename ) {
OTodoAccessVCal* cal = new OTodoAccessVCal(filename );
+
OTodoAccess acc( cal );
@@ -572,12 +596,15 @@ void MainWindow::receiveFile( const QString& filename ) {
- QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
+ if (list.count()){
- if ( QMessageBox::information(this, QWidget::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) );
+ QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
- currentView()->updateView();
+ if ( QMessageBox::information(this, QWidget::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();
+ }
}
@@ -636,2 +663,9 @@ ViewBase* MainWindow::currentView() {
void MainWindow::raiseCurrentView() {
+ // due QPE/Application/todolist show(int)
+ // we might not have the populateCategories slot called once
+ // we would show the otodo but then imediately switch to the currentView
+ // if we're initially showing we shouldn't raise the table
+ // in returnFromView we fix up m_showing
+ if (m_showing ) return;
+
m_stack->raiseWidget( m_curView->widget() );
@@ -644,2 +678,3 @@ void MainWindow::slotShowDue(bool ov) {
void MainWindow::slotShow( int uid ) {
+ if ( uid == 0 ) return;
qWarning("slotShow");
@@ -648,7 +683,17 @@ void MainWindow::slotShow( int uid ) {
}
+void MainWindow::slotShowNext() {
+ int l = currentView()->next();
+ if (l!=0)
+ slotShow(l);
+}
+void MainWindow::slotShowPrev() {
+ int l = currentView()->prev();
+ if (l!=0)
+ slotShow(l);
+}
void MainWindow::slotEdit( int uid ) {
- if (uid == 1 ) return;
+ if (uid == 0 ) return;
if(m_syncing) {
QMessageBox::warning(this, QWidget::tr("Todo"),
- QWidget::tr("Can not edit data, currently syncing"));
+ QWidget::tr("Data can't be edited, currently syncing"));
return;
@@ -662,3 +707,2 @@ void MainWindow::slotEdit( int uid ) {
if ( currentEditor()->accepted() ) {
- qWarning("Replacing now" );
handleAlarms( old_todo, todo );
@@ -720,2 +764,6 @@ void MainWindow::slotComplete( const OTodo& todo ) {
* 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
*/
@@ -736,2 +784,4 @@ void MainWindow::slotComplete( const OTodo& todo ) {
if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
+ int dayDiff = to.dueDate().daysTo( date );
+ qWarning("day diff is %d", dayDiff );
QDate inval;
@@ -749,5 +799,26 @@ void MainWindow::slotComplete( const OTodo& todo ) {
to2.setDueDate( date );
- to2.setStartDate( inval );
+ 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( OTodo(), todo );
+ }
to2.setCompletedDate( inval );
to2.setCompleted( false );
+
updateTodo( to2 );
@@ -771,5 +842,6 @@ int MainWindow::create() {
QMessageBox::warning(this, QWidget::tr("Todo"),
- QWidget::tr("Can not edit data, currently syncing"));
+ QWidget::tr("Data can not be edited, currently syncing"));
return uid;
}
+ m_todoMgr.load();
@@ -806,3 +878,7 @@ bool MainWindow::remove( int uid ) {
void MainWindow::beam( int uid) {
+ if( uid == 0 ) return;
+
::unlink( beamfile );
+ m_todoMgr.load();
+
OTodo todo = event( uid );
@@ -819,5 +895,10 @@ void MainWindow::beam( int uid) {
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 );
@@ -826,2 +907,3 @@ void MainWindow::add( const OPimRecord& rec) {
if ( rec.rtti() != OTodo::rtti() ) return;
+ m_todoMgr.load(); // might not be loaded
@@ -839,2 +921,3 @@ void MainWindow::add( const OPimRecord& rec) {
void MainWindow::slotReturnFromView() {
+ m_showing = false;
raiseCurrentView();
@@ -934,3 +1017,3 @@ void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
- QString text = tr("<h1>Alarm at %0</h1><br>").arg( TimeString::dateString( dt ) );
+ QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) );
text += todo.toRichText();
@@ -945,6 +1028,6 @@ void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
if (needToStay) {
- showMaximized();
- raise();
+// showMaximized();
+// raise();
QPEApplication::setKeepRunning();
- setActiveWindow();
+// setActiveWindow();
}
@@ -952 +1035,2 @@ void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
}
+