author | alwin <alwin> | 2005-03-19 18:06:44 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-19 18:06:44 (UTC) |
commit | ff7fd64d755b2cc63f9944b1a17a6a2e186da0b6 (patch) (unidiff) | |
tree | 11c335300ae6e9dd55b62e5558e56a85222d3fb6 /core/pim/datebook/modules/weeklst | |
parent | 93d0e2c50c24c518323d7926df37827d3b562a28 (diff) | |
download | opie-ff7fd64d755b2cc63f9944b1a17a6a2e186da0b6.zip opie-ff7fd64d755b2cc63f9944b1a17a6a2e186da0b6.tar.gz opie-ff7fd64d755b2cc63f9944b1a17a6a2e186da0b6.tar.bz2 |
hopefull speedup the weeklistview.
deleting the main widget 4 times when date changed isn't that usefull.
After 1.2 OPIE this view should completly rewritten or removed.
Diffstat (limited to 'core/pim/datebook/modules/weeklst') (more/less context) (show whitespace changes)
6 files changed, 221 insertions, 54 deletions
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp index 47bc597..6556373 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp +++ b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp | |||
@@ -22,49 +22,58 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, | |||
22 | const char *name ) | 22 | const char *name ) |
23 | : QWidget( parent, name ), | 23 | : QWidget( parent, name ), |
24 | db( newDB ), | 24 | db( newDB ), |
25 | startTime( 0 ), | 25 | startTime( 0 ), |
26 | ampm( ap ), | 26 | ampm( ap ), |
27 | bStartOnMonday(onM) | 27 | bStartOnMonday(onM) |
28 | { | 28 | { |
29 | setFocusPolicy(StrongFocus); | 29 | setFocusPolicy(StrongFocus); |
30 | dateset = false; | ||
30 | layout = new QVBoxLayout( this ); | 31 | layout = new QVBoxLayout( this ); |
31 | layout->setMargin(0); | 32 | layout->setMargin(0); |
32 | 33 | ||
33 | header=new DateBookWeekLstHeader(onM, this); | 34 | header=new DateBookWeekLstHeader(onM, this); |
34 | layout->addWidget( header ); | 35 | layout->addWidget( header ); |
35 | connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); | 36 | connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); |
36 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); | 37 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); |
37 | 38 | ||
38 | scroll=new QScrollView(this); | 39 | scroll=new QScrollView(this); |
39 | scroll->setResizePolicy(QScrollView::AutoOneFit); | 40 | scroll->setResizePolicy(QScrollView::AutoOneFit); |
40 | layout->addWidget(scroll); | 41 | layout->addWidget(scroll); |
41 | 42 | ||
42 | view=NULL; | 43 | m_CurrentView=NULL; |
43 | Config config("DateBook"); | 44 | Config config("DateBook"); |
44 | config.setGroup("Main"); | 45 | config.setGroup("Main"); |
45 | dbl=config.readBoolEntry("weeklst_dbl", false); | 46 | dbl=config.readBoolEntry("weeklst_dbl", false); |
46 | header->dbl->setOn(dbl); | 47 | header->dbl->setOn(dbl); |
47 | } | 48 | } |
49 | |||
48 | DateBookWeekLst::~DateBookWeekLst(){ | 50 | DateBookWeekLst::~DateBookWeekLst(){ |
49 | Config config("DateBook"); | 51 | Config config("DateBook"); |
50 | config.setGroup("Main"); | 52 | config.setGroup("Main"); |
51 | config.writeEntry("weeklst_dbl", dbl); | 53 | config.writeEntry("weeklst_dbl", dbl); |
52 | } | 54 | } |
53 | 55 | ||
54 | void DateBookWeekLst::setDate(const QDate &d) { | 56 | void DateBookWeekLst::setDate(const QDate &d) { |
55 | bdate=d; | 57 | bdate=d; |
56 | header->setDate(d); | 58 | header->setDate(d); |
57 | } | 59 | } |
58 | 60 | ||
59 | void DateBookWeekLst::setDbl(bool on) { | 61 | void DateBookWeekLst::setDbl(bool on) { |
60 | dbl=on; | 62 | dbl=on; |
61 | redraw(); | 63 | bool displayed = false; |
64 | if (m_CurrentView) { | ||
65 | displayed = m_CurrentView->toggleDoubleView(on); | ||
66 | } | ||
67 | if (!displayed||dbl) { | ||
68 | getEvents(); | ||
69 | } | ||
62 | } | 70 | } |
71 | |||
63 | void DateBookWeekLst::redraw() {getEvents();} | 72 | void DateBookWeekLst::redraw() {getEvents();} |
64 | 73 | ||
65 | QDate DateBookWeekLst::date() { | 74 | QDate DateBookWeekLst::date() { |
66 | return bdate; | 75 | return bdate; |
67 | } | 76 | } |
68 | 77 | ||
69 | // return the date at the beginning of the week... | 78 | // return the date at the beginning of the week... |
70 | // copied from DateBookWeek | 79 | // copied from DateBookWeek |
@@ -77,48 +86,60 @@ QDate DateBookWeekLst::weekDate() const | |||
77 | if(bStartOnMonday) dayoffset--; | 86 | if(bStartOnMonday) dayoffset--; |
78 | else if( dayoffset == 7 ) | 87 | else if( dayoffset == 7 ) |
79 | dayoffset = 0; | 88 | dayoffset = 0; |
80 | 89 | ||
81 | return d.addDays(-dayoffset); | 90 | return d.addDays(-dayoffset); |
82 | } | 91 | } |
83 | 92 | ||
84 | void DateBookWeekLst::getEvents() { | 93 | void DateBookWeekLst::getEvents() { |
94 | if (!dateset) return; | ||
85 | QDate start = weekDate(); //date(); | 95 | QDate start = weekDate(); //date(); |
86 | QDate stop = start.addDays(6); | 96 | QDate stop = start.addDays(6); |
97 | QDate start2; | ||
98 | |||
99 | |||
87 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 100 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
101 | QValueList<EffectiveEvent> el2; | ||
88 | 102 | ||
89 | setUpdatesEnabled(false); | ||
90 | if (view) delete view; | ||
91 | if (dbl) { | 103 | if (dbl) { |
92 | QDate start2=start.addDays(7); | 104 | start2 = start.addDays(7); |
93 | stop=start2.addDays(6); | 105 | stop=start2.addDays(6); |
94 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | 106 | el2 = db->getEffectiveEvents(start2, stop); |
95 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); | 107 | } |
108 | if (!m_CurrentView) { | ||
109 | if (dbl) { | ||
110 | m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); | ||
96 | } else { | 111 | } else { |
97 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); | 112 | m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,scroll); |
98 | } | 113 | } |
99 | 114 | m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | |
100 | connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 115 | connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
101 | connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | 116 | connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); |
102 | connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | 117 | connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); |
103 | connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | 118 | connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); |
104 | connect (view, SIGNAL(redraw()), this, SLOT(redraw())); | 119 | connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw())); |
105 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 120 | connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
106 | connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 121 | connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
107 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 122 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
108 | 123 | scroll->addChild(m_CurrentView); | |
109 | scroll->addChild(view); | 124 | } else { |
110 | view->show(); | 125 | if (dbl) { |
126 | m_CurrentView->setEvents(el,el2,start,bStartOnMonday); | ||
127 | } else { | ||
128 | m_CurrentView->setEvents(el,start,bStartOnMonday); | ||
129 | } | ||
130 | } | ||
111 | scroll->updateScrollBars(); | 131 | scroll->updateScrollBars(); |
112 | setUpdatesEnabled(true); | ||
113 | } | 132 | } |
114 | 133 | ||
115 | void DateBookWeekLst::dateChanged(QDate &newdate) { | 134 | void DateBookWeekLst::dateChanged(QDate &newdate) { |
135 | dateset = true; | ||
116 | bdate=newdate; | 136 | bdate=newdate; |
137 | odebug << "Date changed " << oendl; | ||
117 | getEvents(); | 138 | getEvents(); |
118 | } | 139 | } |
119 | 140 | ||
120 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | 141 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) |
121 | { | 142 | { |
122 | switch(e->key()) { | 143 | switch(e->key()) { |
123 | case Key_Up: | 144 | case Key_Up: |
124 | scroll->scrollBy(0, -20); | 145 | scroll->scrollBy(0, -20); |
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.h b/core/pim/datebook/modules/weeklst/datebookweeklst.h index 3922fa1..505810b 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklst.h +++ b/core/pim/datebook/modules/weeklst/datebookweeklst.h | |||
@@ -5,17 +5,17 @@ | |||
5 | 5 | ||
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | 8 | ||
9 | class DateBookDB; | 9 | class DateBookDB; |
10 | class DateBookDBHoliday; | 10 | class DateBookDBHoliday; |
11 | class DateBookWeekLstHeader; | 11 | class DateBookWeekLstHeader; |
12 | class DateBookWeekLstEvent; | 12 | class DateBookWeekLstEvent; |
13 | class DateBookWeekLstView; | 13 | class DateBookWeekLstDblView; |
14 | class QVBoxLayout; | 14 | class QVBoxLayout; |
15 | class QScrollView; | 15 | class QScrollView; |
16 | 16 | ||
17 | class DateBookWeekLst : public QWidget | 17 | class DateBookWeekLst : public QWidget |
18 | { | 18 | { |
19 | Q_OBJECT | 19 | Q_OBJECT |
20 | 20 | ||
21 | public: | 21 | public: |
@@ -50,16 +50,17 @@ private: | |||
50 | DateBookDBHoliday *db; | 50 | DateBookDBHoliday *db; |
51 | int startTime; | 51 | int startTime; |
52 | bool ampm; | 52 | bool ampm; |
53 | bool bStartOnMonday; | 53 | bool bStartOnMonday; |
54 | bool dbl; | 54 | bool dbl; |
55 | QDate bdate; | 55 | QDate bdate; |
56 | int year, _week,dow; | 56 | int year, _week,dow; |
57 | DateBookWeekLstHeader *header; | 57 | DateBookWeekLstHeader *header; |
58 | QWidget *view; | ||
59 | QVBoxLayout *layout; | 58 | QVBoxLayout *layout; |
60 | QScrollView *scroll; | 59 | QScrollView *scroll; |
60 | DateBookWeekLstDblView*m_CurrentView; | ||
61 | bool dateset:1; | ||
61 | 62 | ||
62 | void getEvents(); | 63 | void getEvents(); |
63 | }; | 64 | }; |
64 | 65 | ||
65 | #endif | 66 | #endif |
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp index 1cea602..6389822 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp | |||
@@ -5,37 +5,127 @@ | |||
5 | 5 | ||
6 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 6 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
7 | QValueList<EffectiveEvent> &ev2, | 7 | QValueList<EffectiveEvent> &ev2, |
8 | QDate &d, bool onM, | 8 | QDate &d, bool onM, |
9 | QWidget* parent, | 9 | QWidget* parent, |
10 | const char* name, WFlags fl) | 10 | const char* name, WFlags fl) |
11 | : QWidget( parent, name, fl ) | 11 | : QWidget( parent, name, fl ) |
12 | { | 12 | { |
13 | QHBoxLayout *layout = new QHBoxLayout( this ); | 13 | m_MainLayout = new QHBoxLayout( this ); |
14 | 14 | ||
15 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | 15 | leftView = 0; |
16 | layout->addWidget(w); | 16 | rightView = 0; |
17 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 17 | setEvents(ev1,ev2,d,onM); |
18 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | 18 | } |
19 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | 19 | |
20 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | 20 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
21 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); | 21 | QDate &d, bool onM, |
22 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 22 | QWidget* parent, |
23 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 23 | const char* name, WFlags fl) |
24 | : QWidget( parent, name, fl ) | ||
25 | { | ||
26 | m_MainLayout = new QHBoxLayout( this ); | ||
27 | |||
28 | leftView = 0; | ||
29 | rightView = 0; | ||
30 | setEvents(ev1,d,onM); | ||
31 | } | ||
32 | |||
33 | /* setting the variant with both views */ | ||
34 | void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueList<EffectiveEvent> &ev2,QDate &d, bool onM) | ||
35 | { | ||
36 | setUpdatesEnabled(false); | ||
37 | if (!leftView) { | ||
38 | leftView=new DateBookWeekLstView(ev1,d,onM,this); | ||
39 | m_MainLayout->addWidget(leftView); | ||
40 | connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
41 | connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
42 | connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
43 | connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
44 | connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
45 | connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
46 | connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
47 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | ||
48 | |||
49 | } else { | ||
50 | leftView->hide(); | ||
51 | leftView->setEvents(ev1,d,onM); | ||
52 | } | ||
53 | |||
54 | if (!rightView) { | ||
55 | rightView=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | ||
56 | m_MainLayout->addWidget(rightView); | ||
57 | connect (rightView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
58 | connect (rightView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
59 | connect (rightView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
60 | connect (rightView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
61 | connect (rightView, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
62 | connect (rightView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
63 | connect (rightView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
64 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | ||
65 | } else { | ||
66 | rightView->hide(); | ||
67 | rightView->setEvents(ev2,d.addDays(7),onM); | ||
68 | } | ||
69 | |||
70 | leftView->show(); | ||
71 | rightView->show(); | ||
72 | setUpdatesEnabled(true); | ||
73 | } | ||
74 | |||
75 | void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM) | ||
76 | { | ||
77 | if (!leftView) { | ||
78 | leftView=new DateBookWeekLstView(ev1,d,onM,this); | ||
79 | m_MainLayout->addWidget(leftView); | ||
80 | connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | ||
81 | connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | ||
82 | connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | ||
83 | connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | ||
84 | connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
85 | connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
86 | connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
24 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 87 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
88 | } else { | ||
89 | leftView->hide(); | ||
90 | leftView->setEvents(ev1,d,onM); | ||
91 | } | ||
92 | leftView->show(); | ||
25 | 93 | ||
94 | if (rightView) { | ||
95 | rightView->hide(); | ||
96 | } | ||
97 | } | ||
26 | 98 | ||
27 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | 99 | void DateBookWeekLstDblView::setRightEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM) |
28 | layout->addWidget(w); | 100 | { |
29 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 101 | if (!rightView) { |
30 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | 102 | rightView=new DateBookWeekLstView(ev1,d,onM,this); |
31 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | 103 | m_MainLayout->addWidget(rightView); |
32 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | 104 | connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
33 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); | 105 | connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); |
34 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 106 | connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); |
35 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 107 | connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); |
108 | connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw())); | ||
109 | connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
110 | connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | ||
36 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 111 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
112 | } else { | ||
113 | rightView->hide(); | ||
114 | rightView->setEvents(ev1,d,onM); | ||
115 | } | ||
116 | rightView->show(); | ||
117 | } | ||
118 | |||
119 | bool DateBookWeekLstDblView::toggleDoubleView(bool how) | ||
120 | { | ||
121 | if (rightView) { | ||
122 | if (how) rightView->show(); | ||
123 | else rightView->hide(); | ||
124 | return true; | ||
125 | } | ||
126 | return false; | ||
37 | } | 127 | } |
38 | 128 | ||
39 | DateBookWeekLstDblView::~DateBookWeekLstDblView() | 129 | DateBookWeekLstDblView::~DateBookWeekLstDblView() |
40 | { | 130 | { |
41 | } | 131 | } |
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h index 57e9690..808556e 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h | |||
@@ -3,29 +3,46 @@ | |||
3 | 3 | ||
4 | #include <qpe/event.h> | 4 | #include <qpe/event.h> |
5 | 5 | ||
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qvaluelist.h> | 7 | #include <qvaluelist.h> |
8 | #include <qdatetime.h> | 8 | #include <qdatetime.h> |
9 | #include <qstring.h> | 9 | #include <qstring.h> |
10 | 10 | ||
11 | class DateBookWeekLstView; | ||
12 | class QHBoxLayout; | ||
13 | |||
11 | class DateBookWeekLstDblView: public QWidget { | 14 | class DateBookWeekLstDblView: public QWidget { |
12 | Q_OBJECT | 15 | Q_OBJECT |
13 | public: | 16 | public: |
14 | DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 17 | DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
15 | QValueList<EffectiveEvent> &ev2, | 18 | QValueList<EffectiveEvent> &ev2, |
16 | QDate &d, bool onM, | 19 | QDate &d, bool onM, |
17 | QWidget* parent = 0, const char* name = 0, | 20 | QWidget* parent = 0, const char* name = 0, |
18 | WFlags fl = 0 ); | 21 | WFlags fl = 0 ); |
22 | DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | ||
23 | QDate &d, bool onM, | ||
24 | QWidget* parent = 0, const char* name = 0, | ||
25 | WFlags fl = 0 ); | ||
19 | virtual ~DateBookWeekLstDblView(); | 26 | virtual ~DateBookWeekLstDblView(); |
27 | void setEvents(QValueList<EffectiveEvent> &ev1,QValueList<EffectiveEvent> &ev2,QDate &d, bool onM); | ||
28 | void setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM); | ||
29 | void setRightEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM); | ||
30 | |||
31 | bool toggleDoubleView(bool how); | ||
32 | |||
20 | signals: | 33 | signals: |
21 | void editEvent(const Event &e); | 34 | void editEvent(const Event &e); |
22 | void duplicateEvent(const Event &e); | 35 | void duplicateEvent(const Event &e); |
23 | void removeEvent(const Event &e); | 36 | void removeEvent(const Event &e); |
24 | void beamEvent(const Event &e); | 37 | void beamEvent(const Event &e); |
25 | void redraw(); | 38 | void redraw(); |
26 | void showDate(int y, int m, int d); | 39 | void showDate(int y, int m, int d); |
27 | void addEvent(const QDateTime &start, const QDateTime &stop, | 40 | void addEvent(const QDateTime &start, const QDateTime &stop, |
28 | const QString &str, const QString &location); | 41 | const QString &str, const QString &location); |
42 | |||
43 | protected: | ||
44 | QHBoxLayout*m_MainLayout; | ||
45 | DateBookWeekLstView *leftView,*rightView; | ||
29 | }; | 46 | }; |
30 | 47 | ||
31 | #endif | 48 | #endif |
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 | |||
@@ -12,27 +12,41 @@ | |||
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 { |
@@ -41,33 +55,50 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | |||
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 | */ | ||
94 | } | ||
95 | setUpdatesEnabled(true); | ||
70 | } | 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();} | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.h b/core/pim/datebook/modules/weeklst/datebookweeklstview.h index 2428f1f..3d47842 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstview.h +++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.h | |||
@@ -4,33 +4,40 @@ | |||
4 | #include <qpe/event.h> | 4 | #include <qpe/event.h> |
5 | 5 | ||
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qvaluelist.h> | 7 | #include <qvaluelist.h> |
8 | #include <qstring.h> | 8 | #include <qstring.h> |
9 | #include <qdatetime.h> | 9 | #include <qdatetime.h> |
10 | 10 | ||
11 | class QKeyEvent; | 11 | class QKeyEvent; |
12 | class QVBoxLayout; | ||
12 | 13 | ||
13 | class DateBookWeekLstView: public QWidget | 14 | class DateBookWeekLstView: public QWidget |
14 | { | 15 | { |
15 | Q_OBJECT | 16 | Q_OBJECT |
16 | public: | 17 | public: |
17 | DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, | 18 | DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent = 0, const char* name = 0, |
18 | QWidget* parent = 0, const char* name = 0, | ||
19 | WFlags fl = 0 ); | 19 | WFlags fl = 0 ); |
20 | ~DateBookWeekLstView(); | 20 | ~DateBookWeekLstView(); |
21 | |||
22 | void setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM); | ||
23 | |||
21 | signals: | 24 | signals: |
22 | void editEvent(const Event &e); | 25 | void editEvent(const Event &e); |
23 | void duplicateEvent(const Event &e); | 26 | void duplicateEvent(const Event &e); |
24 | void removeEvent(const Event &e); | 27 | void removeEvent(const Event &e); |
25 | void beamEvent(const Event &e); | 28 | void beamEvent(const Event &e); |
26 | void redraw(); | 29 | void redraw(); |
27 | void showDate(int y, int m, int d); | 30 | void showDate(int y, int m, int d); |
28 | void addEvent(const QDateTime &start, const QDateTime &stop, | 31 | void addEvent(const QDateTime &start, const QDateTime &stop, |
29 | const QString &str, const QString &location); | 32 | const QString &str, const QString &location); |
30 | private: | 33 | protected: |
31 | bool bStartOnMonday; | 34 | bool bStartOnMonday; |
35 | QValueList<QObject*> childs; | ||
36 | |||
37 | QVBoxLayout*m_MainLayout; | ||
38 | |||
32 | protected slots: | 39 | protected slots: |
33 | void keyPressEvent(QKeyEvent *); | 40 | void keyPressEvent(QKeyEvent *); |
34 | }; | 41 | }; |
35 | 42 | ||
36 | #endif | 43 | #endif |