summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweekheaderimpl.cpp
authorumopapisdn <umopapisdn>2003-03-25 23:44:32 (UTC)
committer umopapisdn <umopapisdn>2003-03-25 23:44:32 (UTC)
commitc98faafefdf2e9b9e16dcf2b1d57525f38282296 (patch) (unidiff)
tree75a6bc72f13ee81b86c368517aba3496b2c7e800 /core/pim/datebook/datebookweekheaderimpl.cpp
parentaca404f0c049c5b1bace7e842e7e64b987f04616 (diff)
downloadopie-c98faafefdf2e9b9e16dcf2b1d57525f38282296.zip
opie-c98faafefdf2e9b9e16dcf2b1d57525f38282296.tar.gz
opie-c98faafefdf2e9b9e16dcf2b1d57525f38282296.tar.bz2
Revamped the userinterface of the header for weekview to look more like the other views.
Diffstat (limited to 'core/pim/datebook/datebookweekheaderimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp64
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
@@ -18,9 +18,15 @@
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
@@ -33,6 +39,13 @@ DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent,
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/*
@@ -43,6 +56,24 @@ DateBookWeekHeader::~DateBookWeekHeader()
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
59void 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 */
@@ -50,13 +81,27 @@ void DateBookWeekHeader::yearChanged( int y )
50{ 81{
51 setDate( y, week ); 82 setDate( y, week );
52} 83}
84void 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}
90void 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 */
56void DateBookWeekHeader::nextWeek() 99void 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/*
@@ -64,8 +109,10 @@ void DateBookWeekHeader::nextWeek()
64 */ 109 */
65void DateBookWeekHeader::prevWeek() 110void 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/*
@@ -76,6 +123,12 @@ void DateBookWeekHeader::weekChanged( int w )
76 setDate( year, w ); 123 setDate( year, w );
77} 124}
78 125
126void DateBookWeekHeader::setDate( int y, int m, int d )
127{
128 calcWeek( QDate(y,m,d), week, year, bStartOnMonday );
129 setDate( year, week );
130}
131
79void DateBookWeekHeader::setDate( int y, int w ) 132void DateBookWeekHeader::setDate( int y, int w )
80{ 133{
81 year = y; 134 year = y;
@@ -89,7 +142,8 @@ void DateBookWeekHeader::setDate( int y, int w )
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() );
92 labelDate->setText( s ); 145 s += " ("+tr("week")+":"+QString::number( w )+")";
146 labelDate->setText( s );
93 147
94 emit dateChanged( y, w ); 148 emit dateChanged( y, w );
95} 149}