summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp50
1 files changed, 29 insertions, 21 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index b6ee16f..19a6675 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -240,117 +240,125 @@ void MainWindow::closeEvent( QCloseEvent* e ) {
m_showing = false;
raiseCurrentView();
e->ignore();
return;
}
/*
* we should have flushed and now we're still saving
* so there is no need to flush
*/
if (m_syncing ) {
e->accept();
return;
}
bool quit = false;
if ( m_todoMgr.saveAll() ){
quit = true;
}else {
if ( QMessageBox::critical( this, QWidget::tr("Out of space"),
QWidget::tr("Todo was unable\n"
"to save your changes.\n"
"Free up some space\n"
"and try again.\n"
"\nQuit Anyway?"),
QMessageBox::Yes|QMessageBox::Escape,
QMessageBox::No|QMessageBox::Default)
!= QMessageBox::No ) {
e->accept();
quit = true;
}else
e->ignore();
}
if (quit ) {
Config config( "todo" );
config.setGroup( "View" );
config.writeEntry( "ShowComplete", showCompleted() );
config.writeEntry( "Category", currentCategory() );
config.writeEntry( "ShowDeadLine", showDeadline());
config.writeEntry( "ShowOverDue", showOverDue() );
config.writeEntry( "ShowQuickTask", showQuickTask() );
/* save templates */
templateManager()->save();
e->accept();
QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) );
}
}
void MainWindow::slotItemNew() {
- NewTaskDlg dlg( templateManager()->templates(), this );
- if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
- QString tempName = dlg.tempSelected();
- if ( tempName.isNull() )
- // Create new, blank task
- create();
- else {
- // Create new task from the template selected
- OPimTodo event = templateManager()->templateEvent( tempName );
- event = currentEditor()->edit( this, event );
- if ( currentEditor()->accepted() ) {
- event.setUid( 1 );
- handleAlarms( OPimTodo(), event );
- m_todoMgr.add( event );
- currentView()->addEvent( event );
-
- reloadCategories();
- }
- raiseCurrentView();
- }
- }
+ QStringList templateList = templateManager()->templates();
+ if(templateList.isEmpty()) {
+ // No templates, just create a blank task
+ create();
+ }
+ else {
+ // There are templates, so allow the user to select one
+ NewTaskDlg dlg( templateList, this );
+ if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
+ QString tempName = dlg.tempSelected();
+ if ( tempName.isNull() )
+ // Create new, blank task
+ create();
+ else {
+ // Create new task from the template selected
+ OPimTodo event = templateManager()->templateEvent( tempName );
+ event = currentEditor()->edit( this, event );
+ if ( currentEditor()->accepted() ) {
+ event.setUid( 1 );
+ handleAlarms( OPimTodo(), event );
+ m_todoMgr.add( event );
+ currentView()->addEvent( event );
+
+ reloadCategories();
+ }
+ raiseCurrentView();
+ }
+ }
+ }
}
void MainWindow::slotItemEdit() {
slotEdit( currentView()->current() );
}
void MainWindow::slotItemDuplicate() {
if(m_syncing) {
QMessageBox::warning(this, QWidget::tr("Todo"),
QWidget::tr("Data can not be edited, currently syncing"));
return;
}
OPimTodo ev = m_todoMgr.event( currentView()->current() );
/* let's generate a new uid */
ev.setUid(1);
m_todoMgr.add( ev );
currentView()->addEvent( ev );
raiseCurrentView();
}
void MainWindow::slotItemDelete() {
if (!currentView()->current() )
return;
if(m_syncing) {
QMessageBox::warning(this, QWidget::tr("Todo"),
QWidget::tr("Data can not be edited, currently syncing"));
return;
}
QString strName = currentView()->currentRepresentation();
if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) )
return;
handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() );
m_todoMgr.remove( currentView()->current() );
currentView()->removeEvent( currentView()->current() );
raiseCurrentView();
}
static const char *beamfile = "/tmp/opie-todo.vcs";
void MainWindow::slotItemBeam() {
beam( currentView()->current() );
}
void MainWindow::slotItemFind() {
}
void MainWindow::slotConfigure() {
TemplateDialogImpl dlg( this, m_tempManager );
if ( QPEApplication::execDialog( &dlg ) != QDialog::Accepted )
m_tempManager->load();
}