summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweeklst.cpp
authorumopapisdn <umopapisdn>2003-04-12 03:56:46 (UTC)
committer umopapisdn <umopapisdn>2003-04-12 03:56:46 (UTC)
commit8c690a7bb709773217ba3d39d3ef769a2414cc72 (patch) (side-by-side diff)
treea34bae70ee8dc46f40f60150e1703088fbc4da36 /core/pim/datebook/datebookweeklst.cpp
parent212aef7fd20182fe926644af2ab10a4b49549440 (diff)
downloadopie-8c690a7bb709773217ba3d39d3ef769a2414cc72.zip
opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.tar.gz
opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.tar.bz2
New feature:
Added a configurable option to make the weeklist view display either no times at all, only start times, or both start and end time. Also moved the configuration of default view from the menu into the preference dialog.
Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweeklst.cpp297
1 files changed, 153 insertions, 144 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
@@ -3,4 +3,6 @@
#include "datebookweekheaderimpl.h"
+#include "datebook.h"
+
#include <qpe/calendar.h>
#include <qpe/datebookdb.h>
@@ -144,22 +146,42 @@ void DateBookWeekLstDayHdr::newEvent() {
}
DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
- QWidget* parent,
- const char* name,
- WFlags fl) :
- OClickableLabel(parent,name,fl),
- event(ev)
+ int weeklistviewconfig,
+ QWidget* parent,
+ const char* name,
+ 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());
@@ -168,5 +190,5 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
}
void DateBookWeekLstEvent::editMe() {
- emit editEvent(event.event());
+ emit editEvent(event.event());
}
@@ -178,34 +200,34 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
: QWidget( parent, name, fl )
{
- onMonday=onM;
- setPalette(white);
- setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
+ Config config("DateBook");
+ config.setGroup("Main");
+ int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
+ qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
- QVBoxLayout *layout = new QVBoxLayout( this );
+ onMonday=onM;
+ setPalette(white);
+ setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
- qBubbleSort(ev);
- QValueListIterator<EffectiveEvent> it;
- it=ev.begin();
+ QVBoxLayout *layout = new QVBoxLayout( this );
- int dayOrder[7];
- if (onMonday)
- for (int d=0; d<7; d++) dayOrder[d]=d+1;
- else {
- for (int d=0; d<7; d++) dayOrder[d]=d;
- dayOrder[0]=7;
- }
+ qBubbleSort(ev);
+ QValueListIterator<EffectiveEvent> it;
+ it=ev.begin();
+
+ int dayOrder[7];
+ if (onMonday) {
+ for (int d=0; d<7; d++) dayOrder[d]=d+1;
+ } 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);
@@ -213,8 +235,7 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
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++;
@@ -234,28 +255,20 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
: QWidget( parent, name, fl )
{
- 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 &)));
-
-
- 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 &)));
+ 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 &)));
+
+
+ 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 &)));
}
@@ -275,107 +288,103 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
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)));
-
- scroll=new QScrollView(this);
- //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
- //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
- scroll->setResizePolicy(QScrollView::AutoOneFit);
- layout->addWidget(scroll);
-
- view=NULL;
- Config config("DateBook");
- config.setGroup("Main");
- dbl=config.readBoolEntry("weeklst_dbl", false);
- header->dbl->setOn(dbl);
+ 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);
+ scroll->setResizePolicy(QScrollView::AutoOneFit);
+ layout->addWidget(scroll);
+
+ view=NULL;
+ Config config("DateBook");
+ config.setGroup("Main");
+ dbl=config.readBoolEntry("weeklst_dbl", false);
+ header->dbl->setOn(dbl);
}
DateBookWeekLst::~DateBookWeekLst(){
- Config config("DateBook");
- config.setGroup("Main");
- config.writeEntry("weeklst_dbl", dbl);
+ Config config("DateBook");
+ config.setGroup("Main");
+ config.writeEntry("weeklst_dbl", dbl);
}
void DateBookWeekLst::setDate(const QDate &d) {
- int w,y;
- calcWeek(d,w,y,onMonday);
- year=y;
- _week=w;
- header->setDate(date());
+ int w,y;
+ calcWeek(d,w,y,onMonday);
+ year=y;
+ _week=w;
+ header->setDate(date());
}
void DateBookWeekLst::setDbl(bool on) {
- dbl=on;
- redraw();
+ dbl=on;
+ redraw();
}
void DateBookWeekLst::redraw() {getEvents();}
QDate DateBookWeekLst::date() const {
- QDate d;
- d.setYMD(year,1,1);
+ QDate d;
+ d.setYMD(year,1,1);
- int dow= d.dayOfWeek();
- if (!onMonday)
- if (dow==7) dow=1;
- else dow++;
+ int dow= d.dayOfWeek();
+ if (!onMonday)
+ if (dow==7) {
+ dow=1;
+ } else {
+ dow++;
+ }
- d=d.addDays( (_week-1)*7 - dow + 1 );
- return d;
+ d=d.addDays( (_week-1)*7 - dow + 1 );
+ return d;
}
void DateBookWeekLst::getEvents() {
- QDate start = date();
- QDate stop = start.addDays(6);
- QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
-
- if (view) delete view;
- 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);
- }
+ QDate start = date();
+ QDate stop = start.addDays(6);
+ QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
+
+ if (view) delete view;
+ 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();
+ scroll->addChild(view);
+ view->show();
+ scroll->updateScrollBars();
}
void DateBookWeekLst::dateChanged(int y, int w) {
- year=y;
- _week=w;
- getEvents();
+ year=y;
+ _week=w;
+ getEvents();
}
void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
{
- switch(e->key()) {
- case Key_Up:
- scroll->scrollBy(0, -20);
- break;
- case Key_Down:
- scroll->scrollBy(0, 20);
- break;
- case Key_Left:
- header->prevWeek();
- break;
- case Key_Right:
- header->nextWeek();
- break;
- default:
- e->ignore();
- }
+ switch(e->key()) {
+ case Key_Up:
+ scroll->scrollBy(0, -20);
+ break;
+ case Key_Down:
+ scroll->scrollBy(0, 20);
+ break;
+ case Key_Left:
+ header->prevWeek();
+ break;
+ case Key_Right:
+ header->nextWeek();
+ break;
+ default:
+ e->ignore();
+ }
}