summaryrefslogtreecommitdiff
path: root/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/modules/weeklst/datebookweeklst.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklst.cpp65
1 files changed, 43 insertions, 22 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
@@ -27,6 +27,7 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
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
@@ -39,12 +40,13 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
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
48DateBookWeekLst::~DateBookWeekLst(){ 50DateBookWeekLst::~DateBookWeekLst(){
49 Config config("DateBook"); 51 Config config("DateBook");
50 config.setGroup("Main"); 52 config.setGroup("Main");
@@ -58,8 +60,15 @@ void DateBookWeekLst::setDate(const QDate &d) {
58 60
59void DateBookWeekLst::setDbl(bool on) { 61void 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
63void DateBookWeekLst::redraw() {getEvents();} 72void DateBookWeekLst::redraw() {getEvents();}
64 73
65QDate DateBookWeekLst::date() { 74QDate DateBookWeekLst::date() {
@@ -82,38 +91,50 @@ QDate DateBookWeekLst::weekDate() const
82} 91}
83 92
84void DateBookWeekLst::getEvents() { 93void 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);
111 } else {
112 m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,scroll);
113 }
114 m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
115 connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
116 connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
117 connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
118 connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
119 connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw()));
120 connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
121 connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
122 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
123 scroll->addChild(m_CurrentView);
96 } else { 124 } else {
97 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); 125 if (dbl) {
126 m_CurrentView->setEvents(el,el2,start,bStartOnMonday);
127 } else {
128 m_CurrentView->setEvents(el,start,bStartOnMonday);
129 }
98 } 130 }
99
100 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
101 connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
102 connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
103 connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
104 connect (view, SIGNAL(redraw()), this, SLOT(redraw()));
105 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
106 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
107 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
108
109 scroll->addChild(view);
110 view->show();
111 scroll->updateScrollBars(); 131 scroll->updateScrollBars();
112 setUpdatesEnabled(true);
113} 132}
114 133
115void DateBookWeekLst::dateChanged(QDate &newdate) { 134void 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