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.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
index b36bf6d..59f937f 100644
--- a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
+++ b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
@@ -1,36 +1,37 @@
1#include "namespace_hack.h" 1#include "namespace_hack.h"
2#include "datebookweeklst.h" 2#include "datebookweeklst.h"
3#include "datebookweeklstheader.h" 3#include "datebookweeklstheader.h"
4#include "datebookweeklstview.h" 4#include "datebookweeklstview.h"
5#include "datebookweeklstdblview.h" 5#include "datebookweeklstdblview.h"
6 6
7#include "datebook.h" 7#include "datebook.h"
8 8
9#include <opie2/odebug.h> 9#include <opie2/odebug.h>
10 10
11#include <qpe/datebookmonth.h> 11#include <qpe/datebookmonth.h>
12#include <qpe/config.h> 12#include <qpe/config.h>
13#include <qpe/qpeapplication.h>
13 14
14#include <qlayout.h> 15#include <qlayout.h>
15#include <qtoolbutton.h> 16#include <qtoolbutton.h>
16 17
17using namespace Opie::Ui; 18using namespace Opie::Ui;
18 19
19DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, 20DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
20 QWidget *parent, 21 QWidget *parent,
21 const char *name ) 22 const char *name )
22 : QWidget( parent, name ), 23 : QWidget( parent, name ),
23 db( newDB ), 24 db( newDB ),
24 startTime( 0 ), 25 startTime( 0 ),
25 ampm( ap ), 26 ampm( ap ),
26 bStartOnMonday(onM) 27 bStartOnMonday(onM)
27{ 28{
28 setFocusPolicy(StrongFocus); 29 setFocusPolicy(StrongFocus);
29 dateset = false; 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)));
@@ -47,110 +48,118 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
47} 48}
48 49
49DateBookWeekLst::~DateBookWeekLst(){ 50DateBookWeekLst::~DateBookWeekLst(){
50 Config config("DateBook"); 51 Config config("DateBook");
51 config.setGroup("Main"); 52 config.setGroup("Main");
52 config.writeEntry("weeklst_dbl", dbl); 53 config.writeEntry("weeklst_dbl", dbl);
53} 54}
54 55
55void DateBookWeekLst::setDate(const QDate &d) { 56void DateBookWeekLst::setDate(const QDate &d) {
56 bdate=d; 57 bdate=d;
57 header->setDate(d); 58 header->setDate(d);
58} 59}
59 60
60void DateBookWeekLst::setDbl(bool on) { 61void DateBookWeekLst::setDbl(bool on) {
61 dbl=on; 62 dbl=on;
62 bool displayed = false; 63 bool displayed = false;
63 if (m_CurrentView) { 64 if (m_CurrentView) {
64 displayed = m_CurrentView->toggleDoubleView(on); 65 displayed = m_CurrentView->toggleDoubleView(on);
65 } 66 }
66 if (!displayed||dbl) { 67 if (!displayed||dbl) {
67 getEvents(); 68 getEvents();
68 } 69 }
69} 70}
70 71
71void DateBookWeekLst::redraw() {getEvents();} 72void DateBookWeekLst::redraw() {
73 getEvents();
74}
72 75
73QDate DateBookWeekLst::date() { 76QDate DateBookWeekLst::date() {
74 return bdate; 77 return bdate;
75} 78}
76 79
77// return the date at the beginning of the week... 80// return the date at the beginning of the week...
78// copied from DateBookWeek 81// copied from DateBookWeek
79QDate DateBookWeekLst::weekDate() const 82QDate DateBookWeekLst::weekDate() const
80{ 83{
81 QDate d=bdate; 84 QDate d=bdate;
82 85
83 // Calculate offset to first day of week. 86 // Calculate offset to first day of week.
84 int dayoffset=d.dayOfWeek(); 87 int dayoffset=d.dayOfWeek();
85 if(bStartOnMonday) dayoffset--; 88 if(bStartOnMonday) dayoffset--;
86 else if( dayoffset == 7 ) 89 else if( dayoffset == 7 )
87 dayoffset = 0; 90 dayoffset = 0;
88 91
89 return d.addDays(-dayoffset); 92 return d.addDays(-dayoffset);
90} 93}
91 94
92void DateBookWeekLst::getEvents() { 95void DateBookWeekLst::getEvents() {
93 if (!dateset) return; 96 if (!dateset) return;
94 QDate start = weekDate(); //date(); 97 QDate start = weekDate(); //date();
95 QDate stop = start.addDays(6); 98 QDate stop = start.addDays(6);
96 QDate start2; 99 QDate start2;
97 100
98 101
99 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 102 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
100 QValueList<EffectiveEvent> el2; 103 QValueList<EffectiveEvent> el2;
101 104
102 if (dbl) { 105 if (dbl) {
103 start2 = start.addDays(7); 106 start2 = start.addDays(7);
104 stop = start2.addDays(6); 107 stop = start2.addDays(6);
105 el2 = db->getEffectiveEvents(start2, stop); 108 el2 = db->getEffectiveEvents(start2, stop);
106 } 109 }
107 if (!m_CurrentView) { 110 if (!m_CurrentView) {
108 if (dbl) { 111 if (dbl) {
109 m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 112 m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,ampm,scroll);
110 } else { 113 } else {
111 m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,scroll); 114 m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,ampm,scroll);
112 } 115 }
113 m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 116 m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
114 connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 117 connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
115 connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 118 connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
116 connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 119 connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
117 connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 120 connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
118 connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw())); 121 connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw()));
119 connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 122 connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
120 connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 123 connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
121 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 124 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
125 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
122 scroll->addChild(m_CurrentView); 126 scroll->addChild(m_CurrentView);
123 } else { 127 } else {
124 if (dbl) { 128 if (dbl) {
125 m_CurrentView->setEvents(el,el2,start,bStartOnMonday); 129 m_CurrentView->setEvents(el,el2,start,bStartOnMonday);
126 } else { 130 } else {
127 m_CurrentView->setEvents(el,start,bStartOnMonday); 131 m_CurrentView->setEvents(el,start,bStartOnMonday);
128 } 132 }
129 } 133 }
130 scroll->updateScrollBars(); 134 scroll->updateScrollBars();
131} 135}
132 136
137void DateBookWeekLst::slotClockChanged( bool ap ) {
138 ampm = ap;
139 getEvents();
140}
141
133void DateBookWeekLst::dateChanged(QDate &newdate) { 142void DateBookWeekLst::dateChanged(QDate &newdate) {
134 dateset = true; 143 dateset = true;
135 bdate=newdate; 144 bdate=newdate;
136 odebug << "Date changed " << oendl; 145 odebug << "Date changed " << oendl;
137 getEvents(); 146 getEvents();
138} 147}
139 148
140void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 149void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
141{ 150{
142 switch(e->key()) { 151 switch(e->key()) {
143 case Key_Up: 152 case Key_Up:
144 scroll->scrollBy(0, -20); 153 scroll->scrollBy(0, -20);
145 break; 154 break;
146 case Key_Down: 155 case Key_Down:
147 scroll->scrollBy(0, 20); 156 scroll->scrollBy(0, 20);
148 break; 157 break;
149 case Key_Left: 158 case Key_Left:
150 header->prevWeek(); 159 header->prevWeek();
151 break; 160 break;
152 case Key_Right: 161 case Key_Right:
153 header->nextWeek(); 162 header->nextWeek();
154 break; 163 break;
155 default: 164 default:
156 e->ignore(); 165 e->ignore();