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/datebookweeklst.cpp | |
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/datebookweeklst.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/modules/weeklst/datebookweeklst.cpp | 61 |
1 files changed, 41 insertions, 20 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 | |||
@@ -28,4 +28,5 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, | |||
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); |
@@ -40,5 +41,5 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, | |||
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"); |
@@ -46,4 +47,5 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, | |||
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"); |
@@ -59,6 +61,13 @@ void DateBookWeekLst::setDate(const QDate &d) { | |||
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 | ||
@@ -83,36 +92,48 @@ QDate DateBookWeekLst::weekDate() const | |||
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 | } |