summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -362,198 +362,177 @@ void DateBook::view(int v, const QDate &d) {
weekAction->setOn( TRUE );
weekView->setDate( d );
views->raiseWidget( weekView );
weekView->redraw();
} else if (v==WEEKLST) {
initWeekLst();
weekLstAction->setOn( TRUE );
weekLstView->setDate(d);
views->raiseWidget( weekLstView );
weekLstView->redraw();
} else if (v==MONTH) {
initMonth();
monthAction->setOn( TRUE );
monthView->setDate( d.year(), d.month(), d.day() );
views->raiseWidget( monthView );
monthView->redraw();
}
}
void DateBook::viewDefault(const QDate &d) {
Config config("DateBook");
config.setGroup("Main");
int current=config.readNumEntry("defaultview", DAY);
view(current,d);
}
void DateBook::viewDay() {
view(DAY,currentDate());
}
void DateBook::viewWeek() {
view(WEEK,currentDate());
}
void DateBook::viewWeekLst() {
view(WEEKLST,currentDate());
}
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;
+ 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());
-
+
+ Event dupevent(e); // Make a duplicate.
+
// 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 );
+ 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;
+ while (editDlg.exec() ) {
+ Event newEv = entry->event();
+ 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;
}
- 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;
- }
+ if (syncing) {
+ QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
+ return;
+ }
- // workaround added for text input.
- QDialog editDlg( this, 0, TRUE );
- DateEntry *entry;
- editDlg.setCaption( tr("Edit 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, e, ampm, &editDlg, "editor" );
- entry->timezone->setEnabled( FALSE );
- sv->addChild( entry );
+ // workaround added for text input.
+ QDialog editDlg( this, 0, TRUE );
+ DateEntry *entry;
+ editDlg.setCaption( tr("Edit 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, e, ampm, &editDlg, "editor" );
+ entry->timezone->setEnabled( FALSE );
+ sv->addChild( entry );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
- editDlg.showMaximized();
+ 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;
+ 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->editEvent(e, newEv);
emit newEvent();
break;
- }
+ }
}
void DateBook::removeEvent( const Event &e )
{
- if (syncing) {
- QMessageBox::warning( this, tr("Calendar"),
- tr( "Can not edit data, currently syncing") );
- return;
- }
+ if (syncing) {
+ QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
+ return;
+ }
QString strName = e.description();
if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
return;
db->removeEvent( e );
if ( views->visibleWidget() == dayView && dayView )
dayView->redraw();
}
void DateBook::addEvent( const Event &e )
{
QDate d = e.start().date();
initDay();
dayView->setDate( d );
}
void DateBook::showDay( int year, int month, int day )
{
QDate d(year, month, day);
view(DAY,d);
}
void DateBook::initDay()
{
if ( !dayView ) {
dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
views->addWidget( dayView, DAY );
dayView->setStartViewTime( startTime );
dayView->setJumpToCurTime( bJumpToCurTime );
dayView->setRowStyle( rowStyle );
connect( this, SIGNAL( newEvent() ),
dayView, SLOT( redraw() ) );
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 &)) );
}
}