summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweeklst.cpp
Side-by-side diff
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 @@
-bool calcWeek(const QDate &d, int &week, int &year,
- bool startOnMonday = false);
+bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
-DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
- const char* name, WFlags fl)
+DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
: DateBookWeekLstHeaderBase(parent, name, fl)
@@ -38,7 +36,10 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
labelDate->setBackgroundMode( PaletteButton );
- labelWeek->setBackgroundMode( PaletteButton );
- forward->setBackgroundMode( PaletteButton );
- forward->setPixmap( Resource::loadPixmap("forward") );
- back->setBackgroundMode( PaletteButton );
- back->setPixmap( Resource::loadPixmap("back") );
+ forwardweek->setBackgroundMode( PaletteButton );
+ forwardweek->setPixmap( Resource::loadPixmap("forward") );
+ forwardmonth->setBackgroundMode( PaletteButton );
+ forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
+ backweek->setBackgroundMode( PaletteButton );
+ backweek->setPixmap( Resource::loadPixmap("back") );
+ backmonth->setBackgroundMode( PaletteButton );
+ backmonth->setPixmap( Resource::loadPixmap("fastback") );
DateBookWeekLstHeaderBaseLayout->setSpacing(0);
@@ -48,24 +49,30 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
- connect(back, SIGNAL(clicked()), this, SLOT(prevWeek()));
- connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek()));
- connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate()));
+ connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
+ connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
+ connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
+ connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
+ connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
- onMonday=onM;
+ bStartOnMonday=onM;
}
DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
+
void DateBookWeekLstHeader::setDate(const QDate &d) {
+ int year,week,dayofweek;
date=d;
+ dayofweek=d.dayOfWeek();
+ if(bStartOnMonday) dayofweek--;
+ date=date.addDays(-dayofweek);
- int year,week;
- calcWeek(d,week,year,onMonday);
- labelWeek->setText(tr( "W: %1" ).arg( ( QString::number(week)) ) );
-
+ calcWeek(date,week,year,bStartOnMonday);
QDate start=date;
QDate stop=start.addDays(6);
- labelDate->setText( QString::number(start.day()) + " " +
+ labelDate->setText( QString::number(start.day()) + "." +
start.monthName(start.month()) + " - " +
- QString::number(stop.day()) + " " +
- start.monthName(stop.month()) );
+ QString::number(stop.day()) + "." +
+ start.monthName(stop.month()) +" ("+
+ tr("w")+":"+QString::number( week ) +")");
emit dateChanged(year,week);
}
+
void DateBookWeekLstHeader::pickDate() {
@@ -77,4 +84,3 @@ void DateBookWeekLstHeader::pickDate() {
m1->insertItem( picker );
- connect( picker, SIGNAL( dateClicked( int, int, int ) ),
- this, SLOT( setDate( int, int, int ) ) );
+ connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) );
//connect( m1, SIGNAL( aboutToHide() ),
@@ -83,3 +89,3 @@ void DateBookWeekLstHeader::pickDate() {
picker->setDate( date.year(), date.month(), date.day() );
- m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height())));
+ m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
picker->setFocus();
@@ -87,4 +93,3 @@ void DateBookWeekLstHeader::pickDate() {
void DateBookWeekLstHeader::setDate(int y, int m, int d) {
- QDate new_date(y,m,d);
- setDate(new_date);
+ setDate(QDate(y,m,d));
}
@@ -97,2 +102,10 @@ void DateBookWeekLstHeader::prevWeek() {
}
+void DateBookWeekLstHeader::nextMonth()
+{
+ setDate(date.addDays(28));
+}
+void DateBookWeekLstHeader::prevMonth()
+{
+ setDate(date.addDays(-28));
+}
@@ -109,4 +122,3 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
- label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +
- QString::number(d.day()) );
+ label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
add->setText("+");
@@ -130,3 +142,2 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
-
connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
@@ -138,2 +149,3 @@ void DateBookWeekLstDayHdr::showDay() {
}
+
void DateBookWeekLstDayHdr::newEvent() {
@@ -206,3 +218,3 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
- onMonday=onM;
+ bStartOnMonday=onM;
setPalette(white);
@@ -217,3 +229,3 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
int dayOrder[7];
- if (onMonday) {
+ if (bStartOnMonday) {
for (int d=0; d<7; d++) dayOrder[d]=d+1;
@@ -226,5 +238,4 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
// Header
- DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this);
- connect(hdr, SIGNAL(showDate(int,int,int)),
- this, SIGNAL(showDate(int,int,int)));
+ DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), bStartOnMonday,this);
+ connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
@@ -281,3 +292,3 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
ampm( ap ),
- onMonday(onM)
+ bStartOnMonday(onM)
{
@@ -293,4 +304,2 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
scroll=new QScrollView(this);
- //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
- //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
scroll->setResizePolicy(QScrollView::AutoOneFit);
@@ -312,3 +321,3 @@ void DateBookWeekLst::setDate(const QDate &d) {
int w,y;
- calcWeek(d,w,y,onMonday);
+ calcWeek(d,w,y,bStartOnMonday);
year=y;
@@ -328,3 +337,3 @@ QDate DateBookWeekLst::date() const {
int dow= d.dayOfWeek();
- if (!onMonday)
+ if (!bStartOnMonday)
if (dow==7) {
@@ -349,5 +358,5 @@ void DateBookWeekLst::getEvents() {
QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
- view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll);
+ view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
} else {
- view=new DateBookWeekLstView(el,start,onMonday,scroll);
+ view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
}
@@ -389,2 +398 @@ void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
}
-