Diffstat (limited to 'core/pim/datebook/modules/weeklst/datebookweeklstview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/modules/weeklst/datebookweeklstview.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp new file mode 100644 index 0000000..efb4c01 --- a/dev/null +++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp | |||
@@ -0,0 +1,73 @@ | |||
1 | #include "datebookweeklstview.h" | ||
2 | #include "datebooktypes.h" | ||
3 | #include "datebookweeklstdayhdr.h" | ||
4 | #include "datebookweeklstheader.h" | ||
5 | #include "datebookweeklstevent.h" | ||
6 | |||
7 | #include <opie2/odebug.h> | ||
8 | |||
9 | #include <qpe/config.h> | ||
10 | |||
11 | #include <qlayout.h> | ||
12 | #include <qtl.h> | ||
13 | |||
14 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | ||
15 | const QDate &d, bool onM, | ||
16 | QWidget* parent, | ||
17 | const char* name, WFlags fl) | ||
18 | : QWidget( parent, name, fl ) | ||
19 | { | ||
20 | Config config("DateBook"); | ||
21 | config.setGroup("Main"); | ||
22 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); | ||
23 | odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; | ||
24 | |||
25 | bStartOnMonday=onM; | ||
26 | setPalette(white); | ||
27 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | ||
28 | |||
29 | QVBoxLayout *layout = new QVBoxLayout( this ); | ||
30 | |||
31 | qBubbleSort(ev); | ||
32 | QValueListIterator<EffectiveEvent> it; | ||
33 | it=ev.begin(); | ||
34 | |||
35 | int dayOrder[7]; | ||
36 | if (bStartOnMonday) { | ||
37 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | ||
38 | } else { | ||
39 | for (int d=0; d<7; d++) dayOrder[d]=d; | ||
40 | dayOrder[0]=7; | ||
41 | } | ||
42 | |||
43 | // Calculate offset to first day of week. | ||
44 | int dayoffset=d.dayOfWeek(); | ||
45 | if(bStartOnMonday) dayoffset--; | ||
46 | else if( dayoffset == 7 ) dayoffset = 0; | ||
47 | |||
48 | for (int i=0; i<7; i++) { | ||
49 | // Header | ||
50 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); | ||
51 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
52 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
53 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | ||
54 | layout->addWidget(hdr); | ||
55 | |||
56 | // Events | ||
57 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | ||
58 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. | ||
59 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); | ||
60 | layout->addWidget(l); | ||
61 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
62 | connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
63 | connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
64 | connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
65 | connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
66 | } | ||
67 | it++; | ||
68 | } | ||
69 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | ||
70 | } | ||
71 | } | ||
72 | DateBookWeekLstView::~DateBookWeekLstView(){} | ||
73 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | ||