summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweeklst.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebookweeklst.cpp90
1 files changed, 49 insertions, 41 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 3c8fc89..a39ff40 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -29,7 +29,5 @@
29 29
30bool calcWeek(const QDate &d, int &week, int &year, 30bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
31 bool startOnMonday = false);
32 31
33DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, 32DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
34 const char* name, WFlags fl)
35 : DateBookWeekLstHeaderBase(parent, name, fl) 33 : DateBookWeekLstHeaderBase(parent, name, fl)
@@ -38,7 +36,10 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
38 labelDate->setBackgroundMode( PaletteButton ); 36 labelDate->setBackgroundMode( PaletteButton );
39 labelWeek->setBackgroundMode( PaletteButton ); 37 forwardweek->setBackgroundMode( PaletteButton );
40 forward->setBackgroundMode( PaletteButton ); 38 forwardweek->setPixmap( Resource::loadPixmap("forward") );
41 forward->setPixmap( Resource::loadPixmap("forward") ); 39 forwardmonth->setBackgroundMode( PaletteButton );
42 back->setBackgroundMode( PaletteButton ); 40 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
43 back->setPixmap( Resource::loadPixmap("back") ); 41 backweek->setBackgroundMode( PaletteButton );
42 backweek->setPixmap( Resource::loadPixmap("back") );
43 backmonth->setBackgroundMode( PaletteButton );
44 backmonth->setPixmap( Resource::loadPixmap("fastback") );
44 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 45 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
@@ -48,24 +49,30 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
48 49
49 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); 50 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
50 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); 51 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
51 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); 52 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
53 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
54 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
52 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 55 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
53 onMonday=onM; 56 bStartOnMonday=onM;
54} 57}
55DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 58DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
59
56void DateBookWeekLstHeader::setDate(const QDate &d) { 60void DateBookWeekLstHeader::setDate(const QDate &d) {
61 int year,week,dayofweek;
57 date=d; 62 date=d;
63 dayofweek=d.dayOfWeek();
64 if(bStartOnMonday) dayofweek--;
65 date=date.addDays(-dayofweek);
58 66
59 int year,week; 67 calcWeek(date,week,year,bStartOnMonday);
60 calcWeek(d,week,year,onMonday);
61 labelWeek->setText(tr( "W: %1" ).arg( ( QString::number(week)) ) );
62
63 QDate start=date; 68 QDate start=date;
64 QDate stop=start.addDays(6); 69 QDate stop=start.addDays(6);
65 labelDate->setText( QString::number(start.day()) + " " + 70 labelDate->setText( QString::number(start.day()) + "." +
66 start.monthName(start.month()) + " - " + 71 start.monthName(start.month()) + " - " +
67 QString::number(stop.day()) + " " + 72 QString::number(stop.day()) + "." +
68 start.monthName(stop.month()) ); 73 start.monthName(stop.month()) +" ("+
74 tr("w")+":"+QString::number( week ) +")");
69 emit dateChanged(year,week); 75 emit dateChanged(year,week);
70} 76}
77
71void DateBookWeekLstHeader::pickDate() { 78void DateBookWeekLstHeader::pickDate() {
@@ -77,4 +84,3 @@ void DateBookWeekLstHeader::pickDate() {
77 m1->insertItem( picker ); 84 m1->insertItem( picker );
78 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 85 connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) );
79 this, SLOT( setDate( int, int, int ) ) );
80 //connect( m1, SIGNAL( aboutToHide() ), 86 //connect( m1, SIGNAL( aboutToHide() ),
@@ -83,3 +89,3 @@ void DateBookWeekLstHeader::pickDate() {
83 picker->setDate( date.year(), date.month(), date.day() ); 89 picker->setDate( date.year(), date.month(), date.day() );
84 m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height()))); 90 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
85 picker->setFocus(); 91 picker->setFocus();
@@ -87,4 +93,3 @@ void DateBookWeekLstHeader::pickDate() {
87void DateBookWeekLstHeader::setDate(int y, int m, int d) { 93void DateBookWeekLstHeader::setDate(int y, int m, int d) {
88 QDate new_date(y,m,d); 94 setDate(QDate(y,m,d));
89 setDate(new_date);
90} 95}
@@ -97,2 +102,10 @@ void DateBookWeekLstHeader::prevWeek() {
97} 102}
103void DateBookWeekLstHeader::nextMonth()
104{
105 setDate(date.addDays(28));
106}
107void DateBookWeekLstHeader::prevMonth()
108{
109 setDate(date.addDays(-28));
110}
98 111
@@ -109,4 +122,3 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
109 122
110 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " + 123 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
111 QString::number(d.day()) );
112 add->setText("+"); 124 add->setText("+");
@@ -130,3 +142,2 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
130 142
131
132 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 143 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
@@ -138,2 +149,3 @@ void DateBookWeekLstDayHdr::showDay() {
138} 149}
150
139void DateBookWeekLstDayHdr::newEvent() { 151void DateBookWeekLstDayHdr::newEvent() {
@@ -206,3 +218,3 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
206 218
207 onMonday=onM; 219 bStartOnMonday=onM;
208 setPalette(white); 220 setPalette(white);
@@ -217,3 +229,3 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
217 int dayOrder[7]; 229 int dayOrder[7];
218 if (onMonday) { 230 if (bStartOnMonday) {
219 for (int d=0; d<7; d++) dayOrder[d]=d+1; 231 for (int d=0; d<7; d++) dayOrder[d]=d+1;
@@ -226,5 +238,4 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
226 // Header 238 // Header
227 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this); 239 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), bStartOnMonday,this);
228 connect(hdr, SIGNAL(showDate(int,int,int)), 240 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
229 this, SIGNAL(showDate(int,int,int)));
230 connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), 241 connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
@@ -281,3 +292,3 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
281 ampm( ap ), 292 ampm( ap ),
282 onMonday(onM) 293 bStartOnMonday(onM)
283{ 294{
@@ -293,4 +304,2 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
293 scroll=new QScrollView(this); 304 scroll=new QScrollView(this);
294 //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
295 //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
296 scroll->setResizePolicy(QScrollView::AutoOneFit); 305 scroll->setResizePolicy(QScrollView::AutoOneFit);
@@ -312,3 +321,3 @@ void DateBookWeekLst::setDate(const QDate &d) {
312 int w,y; 321 int w,y;
313 calcWeek(d,w,y,onMonday); 322 calcWeek(d,w,y,bStartOnMonday);
314 year=y; 323 year=y;
@@ -328,3 +337,3 @@ QDate DateBookWeekLst::date() const {
328 int dow= d.dayOfWeek(); 337 int dow= d.dayOfWeek();
329 if (!onMonday) 338 if (!bStartOnMonday)
330 if (dow==7) { 339 if (dow==7) {
@@ -349,5 +358,5 @@ void DateBookWeekLst::getEvents() {
349 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 358 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
350 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); 359 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
351 } else { 360 } else {
352 view=new DateBookWeekLstView(el,start,onMonday,scroll); 361 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
353 } 362 }
@@ -389,2 +398 @@ void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
389} }
390