Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index fa509d9..47be523 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -399,12 +399,69 @@ void DateBook::viewWeekLst() { | |||
399 | } | 399 | } |
400 | 400 | ||
401 | void DateBook::viewMonth() { | 401 | void DateBook::viewMonth() { |
402 | view(MONTH,currentDate()); | 402 | view(MONTH,currentDate()); |
403 | } | 403 | } |
404 | 404 | ||
405 | void DateBook::duplicateEvent( const Event &e ) | ||
406 | { | ||
407 | qWarning("Hmmm..."); | ||
408 | // Alot of code duplication, as this is almost like editEvent(); | ||
409 | if (syncing) { | ||
410 | QMessageBox::warning( this, tr("Calendar"), | ||
411 | tr( "Can not edit data, currently syncing") ); | ||
412 | return; | ||
413 | } | ||
414 | |||
415 | Event dupevent; | ||
416 | dupevent.setStart(e.start()); | ||
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. | ||
428 | QDialog editDlg( this, 0, TRUE ); | ||
429 | DateEntry *entry; | ||
430 | editDlg.setCaption( tr("Duplicate Event") ); | ||
431 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | ||
432 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | ||
433 | sv->setResizePolicy( QScrollView::AutoOneFit ); | ||
434 | // KLUDGE!!! | ||
435 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | ||
436 | vb->addWidget( sv ); | ||
437 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); | ||
438 | entry->timezone->setEnabled( FALSE ); | ||
439 | sv->addChild( entry ); | ||
440 | |||
441 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | ||
442 | editDlg.showMaximized(); | ||
443 | #endif | ||
444 | while (editDlg.exec() ) { | ||
445 | Event newEv = entry->event(); | ||
446 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) | ||
447 | break; | ||
448 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | ||
449 | QString error = checkEvent(newEv); | ||
450 | if (!error.isNull()) { | ||
451 | if (QMessageBox::warning(this, "error box", | ||
452 | error, "Fix it", "Continue", | ||
453 | 0, 0, 1) == 0) | ||
454 | continue; | ||
455 | } | ||
456 | db->addEvent(newEv); | ||
457 | emit newEvent(); | ||
458 | break; | ||
459 | } | ||
460 | } | ||
461 | |||
405 | void DateBook::editEvent( const Event &e ) | 462 | void DateBook::editEvent( const Event &e ) |
406 | { | 463 | { |
407 | if (syncing) { | 464 | if (syncing) { |
408 | QMessageBox::warning( this, tr("Calendar"), | 465 | QMessageBox::warning( this, tr("Calendar"), |
409 | tr( "Can not edit data, currently syncing") ); | 466 | tr( "Can not edit data, currently syncing") ); |
410 | return; | 467 | return; |
@@ -489,12 +546,14 @@ void DateBook::initDay() | |||
489 | connect( dayView, SIGNAL( newEvent() ), | 546 | connect( dayView, SIGNAL( newEvent() ), |
490 | this, SLOT( fileNew() ) ); | 547 | this, SLOT( fileNew() ) ); |
491 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), | 548 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), |
492 | this, SLOT( removeEvent( const Event & ) ) ); | 549 | this, SLOT( removeEvent( const Event & ) ) ); |
493 | connect( dayView, SIGNAL( editEvent( const Event & ) ), | 550 | connect( dayView, SIGNAL( editEvent( const Event & ) ), |
494 | this, SLOT( editEvent( const Event & ) ) ); | 551 | this, SLOT( editEvent( const Event & ) ) ); |
552 | connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), | ||
553 | this, SLOT( duplicateEvent( const Event & ) ) ); | ||
495 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), | 554 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), |
496 | this, SLOT( beamEvent( const Event & ) ) ); | 555 | this, SLOT( beamEvent( const Event & ) ) ); |
497 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), | 556 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), |
498 | this, SLOT(slotNewEventFromKey(const QString &)) ); | 557 | this, SLOT(slotNewEventFromKey(const QString &)) ); |
499 | } | 558 | } |
500 | } | 559 | } |
@@ -813,13 +872,13 @@ void DateBook::slotNewEventFromKey( const QString &str ) | |||
813 | start = end = d; | 872 | start = end = d; |
814 | start.setTime( QTime( 10, 0 ) ); | 873 | start.setTime( QTime( 10, 0 ) ); |
815 | end.setTime( QTime( 12, 0 ) ); | 874 | end.setTime( QTime( 12, 0 ) ); |
816 | } | 875 | } |
817 | slotNewEntry(start, end, str); | 876 | slotNewEntry(start, end, str); |
818 | } | 877 | } |
819 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { | 878 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { |
820 | // argh! This really needs to be encapsulated in a class | 879 | // argh! This really needs to be encapsulated in a class |
821 | // or function. | 880 | // or function. |
822 | QDialog newDlg( this, 0, TRUE ); | 881 | QDialog newDlg( this, 0, TRUE ); |
823 | newDlg.setCaption( DateEntryBase::tr("New Event") ); | 882 | newDlg.setCaption( DateEntryBase::tr("New Event") ); |
824 | DateEntry *e; | 883 | DateEntry *e; |
825 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); | 884 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); |
@@ -829,13 +888,17 @@ void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const | |||
829 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 888 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
830 | vb->addWidget( sv ); | 889 | vb->addWidget( sv ); |
831 | 890 | ||
832 | Event ev; | 891 | Event ev; |
833 | ev.setDescription( str ); | 892 | ev.setDescription( str ); |
834 | // When the new gui comes in, change this... | 893 | // When the new gui comes in, change this... |
835 | ev.setLocation( tr("(Unknown)") ); | 894 | if(location==0) { |
895 | ev.setLocation( tr("(Unknown)") ); | ||
896 | } else { | ||
897 | ev.setLocation(location); | ||
898 | } | ||
836 | ev.setStart( start ); | 899 | ev.setStart( start ); |
837 | ev.setEnd( end ); | 900 | ev.setEnd( end ); |
838 | 901 | ||
839 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); | 902 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); |
840 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); | 903 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); |
841 | sv->addChild( e ); | 904 | sv->addChild( e ); |