author | zecke <zecke> | 2003-10-07 12:55:16 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-10-07 12:55:16 (UTC) |
commit | 898d453b417e561cea25f6b7578814d31cec6e97 (patch) (unidiff) | |
tree | 92ba0e55f17abcaa7b7883410c8850e59e54f516 | |
parent | e65d5c86b5fff521dfb94282a96606546bad9585 (diff) | |
download | opie-898d453b417e561cea25f6b7578814d31cec6e97.zip opie-898d453b417e561cea25f6b7578814d31cec6e97.tar.gz opie-898d453b417e561cea25f6b7578814d31cec6e97.tar.bz2 |
If you decide to close the mainwindow and have say editor and views open as well
call closeAllWindows() after all events are dispatched
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index ad7899f..7f40645 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -284,257 +284,257 @@ QPopupMenu* MainWindow::contextMenu( int , bool recur ) { | |||
284 | QPopupMenu* menu = new QPopupMenu(); | 284 | QPopupMenu* menu = new QPopupMenu(); |
285 | 285 | ||
286 | m_editAction->addTo( menu ); | 286 | m_editAction->addTo( menu ); |
287 | m_deleteAction->addTo( menu ); | 287 | m_deleteAction->addTo( menu ); |
288 | m_duplicateAction->addTo( menu ); | 288 | m_duplicateAction->addTo( menu ); |
289 | 289 | ||
290 | menu->insertSeparator(); | 290 | menu->insertSeparator(); |
291 | 291 | ||
292 | /* | 292 | /* |
293 | * if this event recurs we allow | 293 | * if this event recurs we allow |
294 | * to detach it. | 294 | * to detach it. |
295 | * remove all | 295 | * remove all |
296 | */ | 296 | */ |
297 | if ( recur ) { | 297 | if ( recur ) { |
298 | ; // FIXME | 298 | ; // FIXME |
299 | } | 299 | } |
300 | 300 | ||
301 | return menu; | 301 | return menu; |
302 | } | 302 | } |
303 | QPopupMenu* MainWindow::options() { | 303 | QPopupMenu* MainWindow::options() { |
304 | qWarning("Options"); | 304 | qWarning("Options"); |
305 | return m_options; | 305 | return m_options; |
306 | } | 306 | } |
307 | QPopupMenu* MainWindow::edit() { | 307 | QPopupMenu* MainWindow::edit() { |
308 | return m_edit; | 308 | return m_edit; |
309 | } | 309 | } |
310 | QToolBar* MainWindow::toolbar() { | 310 | QToolBar* MainWindow::toolbar() { |
311 | return m_tool; | 311 | return m_tool; |
312 | } | 312 | } |
313 | OTodoAccess::List MainWindow::list()const { | 313 | OTodoAccess::List MainWindow::list()const { |
314 | return m_todoMgr.list(); | 314 | return m_todoMgr.list(); |
315 | } | 315 | } |
316 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 316 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
317 | int cat = 0; | 317 | int cat = 0; |
318 | if ( m_curCat != QWidget::tr("All Categories") ) | 318 | if ( m_curCat != QWidget::tr("All Categories") ) |
319 | cat = currentCatId(); | 319 | cat = currentCatId(); |
320 | if ( m_curCat == QWidget::tr("Unfiled") ) | 320 | if ( m_curCat == QWidget::tr("Unfiled") ) |
321 | cat = -1; | 321 | cat = -1; |
322 | 322 | ||
323 | qWarning(" Category %d %s", cat, m_curCat.latin1() ); | 323 | qWarning(" Category %d %s", cat, m_curCat.latin1() ); |
324 | 324 | ||
325 | int filter = 1; | 325 | int filter = 1; |
326 | 326 | ||
327 | if (!m_completed ) | 327 | if (!m_completed ) |
328 | filter |= 4; | 328 | filter |= 4; |
329 | if (m_overdue) | 329 | if (m_overdue) |
330 | filter |= 2; | 330 | filter |= 2; |
331 | 331 | ||
332 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 332 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
333 | } | 333 | } |
334 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 334 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
335 | int cat = 0; | 335 | int cat = 0; |
336 | if ( m_curCat != QWidget::tr("All Categories") ) | 336 | if ( m_curCat != QWidget::tr("All Categories") ) |
337 | cat = currentCatId(); | 337 | cat = currentCatId(); |
338 | 338 | ||
339 | if ( m_curCat == QWidget::tr("Unfiled") ) | 339 | if ( m_curCat == QWidget::tr("Unfiled") ) |
340 | cat = -1; | 340 | cat = -1; |
341 | 341 | ||
342 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 342 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
343 | } | 343 | } |
344 | OTodo MainWindow::event( int uid ) { | 344 | OTodo MainWindow::event( int uid ) { |
345 | return m_todoMgr.event( uid ); | 345 | return m_todoMgr.event( uid ); |
346 | } | 346 | } |
347 | bool MainWindow::isSyncing()const { | 347 | bool MainWindow::isSyncing()const { |
348 | return m_syncing; | 348 | return m_syncing; |
349 | } | 349 | } |
350 | TemplateManager* MainWindow::templateManager() { | 350 | TemplateManager* MainWindow::templateManager() { |
351 | return m_tempManager; | 351 | return m_tempManager; |
352 | } | 352 | } |
353 | Editor* MainWindow::currentEditor() { | 353 | Editor* MainWindow::currentEditor() { |
354 | return m_curEdit; | 354 | return m_curEdit; |
355 | } | 355 | } |
356 | TodoShow* MainWindow::currentShow() { | 356 | TodoShow* MainWindow::currentShow() { |
357 | return m_curShow; | 357 | return m_curShow; |
358 | } | 358 | } |
359 | void MainWindow::slotReload() { | 359 | void MainWindow::slotReload() { |
360 | m_syncing = FALSE; | 360 | m_syncing = FALSE; |
361 | m_todoMgr.reload(); | 361 | m_todoMgr.reload(); |
362 | currentView()->updateView( ); | 362 | currentView()->updateView( ); |
363 | raiseCurrentView(); | 363 | raiseCurrentView(); |
364 | } | 364 | } |
365 | void MainWindow::closeEvent( QCloseEvent* e ) { | 365 | void MainWindow::closeEvent( QCloseEvent* e ) { |
366 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 366 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
367 | m_showing = false; | 367 | m_showing = false; |
368 | raiseCurrentView(); | 368 | raiseCurrentView(); |
369 | e->ignore(); | 369 | e->ignore(); |
370 | return; | 370 | return; |
371 | } | 371 | } |
372 | /* | 372 | /* |
373 | * we should have flushed and now we're still saving | 373 | * we should have flushed and now we're still saving |
374 | * so there is no need to flush | 374 | * so there is no need to flush |
375 | */ | 375 | */ |
376 | if (m_syncing ) { | 376 | if (m_syncing ) { |
377 | e->accept(); | 377 | e->accept(); |
378 | return; | 378 | return; |
379 | } | 379 | } |
380 | bool quit = false; | 380 | bool quit = false; |
381 | if ( m_todoMgr.saveAll() ){ | 381 | if ( m_todoMgr.saveAll() ){ |
382 | qWarning("saved"); | 382 | qWarning("saved"); |
383 | quit = true; | 383 | quit = true; |
384 | }else { | 384 | }else { |
385 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), | 385 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), |
386 | QWidget::tr("Todo was unable\n" | 386 | QWidget::tr("Todo was unable\n" |
387 | "to save your changes.\n" | 387 | "to save your changes.\n" |
388 | "Free up some space\n" | 388 | "Free up some space\n" |
389 | "and try again.\n" | 389 | "and try again.\n" |
390 | "\nQuit Anyway?"), | 390 | "\nQuit Anyway?"), |
391 | QMessageBox::Yes|QMessageBox::Escape, | 391 | QMessageBox::Yes|QMessageBox::Escape, |
392 | QMessageBox::No|QMessageBox::Default) | 392 | QMessageBox::No|QMessageBox::Default) |
393 | != QMessageBox::No ) { | 393 | != QMessageBox::No ) { |
394 | e->accept(); | 394 | e->accept(); |
395 | quit = true; | 395 | quit = true; |
396 | }else | 396 | }else |
397 | e->ignore(); | 397 | e->ignore(); |
398 | 398 | ||
399 | } | 399 | } |
400 | 400 | ||
401 | if (quit ) { | 401 | if (quit ) { |
402 | Config config( "todo" ); | 402 | Config config( "todo" ); |
403 | config.setGroup( "View" ); | 403 | config.setGroup( "View" ); |
404 | config.writeEntry( "ShowComplete", showCompleted() ); | 404 | config.writeEntry( "ShowComplete", showCompleted() ); |
405 | config.writeEntry( "Category", currentCategory() ); | 405 | config.writeEntry( "Category", currentCategory() ); |
406 | config.writeEntry( "ShowDeadLine", showDeadline()); | 406 | config.writeEntry( "ShowDeadLine", showDeadline()); |
407 | config.writeEntry( "ShowOverDue", showOverDue() ); | 407 | config.writeEntry( "ShowOverDue", showOverDue() ); |
408 | config.writeEntry( "ShowQuickTask", showQuickTask() ); | 408 | config.writeEntry( "ShowQuickTask", showQuickTask() ); |
409 | /* save templates */ | 409 | /* save templates */ |
410 | templateManager()->save(); | 410 | templateManager()->save(); |
411 | e->accept(); | 411 | e->accept(); |
412 | qApp->quit(); | 412 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); |
413 | } | 413 | } |
414 | } | 414 | } |
415 | void MainWindow::populateTemplates() { | 415 | void MainWindow::populateTemplates() { |
416 | m_template->clear(); | 416 | m_template->clear(); |
417 | QStringList list = templateManager()->templates(); | 417 | QStringList list = templateManager()->templates(); |
418 | QStringList::Iterator it; | 418 | QStringList::Iterator it; |
419 | for ( it = list.begin(); it != list.end(); ++it ) { | 419 | for ( it = list.begin(); it != list.end(); ++it ) { |
420 | m_template->insertItem( (*it) ); | 420 | m_template->insertItem( (*it) ); |
421 | } | 421 | } |
422 | } | 422 | } |
423 | /* | 423 | /* |
424 | * slotNewFromTemplate | 424 | * slotNewFromTemplate |
425 | * We use the edit widget to do | 425 | * We use the edit widget to do |
426 | * the config but we setUid(1) | 426 | * the config but we setUid(1) |
427 | * to get a new uid | 427 | * to get a new uid |
428 | */ | 428 | */ |
429 | /* | 429 | /* |
430 | * first we get the name of the template | 430 | * first we get the name of the template |
431 | * then we will use the TemplateManager | 431 | * then we will use the TemplateManager |
432 | */ | 432 | */ |
433 | void MainWindow::slotNewFromTemplate( int id ) { | 433 | void MainWindow::slotNewFromTemplate( int id ) { |
434 | QString name = m_template->text( id ); | 434 | QString name = m_template->text( id ); |
435 | 435 | ||
436 | OTodo event = templateManager()->templateEvent( name ); | 436 | OTodo event = templateManager()->templateEvent( name ); |
437 | event = currentEditor()->edit(this, | 437 | event = currentEditor()->edit(this, |
438 | event ); | 438 | event ); |
439 | 439 | ||
440 | if ( currentEditor()->accepted() ) { | 440 | if ( currentEditor()->accepted() ) { |
441 | /* assign new todo */ | 441 | /* assign new todo */ |
442 | event.setUid( 1 ); | 442 | event.setUid( 1 ); |
443 | handleAlarms( OTodo(), event ); | 443 | handleAlarms( OTodo(), event ); |
444 | m_todoMgr.add( event ); | 444 | m_todoMgr.add( event ); |
445 | currentView()->addEvent( event ); | 445 | currentView()->addEvent( event ); |
446 | 446 | ||
447 | populateCategories(); | 447 | populateCategories(); |
448 | } | 448 | } |
449 | raiseCurrentView(); | 449 | raiseCurrentView(); |
450 | } | 450 | } |
451 | void MainWindow::slotNew() { | 451 | void MainWindow::slotNew() { |
452 | create(); | 452 | create(); |
453 | } | 453 | } |
454 | void MainWindow::slotDuplicate() { | 454 | void MainWindow::slotDuplicate() { |
455 | if(m_syncing) { | 455 | if(m_syncing) { |
456 | QMessageBox::warning(this, QWidget::tr("Todo"), | 456 | QMessageBox::warning(this, QWidget::tr("Todo"), |
457 | QWidget::tr("Data can not be edited, currently syncing")); | 457 | QWidget::tr("Data can not be edited, currently syncing")); |
458 | return; | 458 | return; |
459 | } | 459 | } |
460 | OTodo ev = m_todoMgr.event( currentView()->current() ); | 460 | OTodo ev = m_todoMgr.event( currentView()->current() ); |
461 | /* let's generate a new uid */ | 461 | /* let's generate a new uid */ |
462 | ev.setUid(1); | 462 | ev.setUid(1); |
463 | m_todoMgr.add( ev ); | 463 | m_todoMgr.add( ev ); |
464 | 464 | ||
465 | currentView()->addEvent( ev ); | 465 | currentView()->addEvent( ev ); |
466 | raiseCurrentView(); | 466 | raiseCurrentView(); |
467 | } | 467 | } |
468 | void MainWindow::slotDelete() { | 468 | void MainWindow::slotDelete() { |
469 | if (!currentView()->current() ) | 469 | if (!currentView()->current() ) |
470 | return; | 470 | return; |
471 | 471 | ||
472 | if(m_syncing) { | 472 | if(m_syncing) { |
473 | QMessageBox::warning(this, QWidget::tr("Todo"), | 473 | QMessageBox::warning(this, QWidget::tr("Todo"), |
474 | QWidget::tr("Data can not be edited, currently syncing")); | 474 | QWidget::tr("Data can not be edited, currently syncing")); |
475 | return; | 475 | return; |
476 | } | 476 | } |
477 | QString strName = currentView()->currentRepresentation(); | 477 | QString strName = currentView()->currentRepresentation(); |
478 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) | 478 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) |
479 | return; | 479 | return; |
480 | 480 | ||
481 | handleAlarms( m_todoMgr.event( currentView()->current() ), OTodo() ); | 481 | handleAlarms( m_todoMgr.event( currentView()->current() ), OTodo() ); |
482 | m_todoMgr.remove( currentView()->current() ); | 482 | m_todoMgr.remove( currentView()->current() ); |
483 | currentView()->removeEvent( currentView()->current() ); | 483 | currentView()->removeEvent( currentView()->current() ); |
484 | raiseCurrentView(); | 484 | raiseCurrentView(); |
485 | } | 485 | } |
486 | void MainWindow::slotDelete(int uid ) { | 486 | void MainWindow::slotDelete(int uid ) { |
487 | if( uid == 0 ) return; | 487 | if( uid == 0 ) return; |
488 | if(m_syncing) { | 488 | if(m_syncing) { |
489 | QMessageBox::warning(this, QWidget::tr("Todo"), | 489 | QMessageBox::warning(this, QWidget::tr("Todo"), |
490 | QWidget::tr("Data can not be edited, currently syncing")); | 490 | QWidget::tr("Data can not be edited, currently syncing")); |
491 | return; | 491 | return; |
492 | } | 492 | } |
493 | OTodo to = m_todoMgr.event(uid); | 493 | OTodo to = m_todoMgr.event(uid); |
494 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) | 494 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) |
495 | return; | 495 | return; |
496 | 496 | ||
497 | handleAlarms(to, OTodo() ); | 497 | handleAlarms(to, OTodo() ); |
498 | m_todoMgr.remove( to.uid() ); | 498 | m_todoMgr.remove( to.uid() ); |
499 | currentView()->removeEvent( to.uid() ); | 499 | currentView()->removeEvent( to.uid() ); |
500 | raiseCurrentView(); | 500 | raiseCurrentView(); |
501 | } | 501 | } |
502 | void MainWindow::slotDeleteAll() { | 502 | void MainWindow::slotDeleteAll() { |
503 | if(m_syncing) { | 503 | if(m_syncing) { |
504 | QMessageBox::warning(this, QWidget::tr("Todo"), | 504 | QMessageBox::warning(this, QWidget::tr("Todo"), |
505 | QWidget::tr("Data can not be edited, currently syncing")); | 505 | QWidget::tr("Data can not be edited, currently syncing")); |
506 | return; | 506 | return; |
507 | } | 507 | } |
508 | 508 | ||
509 | 509 | ||
510 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) | 510 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) |
511 | return; | 511 | return; |
512 | 512 | ||
513 | m_todoMgr.removeAll(); | 513 | m_todoMgr.removeAll(); |
514 | currentView()->clear(); | 514 | currentView()->clear(); |
515 | 515 | ||
516 | raiseCurrentView(); | 516 | raiseCurrentView(); |
517 | } | 517 | } |
518 | void MainWindow::slotDeleteCompleted() { | 518 | void MainWindow::slotDeleteCompleted() { |
519 | if(m_syncing) { | 519 | if(m_syncing) { |
520 | QMessageBox::warning(this, QWidget::tr("Todo"), | 520 | QMessageBox::warning(this, QWidget::tr("Todo"), |
521 | QWidget::tr("Data can not be edited, currently syncing")); | 521 | QWidget::tr("Data can not be edited, currently syncing")); |
522 | return; | 522 | return; |
523 | } | 523 | } |
524 | 524 | ||
525 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) | 525 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) |
526 | return; | 526 | return; |
527 | 527 | ||
528 | 528 | ||
529 | m_todoMgr.removeCompleted(); | 529 | m_todoMgr.removeCompleted(); |
530 | currentView()->updateView( ); | 530 | currentView()->updateView( ); |
531 | } | 531 | } |
532 | void MainWindow::slotFind() { | 532 | void MainWindow::slotFind() { |
533 | 533 | ||
534 | } | 534 | } |
535 | void MainWindow::slotEdit() { | 535 | void MainWindow::slotEdit() { |
536 | slotEdit( currentView()->current() ); | 536 | slotEdit( currentView()->current() ); |
537 | } | 537 | } |
538 | /* | 538 | /* |
539 | * set the category | 539 | * set the category |
540 | */ | 540 | */ |