author | alwin <alwin> | 2005-03-19 18:06:44 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-19 18:06:44 (UTC) |
commit | ff7fd64d755b2cc63f9944b1a17a6a2e186da0b6 (patch) (side-by-side diff) | |
tree | 11c335300ae6e9dd55b62e5558e56a85222d3fb6 | |
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.
7 files changed, 222 insertions, 55 deletions
diff --git a/core/pim/datebook/holiday/christian/christian-holidays.pro b/core/pim/datebook/holiday/christian/christian-holidays.pro index db3c777..c943510 100644 --- a/core/pim/datebook/holiday/christian/christian-holidays.pro +++ b/core/pim/datebook/holiday/christian/christian-holidays.pro @@ -12,7 +12,7 @@ INCLUDEPATH += $(OPIEDIR)/include \ DEPENDPATH += $(OPIEDIR)/include \ ../ ../library -LIBS+= -lqpe -lopiecore2 -lopieui2 -opiepim2 +LIBS+= -lqpe -lopiecore2 -lopieui2 -lopiepim2 DESTDIR = $(OPIEDIR)/plugins/holidays TARGET = chrisholidayplugin 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 @@ -27,6 +27,7 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, bStartOnMonday(onM) { setFocusPolicy(StrongFocus); + dateset = false; layout = new QVBoxLayout( this ); layout->setMargin(0); @@ -39,12 +40,13 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, scroll->setResizePolicy(QScrollView::AutoOneFit); layout->addWidget(scroll); - view=NULL; + m_CurrentView=NULL; Config config("DateBook"); config.setGroup("Main"); dbl=config.readBoolEntry("weeklst_dbl", false); header->dbl->setOn(dbl); } + DateBookWeekLst::~DateBookWeekLst(){ Config config("DateBook"); config.setGroup("Main"); @@ -58,8 +60,15 @@ void DateBookWeekLst::setDate(const QDate &d) { void DateBookWeekLst::setDbl(bool on) { dbl=on; - redraw(); + bool displayed = false; + if (m_CurrentView) { + displayed = m_CurrentView->toggleDoubleView(on); + } + if (!displayed||dbl) { + getEvents(); + } } + void DateBookWeekLst::redraw() {getEvents();} QDate DateBookWeekLst::date() { @@ -82,38 +91,50 @@ QDate DateBookWeekLst::weekDate() const } void DateBookWeekLst::getEvents() { + if (!dateset) return; QDate start = weekDate(); //date(); QDate stop = start.addDays(6); + QDate start2; + + QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); + QValueList<EffectiveEvent> el2; - setUpdatesEnabled(false); - if (view) delete view; if (dbl) { - QDate start2=start.addDays(7); + start2 = start.addDays(7); stop=start2.addDays(6); - QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); - view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); + el2 = db->getEffectiveEvents(start2, stop); + } + if (!m_CurrentView) { + if (dbl) { + m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); } else { - view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); + m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,scroll); } - - connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); - connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); - connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); - connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); - connect (view, SIGNAL(redraw()), this, SLOT(redraw())); - connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); - connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), + m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); + connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); + connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); + connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); + connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw())); + connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); + connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); - - scroll->addChild(view); - view->show(); + scroll->addChild(m_CurrentView); + } else { + if (dbl) { + m_CurrentView->setEvents(el,el2,start,bStartOnMonday); + } else { + m_CurrentView->setEvents(el,start,bStartOnMonday); + } + } scroll->updateScrollBars(); - setUpdatesEnabled(true); } void DateBookWeekLst::dateChanged(QDate &newdate) { + dateset = true; bdate=newdate; + odebug << "Date changed " << oendl; getEvents(); } 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 @@ -10,7 +10,7 @@ class DateBookDB; class DateBookDBHoliday; class DateBookWeekLstHeader; class DateBookWeekLstEvent; -class DateBookWeekLstView; +class DateBookWeekLstDblView; class QVBoxLayout; class QScrollView; @@ -55,9 +55,10 @@ private: QDate bdate; int year, _week,dow; DateBookWeekLstHeader *header; - QWidget *view; QVBoxLayout *layout; QScrollView *scroll; + DateBookWeekLstDblView*m_CurrentView; + bool dateset:1; void getEvents(); }; 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 @@ -10,30 +10,120 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, const char* name, WFlags fl)
: QWidget( parent, name, fl )
{
- QHBoxLayout *layout = new QHBoxLayout( this );
-
- DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
- layout->addWidget(w);
- connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
- connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
- connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
- connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
- connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
- connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
- connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
+ m_MainLayout = new QHBoxLayout( this );
+
+ leftView = 0;
+ rightView = 0;
+ setEvents(ev1,ev2,d,onM);
+}
+
+DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
+ QDate &d, bool onM,
+ QWidget* parent,
+ const char* name, WFlags fl)
+ : QWidget( parent, name, fl )
+{
+ m_MainLayout = new QHBoxLayout( this );
+
+ leftView = 0;
+ rightView = 0;
+ setEvents(ev1,d,onM);
+}
+
+/* setting the variant with both views */
+void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueList<EffectiveEvent> &ev2,QDate &d, bool onM)
+{
+ setUpdatesEnabled(false);
+ if (!leftView) {
+ leftView=new DateBookWeekLstView(ev1,d,onM,this);
+ m_MainLayout->addWidget(leftView);
+ connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
+ connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
+ connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
+ connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
+ connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
+ connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
+ connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
+ this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
+
+ } else {
+ leftView->hide();
+ leftView->setEvents(ev1,d,onM);
+ }
+
+ if (!rightView) {
+ rightView=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
+ m_MainLayout->addWidget(rightView);
+ connect (rightView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
+ connect (rightView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
+ connect (rightView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
+ connect (rightView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
+ connect (rightView, SIGNAL(redraw()), this, SIGNAL(redraw()));
+ connect (rightView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
+ connect (rightView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
+ this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
+ } else {
+ rightView->hide();
+ rightView->setEvents(ev2,d.addDays(7),onM);
+ }
+
+ leftView->show();
+ rightView->show();
+ setUpdatesEnabled(true);
+}
+
+void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM)
+{
+ if (!leftView) {
+ leftView=new DateBookWeekLstView(ev1,d,onM,this);
+ m_MainLayout->addWidget(leftView);
+ connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
+ connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
+ connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
+ connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
+ connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
+ connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
+ connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
+ } else {
+ leftView->hide();
+ leftView->setEvents(ev1,d,onM);
+ }
+ leftView->show();
+ if (rightView) {
+ rightView->hide();
+ }
+}
- w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
- layout->addWidget(w);
- connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
- connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
- connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
- connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
- connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
- connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
- connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
+void DateBookWeekLstDblView::setRightEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM)
+{
+ if (!rightView) {
+ rightView=new DateBookWeekLstView(ev1,d,onM,this);
+ m_MainLayout->addWidget(rightView);
+ connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
+ connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
+ connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
+ connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
+ connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
+ connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
+ connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
+ } else {
+ rightView->hide();
+ rightView->setEvents(ev1,d,onM);
+ }
+ rightView->show();
+}
+
+bool DateBookWeekLstDblView::toggleDoubleView(bool how)
+{
+ if (rightView) {
+ if (how) rightView->show();
+ else rightView->hide();
+ return true;
+ }
+ return false;
}
DateBookWeekLstDblView::~DateBookWeekLstDblView()
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 @@ -8,6 +8,9 @@ #include <qdatetime.h>
#include <qstring.h>
+class DateBookWeekLstView;
+class QHBoxLayout;
+
class DateBookWeekLstDblView: public QWidget {
Q_OBJECT
public:
@@ -16,7 +19,17 @@ public: QDate &d, bool onM,
QWidget* parent = 0, const char* name = 0,
WFlags fl = 0 );
+ DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
+ QDate &d, bool onM,
+ QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0 );
virtual ~DateBookWeekLstDblView();
+ void setEvents(QValueList<EffectiveEvent> &ev1,QValueList<EffectiveEvent> &ev2,QDate &d, bool onM);
+ void setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM);
+ void setRightEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM);
+
+ bool toggleDoubleView(bool how);
+
signals:
void editEvent(const Event &e);
void duplicateEvent(const Event &e);
@@ -26,6 +39,10 @@ signals: void showDate(int y, int m, int d);
void addEvent(const QDateTime &start, const QDateTime &stop,
const QString &str, const QString &location);
+
+protected:
+ QHBoxLayout*m_MainLayout;
+ DateBookWeekLstView *leftView,*rightView;
};
#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 @@ -17,6 +17,22 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const char* name, WFlags fl)
: QWidget( parent, name, fl )
{
+ childs.clear();
+ m_MainLayout = new QVBoxLayout( this );
+ setEvents(ev,d,onM);
+}
+
+void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM)
+{
+ QValueList<QObject*>::Iterator wIter;
+ for (wIter=childs.begin();wIter!=childs.end();++wIter) {
+ QObject*w = (*wIter);
+ delete w;
+ }
+ childs.clear();
+
+ setUpdatesEnabled(false);
+// m_MainLayout->deleteAllItems();
Config config("DateBook");
config.setGroup("Main");
int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
@@ -26,8 +42,6 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, setPalette(white);
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
- QVBoxLayout *layout = new QVBoxLayout( this );
-
qBubbleSort(ev);
QValueListIterator<EffectiveEvent> it;
it=ev.begin();
@@ -46,18 +60,23 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, else if( dayoffset == 7 ) dayoffset = 0;
for (int i=0; i<7; i++) {
+ QWidget*w = new QWidget(this);
+ w->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
+ w->setPalette(white);
+ QVBoxLayout * tlayout = new QVBoxLayout(w);
+ childs.append(w);
// Header
- DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
+ DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,w);
connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
- layout->addWidget(hdr);
+ tlayout->addWidget(hdr);
// Events
while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day.
- DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
- layout->addWidget(l);
+ DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,w);
+ tlayout->addWidget(l);
connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
@@ -66,8 +85,20 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, }
it++;
}
- layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
+ tlayout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
+ m_MainLayout->addWidget(w);
+/*
+ QSpacerItem * tmp = new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding);
+ m_MainLayout->addItem(tmp);
+*/
+ }
+ setUpdatesEnabled(true);
}
+
+DateBookWeekLstView::~DateBookWeekLstView()
+{}
+
+void DateBookWeekLstView::keyPressEvent(QKeyEvent *e)
+{
+ e->ignore();
}
-DateBookWeekLstView::~DateBookWeekLstView(){}
-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 @@ -9,15 +9,18 @@ #include <qdatetime.h>
class QKeyEvent;
+class QVBoxLayout;
class DateBookWeekLstView: public QWidget
{
Q_OBJECT
public:
- DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM,
- QWidget* parent = 0, const char* name = 0,
+ DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent = 0, const char* name = 0,
WFlags fl = 0 );
~DateBookWeekLstView();
+
+ void setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM);
+
signals:
void editEvent(const Event &e);
void duplicateEvent(const Event &e);
@@ -27,8 +30,12 @@ signals: void showDate(int y, int m, int d);
void addEvent(const QDateTime &start, const QDateTime &stop,
const QString &str, const QString &location);
-private:
+protected:
bool bStartOnMonday;
+ QValueList<QObject*> childs;
+
+ QVBoxLayout*m_MainLayout;
+
protected slots:
void keyPressEvent(QKeyEvent *);
};
|