author | umopapisdn <umopapisdn> | 2003-05-05 21:44:39 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-05-05 21:44:39 (UTC) |
commit | 3b193b852133a82b5c1708b68a7e460c63629768 (patch) (unidiff) | |
tree | 8cd0ff3adc14f0b937d24ab99fca327fb3f16875 /core/pim/datebook/datebookweek.cpp | |
parent | 12a700f8903eedeba03d3aba7990b9d660410045 (diff) | |
download | opie-3b193b852133a82b5c1708b68a7e460c63629768.zip opie-3b193b852133a82b5c1708b68a7e460c63629768.tar.gz opie-3b193b852133a82b5c1708b68a7e460c63629768.tar.bz2 |
UI and code cleanup. Both UI and code is now more consistent. Also removed menus in favor of toolbuttons. (why were they even available as menus in the first place?)
Diffstat (limited to 'core/pim/datebook/datebookweek.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 47 |
1 files changed, 10 insertions, 37 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index 8241655..3ae4610 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp | |||
@@ -364,30 +364,20 @@ DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, | |||
364 | lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); | 364 | lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); |
365 | lblDesc->setBackgroundColor( yellow ); | 365 | lblDesc->setBackgroundColor( yellow ); |
366 | lblDesc->hide(); | 366 | lblDesc->hide(); |
367 | 367 | ||
368 | tHide = new QTimer( this ); | 368 | tHide = new QTimer( this ); |
369 | 369 | ||
370 | connect( view, SIGNAL( showDay( int ) ), | 370 | connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); |
371 | this, SLOT( showDay( int ) ) ); | 371 | connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); |
372 | connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), | 372 | connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); |
373 | this, SLOT(slotShowEvent(const EffectiveEvent&)) ); | 373 | connect( header, SIGNAL( dateChanged( int, int ) ), this, SLOT( dateChanged( int, int ) ) ); |
374 | connect( view, SIGNAL(signalHideEvent()), | 374 | connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); |
375 | this, SLOT(slotHideEvent()) ); | 375 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
376 | connect( header, SIGNAL( dateChanged( int, int ) ), | 376 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); |
377 | this, SLOT( dateChanged( int, int ) ) ); | ||
378 | connect( tHide, SIGNAL( timeout() ), | ||
379 | lblDesc, SLOT( hide() ) ); | ||
380 | connect( header->spinYear, SIGNAL(valueChanged(int)), | ||
381 | this, SLOT(slotYearChanged(int)) ); | ||
382 | connect( qApp, SIGNAL(weekChanged(bool)), | ||
383 | this, SLOT(slotWeekChanged(bool)) ); | ||
384 | connect( qApp, SIGNAL(clockChanged(bool)), | ||
385 | this, SLOT(slotClockChanged(bool))); | ||
386 | setDate(QDate::currentDate()); | 377 | setDate(QDate::currentDate()); |
387 | |||
388 | } | 378 | } |
389 | 379 | ||
390 | void DateBookWeek::keyPressEvent(QKeyEvent *e) | 380 | void DateBookWeek::keyPressEvent(QKeyEvent *e) |
391 | { | 381 | { |
392 | switch(e->key()) { | 382 | switch(e->key()) { |
393 | case Key_Up: | 383 | case Key_Up: |
@@ -415,23 +405,21 @@ void DateBookWeek::showDay( int day ) | |||
415 | d = d.addDays( day ); | 405 | d = d.addDays( day ); |
416 | emit showDate( d.year(), d.month(), d.day() ); | 406 | emit showDate( d.year(), d.month(), d.day() ); |
417 | } | 407 | } |
418 | 408 | ||
419 | void DateBookWeek::setDate( int y, int m, int d ) | 409 | void DateBookWeek::setDate( int y, int m, int d ) |
420 | { | 410 | { |
421 | QDate date; | ||
422 | date.setYMD( y, m, d ); | ||
423 | setDate(QDate(y, m, d)); | 411 | setDate(QDate(y, m, d)); |
424 | } | 412 | } |
425 | 413 | ||
426 | void DateBookWeek::setDate(QDate date) | 414 | void DateBookWeek::setDate(QDate date) |
427 | { | 415 | { |
428 | dow = date.dayOfWeek(); | 416 | dow = date.dayOfWeek(); |
429 | int w, y; | 417 | int w, y; |
430 | calcWeek( date, w, y, bStartOnMonday ); | 418 | calcWeek( date, w, y, bStartOnMonday ); |
431 | header->setDate( y, w ); | 419 | header->setDate( date ); |
432 | } | 420 | } |
433 | 421 | ||
434 | void DateBookWeek::dateChanged( int y, int w ) | 422 | void DateBookWeek::dateChanged( int y, int w ) |
435 | { | 423 | { |
436 | year = y; | 424 | year = y; |
437 | _week = w; | 425 | _week = w; |
@@ -455,24 +443,22 @@ QDate DateBookWeek::date() const | |||
455 | 443 | ||
456 | void DateBookWeek::getEvents() | 444 | void DateBookWeek::getEvents() |
457 | { | 445 | { |
458 | QDate startWeek = weekDate(); | 446 | QDate startWeek = weekDate(); |
459 | 447 | ||
460 | QDate endWeek = startWeek.addDays( 6 ); | 448 | QDate endWeek = startWeek.addDays( 6 ); |
461 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, | 449 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); |
462 | endWeek); | ||
463 | view->showEvents( eventList ); | 450 | view->showEvents( eventList ); |
464 | view->moveToHour( startTime ); | 451 | view->moveToHour( startTime ); |
465 | } | 452 | } |
466 | 453 | ||
467 | void DateBookWeek::generateAllDayTooltext( QString& text ) { | 454 | void DateBookWeek::generateAllDayTooltext( QString& text ) { |
468 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; | 455 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; |
469 | } | 456 | } |
470 | 457 | ||
471 | void DateBookWeek::generateNormalTooltext( QString& str, | 458 | void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { |
472 | const EffectiveEvent &ev ) { | ||
473 | str += "<b>" + QObject::tr("Start") + "</b>: "; | 459 | str += "<b>" + QObject::tr("Start") + "</b>: "; |
474 | str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); | 460 | str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); |
475 | if( ev.startDate()!=ev.endDate() ) { | 461 | if( ev.startDate()!=ev.endDate() ) { |
476 | str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; | 462 | str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; |
477 | } | 463 | } |
478 | str += "<br>"; | 464 | str += "<br>"; |
@@ -571,25 +557,12 @@ void DateBookWeek::slotYearChanged( int y ) | |||
571 | int throwAway; | 557 | int throwAway; |
572 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); | 558 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); |
573 | while ( totWeek == 1 ) { | 559 | while ( totWeek == 1 ) { |
574 | d = d.addDays( -1 ); | 560 | d = d.addDays( -1 ); |
575 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); | 561 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); |
576 | } | 562 | } |
577 | if ( totWeek != totalWeeks() ) | ||
578 | setTotalWeeks( totWeek ); | ||
579 | } | ||
580 | |||
581 | |||
582 | void DateBookWeek::setTotalWeeks( int numWeeks ) | ||
583 | { | ||
584 | header->spinWeek->setMaxValue( numWeeks ); | ||
585 | } | ||
586 | |||
587 | int DateBookWeek::totalWeeks() const | ||
588 | { | ||
589 | return header->spinWeek->maxValue(); | ||
590 | } | 563 | } |
591 | 564 | ||
592 | void DateBookWeek::slotWeekChanged( bool onMonday ) | 565 | void DateBookWeek::slotWeekChanged( bool onMonday ) |
593 | { | 566 | { |
594 | bStartOnMonday = onMonday; | 567 | bStartOnMonday = onMonday; |
595 | view->setStartOfWeek( bStartOnMonday ); | 568 | view->setStartOfWeek( bStartOnMonday ); |