summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2007-01-03 11:41:01 (UTC)
committer korovkin <korovkin>2007-01-03 11:41:01 (UTC)
commitc880d9e087019f27f19c80b13fe2c7a5a4b37e3d (patch) (unidiff)
treeba79fe22adc7ebc062383aae1c49ddcf240b0f71
parent188c44c1196c3597a84189c2d148813df16dfe95 (diff)
downloadopie-c880d9e087019f27f19c80b13fe2c7a5a4b37e3d.zip
opie-c880d9e087019f27f19c80b13fe2c7a5a4b37e3d.tar.gz
opie-c880d9e087019f27f19c80b13fe2c7a5a4b37e3d.tar.bz2
Fix for bug#0001547 provided by Paul Eggleton <bluelightning@bluelightning.org>
If there are no templates, just create the blank task.
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
@@ -224,149 +224,157 @@ TemplateManager* MainWindow::templateManager() {
224 return m_tempManager; 224 return m_tempManager;
225} 225}
226Editor* MainWindow::currentEditor() { 226Editor* MainWindow::currentEditor() {
227 return m_curEdit; 227 return m_curEdit;
228} 228}
229TodoShow* MainWindow::currentShow() { 229TodoShow* MainWindow::currentShow() {
230 return m_curShow; 230 return m_curShow;
231} 231}
232void MainWindow::slotReload() { 232void MainWindow::slotReload() {
233 m_syncing = false; 233 m_syncing = false;
234 m_todoMgr.reload(); 234 m_todoMgr.reload();
235 currentView()->updateView( ); 235 currentView()->updateView( );
236 raiseCurrentView(); 236 raiseCurrentView();
237} 237}
238void MainWindow::closeEvent( QCloseEvent* e ) { 238void MainWindow::closeEvent( QCloseEvent* e ) {
239 if (m_stack->visibleWidget() == currentShow()->widget() ) { 239 if (m_stack->visibleWidget() == currentShow()->widget() ) {
240 m_showing = false; 240 m_showing = false;
241 raiseCurrentView(); 241 raiseCurrentView();
242 e->ignore(); 242 e->ignore();
243 return; 243 return;
244 } 244 }
245 /* 245 /*
246 * we should have flushed and now we're still saving 246 * we should have flushed and now we're still saving
247 * so there is no need to flush 247 * so there is no need to flush
248 */ 248 */
249 if (m_syncing ) { 249 if (m_syncing ) {
250 e->accept(); 250 e->accept();
251 return; 251 return;
252 } 252 }
253 bool quit = false; 253 bool quit = false;
254 if ( m_todoMgr.saveAll() ){ 254 if ( m_todoMgr.saveAll() ){
255 quit = true; 255 quit = true;
256 }else { 256 }else {
257 if ( QMessageBox::critical( this, QWidget::tr("Out of space"), 257 if ( QMessageBox::critical( this, QWidget::tr("Out of space"),
258 QWidget::tr("Todo was unable\n" 258 QWidget::tr("Todo was unable\n"
259 "to save your changes.\n" 259 "to save your changes.\n"
260 "Free up some space\n" 260 "Free up some space\n"
261 "and try again.\n" 261 "and try again.\n"
262 "\nQuit Anyway?"), 262 "\nQuit Anyway?"),
263 QMessageBox::Yes|QMessageBox::Escape, 263 QMessageBox::Yes|QMessageBox::Escape,
264 QMessageBox::No|QMessageBox::Default) 264 QMessageBox::No|QMessageBox::Default)
265 != QMessageBox::No ) { 265 != QMessageBox::No ) {
266 e->accept(); 266 e->accept();
267 quit = true; 267 quit = true;
268 }else 268 }else
269 e->ignore(); 269 e->ignore();
270 270
271 } 271 }
272 272
273 if (quit ) { 273 if (quit ) {
274 Config config( "todo" ); 274 Config config( "todo" );
275 config.setGroup( "View" ); 275 config.setGroup( "View" );
276 config.writeEntry( "ShowComplete", showCompleted() ); 276 config.writeEntry( "ShowComplete", showCompleted() );
277 config.writeEntry( "Category", currentCategory() ); 277 config.writeEntry( "Category", currentCategory() );
278 config.writeEntry( "ShowDeadLine", showDeadline()); 278 config.writeEntry( "ShowDeadLine", showDeadline());
279 config.writeEntry( "ShowOverDue", showOverDue() ); 279 config.writeEntry( "ShowOverDue", showOverDue() );
280 config.writeEntry( "ShowQuickTask", showQuickTask() ); 280 config.writeEntry( "ShowQuickTask", showQuickTask() );
281 /* save templates */ 281 /* save templates */
282 templateManager()->save(); 282 templateManager()->save();
283 e->accept(); 283 e->accept();
284 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); 284 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) );
285 } 285 }
286} 286}
287void MainWindow::slotItemNew() { 287void MainWindow::slotItemNew() {
288 NewTaskDlg dlg( templateManager()->templates(), this ); 288 QStringList templateList = templateManager()->templates();
289 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { 289 if(templateList.isEmpty()) {
290 QString tempName = dlg.tempSelected(); 290 // No templates, just create a blank task
291 if ( tempName.isNull() ) 291 create();
292 // Create new, blank task 292 }
293 create(); 293 else {
294 else { 294 // There are templates, so allow the user to select one
295 // Create new task from the template selected 295 NewTaskDlg dlg( templateList, this );
296 OPimTodo event = templateManager()->templateEvent( tempName ); 296 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
297 event = currentEditor()->edit( this, event ); 297 QString tempName = dlg.tempSelected();
298 if ( currentEditor()->accepted() ) { 298 if ( tempName.isNull() )
299 event.setUid( 1 ); 299 // Create new, blank task
300 handleAlarms( OPimTodo(), event ); 300 create();
301 m_todoMgr.add( event ); 301 else {
302 currentView()->addEvent( event ); 302 // Create new task from the template selected
303 303 OPimTodo event = templateManager()->templateEvent( tempName );
304 reloadCategories(); 304 event = currentEditor()->edit( this, event );
305 } 305 if ( currentEditor()->accepted() ) {
306 raiseCurrentView(); 306 event.setUid( 1 );
307 } 307 handleAlarms( OPimTodo(), event );
308 } 308 m_todoMgr.add( event );
309 currentView()->addEvent( event );
310
311 reloadCategories();
312 }
313 raiseCurrentView();
314 }
315 }
316 }
309} 317}
310void MainWindow::slotItemEdit() { 318void MainWindow::slotItemEdit() {
311 slotEdit( currentView()->current() ); 319 slotEdit( currentView()->current() );
312} 320}
313void MainWindow::slotItemDuplicate() { 321void MainWindow::slotItemDuplicate() {
314 if(m_syncing) { 322 if(m_syncing) {
315 QMessageBox::warning(this, QWidget::tr("Todo"), 323 QMessageBox::warning(this, QWidget::tr("Todo"),
316 QWidget::tr("Data can not be edited, currently syncing")); 324 QWidget::tr("Data can not be edited, currently syncing"));
317 return; 325 return;
318 } 326 }
319 OPimTodo ev = m_todoMgr.event( currentView()->current() ); 327 OPimTodo ev = m_todoMgr.event( currentView()->current() );
320 /* let's generate a new uid */ 328 /* let's generate a new uid */
321 ev.setUid(1); 329 ev.setUid(1);
322 m_todoMgr.add( ev ); 330 m_todoMgr.add( ev );
323 331
324 currentView()->addEvent( ev ); 332 currentView()->addEvent( ev );
325 raiseCurrentView(); 333 raiseCurrentView();
326} 334}
327void MainWindow::slotItemDelete() { 335void MainWindow::slotItemDelete() {
328 if (!currentView()->current() ) 336 if (!currentView()->current() )
329 return; 337 return;
330 338
331 if(m_syncing) { 339 if(m_syncing) {
332 QMessageBox::warning(this, QWidget::tr("Todo"), 340 QMessageBox::warning(this, QWidget::tr("Todo"),
333 QWidget::tr("Data can not be edited, currently syncing")); 341 QWidget::tr("Data can not be edited, currently syncing"));
334 return; 342 return;
335 } 343 }
336 QString strName = currentView()->currentRepresentation(); 344 QString strName = currentView()->currentRepresentation();
337 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) 345 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) )
338 return; 346 return;
339 347
340 handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); 348 handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() );
341 m_todoMgr.remove( currentView()->current() ); 349 m_todoMgr.remove( currentView()->current() );
342 currentView()->removeEvent( currentView()->current() ); 350 currentView()->removeEvent( currentView()->current() );
343 raiseCurrentView(); 351 raiseCurrentView();
344} 352}
345 353
346static const char *beamfile = "/tmp/opie-todo.vcs"; 354static const char *beamfile = "/tmp/opie-todo.vcs";
347void MainWindow::slotItemBeam() { 355void MainWindow::slotItemBeam() {
348 beam( currentView()->current() ); 356 beam( currentView()->current() );
349} 357}
350void MainWindow::slotItemFind() { 358void MainWindow::slotItemFind() {
351} 359}
352void MainWindow::slotConfigure() { 360void MainWindow::slotConfigure() {
353 TemplateDialogImpl dlg( this, m_tempManager ); 361 TemplateDialogImpl dlg( this, m_tempManager );
354 if ( QPEApplication::execDialog( &dlg ) != QDialog::Accepted ) 362 if ( QPEApplication::execDialog( &dlg ) != QDialog::Accepted )
355 m_tempManager->load(); 363 m_tempManager->load();
356} 364}
357void MainWindow::slotDelete(int uid ) { 365void MainWindow::slotDelete(int uid ) {
358 if( uid == 0 ) return; 366 if( uid == 0 ) return;
359 if(m_syncing) { 367 if(m_syncing) {
360 QMessageBox::warning(this, QWidget::tr("Todo"), 368 QMessageBox::warning(this, QWidget::tr("Todo"),
361 QWidget::tr("Data can not be edited, currently syncing")); 369 QWidget::tr("Data can not be edited, currently syncing"));
362 return; 370 return;
363 } 371 }
364 OPimTodo to = m_todoMgr.event(uid); 372 OPimTodo to = m_todoMgr.event(uid);
365 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) 373 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) )
366 return; 374 return;
367 375
368 handleAlarms(to, OPimTodo() ); 376 handleAlarms(to, OPimTodo() );
369 m_todoMgr.remove( to.uid() ); 377 m_todoMgr.remove( to.uid() );
370 currentView()->removeEvent( to.uid() ); 378 currentView()->removeEvent( to.uid() );
371 raiseCurrentView(); 379 raiseCurrentView();
372} 380}