Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 10a9b59..07d7164 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -171,48 +171,50 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
171 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); | 171 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); |
172 | if(defaultView==WEEKLST) viewWeekLst(); | 172 | if(defaultView==WEEKLST) viewWeekLst(); |
173 | if(defaultView==MONTH) viewMonth(); | 173 | if(defaultView==MONTH) viewMonth(); |
174 | 174 | ||
175 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | 175 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); |
176 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); | 176 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); |
177 | 177 | ||
178 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 178 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
179 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 179 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); |
180 | #endif | 180 | #endif |
181 | 181 | ||
182 | // listen on QPE/System | 182 | // listen on QPE/System |
183 | #if defined(Q_WS_QWS) | 183 | #if defined(Q_WS_QWS) |
184 | #if !defined(QT_NO_COP) | 184 | #if !defined(QT_NO_COP) |
185 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 185 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
186 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 186 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); |
187 | channel = new QCopChannel( "QPE/Datebook", this ); | 187 | channel = new QCopChannel( "QPE/Datebook", this ); |
188 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 188 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); |
189 | qDebug("olle\n"); | 189 | qDebug("olle\n"); |
190 | #endif | 190 | #endif |
191 | #endif | 191 | #endif |
192 | 192 | ||
193 | qDebug("done t=%d", t.elapsed() ); | 193 | qDebug("done t=%d", t.elapsed() ); |
194 | 194 | ||
195 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | ||
196 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); | ||
195 | /* | 197 | /* |
196 | * Here is a problem description: | 198 | * Here is a problem description: |
197 | * When Weekview is the default view | 199 | * When Weekview is the default view |
198 | * a DateBookWeekView get's created | 200 | * a DateBookWeekView get's created |
199 | * redraw() get's called. So what? | 201 | * redraw() get's called. So what? |
200 | * Remember that we're still in the c'tor | 202 | * Remember that we're still in the c'tor |
201 | * and no final layout has happened? Ok | 203 | * and no final layout has happened? Ok |
202 | * now all Events get arranged. Their x | 204 | * now all Events get arranged. Their x |
203 | * position get's determined by a QHeader | 205 | * position get's determined by a QHeader |
204 | * position. But the QHeader isn't layouted or | 206 | * position. But the QHeader isn't layouted or |
205 | * at the right position. redraw() is a slot | 207 | * at the right position. redraw() is a slot |
206 | * so we'll call it then via a singleShot | 208 | * so we'll call it then via a singleShot |
207 | * from view() | 209 | * from view() |
208 | */ | 210 | */ |
209 | if( needEvilHack ){ | 211 | if( needEvilHack ){ |
210 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); | 212 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); |
211 | } | 213 | } |
212 | } | 214 | } |
213 | 215 | ||
214 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 216 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
215 | { | 217 | { |
216 | QDataStream stream( data, IO_ReadOnly ); | 218 | QDataStream stream( data, IO_ReadOnly ); |
217 | if ( msg == "timeChange(QString)" ) { | 219 | if ( msg == "timeChange(QString)" ) { |
218 | // update active view! | 220 | // update active view! |
@@ -381,98 +383,102 @@ void DateBook::view(int v, const QDate &d) { | |||
381 | 383 | ||
382 | void DateBook::viewDefault(const QDate &d) { | 384 | void DateBook::viewDefault(const QDate &d) { |
383 | view(defaultView,d); | 385 | view(defaultView,d); |
384 | } | 386 | } |
385 | 387 | ||
386 | void DateBook::viewDay() { | 388 | void DateBook::viewDay() { |
387 | view(DAY,currentDate()); | 389 | view(DAY,currentDate()); |
388 | } | 390 | } |
389 | 391 | ||
390 | void DateBook::viewWeek() { | 392 | void DateBook::viewWeek() { |
391 | view(WEEK,currentDate()); | 393 | view(WEEK,currentDate()); |
392 | } | 394 | } |
393 | 395 | ||
394 | void DateBook::viewWeekLst() { | 396 | void DateBook::viewWeekLst() { |
395 | view(WEEKLST,currentDate()); | 397 | view(WEEKLST,currentDate()); |
396 | } | 398 | } |
397 | 399 | ||
398 | void DateBook::viewMonth() { | 400 | void DateBook::viewMonth() { |
399 | view(MONTH,currentDate()); | 401 | view(MONTH,currentDate()); |
400 | } | 402 | } |
401 | 403 | ||
402 | void DateBook::insertEvent( const Event &e ) | 404 | void DateBook::insertEvent( const Event &e ) |
403 | { | 405 | { |
404 | Event dupEvent=e; | 406 | Event dupEvent=e; |
407 | if(!dupEvent.isValidUid() ) // tkcRom seems to be different | ||
408 | dupEvent.assignUid(); | ||
405 | dupEvent.setLocation(defaultLocation); | 409 | dupEvent.setLocation(defaultLocation); |
406 | dupEvent.setCategories(defaultCategories); | 410 | dupEvent.setCategories(defaultCategories); |
407 | db->addEvent(dupEvent); | 411 | db->addEvent(dupEvent); |
408 | emit newEvent(); | 412 | emit newEvent(); |
409 | } | 413 | } |
410 | 414 | ||
411 | void DateBook::duplicateEvent( const Event &e ) | 415 | void DateBook::duplicateEvent( const Event &e ) |
412 | { | 416 | { |
413 | qWarning("Hmmm..."); | 417 | qWarning("Hmmm..."); |
414 | // Alot of code duplication, as this is almost like editEvent(); | 418 | // Alot of code duplication, as this is almost like editEvent(); |
415 | if (syncing) { | 419 | if (syncing) { |
416 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 420 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
417 | return; | 421 | return; |
418 | } | 422 | } |
419 | 423 | ||
420 | Event dupevent(e);// Make a duplicate. | 424 | Event dupevent(e);// Make a duplicate. |
421 | 425 | ||
422 | // workaround added for text input. | 426 | // workaround added for text input. |
423 | QDialog editDlg( this, 0, TRUE ); | 427 | QDialog editDlg( this, 0, TRUE ); |
424 | DateEntry *entry; | 428 | DateEntry *entry; |
425 | editDlg.setCaption( tr("Duplicate Event") ); | 429 | editDlg.setCaption( tr("Duplicate Event") ); |
426 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 430 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
427 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 431 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
428 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 432 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
429 | // KLUDGE!!! | 433 | // KLUDGE!!! |
430 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 434 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
431 | vb->addWidget( sv ); | 435 | vb->addWidget( sv ); |
432 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); | 436 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); |
433 | entry->timezone->setEnabled( FALSE ); | 437 | entry->timezone->setEnabled( FALSE ); |
434 | sv->addChild( entry ); | 438 | sv->addChild( entry ); |
435 | 439 | ||
436 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 440 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
437 | editDlg.showMaximized(); | 441 | editDlg.showMaximized(); |
438 | #endif | 442 | #endif |
439 | while (editDlg.exec() ) { | 443 | while (editDlg.exec() ) { |
440 | Event newEv = entry->event(); | 444 | Event newEv = entry->event(); |
441 | QString error = checkEvent(newEv); | 445 | QString error = checkEvent(newEv); |
442 | if (!error.isNull()) { | 446 | if (!error.isNull()) { |
443 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) | 447 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) |
444 | continue; | 448 | continue; |
445 | } | 449 | } |
446 | /* | 450 | /* |
447 | * The problem: | 451 | * The problem: |
448 | * DateBookDB does remove repeating events not by uid but by the time | 452 | * DateBookDB does remove repeating events not by uid but by the time |
449 | * the recurrence was created | 453 | * the recurrence was created |
450 | * so we need to update that time as well | 454 | * so we need to update that time as well |
451 | */ | 455 | */ |
452 | Event::RepeatPattern rp = newEv.repeatPattern(); | 456 | Event::RepeatPattern rp = newEv.repeatPattern(); |
453 | rp.createTime = ::time( NULL ); | 457 | rp.createTime = ::time( NULL ); |
454 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... | 458 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... |
459 | if( newEv.uid() == e.uid() || !newEv.isValidUid() ) | ||
460 | newEv.assignUid(); | ||
455 | 461 | ||
456 | db->addEvent(newEv); | 462 | db->addEvent(newEv); |
457 | emit newEvent(); | 463 | emit newEvent(); |
458 | break; | 464 | break; |
459 | } | 465 | } |
460 | } | 466 | } |
461 | 467 | ||
462 | void DateBook::editEvent( const Event &e ) | 468 | void DateBook::editEvent( const Event &e ) |
463 | { | 469 | { |
464 | if (syncing) { | 470 | if (syncing) { |
465 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 471 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
466 | return; | 472 | return; |
467 | } | 473 | } |
468 | 474 | ||
469 | // workaround added for text input. | 475 | // workaround added for text input. |
470 | QDialog editDlg( this, 0, TRUE ); | 476 | QDialog editDlg( this, 0, TRUE ); |
471 | DateEntry *entry; | 477 | DateEntry *entry; |
472 | editDlg.setCaption( tr("Edit Event") ); | 478 | editDlg.setCaption( tr("Edit Event") ); |
473 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 479 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
474 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 480 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
475 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 481 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
476 | // KLUDGE!!! | 482 | // KLUDGE!!! |
477 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 483 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
478 | vb->addWidget( sv ); | 484 | vb->addWidget( sv ); |