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 | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp index efb4c01..82b9c6d 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp +++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp | |||
@@ -1,73 +1,104 @@ | |||
1 | #include "datebookweeklstview.h" | 1 | #include "datebookweeklstview.h" |
2 | #include "datebooktypes.h" | 2 | #include "datebooktypes.h" |
3 | #include "datebookweeklstdayhdr.h" | 3 | #include "datebookweeklstdayhdr.h" |
4 | #include "datebookweeklstheader.h" | 4 | #include "datebookweeklstheader.h" |
5 | #include "datebookweeklstevent.h" | 5 | #include "datebookweeklstevent.h" |
6 | 6 | ||
7 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
8 | 8 | ||
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | 10 | ||
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | #include <qtl.h> | 12 | #include <qtl.h> |
13 | 13 | ||
14 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | 14 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, |
15 | const QDate &d, bool onM, | 15 | const QDate &d, bool onM, |
16 | QWidget* parent, | 16 | QWidget* parent, |
17 | const char* name, WFlags fl) | 17 | const char* name, WFlags fl) |
18 | : QWidget( parent, name, fl ) | 18 | : QWidget( parent, name, fl ) |
19 | { | 19 | { |
20 | childs.clear(); | ||
21 | m_MainLayout = new QVBoxLayout( this ); | ||
22 | setEvents(ev,d,onM); | ||
23 | } | ||
24 | |||
25 | void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM) | ||
26 | { | ||
27 | QValueList<QObject*>::Iterator wIter; | ||
28 | for (wIter=childs.begin();wIter!=childs.end();++wIter) { | ||
29 | QObject*w = (*wIter); | ||
30 | delete w; | ||
31 | } | ||
32 | childs.clear(); | ||
33 | |||
34 | setUpdatesEnabled(false); | ||
35 | // m_MainLayout->deleteAllItems(); | ||
20 | Config config("DateBook"); | 36 | Config config("DateBook"); |
21 | config.setGroup("Main"); | 37 | config.setGroup("Main"); |
22 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); | 38 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); |
23 | odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; | 39 | odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; |
24 | 40 | ||
25 | bStartOnMonday=onM; | 41 | bStartOnMonday=onM; |
26 | setPalette(white); | 42 | setPalette(white); |
27 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | 43 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); |
28 | 44 | ||
29 | QVBoxLayout *layout = new QVBoxLayout( this ); | ||
30 | |||
31 | qBubbleSort(ev); | 45 | qBubbleSort(ev); |
32 | QValueListIterator<EffectiveEvent> it; | 46 | QValueListIterator<EffectiveEvent> it; |
33 | it=ev.begin(); | 47 | it=ev.begin(); |
34 | 48 | ||
35 | int dayOrder[7]; | 49 | int dayOrder[7]; |
36 | if (bStartOnMonday) { | 50 | if (bStartOnMonday) { |
37 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | 51 | for (int d=0; d<7; d++) dayOrder[d]=d+1; |
38 | } else { | 52 | } else { |
39 | for (int d=0; d<7; d++) dayOrder[d]=d; | 53 | for (int d=0; d<7; d++) dayOrder[d]=d; |
40 | dayOrder[0]=7; | 54 | dayOrder[0]=7; |
41 | } | 55 | } |
42 | 56 | ||
43 | // Calculate offset to first day of week. | 57 | // Calculate offset to first day of week. |
44 | int dayoffset=d.dayOfWeek(); | 58 | int dayoffset=d.dayOfWeek(); |
45 | if(bStartOnMonday) dayoffset--; | 59 | if(bStartOnMonday) dayoffset--; |
46 | else if( dayoffset == 7 ) dayoffset = 0; | 60 | else if( dayoffset == 7 ) dayoffset = 0; |
47 | 61 | ||
48 | for (int i=0; i<7; i++) { | 62 | for (int i=0; i<7; i++) { |
63 | QWidget*w = new QWidget(this); | ||
64 | w->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | ||
65 | w->setPalette(white); | ||
66 | QVBoxLayout * tlayout = new QVBoxLayout(w); | ||
67 | childs.append(w); | ||
49 | // Header | 68 | // Header |
50 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); | 69 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,w); |
51 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 70 | 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&)), | 71 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
53 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 72 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
54 | layout->addWidget(hdr); | 73 | tlayout->addWidget(hdr); |
55 | 74 | ||
56 | // Events | 75 | // Events |
57 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 76 | 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. | 77 | 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); | 78 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,w); |
60 | layout->addWidget(l); | 79 | tlayout->addWidget(l); |
61 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 80 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
62 | connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | 81 | connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); |
63 | connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | 82 | connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); |
64 | connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | 83 | connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); |
65 | connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); | 84 | connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); |
66 | } | 85 | } |
67 | it++; | 86 | it++; |
68 | } | 87 | } |
69 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 88 | tlayout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
89 | m_MainLayout->addWidget(w); | ||
90 | /* | ||
91 | QSpacerItem * tmp = new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding); | ||
92 | m_MainLayout->addItem(tmp); | ||
93 | */ | ||
70 | } | 94 | } |
95 | setUpdatesEnabled(true); | ||
96 | } | ||
97 | |||
98 | DateBookWeekLstView::~DateBookWeekLstView() | ||
99 | {} | ||
100 | |||
101 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) | ||
102 | { | ||
103 | e->ignore(); | ||
71 | } | 104 | } |
72 | DateBookWeekLstView::~DateBookWeekLstView(){} | ||
73 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | ||