Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index fe2ab51..771aa00 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -1,21 +1,22 @@ | |||
1 | #include "namespace_hack.h" | 1 | #include "namespace_hack.h" |
2 | #include "datebookweeklst.h" | 2 | #include "datebookweeklst.h" |
3 | 3 | ||
4 | #include "datebook.h" | 4 | #include "datebook.h" |
5 | 5 | ||
6 | #include <opie2/odebug.h> | 6 | #include <opie2/odebug.h> |
7 | 7 | ||
8 | #include <qpe/datebookmonth.h> | 8 | #include <qpe/datebookmonth.h> |
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | #include <qpe/ir.h> | ||
10 | #include <qpe/resource.h> | 11 | #include <qpe/resource.h> |
11 | 12 | ||
12 | #include <qlayout.h> | 13 | #include <qlayout.h> |
13 | #include <qtoolbutton.h> | 14 | #include <qtoolbutton.h> |
14 | #include <qtl.h> | 15 | #include <qtl.h> |
15 | 16 | ||
16 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); | 17 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); |
17 | 18 | ||
18 | using namespace Opie::Ui; | 19 | using namespace Opie::Ui; |
19 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) | 20 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) |
20 | : DateBookWeekLstHeaderBase(parent, name, fl) | 21 | : DateBookWeekLstHeaderBase(parent, name, fl) |
21 | { | 22 | { |
@@ -183,31 +184,53 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | |||
183 | s=day; | 184 | s=day; |
184 | } else if(ev.startDate()==ev.date()) {// start event. | 185 | } else if(ev.startDate()==ev.date()) {// start event. |
185 | s=start; | 186 | s=start; |
186 | } else if(ev.endDate()==ev.date()) { // end event. | 187 | } else if(ev.endDate()==ev.date()) { // end event. |
187 | s=end; | 188 | s=end; |
188 | } else {// middle day. | 189 | } else {// middle day. |
189 | s=middle; | 190 | s=middle; |
190 | } | 191 | } |
191 | } else { | 192 | } else { |
192 | s=""; | 193 | s=""; |
193 | } | 194 | } |
194 | setText(QString(s) + " " + ev.description()); | 195 | setText(QString(s) + " " + ev.description()); |
195 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 196 | //connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
196 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 197 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
197 | } | 198 | } |
198 | void DateBookWeekLstEvent::editMe() { | 199 | void DateBookWeekLstEvent::editMe() { |
199 | emit editEvent(event.event()); | 200 | emit editEvent(event.event()); |
200 | } | 201 | } |
201 | 202 | void DateBookWeekLstEvent::duplicateMe() | |
203 | { | ||
204 | emit duplicateEvent(event.event()); | ||
205 | } | ||
206 | void DateBookWeekLstEvent::deleteMe() | ||
207 | { | ||
208 | emit removeEvent(event.event()); | ||
209 | emit redraw(); | ||
210 | } | ||
211 | void DateBookWeekLstEvent::beamMe() | ||
212 | { | ||
213 | emit beamEvent( event.event() ); | ||
214 | } | ||
215 | void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) | ||
216 | { | ||
217 | popmenue = new QPopupMenu; | ||
218 | popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); | ||
219 | popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); | ||
220 | popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); | ||
221 | if(Ir::supported()) | ||
222 | popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); | ||
223 | popmenue->popup( mapToGlobal( e->pos() )); | ||
224 | } | ||
202 | 225 | ||
203 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | 226 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, |
204 | const QDate &d, bool onM, | 227 | const QDate &d, bool onM, |
205 | QWidget* parent, | 228 | QWidget* parent, |
206 | const char* name, WFlags fl) | 229 | const char* name, WFlags fl) |
207 | : QWidget( parent, name, fl ) | 230 | : QWidget( parent, name, fl ) |
208 | { | 231 | { |
209 | Config config("DateBook"); | 232 | Config config("DateBook"); |
210 | config.setGroup("Main"); | 233 | config.setGroup("Main"); |
211 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); | 234 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); |
212 | odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; | 235 | odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; |
213 | 236 | ||
@@ -239,53 +262,65 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | |||
239 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); | 262 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); |
240 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 263 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
241 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 264 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
242 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 265 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
243 | layout->addWidget(hdr); | 266 | layout->addWidget(hdr); |
244 | 267 | ||
245 | // Events | 268 | // Events |
246 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 269 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { |
247 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. | 270 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. |
248 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); | 271 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); |
249 | layout->addWidget(l); | 272 | layout->addWidget(l); |
250 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 273 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
274 | connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
275 | connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
276 | connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
277 | connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
251 | } | 278 | } |
252 | it++; | 279 | it++; |
253 | } | 280 | } |
254 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 281 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
255 | } | 282 | } |
256 | } | 283 | } |
257 | DateBookWeekLstView::~DateBookWeekLstView(){} | 284 | DateBookWeekLstView::~DateBookWeekLstView(){} |
258 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | 285 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} |
259 | 286 | ||
260 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 287 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
261 | QValueList<EffectiveEvent> &ev2, | 288 | QValueList<EffectiveEvent> &ev2, |
262 | QDate &d, bool onM, | 289 | QDate &d, bool onM, |
263 | QWidget* parent, | 290 | QWidget* parent, |
264 | const char* name, WFlags fl) | 291 | const char* name, WFlags fl) |
265 | : QWidget( parent, name, fl ) | 292 | : QWidget( parent, name, fl ) |
266 | { | 293 | { |
267 | QHBoxLayout *layout = new QHBoxLayout( this ); | 294 | QHBoxLayout *layout = new QHBoxLayout( this ); |
268 | 295 | ||
269 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | 296 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); |
270 | layout->addWidget(w); | 297 | layout->addWidget(w); |
271 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 298 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
299 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
300 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
301 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
302 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
272 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 303 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
273 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 304 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
274 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 305 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
275 | 306 | ||
276 | 307 | ||
277 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | 308 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); |
278 | layout->addWidget(w); | 309 | layout->addWidget(w); |
279 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 310 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
311 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
312 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
313 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
314 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
280 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 315 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
281 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 316 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
282 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 317 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
283 | } | 318 | } |
284 | 319 | ||
285 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | 320 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, |
286 | QWidget *parent, | 321 | QWidget *parent, |
287 | const char *name ) | 322 | const char *name ) |
288 | : QWidget( parent, name ), | 323 | : QWidget( parent, name ), |
289 | db( newDB ), | 324 | db( newDB ), |
290 | startTime( 0 ), | 325 | startTime( 0 ), |
291 | ampm( ap ), | 326 | ampm( ap ), |
@@ -353,24 +388,28 @@ void DateBookWeekLst::getEvents() { | |||
353 | 388 | ||
354 | if (view) delete view; | 389 | if (view) delete view; |
355 | if (dbl) { | 390 | if (dbl) { |
356 | QDate start2=start.addDays(7); | 391 | QDate start2=start.addDays(7); |
357 | stop=start2.addDays(6); | 392 | stop=start2.addDays(6); |
358 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | 393 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); |
359 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); | 394 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); |
360 | } else { | 395 | } else { |
361 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); | 396 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); |
362 | } | 397 | } |
363 | 398 | ||
364 | connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 399 | connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
400 | connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
401 | connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
402 | connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
403 | connect (view, SIGNAL(redraw()), this, SLOT(redraw())); | ||
365 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 404 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
366 | connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 405 | connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
367 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 406 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
368 | 407 | ||
369 | scroll->addChild(view); | 408 | scroll->addChild(view); |
370 | view->show(); | 409 | view->show(); |
371 | scroll->updateScrollBars(); | 410 | scroll->updateScrollBars(); |
372 | } | 411 | } |
373 | 412 | ||
374 | void DateBookWeekLst::dateChanged(QDate &newdate) { | 413 | void DateBookWeekLst::dateChanged(QDate &newdate) { |
375 | bdate=newdate; | 414 | bdate=newdate; |
376 | getEvents(); | 415 | getEvents(); |