author | umopapisdn <umopapisdn> | 2003-05-05 21:44:39 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-05-05 21:44:39 (UTC) |
commit | 3b193b852133a82b5c1708b68a7e460c63629768 (patch) (side-by-side diff) | |
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) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 179 |
1 files changed, 76 insertions, 103 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 @@ -344,152 +344,138 @@ void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) } //------------------------------------------------------------------- DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, QWidget *parent, const char *name ) : QWidget( parent, name ), db( newDB ), startTime( 0 ), ampm( ap ), bStartOnMonday( startOnMonday ) { - setFocusPolicy(StrongFocus); - QVBoxLayout *vb = new QVBoxLayout( this ); - header = new DateBookWeekHeader( bStartOnMonday, this ); - view = new DateBookWeekView( ampm, startOnMonday, this ); - vb->addWidget( header ); - vb->addWidget( view ); - - lblDesc = new QLabel( this, "event label" ); - lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); - lblDesc->setBackgroundColor( yellow ); - lblDesc->hide(); - - tHide = new QTimer( this ); - - connect( view, SIGNAL( showDay( int ) ), - this, SLOT( showDay( int ) ) ); - connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), - this, SLOT(slotShowEvent(const EffectiveEvent&)) ); - connect( view, SIGNAL(signalHideEvent()), - this, SLOT(slotHideEvent()) ); - connect( header, SIGNAL( dateChanged( int, int ) ), - this, SLOT( dateChanged( int, int ) ) ); - connect( tHide, SIGNAL( timeout() ), - lblDesc, SLOT( hide() ) ); - connect( header->spinYear, SIGNAL(valueChanged(int)), - this, SLOT(slotYearChanged(int)) ); - connect( qApp, SIGNAL(weekChanged(bool)), - this, SLOT(slotWeekChanged(bool)) ); - connect( qApp, SIGNAL(clockChanged(bool)), - this, SLOT(slotClockChanged(bool))); - setDate(QDate::currentDate()); - + setFocusPolicy(StrongFocus); + QVBoxLayout *vb = new QVBoxLayout( this ); + header = new DateBookWeekHeader( bStartOnMonday, this ); + view = new DateBookWeekView( ampm, startOnMonday, this ); + vb->addWidget( header ); + vb->addWidget( view ); + + lblDesc = new QLabel( this, "event label" ); + lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); + lblDesc->setBackgroundColor( yellow ); + lblDesc->hide(); + + tHide = new QTimer( this ); + + connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); + connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); + connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); + connect( header, SIGNAL( dateChanged( int, int ) ), this, SLOT( dateChanged( int, int ) ) ); + connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); + connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); + connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); + setDate(QDate::currentDate()); } void DateBookWeek::keyPressEvent(QKeyEvent *e) { switch(e->key()) { case Key_Up: view->scrollBy(0, -20); break; case Key_Down: view->scrollBy(0, 20); break; case Key_Left: setDate(date().addDays(-7)); break; case Key_Right: setDate(date().addDays(7)); break; default: e->ignore(); } } void DateBookWeek::showDay( int day ) { - QDate d; - d = dateFromWeek( _week, year, bStartOnMonday ); - day--; - d = d.addDays( day ); - emit showDate( d.year(), d.month(), d.day() ); + QDate d; + d = dateFromWeek( _week, year, bStartOnMonday ); + day--; + d = d.addDays( day ); + emit showDate( d.year(), d.month(), d.day() ); } void DateBookWeek::setDate( int y, int m, int d ) { - QDate date; - date.setYMD( y, m, d ); - setDate(QDate(y, m, d)); + setDate(QDate(y, m, d)); } void DateBookWeek::setDate(QDate date) { - dow = date.dayOfWeek(); - int w, y; - calcWeek( date, w, y, bStartOnMonday ); - header->setDate( y, w ); + dow = date.dayOfWeek(); + int w, y; + calcWeek( date, w, y, bStartOnMonday ); + header->setDate( date ); } void DateBookWeek::dateChanged( int y, int w ) { - year = y; - _week = w; - getEvents(); + year = y; + _week = w; + getEvents(); } QDate DateBookWeek::date() const { - QDate d; - d = dateFromWeek( _week - 1, year, bStartOnMonday ); - if ( bStartOnMonday ) - d = d.addDays( 7 + dow - 1 ); - else { - if ( dow == 7 ) - d = d.addDays( dow ); - else - d = d.addDays( 7 + dow ); - } - return d; + QDate d; + d = dateFromWeek( _week - 1, year, bStartOnMonday ); + if ( bStartOnMonday ) + d = d.addDays( 7 + dow - 1 ); + else { + if ( dow == 7 ) + d = d.addDays( dow ); + else + d = d.addDays( 7 + dow ); + } + return d; } void DateBookWeek::getEvents() { - QDate startWeek = weekDate(); + QDate startWeek = weekDate(); - QDate endWeek = startWeek.addDays( 6 ); - QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, - endWeek); - view->showEvents( eventList ); - view->moveToHour( startTime ); + QDate endWeek = startWeek.addDays( 6 ); + QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); + view->showEvents( eventList ); + view->moveToHour( startTime ); } void DateBookWeek::generateAllDayTooltext( QString& text ) { - text += "<b>" + tr("This is an all day event.") + "</b><br>"; + text += "<b>" + tr("This is an all day event.") + "</b><br>"; } -void DateBookWeek::generateNormalTooltext( QString& str, - const EffectiveEvent &ev ) { - str += "<b>" + QObject::tr("Start") + "</b>: "; - str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); - if( ev.startDate()!=ev.endDate() ) { - str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; - } - str += "<br>"; - str += "<b>" + QObject::tr("End") + "</b>: "; - str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); - if( ev.startDate()!=ev.endDate() ) { - str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; - } +void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { + str += "<b>" + QObject::tr("Start") + "</b>: "; + str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); + if( ev.startDate()!=ev.endDate() ) { + str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; + } + str += "<br>"; + str += "<b>" + QObject::tr("End") + "</b>: "; + str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); + if( ev.startDate()!=ev.endDate() ) { + str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; + } } void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) { if ( tHide->isActive() ) tHide->stop(); // why would someone use "<"? Oh well, fix it up... // I wonder what other things may be messed up... QString strDesc = ev.description(); int where = strDesc.find( "<" ); while ( where != -1 ) { @@ -557,58 +543,45 @@ void DateBookWeek::setStartViewTime( int startHere ) int DateBookWeek::startViewTime() const { return startTime; } void DateBookWeek::redraw() { getEvents(); } void DateBookWeek::slotYearChanged( int y ) { - int totWeek; - QDate d( y, 12, 31 ); - int throwAway; - calcWeek( d, totWeek, throwAway, bStartOnMonday ); - while ( totWeek == 1 ) { - d = d.addDays( -1 ); + int totWeek; + QDate d( y, 12, 31 ); + int throwAway; calcWeek( d, totWeek, throwAway, bStartOnMonday ); - } - if ( totWeek != totalWeeks() ) - setTotalWeeks( totWeek ); -} - - -void DateBookWeek::setTotalWeeks( int numWeeks ) -{ - header->spinWeek->setMaxValue( numWeeks ); -} - -int DateBookWeek::totalWeeks() const -{ - return header->spinWeek->maxValue(); + while ( totWeek == 1 ) { + d = d.addDays( -1 ); + calcWeek( d, totWeek, throwAway, bStartOnMonday ); + } } void DateBookWeek::slotWeekChanged( bool onMonday ) { - bStartOnMonday = onMonday; - view->setStartOfWeek( bStartOnMonday ); - header->setStartOfWeek( bStartOnMonday ); - redraw(); + bStartOnMonday = onMonday; + view->setStartOfWeek( bStartOnMonday ); + header->setStartOfWeek( bStartOnMonday ); + redraw(); } void DateBookWeek::slotClockChanged( bool ap ) { - ampm = ap; + ampm = ap; } // return the date at the beginning of the week... QDate DateBookWeek::weekDate() const { return dateFromWeek( _week, year, bStartOnMonday ); } // this used to only be needed by datebook.cpp, but now we need it inside // week view since // we need to be able to figure out our total number of weeks on the fly... // this is probably the best place to put it.. |