Diffstat (limited to 'core/pim/datebook/datebookweekheaderimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweekheaderimpl.cpp | 64 |
1 files changed, 59 insertions, 5 deletions
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp index e7c7208..5f555d5 100644 --- a/core/pim/datebook/datebookweekheaderimpl.cpp +++ b/core/pim/datebook/datebookweekheaderimpl.cpp @@ -19,7 +19,13 @@ **********************************************************************/ #include "datebookweekheaderimpl.h" +#include "datebookweekheader.h" +#include "datebookweek.h" #include <qlabel.h> #include <qspinbox.h> #include <qdatetime.h> +#include <qpe/resource.h> +#include <qpe/datebookmonth.h> + +#include <qtoolbutton.h> /* @@ -34,4 +40,11 @@ DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, setBackgroundMode( PaletteButton ); labelDate->setBackgroundMode( PaletteButton ); + + backmonth->setPixmap( Resource::loadPixmap("fastback") ); + backweek->setPixmap( Resource::loadPixmap("back") ); + forwardweek->setPixmap( Resource::loadPixmap("forward") ); + forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); + spinYear->hide(); + spinWeek->hide(); } @@ -44,4 +57,22 @@ DateBookWeekHeader::~DateBookWeekHeader() } +void DateBookWeekHeader::pickDate() +{ + static QPopupMenu *m1 = 0; + static DateBookMonth *picker = 0; + QDate currDate = dateFromWeek( week, year, bStartOnMonday ); + if ( !m1 ) { + m1 = new QPopupMenu( this ); + picker = new DateBookMonth( m1, 0, TRUE ); + m1->insertItem( picker ); + 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() ); + m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); + picker->setFocus(); +} /* * public slot @@ -51,4 +82,16 @@ 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 +} +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 +} /* * public slot @@ -56,6 +99,8 @@ void DateBookWeekHeader::yearChanged( int y ) void DateBookWeekHeader::nextWeek() { - if ( week < 52 ) - week++; + 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 ); } @@ -65,6 +110,8 @@ void DateBookWeekHeader::nextWeek() void DateBookWeekHeader::prevWeek() { - if ( week > 1 ) - week--; + 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 ); } @@ -77,4 +124,10 @@ void DateBookWeekHeader::weekChanged( int w ) } +void DateBookWeekHeader::setDate( int y, int m, int d ) +{ + calcWeek( QDate(y,m,d), week, year, bStartOnMonday ); + setDate( year, week ); +} + void DateBookWeekHeader::setDate( int y, int w ) { @@ -90,5 +143,6 @@ void DateBookWeekHeader::setDate( int y, int w ) d = d.addDays( 6 ); s += QString::number( d.day() ) + ". " + d.monthName( d.month() ); - labelDate->setText( s ); + s += " ("+tr("week")+":"+QString::number( w )+")"; + labelDate->setText( s ); emit dateChanged( y, w ); |