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) (unidiff)
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) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebookweeklst.cpp123
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
@@ -2,6 +2,8 @@
2 2
3#include "datebookweekheaderimpl.h" 3#include "datebookweekheaderimpl.h"
4 4
5#include "datebook.h"
6
5#include <qpe/calendar.h> 7#include <qpe/calendar.h>
6#include <qpe/datebookdb.h> 8#include <qpe/datebookdb.h>
7#include <qpe/event.h> 9#include <qpe/event.h>
@@ -143,24 +145,44 @@ void DateBookWeekLstDayHdr::newEvent() {
143 emit addEvent(start,stop,"",0); 145 emit addEvent(start,stop,"",0);
144} 146}
145DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 147DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
148 int weeklistviewconfig,
146 QWidget* parent, 149 QWidget* parent,
147 const char* name, 150 const char* name,
148 WFlags fl) : 151 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
149 OClickableLabel(parent,name,fl),
150 event(ev)
151{ 152{
152 char s[10]; 153 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
153 if ( ev.startDate() != ev.date() ) { // multiday event (not first day) 154 QString s,start,middle,end,day;
154 if ( ev.endDate() == ev.date() ) { // last day 155
155 strcpy(s, "__|__"); 156 qDebug("weeklistviewconfig=%d",weeklistviewconfig);
156 } else { 157 if(weeklistviewconfig==NONE) {// No times displayed.
157 strcpy(s, " |---"); 158 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
159 // middle.sprintf("<--->");
160 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
161 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
162 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
163 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
164 middle.sprintf(" |---");
165 end.sprintf("__|__");
166 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
167 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
168 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
169 middle.sprintf("<--->");
170 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
171 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
172 }
173
174 if(ev.event().type() == Event::Normal) {
175 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
176 s=day;
177 } else if(ev.startDate()==ev.date()) {// start event.
178 s=start;
179 } else if(ev.endDate()==ev.date()) { // end event.
180 s=end;
181 } else {// middle day.
182 s=middle;
158 } 183 }
159 } else { 184 } else {
160 if(ev.event().type() == Event::Normal ) 185 s="";
161 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute());
162 else
163 sprintf(s," ");
164 } 186 }
165 setText(QString(s) + " " + ev.description()); 187 setText(QString(s) + " " + ev.description());
166 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 188 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
@@ -177,6 +199,11 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
177 const char* name, WFlags fl) 199 const char* name, WFlags fl)
178 : QWidget( parent, name, fl ) 200 : QWidget( parent, name, fl )
179{ 201{
202 Config config("DateBook");
203 config.setGroup("Main");
204 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
205 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
206
180 onMonday=onM; 207 onMonday=onM;
181 setPalette(white); 208 setPalette(white);
182 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 209 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
@@ -188,34 +215,28 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
188 it=ev.begin(); 215 it=ev.begin();
189 216
190 int dayOrder[7]; 217 int dayOrder[7];
191 if (onMonday) 218 if (onMonday) {
192 for (int d=0; d<7; d++) dayOrder[d]=d+1; 219 for (int d=0; d<7; d++) dayOrder[d]=d+1;
193 else { 220 } else {
194 for (int d=0; d<7; d++) dayOrder[d]=d; 221 for (int d=0; d<7; d++) dayOrder[d]=d;
195 dayOrder[0]=7; 222 dayOrder[0]=7;
196 } 223 }
197 224
198 for (int i=0; i<7; i++) { 225 for (int i=0; i<7; i++) {
199 // Header 226 // Header
200 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), 227 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this);
201 onMonday,this);
202 connect(hdr, SIGNAL(showDate(int,int,int)), 228 connect(hdr, SIGNAL(showDate(int,int,int)),
203 this, SIGNAL(showDate(int,int,int))); 229 this, SIGNAL(showDate(int,int,int)));
204 connect(hdr, SIGNAL(addEvent(const QDateTime &, 230 connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
205 const QDateTime &, 231 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
206 const QString &, const QString &)),
207 this, SIGNAL(addEvent(const QDateTime &,
208 const QDateTime &,
209 const QString &, const QString &)));
210 layout->addWidget(hdr); 232 layout->addWidget(hdr);
211 233
212 // Events 234 // Events
213 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 235 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
214 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. 236 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
215 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); 237 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
216 layout->addWidget(l); 238 layout->addWidget(l);
217 connect (l, SIGNAL(editEvent(const Event &)), 239 connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
218 this, SIGNAL(editEvent(const Event &)));
219 } 240 }
220 it++; 241 it++;
221 } 242 }
@@ -237,26 +258,18 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
237 258
238 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 259 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
239 layout->addWidget(w); 260 layout->addWidget(w);
240 connect (w, SIGNAL(editEvent(const Event &)), 261 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
241 this, SIGNAL(editEvent(const Event &))); 262 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
242 connect (w, SIGNAL(showDate(int,int,int)), 263 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)),
243 this, SIGNAL(showDate(int,int,int))); 264 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
244 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
245 const QString &,const QString &)),
246 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
247 const QString &, const QString &)));
248 265
249 266
250 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 267 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
251 layout->addWidget(w); 268 layout->addWidget(w);
252 connect (w, SIGNAL(editEvent(const Event &)), 269 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
253 this, SIGNAL(editEvent(const Event &))); 270 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
254 connect (w, SIGNAL(showDate(int,int,int)), 271 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
255 this, SIGNAL(showDate(int,int,int))); 272 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
256 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
257 const QString &, const QString &)),
258 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
259 const QString &, const QString &)));
260} 273}
261 274
262DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 275DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
@@ -274,10 +287,8 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
274 287
275 header=new DateBookWeekLstHeader(onM, this); 288 header=new DateBookWeekLstHeader(onM, this);
276 layout->addWidget( header ); 289 layout->addWidget( header );
277 connect(header, SIGNAL(dateChanged(int,int)), 290 connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int)));
278 this, SLOT(dateChanged(int,int))); 291 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
279 connect(header, SIGNAL(setDbl(bool)),
280 this, SLOT(setDbl(bool)));
281 292
282 scroll=new QScrollView(this); 293 scroll=new QScrollView(this);
283 //scroll->setVScrollBarMode(QScrollView::AlwaysOn); 294 //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
@@ -316,8 +327,11 @@ QDate DateBookWeekLst::date() const {
316 327
317 int dow= d.dayOfWeek(); 328 int dow= d.dayOfWeek();
318 if (!onMonday) 329 if (!onMonday)
319 if (dow==7) dow=1; 330 if (dow==7) {
320 else dow++; 331 dow=1;
332 } else {
333 dow++;
334 }
321 335
322 d=d.addDays( (_week-1)*7 - dow + 1 ); 336 d=d.addDays( (_week-1)*7 - dow + 1 );
323 return d; 337 return d;
@@ -333,20 +347,15 @@ void DateBookWeekLst::getEvents() {
333 QDate start2=start.addDays(7); 347 QDate start2=start.addDays(7);
334 stop=start2.addDays(6); 348 stop=start2.addDays(6);
335 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 349 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
336
337 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); 350 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll);
338 } else { 351 } else {
339 view=new DateBookWeekLstView(el,start,onMonday,scroll); 352 view=new DateBookWeekLstView(el,start,onMonday,scroll);
340 } 353 }
341 354
342 connect (view, SIGNAL(editEvent(const Event &)), 355 connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
343 this, SIGNAL(editEvent(const Event &))); 356 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
344 connect (view, SIGNAL(showDate(int,int,int)), 357 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
345 this, SIGNAL(showDate(int,int,int))); 358 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
346 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
347 const QString &, const QString &)),
348 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
349 const QString &, const QString &)));
350 359
351 scroll->addChild(view); 360 scroll->addChild(view);
352 view->show(); 361 view->show();