author | umopapisdn <umopapisdn> | 2003-03-24 09:06:06 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-03-24 09:06:06 (UTC) |
commit | fea2436fef9e7096b31840e7170a23280f3d6e39 (patch) (side-by-side diff) | |
tree | 83bcaeafa071242e4b1d5df76409ff41d9900eac /core/pim/datebook/datebook.cpp | |
parent | 4a0041efd5cc7e08063c09b02858fcd9c2b59880 (diff) | |
download | opie-fea2436fef9e7096b31840e7170a23280f3d6e39.zip opie-fea2436fef9e7096b31840e7170a23280f3d6e39.tar.gz opie-fea2436fef9e7096b31840e7170a23280f3d6e39.tar.bz2 |
New feature: In dayview it's now possible to duplicate an event (and immediatly change some parameters for the duplicate).
Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 65 |
1 files changed, 64 insertions, 1 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 @@ -402,6 +402,63 @@ void DateBook::viewMonth() { view(MONTH,currentDate()); } +void DateBook::duplicateEvent( const Event &e ) +{ + qWarning("Hmmm..."); + // Alot of code duplication, as this is almost like editEvent(); + if (syncing) { + QMessageBox::warning( this, tr("Calendar"), + tr( "Can not edit data, currently syncing") ); + return; + } + + Event dupevent; + dupevent.setStart(e.start()); + dupevent.setEnd(e.end()); + dupevent.setDescription(e.description()); + dupevent.setLocation(e.location()); +// dupevent.setCategory(e.category()); // how is this done?? + dupevent.setNotes(e.notes()); + dupevent.setAllDay(e.isAllDay()); + dupevent.setTimeZone(e.timeZone()); + if(e.hasAlarm()) dupevent.setAlarm(e.alarmDelay(),e.alarmSound()); + if(e.hasRepeat()) dupevent.setRepeat(e.repeatPattern()); + + // workaround added for text input. + QDialog editDlg( this, 0, TRUE ); + DateEntry *entry; + editDlg.setCaption( tr("Duplicate Event") ); + QVBoxLayout *vb = new QVBoxLayout( &editDlg ); + QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); + sv->setResizePolicy( QScrollView::AutoOneFit ); + // KLUDGE!!! + sv->setHScrollBarMode( QScrollView::AlwaysOff ); + vb->addWidget( sv ); + entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); + entry->timezone->setEnabled( FALSE ); + sv->addChild( entry ); + +#if defined(Q_WS_QWS) || defined(_WS_QWS_) + editDlg.showMaximized(); +#endif + while (editDlg.exec() ) { + Event newEv = entry->event(); + if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) + break; + newEv.setUid(e.uid()); // FIXME: Hack not to clear uid + QString error = checkEvent(newEv); + if (!error.isNull()) { + if (QMessageBox::warning(this, "error box", + error, "Fix it", "Continue", + 0, 0, 1) == 0) + continue; + } + db->addEvent(newEv); + emit newEvent(); + break; + } +} + void DateBook::editEvent( const Event &e ) { if (syncing) { @@ -492,6 +549,8 @@ void DateBook::initDay() this, SLOT( removeEvent( const Event & ) ) ); connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); + connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), + this, SLOT( duplicateEvent( const Event & ) ) ); connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); connect( dayView, SIGNAL(sigNewEvent(const QString &)), @@ -816,7 +875,7 @@ void DateBook::slotNewEventFromKey( const QString &str ) } slotNewEntry(start, end, str); } -void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { +void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { // argh! This really needs to be encapsulated in a class // or function. QDialog newDlg( this, 0, TRUE ); @@ -832,7 +891,11 @@ void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const Event ev; ev.setDescription( str ); // When the new gui comes in, change this... + if(location==0) { ev.setLocation( tr("(Unknown)") ); + } else { + ev.setLocation(location); + } ev.setStart( start ); ev.setEnd( end ); |