summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp189
1 files changed, 97 insertions, 92 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 1bc82a5..829f8f8 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -220,9 +220,9 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
220#endif 220#endif
221#endif 221#endif
222 222
223 qDebug("done t=%d", t.elapsed() ); 223 qDebug("done t=%d", t.elapsed() );
224 224
225 /* 225 /*
226 * Here is a problem description: 226 * Here is a problem description:
227 * When Weekview is the default view 227 * When Weekview is the default view
228 * a DateBookWeekView get's created 228 * a DateBookWeekView get's created
@@ -235,11 +235,11 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
235 * at the right position. redraw() is a slot 235 * at the right position. redraw() is a slot
236 * so we'll call it then via a singleShot 236 * so we'll call it then via a singleShot
237 * from view() 237 * from view()
238 */ 238 */
239 if( needEvilHack ){ 239 if( needEvilHack ){
240 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 240 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
241 } 241 }
242} 242}
243 243
244void DateBook::receive( const QCString &msg, const QByteArray &data ) 244void DateBook::receive( const QCString &msg, const QByteArray &data )
245{ 245{
@@ -275,30 +275,34 @@ void DateBook::slotSettings()
275#if defined (Q_WS_QWS) || defined(_WS_QWS_) 275#if defined (Q_WS_QWS) || defined(_WS_QWS_)
276 frmSettings.showMaximized(); 276 frmSettings.showMaximized();
277#endif 277#endif
278 278
279 if ( frmSettings.exec() ) { 279 if ( frmSettings.exec() ) {
280 aPreset = frmSettings.alarmPreset(); 280
281 presetTime = frmSettings.presetTime(); 281 aPreset = frmSettings.alarmPreset();
282 startTime = frmSettings.startTime(); 282 presetTime = frmSettings.presetTime();
283 bJumpToCurTime = frmSettings.jumpToCurTime(); 283 startTime = frmSettings.startTime();
284 rowStyle = frmSettings.rowStyle(); 284 bJumpToCurTime = frmSettings.jumpToCurTime();
285 if ( dayView ) 285 rowStyle = frmSettings.rowStyle();
286 dayView->setStartViewTime( startTime ); 286
287 dayView->setJumpToCurTime( bJumpToCurTime ); 287 if ( dayView ) {
288 dayView->setRowStyle( rowStyle ); 288 dayView->setStartViewTime( startTime );
289 if ( weekView ) 289 dayView->setJumpToCurTime( bJumpToCurTime );
290 weekView->setStartViewTime( startTime ); 290 dayView->setRowStyle( rowStyle );
291 saveSettings(); 291 }
292 292 if ( weekView ) {
293 // make the change obvious 293 weekView->setStartViewTime( startTime );
294 if ( views->visibleWidget() ) { 294 }
295 if ( views->visibleWidget() == dayView ) 295 saveSettings();
296 dayView->redraw(); 296
297 else if ( views->visibleWidget() == weekView ) 297 // make the change obvious
298 weekView->redraw(); 298 if ( views->visibleWidget() ) {
299 if ( views->visibleWidget() == dayView )
300 dayView->redraw();
301 else if ( views->visibleWidget() == weekView )
302 weekView->redraw();
303 }
299 } 304 }
300 }
301} 305}
302 306
303void DateBook::fileNew() 307void DateBook::fileNew()
304{ 308{
@@ -350,33 +354,33 @@ QDate DateBook::currentDate()
350 return d; 354 return d;
351} 355}
352 356
353void DateBook::view(int v, const QDate &d) { 357void DateBook::view(int v, const QDate &d) {
354 if (v==DAY) { 358 if (v==DAY) {
355 initDay(); 359 initDay();
356 dayAction->setOn( TRUE ); 360 dayAction->setOn( TRUE );
357 dayView->setDate( d ); 361 dayView->setDate( d );
358 views->raiseWidget( dayView ); 362 views->raiseWidget( dayView );
359 dayView->redraw(); 363 dayView->redraw();
360 } else if (v==WEEK) { 364 } else if (v==WEEK) {
361 initWeek(); 365 initWeek();
362 weekAction->setOn( TRUE ); 366 weekAction->setOn( TRUE );
363 weekView->setDate( d ); 367 weekView->setDate( d );
364 views->raiseWidget( weekView ); 368 views->raiseWidget( weekView );
365 weekView->redraw(); 369 weekView->redraw();
366 } else if (v==WEEKLST) { 370 } else if (v==WEEKLST) {
367 initWeekLst(); 371 initWeekLst();
368 weekLstAction->setOn( TRUE ); 372 weekLstAction->setOn( TRUE );
369 weekLstView->setDate(d); 373 weekLstView->setDate(d);
370 views->raiseWidget( weekLstView ); 374 views->raiseWidget( weekLstView );
371 weekLstView->redraw(); 375 weekLstView->redraw();
372 } else if (v==MONTH) { 376 } else if (v==MONTH) {
373 initMonth(); 377 initMonth();
374 monthAction->setOn( TRUE ); 378 monthAction->setOn( TRUE );
375 monthView->setDate( d.year(), d.month(), d.day() ); 379 monthView->setDate( d.year(), d.month(), d.day() );
376 views->raiseWidget( monthView ); 380 views->raiseWidget( monthView );
377 monthView->redraw(); 381 monthView->redraw();
378 } 382 }
379} 383}
380 384
381void DateBook::viewDefault(const QDate &d) { 385void DateBook::viewDefault(const QDate &d) {
382 Config config("DateBook"); 386 Config config("DateBook");
@@ -513,59 +517,60 @@ void DateBook::showDay( int year, int month, int day )
513} 517}
514 518
515void DateBook::initDay() 519void DateBook::initDay()
516{ 520{
517 if ( !dayView ) { 521 if ( !dayView ) {
518 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 522 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
519 views->addWidget( dayView, DAY ); 523 views->addWidget( dayView, DAY );
520 dayView->setStartViewTime( startTime ); 524 dayView->setStartViewTime( startTime );
521 dayView->setJumpToCurTime( bJumpToCurTime ); 525 dayView->setJumpToCurTime( bJumpToCurTime );
522 dayView->setRowStyle( rowStyle ); 526 dayView->setRowStyle( rowStyle );
523 connect( this, SIGNAL( newEvent() ), 527 connect( this, SIGNAL( newEvent() ),
524 dayView, SLOT( redraw() ) ); 528 dayView, SLOT( redraw() ) );
525 connect( dayView, SIGNAL( newEvent() ), 529 connect( dayView, SIGNAL( newEvent() ),
526 this, SLOT( fileNew() ) ); 530 this, SLOT( fileNew() ) );
527 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 531 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
528 this, SLOT( removeEvent( const Event & ) ) ); 532 this, SLOT( removeEvent( const Event & ) ) );
529 connect( dayView, SIGNAL( editEvent( const Event & ) ), 533 connect( dayView, SIGNAL( editEvent( const Event & ) ),
530 this, SLOT( editEvent( const Event & ) ) ); 534 this, SLOT( editEvent( const Event & ) ) );
531 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), 535 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ),
532 this, SLOT( duplicateEvent( const Event & ) ) ); 536 this, SLOT( duplicateEvent( const Event & ) ) );
533 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 537 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
534 this, SLOT( beamEvent( const Event & ) ) ); 538 this, SLOT( beamEvent( const Event & ) ) );
535 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 539 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
536 this, SLOT(slotNewEventFromKey(const QString &)) ); 540 this, SLOT(slotNewEventFromKey(const QString &)) );
537 } 541 }
538} 542}
539 543
540void DateBook::initWeek() 544void DateBook::initWeek()
541{ 545{
542 if ( !weekView ) { 546 if ( !weekView ) {
543 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 547 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
544 weekView->setStartViewTime( startTime ); 548 weekView->setStartViewTime( startTime );
545 views->addWidget( weekView, WEEK ); 549 views->addWidget( weekView, WEEK );
546 connect( weekView, SIGNAL( showDate( int, int, int ) ), 550 connect( weekView, SIGNAL( showDate( int, int, int ) ),
547 this, SLOT( showDay( int, int, int ) ) ); 551 this, SLOT( showDay( int, int, int ) ) );
548 connect( this, SIGNAL( newEvent() ), 552 connect( this, SIGNAL( newEvent() ),
549 weekView, SLOT( redraw() ) ); 553 weekView, SLOT( redraw() ) );
550 } 554 }
551 //But also get it right: the year that we display can be different
552 //from the year of the current date. So, first find the year
553 //number of the current week.
554
555 int yearNumber, totWeeks;
556 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
557 555
558 QDate d = QDate( yearNumber, 12, 31 ); 556 //But also get it right: the year that we display can be different
559 calcWeek( d, totWeeks, yearNumber, onMonday ); 557 //from the year of the current date. So, first find the year
558 //number of the current week.
559 int yearNumber, totWeeks;
560 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
560 561
561 while ( totWeeks == 1 ) { 562 QDate d = QDate( yearNumber, 12, 31 );
562 d = d.addDays( -1 );
563 calcWeek( d, totWeeks, yearNumber, onMonday ); 563 calcWeek( d, totWeeks, yearNumber, onMonday );
564 } 564
565 if ( totWeeks != weekView->totalWeeks() ) 565 while ( totWeeks == 1 ) {
566 weekView->setTotalWeeks( totWeeks ); 566 d = d.addDays( -1 );
567 calcWeek( d, totWeeks, yearNumber, onMonday );
568 }
569 if ( totWeeks != weekView->totalWeeks() )
570 weekView->setTotalWeeks( totWeeks );
567} 571}
572
568void DateBook::initWeekLst() { 573void DateBook::initWeekLst() {
569 if ( !weekLstView ) { 574 if ( !weekLstView ) {
570 weekLstView = new DateBookWeekLst( ampm, onMonday, db, 575 weekLstView = new DateBookWeekLst( ampm, onMonday, db,
571 views, "weeklst view" ); 576 views, "weeklst view" );