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/datebookweekheaderimpl.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/datebookweekheaderimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweekheaderimpl.cpp | 93 |
1 files changed, 26 insertions, 67 deletions
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp index 5f555d5..fd792e2 100644 --- a/core/pim/datebook/datebookweekheaderimpl.cpp +++ b/core/pim/datebook/datebookweekheaderimpl.cpp @@ -34,4 +34,3 @@ */ -DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, - const char* name, WFlags fl ) +DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) : DateBookWeekHeaderBase( parent, name, fl ), @@ -41,3 +40,2 @@ DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, labelDate->setBackgroundMode( PaletteButton ); - backmonth->setPixmap( Resource::loadPixmap("fastback") ); @@ -46,4 +44,2 @@ DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); - spinYear->hide(); - spinWeek->hide(); } @@ -62,3 +58,2 @@ void DateBookWeekHeader::pickDate() static DateBookMonth *picker = 0; - QDate currDate = dateFromWeek( week, year, bStartOnMonday ); if ( !m1 ) { @@ -67,8 +62,6 @@ void DateBookWeekHeader::pickDate() m1->insertItem( picker ); - connect( picker, SIGNAL( dateClicked( int, int, int ) ), - this, SLOT( setDate( int, int, int ) ) ); -// connect( m1, SIGNAL( aboutToHide() ), -// this, SLOT( gotHide() ) ); + connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( setDate( int, int, int ) ) ); +// connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); } - picker->setDate( currDate.year(), currDate.month(), currDate.day() ); + picker->setDate( date.year(), date.month(), date.day() ); m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); @@ -76,14 +69,6 @@ void DateBookWeekHeader::pickDate() } -/* - * public slot - */ -void DateBookWeekHeader::yearChanged( int y ) -{ - setDate( y, week ); -} + void DateBookWeekHeader::nextMonth() { - QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week - calcWeek( mydate.addDays(28), week, year, bStartOnMonday ); // Add 4 weeks. - setDate( year, week ); // update view + setDate(date.addDays(28)); } @@ -91,34 +76,11 @@ void DateBookWeekHeader::prevMonth() { - QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week - calcWeek( mydate.addDays(-28), week, year, bStartOnMonday ); // Subtract 4 weeks - setDate( year, week ); // update view + setDate(date.addDays(-28)); } -/* - * public slot - */ void DateBookWeekHeader::nextWeek() { - QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week - calcWeek( mydate.addDays(7), week, year, bStartOnMonday); // Add 1 week -// if ( week < 52 ) -// week++; - setDate( year, week ); + setDate(date.addDays(7)); } -/* - * public slot - */ void DateBookWeekHeader::prevWeek() { - QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week - calcWeek( mydate.addDays(-7), week, year, bStartOnMonday); // Add 1 week -// if ( week > 1 ) -// week--; - setDate( year, week ); -} -/* - * public slot - */ -void DateBookWeekHeader::weekChanged( int w ) -{ - setDate( year, w ); + setDate(date.addDays(-7)); } @@ -127,23 +89,21 @@ void DateBookWeekHeader::setDate( int y, int m, int d ) { - calcWeek( QDate(y,m,d), week, year, bStartOnMonday ); - setDate( year, week ); + setDate(QDate(y,m,d)); } -void DateBookWeekHeader::setDate( int y, int w ) -{ - year = y; - week = w; - spinYear->setValue( y ); - spinWeek->setValue( w ); - - QDate d = dateFromWeek( week, year, bStartOnMonday ); +void DateBookWeekHeader::setDate(const QDate &d) { + int year,week,dayofweek; + date=d; + dayofweek=d.dayOfWeek(); + if(bStartOnMonday) dayofweek--; + date=date.addDays(-dayofweek); - QString s = QString::number( d.day() ) + ". " + d.monthName( d.month() ) - + "-"; - d = d.addDays( 6 ); - s += QString::number( d.day() ) + ". " + d.monthName( d.month() ); - s += " ("+tr("week")+":"+QString::number( w )+")"; - labelDate->setText( s ); - - emit dateChanged( y, w ); + calcWeek(date,week,year,bStartOnMonday); + QDate start=date; + QDate stop=start.addDays(6); + labelDate->setText( QString::number(start.day()) + "." + + start.monthName(start.month()) + "-" + + QString::number(stop.day()) + "." + + start.monthName(stop.month()) +" ("+ + tr("w")+":"+QString::number( week ) +")"); + emit dateChanged(year,week); } @@ -153,3 +113,3 @@ void DateBookWeekHeader::setStartOfWeek( bool onMonday ) bStartOnMonday = onMonday; - setDate( year, week ); + setDate( date ); } @@ -158,3 +118,2 @@ void DateBookWeekHeader::setStartOfWeek( bool onMonday ) // compute the date from the week in the year - QDate dateFromWeek( int week, int year, bool startOnMonday ) |