summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2003-03-24 09:06:06 (UTC)
committer umopapisdn <umopapisdn>2003-03-24 09:06:06 (UTC)
commitfea2436fef9e7096b31840e7170a23280f3d6e39 (patch) (side-by-side diff)
tree83bcaeafa071242e4b1d5df76409ff41d9900eac
parent4a0041efd5cc7e08063c09b02858fcd9c2b59880 (diff)
downloadopie-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 (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp67
-rw-r--r--core/pim/datebook/datebook.h3
-rw-r--r--core/pim/datebook/datebookday.cpp29
-rw-r--r--core/pim/datebook/datebookday.h2
4 files changed, 86 insertions, 15 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() {
}
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) {
QMessageBox::warning( this, tr("Calendar"),
tr( "Can not edit data, currently syncing") );
return;
@@ -489,12 +546,14 @@ void DateBook::initDay()
connect( dayView, SIGNAL( newEvent() ),
this, SLOT( fileNew() ) );
connect( dayView, SIGNAL( removeEvent( const Event & ) ),
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 &)),
this, SLOT(slotNewEventFromKey(const QString &)) );
}
}
@@ -813,13 +872,13 @@ void DateBook::slotNewEventFromKey( const QString &str )
start = end = d;
start.setTime( QTime( 10, 0 ) );
end.setTime( QTime( 12, 0 ) );
}
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 );
newDlg.setCaption( DateEntryBase::tr("New Event") );
DateEntry *e;
QVBoxLayout *vb = new QVBoxLayout( &newDlg );
@@ -829,13 +888,17 @@ void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const
sv->setHScrollBarMode( QScrollView::AlwaysOff );
vb->addWidget( sv );
Event ev;
ev.setDescription( str );
// When the new gui comes in, change this...
- ev.setLocation( tr("(Unknown)") );
+ if(location==0) {
+ ev.setLocation( tr("(Unknown)") );
+ } else {
+ ev.setLocation(location);
+ }
ev.setStart( start );
ev.setEnd( end );
e = new DateEntry( onMonday, ev, ampm, &newDlg );
e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
sv->addChild( e );
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index ba8f97e..623862b 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -62,13 +62,13 @@ protected:
public slots:
void flush();
void reload();
private slots:
void fileNew();
- void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str);
+ void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0);
void slotSettings();
void newDefaultView(QAction *a);
void slotToday(); // view today
void changeClock( bool newClock );
void changeWeek( bool newDay );
void appMessage(const QCString& msg, const QByteArray& data);
@@ -84,12 +84,13 @@ private slots:
void viewWeekLst();
void viewMonth();
void showDay( int y, int m, int d );
void editEvent( const Event &e );
+ void duplicateEvent( const Event &e );
void removeEvent( const Event &e );
void receive( const QCString &msg, const QByteArray &data );
void setDocument( const QString & );
void beamEvent( const Event &e );
void beamDone( Ir *ir );
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index 42f026a..5d472a6 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -310,12 +310,14 @@ void DateBookDay::getEvents()
for ( it = eventList.begin(); it != eventList.end(); ++it ) {
EffectiveEvent ev=*it;
if(!(ev.end().hour()==ev.start().hour() && ev.end().minute()==ev.start().minute())) { // Skip effective events with no duration. (i.e ending at 00:00)
DateBookDayWidget* w = new DateBookDayWidget( *it, this );
connect( w, SIGNAL( deleteMe( const Event & ) ),
this, SIGNAL( removeEvent( const Event & ) ) );
+ connect( w, SIGNAL( duplicateMe( const Event & ) ),
+ this, SIGNAL( duplicateEvent( const Event & ) ) );
connect( w, SIGNAL( editMe( const Event & ) ),
this, SIGNAL( editEvent( const Event & ) ) );
connect( w, SIGNAL( beamMe( const Event & ) ),
this, SIGNAL( beamEvent( const Event & ) ) );
widgetList.append( w );
}
@@ -717,24 +719,27 @@ void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
if (item) item->update();
dateBook->setSelectedWidget(this);
update();
dateBook->repaint();
- QPopupMenu m;
- m.insertItem( tr( "Edit" ), 1 );
- m.insertItem( tr( "Delete" ), 2 );
- if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
- int r = m.exec( e->globalPos() );
- if ( r == 1 ) {
- emit editMe( ev.event() );
- } else if ( r == 2 ) {
- emit deleteMe( ev.event() );
- } else if ( r == 3 ) {
- emit beamMe( ev.event() );
- }
+ QPopupMenu m;
+ m.insertItem( tr( "Edit" ), 1 );
+ m.insertItem( tr( "Duplicate" ), 4 );
+ m.insertItem( tr( "Delete" ), 2 );
+ if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
+ int r = m.exec( e->globalPos() );
+ if ( r == 1 ) {
+ emit editMe( ev.event() );
+ } else if ( r == 2 ) {
+ emit deleteMe( ev.event() );
+ } else if ( r == 3 ) {
+ emit beamMe( ev.event() );
+ } else if ( r == 4 ) {
+ emit duplicateMe( ev.event() );
+ }
}
void DateBookDayWidget::setGeometry( const QRect &r )
{
geom = r;
setFixedSize( r.width()+1, r.height()+1 );
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h
index db1cd04..2faf24e 100644
--- a/core/pim/datebook/datebookday.h
+++ b/core/pim/datebook/datebookday.h
@@ -76,12 +76,13 @@ public:
void setGeometry( const QRect &r );
const EffectiveEvent &event() const { return ev; }
signals:
void deleteMe( const Event &e );
+ void duplicateMe( const Event &e );
void editMe( const Event &e );
void beamMe( const Event &e );
protected:
void paintEvent( QPaintEvent *e );
void mousePressEvent( QMouseEvent *e );
@@ -172,12 +173,13 @@ public slots:
void slotWeekChanged( bool bStartOnMonday );
void updateView(); //updates TimeMarker and DayWidget-colors
signals:
void removeEvent( const Event& );
void editEvent( const Event& );
+ void duplicateEvent( const Event& );
void beamEvent( const Event& );
void newEvent();
void sigNewEvent( const QString & );
protected slots:
void keyPressEvent(QKeyEvent *);