Diffstat (limited to 'core/pim/datebook/datebookweekheaderimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweekheaderimpl.cpp | 62 |
1 files changed, 58 insertions, 4 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 | |||
@@ -17,11 +17,17 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "datebookweekheaderimpl.h" | 20 | #include "datebookweekheaderimpl.h" |
21 | #include "datebookweekheader.h" | ||
22 | #include "datebookweek.h" | ||
21 | #include <qlabel.h> | 23 | #include <qlabel.h> |
22 | #include <qspinbox.h> | 24 | #include <qspinbox.h> |
23 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qpe/resource.h> | ||
27 | #include <qpe/datebookmonth.h> | ||
28 | |||
29 | #include <qtoolbutton.h> | ||
24 | 30 | ||
25 | /* | 31 | /* |
26 | * Constructs a DateBookWeekHeader which is a child of 'parent', with the | 32 | * Constructs a DateBookWeekHeader which is a child of 'parent', with the |
27 | * name 'name' and widget flags set to 'f' | 33 | * name 'name' and widget flags set to 'f' |
@@ -32,8 +38,15 @@ DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, | |||
32 | bStartOnMonday( startOnMonday ) | 38 | bStartOnMonday( startOnMonday ) |
33 | { | 39 | { |
34 | setBackgroundMode( PaletteButton ); | 40 | setBackgroundMode( PaletteButton ); |
35 | labelDate->setBackgroundMode( PaletteButton ); | 41 | labelDate->setBackgroundMode( PaletteButton ); |
42 | |||
43 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); | ||
44 | backweek->setPixmap( Resource::loadPixmap("back") ); | ||
45 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); | ||
46 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); | ||
47 | spinYear->hide(); | ||
48 | spinWeek->hide(); | ||
36 | } | 49 | } |
37 | 50 | ||
38 | /* | 51 | /* |
39 | * Destroys the object and frees any allocated resources | 52 | * Destroys the object and frees any allocated resources |
@@ -42,31 +55,65 @@ DateBookWeekHeader::~DateBookWeekHeader() | |||
42 | { | 55 | { |
43 | // no need to delete child widgets, Qt does it all for us | 56 | // no need to delete child widgets, Qt does it all for us |
44 | } | 57 | } |
45 | 58 | ||
59 | void DateBookWeekHeader::pickDate() | ||
60 | { | ||
61 | static QPopupMenu *m1 = 0; | ||
62 | static DateBookMonth *picker = 0; | ||
63 | QDate currDate = dateFromWeek( week, year, bStartOnMonday ); | ||
64 | if ( !m1 ) { | ||
65 | m1 = new QPopupMenu( this ); | ||
66 | picker = new DateBookMonth( m1, 0, TRUE ); | ||
67 | m1->insertItem( picker ); | ||
68 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | ||
69 | this, SLOT( setDate( int, int, int ) ) ); | ||
70 | // connect( m1, SIGNAL( aboutToHide() ), | ||
71 | // this, SLOT( gotHide() ) ); | ||
72 | } | ||
73 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); | ||
74 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); | ||
75 | picker->setFocus(); | ||
76 | } | ||
46 | /* | 77 | /* |
47 | * public slot | 78 | * public slot |
48 | */ | 79 | */ |
49 | void DateBookWeekHeader::yearChanged( int y ) | 80 | void DateBookWeekHeader::yearChanged( int y ) |
50 | { | 81 | { |
51 | setDate( y, week ); | 82 | setDate( y, week ); |
52 | } | 83 | } |
84 | void DateBookWeekHeader::nextMonth() | ||
85 | { | ||
86 | QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week | ||
87 | calcWeek( mydate.addDays(28), week, year, bStartOnMonday ); // Add 4 weeks. | ||
88 | setDate( year, week ); // update view | ||
89 | } | ||
90 | void DateBookWeekHeader::prevMonth() | ||
91 | { | ||
92 | QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week | ||
93 | calcWeek( mydate.addDays(-28), week, year, bStartOnMonday ); // Subtract 4 weeks | ||
94 | setDate( year, week ); // update view | ||
95 | } | ||
53 | /* | 96 | /* |
54 | * public slot | 97 | * public slot |
55 | */ | 98 | */ |
56 | void DateBookWeekHeader::nextWeek() | 99 | void DateBookWeekHeader::nextWeek() |
57 | { | 100 | { |
58 | if ( week < 52 ) | 101 | QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week |
59 | week++; | 102 | calcWeek( mydate.addDays(7), week, year, bStartOnMonday); // Add 1 week |
103 | // if ( week < 52 ) | ||
104 | //week++; | ||
60 | setDate( year, week ); | 105 | setDate( year, week ); |
61 | } | 106 | } |
62 | /* | 107 | /* |
63 | * public slot | 108 | * public slot |
64 | */ | 109 | */ |
65 | void DateBookWeekHeader::prevWeek() | 110 | void DateBookWeekHeader::prevWeek() |
66 | { | 111 | { |
67 | if ( week > 1 ) | 112 | QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week |
68 | week--; | 113 | calcWeek( mydate.addDays(-7), week, year, bStartOnMonday); // Add 1 week |
114 | // if ( week > 1 ) | ||
115 | //week--; | ||
69 | setDate( year, week ); | 116 | setDate( year, week ); |
70 | } | 117 | } |
71 | /* | 118 | /* |
72 | * public slot | 119 | * public slot |
@@ -75,8 +122,14 @@ void DateBookWeekHeader::weekChanged( int w ) | |||
75 | { | 122 | { |
76 | setDate( year, w ); | 123 | setDate( year, w ); |
77 | } | 124 | } |
78 | 125 | ||
126 | void DateBookWeekHeader::setDate( int y, int m, int d ) | ||
127 | { | ||
128 | calcWeek( QDate(y,m,d), week, year, bStartOnMonday ); | ||
129 | setDate( year, week ); | ||
130 | } | ||
131 | |||
79 | void DateBookWeekHeader::setDate( int y, int w ) | 132 | void DateBookWeekHeader::setDate( int y, int w ) |
80 | { | 133 | { |
81 | year = y; | 134 | year = y; |
82 | week = w; | 135 | week = w; |
@@ -88,8 +141,9 @@ void DateBookWeekHeader::setDate( int y, int w ) | |||
88 | QString s = QString::number( d.day() ) + ". " + d.monthName( d.month() ) | 141 | QString s = QString::number( d.day() ) + ". " + d.monthName( d.month() ) |
89 | + "-"; | 142 | + "-"; |
90 | d = d.addDays( 6 ); | 143 | d = d.addDays( 6 ); |
91 | s += QString::number( d.day() ) + ". " + d.monthName( d.month() ); | 144 | s += QString::number( d.day() ) + ". " + d.monthName( d.month() ); |
145 | s += " ("+tr("week")+":"+QString::number( w )+")"; | ||
92 | labelDate->setText( s ); | 146 | labelDate->setText( s ); |
93 | 147 | ||
94 | emit dateChanged( y, w ); | 148 | emit dateChanged( y, w ); |
95 | } | 149 | } |