Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 123 |
1 files changed, 66 insertions, 57 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 3d6a029..3c8fc89 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp @@ -1,8 +1,10 @@ #include "datebookweeklst.h" #include "datebookweekheaderimpl.h" +#include "datebook.h" + #include <qpe/calendar.h> #include <qpe/datebookdb.h> #include <qpe/event.h> #include <qpe/qpeapplication.h> @@ -142,26 +144,46 @@ void DateBookWeekLstDayHdr::newEvent() { emit addEvent(start,stop,"",0); } DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, + int weeklistviewconfig, QWidget* parent, const char* name, - WFlags fl) : - OClickableLabel(parent,name,fl), - event(ev) + WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) { - char s[10]; - if ( ev.startDate() != ev.date() ) { // multiday event (not first day) - if ( ev.endDate() == ev.date() ) { // last day - strcpy(s, "__|__"); - } else { - strcpy(s, " |---"); + // old values... lastday = "__|__", middle=" |---", Firstday="00:00", + QString s,start,middle,end,day; + + qDebug("weeklistviewconfig=%d",weeklistviewconfig); + if(weeklistviewconfig==NONE) { // No times displayed. +// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); +// middle.sprintf("<--->"); +// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); +// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); + } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. + start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); + middle.sprintf(" |---"); + end.sprintf("__|__"); + day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); + } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. + start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); + middle.sprintf("<--->"); + end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); + day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); + } + + if(ev.event().type() == Event::Normal) { + if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. + s=day; + } else if(ev.startDate()==ev.date()) { // start event. + s=start; + } else if(ev.endDate()==ev.date()) { // end event. + s=end; + } else { // middle day. + s=middle; } } else { - if(ev.event().type() == Event::Normal ) - sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); - else - sprintf(s," "); + s=""; } setText(QString(s) + " " + ev.description()); connect(this, SIGNAL(clicked()), this, SLOT(editMe())); setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); @@ -176,8 +198,13 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { + Config config("DateBook"); + config.setGroup("Main"); + int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); + qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); + onMonday=onM; setPalette(white); setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); @@ -187,36 +214,30 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, QValueListIterator<EffectiveEvent> it; it=ev.begin(); int dayOrder[7]; - if (onMonday) + if (onMonday) { for (int d=0; d<7; d++) dayOrder[d]=d+1; - else { + } else { for (int d=0; d<7; d++) dayOrder[d]=d; dayOrder[0]=7; } for (int i=0; i<7; i++) { // Header - DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), - onMonday,this); + DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,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 &)), - this, SIGNAL(addEvent(const QDateTime &, - const QDateTime &, - const QString &, const QString &))); + connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), + this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); layout->addWidget(hdr); // Events while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. - DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); + DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); layout->addWidget(l); - connect (l, SIGNAL(editEvent(const Event &)), - this, SIGNAL(editEvent(const Event &))); + connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); } it++; } @@ -236,28 +257,20 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, QHBoxLayout *layout = new QHBoxLayout( this ); DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); layout->addWidget(w); - connect (w, SIGNAL(editEvent(const Event &)), - this, SIGNAL(editEvent(const Event &))); - connect (w, SIGNAL(showDate(int,int,int)), - this, SIGNAL(showDate(int,int,int))); - connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, - const QString &,const QString &)), - this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, - const QString &, const QString &))); + connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); + connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); + connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), + this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); layout->addWidget(w); - connect (w, SIGNAL(editEvent(const Event &)), - this, SIGNAL(editEvent(const Event &))); - connect (w, SIGNAL(showDate(int,int,int)), - this, SIGNAL(showDate(int,int,int))); - connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, - const QString &, const QString &)), - this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, - const QString &, const QString &))); + connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); + connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); + connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), + this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); } DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, QWidget *parent, @@ -273,12 +286,10 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, layout->setMargin(0); header=new DateBookWeekLstHeader(onM, this); layout->addWidget( header ); - connect(header, SIGNAL(dateChanged(int,int)), - this, SLOT(dateChanged(int,int))); - connect(header, SIGNAL(setDbl(bool)), - this, SLOT(setDbl(bool))); + connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); + connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); scroll=new QScrollView(this); //scroll->setVScrollBarMode(QScrollView::AlwaysOn); //scroll->setHScrollBarMode(QScrollView::AlwaysOff); @@ -315,10 +326,13 @@ QDate DateBookWeekLst::date() const { d.setYMD(year,1,1); int dow= d.dayOfWeek(); if (!onMonday) - if (dow==7) dow=1; - else dow++; + if (dow==7) { + dow=1; + } else { + dow++; + } d=d.addDays( (_week-1)*7 - dow + 1 ); return d; } @@ -332,22 +346,17 @@ void DateBookWeekLst::getEvents() { if (dbl) { QDate start2=start.addDays(7); stop=start2.addDays(6); QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); - view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); } else { view=new DateBookWeekLstView(el,start,onMonday,scroll); } - connect (view, SIGNAL(editEvent(const Event &)), - this, SIGNAL(editEvent(const Event &))); - connect (view, SIGNAL(showDate(int,int,int)), - this, SIGNAL(showDate(int,int,int))); - connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, - const QString &, const QString &)), - this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, - const QString &, const QString &))); + connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); + connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); + connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), + this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); scroll->addChild(view); view->show(); scroll->updateScrollBars(); |