summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2003-04-12 00:22:57 (UTC)
committer umopapisdn <umopapisdn>2003-04-12 00:22:57 (UTC)
commit59e2de381eebb33238ee1b257736a9ae0afdbb7e (patch) (unidiff)
treeb86025f2f75318aba65534048105cec36d4b7766
parentd37f3eac6b876285eb7a03ab01194ea261458ea5 (diff)
downloadopie-59e2de381eebb33238ee1b257736a9ae0afdbb7e.zip
opie-59e2de381eebb33238ee1b257736a9ae0afdbb7e.tar.gz
opie-59e2de381eebb33238ee1b257736a9ae0afdbb7e.tar.bz2
Bugfix: (bug #0000833) Duplicating an event should also duplicate the category.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp137
1 files changed, 58 insertions, 79 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 3e18374..1bc82a5 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -346,230 +346,209 @@ QDate DateBook::currentDate()
346 } else if ( monthView && views->visibleWidget() == monthView ) { 346 } else if ( monthView && views->visibleWidget() == monthView ) {
347 d = monthView->selectedDate(); 347 d = monthView->selectedDate();
348 } 348 }
349 349
350 return d; 350 return d;
351} 351}
352 352
353void DateBook::view(int v, const QDate &d) { 353void DateBook::view(int v, const QDate &d) {
354 if (v==DAY) { 354 if (v==DAY) {
355 initDay(); 355 initDay();
356 dayAction->setOn( TRUE ); 356 dayAction->setOn( TRUE );
357 dayView->setDate( d ); 357 dayView->setDate( d );
358 views->raiseWidget( dayView ); 358 views->raiseWidget( dayView );
359 dayView->redraw(); 359 dayView->redraw();
360 } else if (v==WEEK) { 360 } else if (v==WEEK) {
361 initWeek(); 361 initWeek();
362 weekAction->setOn( TRUE ); 362 weekAction->setOn( TRUE );
363 weekView->setDate( d ); 363 weekView->setDate( d );
364 views->raiseWidget( weekView ); 364 views->raiseWidget( weekView );
365 weekView->redraw(); 365 weekView->redraw();
366 } else if (v==WEEKLST) { 366 } else if (v==WEEKLST) {
367 initWeekLst(); 367 initWeekLst();
368 weekLstAction->setOn( TRUE ); 368 weekLstAction->setOn( TRUE );
369 weekLstView->setDate(d); 369 weekLstView->setDate(d);
370 views->raiseWidget( weekLstView ); 370 views->raiseWidget( weekLstView );
371 weekLstView->redraw(); 371 weekLstView->redraw();
372 } else if (v==MONTH) { 372 } else if (v==MONTH) {
373 initMonth(); 373 initMonth();
374 monthAction->setOn( TRUE ); 374 monthAction->setOn( TRUE );
375 monthView->setDate( d.year(), d.month(), d.day() ); 375 monthView->setDate( d.year(), d.month(), d.day() );
376 views->raiseWidget( monthView ); 376 views->raiseWidget( monthView );
377 monthView->redraw(); 377 monthView->redraw();
378 } 378 }
379} 379}
380 380
381void DateBook::viewDefault(const QDate &d) { 381void DateBook::viewDefault(const QDate &d) {
382 Config config("DateBook"); 382 Config config("DateBook");
383 config.setGroup("Main"); 383 config.setGroup("Main");
384 int current=config.readNumEntry("defaultview", DAY); 384 int current=config.readNumEntry("defaultview", DAY);
385 385
386 view(current,d); 386 view(current,d);
387} 387}
388 388
389void DateBook::viewDay() { 389void DateBook::viewDay() {
390 view(DAY,currentDate()); 390 view(DAY,currentDate());
391} 391}
392 392
393void DateBook::viewWeek() { 393void DateBook::viewWeek() {
394 view(WEEK,currentDate()); 394 view(WEEK,currentDate());
395} 395}
396 396
397void DateBook::viewWeekLst() { 397void DateBook::viewWeekLst() {
398 view(WEEKLST,currentDate()); 398 view(WEEKLST,currentDate());
399} 399}
400 400
401void DateBook::viewMonth() { 401void DateBook::viewMonth() {
402 view(MONTH,currentDate()); 402 view(MONTH,currentDate());
403} 403}
404 404
405void DateBook::duplicateEvent( const Event &e ) 405void DateBook::duplicateEvent( const Event &e )
406{ 406{
407 qWarning("Hmmm..."); 407 qWarning("Hmmm...");
408 // Alot of code duplication, as this is almost like editEvent(); 408 // Alot of code duplication, as this is almost like editEvent();
409 if (syncing) { 409 if (syncing) {
410 QMessageBox::warning( this, tr("Calendar"), 410 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
411 tr( "Can not edit data, currently syncing") ); 411 return;
412 return;
413 } 412 }
414 413
415 Event dupevent; 414 Event dupevent(e);// Make a duplicate.
416 dupevent.setStart(e.start()); 415
417 dupevent.setEnd(e.end());
418 dupevent.setDescription(e.description());
419 dupevent.setLocation(e.location());
420 // dupevent.setCategory(e.category());// how is this done??
421 dupevent.setNotes(e.notes());
422 dupevent.setAllDay(e.isAllDay());
423 dupevent.setTimeZone(e.timeZone());
424 if(e.hasAlarm()) dupevent.setAlarm(e.alarmDelay(),e.alarmSound());
425 if(e.hasRepeat()) dupevent.setRepeat(e.repeatPattern());
426
427 // workaround added for text input. 416 // workaround added for text input.
428 QDialog editDlg( this, 0, TRUE ); 417 QDialog editDlg( this, 0, TRUE );
429 DateEntry *entry; 418 DateEntry *entry;
430 editDlg.setCaption( tr("Duplicate Event") ); 419 editDlg.setCaption( tr("Duplicate Event") );
431 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 420 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
432 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 421 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
433 sv->setResizePolicy( QScrollView::AutoOneFit ); 422 sv->setResizePolicy( QScrollView::AutoOneFit );
434 // KLUDGE!!! 423 // KLUDGE!!!
435 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 424 sv->setHScrollBarMode( QScrollView::AlwaysOff );
436 vb->addWidget( sv ); 425 vb->addWidget( sv );
437 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 426 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
438 entry->timezone->setEnabled( FALSE ); 427 entry->timezone->setEnabled( FALSE );
439 sv->addChild( entry ); 428 sv->addChild( entry );
440 429
441#if defined(Q_WS_QWS) || defined(_WS_QWS_) 430#if defined(Q_WS_QWS) || defined(_WS_QWS_)
442 editDlg.showMaximized(); 431 editDlg.showMaximized();
443#endif 432#endif
444 while (editDlg.exec() ) { 433 while (editDlg.exec() ) {
445 Event newEv = entry->event(); 434 Event newEv = entry->event();
446 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 435 QString error = checkEvent(newEv);
447 break; 436 if (!error.isNull()) {
448 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 437 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0)
449 QString error = checkEvent(newEv); 438 continue;
450 if (!error.isNull()) { 439 }
451 if (QMessageBox::warning(this, "error box", 440 db->addEvent(newEv);
452 error, "Fix it", "Continue", 441 emit newEvent();
453 0, 0, 1) == 0) 442 break;
454 continue;
455 } 443 }
456 db->addEvent(newEv);
457 emit newEvent();
458 break;
459 }
460} 444}
461 445
462void DateBook::editEvent( const Event &e ) 446void DateBook::editEvent( const Event &e )
463{ 447{
464 if (syncing) { 448 if (syncing) {
465 QMessageBox::warning( this, tr("Calendar"), 449 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
466 tr( "Can not edit data, currently syncing") ); 450 return;
467 return; 451 }
468 }
469 452
470 // workaround added for text input. 453 // workaround added for text input.
471 QDialog editDlg( this, 0, TRUE ); 454 QDialog editDlg( this, 0, TRUE );
472 DateEntry *entry; 455 DateEntry *entry;
473 editDlg.setCaption( tr("Edit Event") ); 456 editDlg.setCaption( tr("Edit Event") );
474 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 457 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
475 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 458 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
476 sv->setResizePolicy( QScrollView::AutoOneFit ); 459 sv->setResizePolicy( QScrollView::AutoOneFit );
477 // KLUDGE!!! 460 // KLUDGE!!!
478 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 461 sv->setHScrollBarMode( QScrollView::AlwaysOff );
479 vb->addWidget( sv ); 462 vb->addWidget( sv );
480 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 463 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
481 entry->timezone->setEnabled( FALSE ); 464 entry->timezone->setEnabled( FALSE );
482 sv->addChild( entry ); 465 sv->addChild( entry );
483 466
484#if defined(Q_WS_QWS) || defined(_WS_QWS_) 467#if defined(Q_WS_QWS) || defined(_WS_QWS_)
485 editDlg.showMaximized(); 468 editDlg.showMaximized();
486#endif 469#endif
487 while (editDlg.exec() ) { 470 while (editDlg.exec() ) {
488 Event newEv = entry->event(); 471 Event newEv = entry->event();
489 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 472 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
490 break; 473 break;
491 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 474 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
492 QString error = checkEvent(newEv); 475 QString error = checkEvent(newEv);
493 if (!error.isNull()) { 476 if (!error.isNull()) {
494 if (QMessageBox::warning(this, "error box", 477 if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue;
495 error, "Fix it", "Continue",
496 0, 0, 1) == 0)
497 continue;
498 } 478 }
499 db->editEvent(e, newEv); 479 db->editEvent(e, newEv);
500 emit newEvent(); 480 emit newEvent();
501 break; 481 break;
502 } 482 }
503} 483}
504 484
505void DateBook::removeEvent( const Event &e ) 485void DateBook::removeEvent( const Event &e )
506{ 486{
507 if (syncing) { 487 if (syncing) {
508 QMessageBox::warning( this, tr("Calendar"), 488 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
509 tr( "Can not edit data, currently syncing") ); 489 return;
510 return; 490 }
511 }
512 491
513 QString strName = e.description(); 492 QString strName = e.description();
514 493
515 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 494 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
516 return; 495 return;
517 496
518 db->removeEvent( e ); 497 db->removeEvent( e );
519 if ( views->visibleWidget() == dayView && dayView ) 498 if ( views->visibleWidget() == dayView && dayView )
520 dayView->redraw(); 499 dayView->redraw();
521} 500}
522 501
523void DateBook::addEvent( const Event &e ) 502void DateBook::addEvent( const Event &e )
524{ 503{
525 QDate d = e.start().date(); 504 QDate d = e.start().date();
526 initDay(); 505 initDay();
527 dayView->setDate( d ); 506 dayView->setDate( d );
528} 507}
529 508
530void DateBook::showDay( int year, int month, int day ) 509void DateBook::showDay( int year, int month, int day )
531{ 510{
532 QDate d(year, month, day); 511 QDate d(year, month, day);
533 view(DAY,d); 512 view(DAY,d);
534} 513}
535 514
536void DateBook::initDay() 515void DateBook::initDay()
537{ 516{
538 if ( !dayView ) { 517 if ( !dayView ) {
539 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 518 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
540 views->addWidget( dayView, DAY ); 519 views->addWidget( dayView, DAY );
541 dayView->setStartViewTime( startTime ); 520 dayView->setStartViewTime( startTime );
542 dayView->setJumpToCurTime( bJumpToCurTime ); 521 dayView->setJumpToCurTime( bJumpToCurTime );
543 dayView->setRowStyle( rowStyle ); 522 dayView->setRowStyle( rowStyle );
544 connect( this, SIGNAL( newEvent() ), 523 connect( this, SIGNAL( newEvent() ),
545 dayView, SLOT( redraw() ) ); 524 dayView, SLOT( redraw() ) );
546 connect( dayView, SIGNAL( newEvent() ), 525 connect( dayView, SIGNAL( newEvent() ),
547 this, SLOT( fileNew() ) ); 526 this, SLOT( fileNew() ) );
548 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 527 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
549 this, SLOT( removeEvent( const Event & ) ) ); 528 this, SLOT( removeEvent( const Event & ) ) );
550 connect( dayView, SIGNAL( editEvent( const Event & ) ), 529 connect( dayView, SIGNAL( editEvent( const Event & ) ),
551 this, SLOT( editEvent( const Event & ) ) ); 530 this, SLOT( editEvent( const Event & ) ) );
552 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), 531 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ),
553 this, SLOT( duplicateEvent( const Event & ) ) ); 532 this, SLOT( duplicateEvent( const Event & ) ) );
554 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 533 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
555 this, SLOT( beamEvent( const Event & ) ) ); 534 this, SLOT( beamEvent( const Event & ) ) );
556 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 535 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
557 this, SLOT(slotNewEventFromKey(const QString &)) ); 536 this, SLOT(slotNewEventFromKey(const QString &)) );
558 } 537 }
559} 538}
560 539
561void DateBook::initWeek() 540void DateBook::initWeek()
562{ 541{
563 if ( !weekView ) { 542 if ( !weekView ) {
564 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 543 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
565 weekView->setStartViewTime( startTime ); 544 weekView->setStartViewTime( startTime );
566 views->addWidget( weekView, WEEK ); 545 views->addWidget( weekView, WEEK );
567 connect( weekView, SIGNAL( showDate( int, int, int ) ), 546 connect( weekView, SIGNAL( showDate( int, int, int ) ),
568 this, SLOT( showDay( int, int, int ) ) ); 547 this, SLOT( showDay( int, int, int ) ) );
569 connect( this, SIGNAL( newEvent() ), 548 connect( this, SIGNAL( newEvent() ),
570 weekView, SLOT( redraw() ) ); 549 weekView, SLOT( redraw() ) );
571 } 550 }
572 //But also get it right: the year that we display can be different 551 //But also get it right: the year that we display can be different
573 //from the year of the current date. So, first find the year 552 //from the year of the current date. So, first find the year
574 //number of the current week. 553 //number of the current week.
575 554