author | alwin <alwin> | 2004-03-02 12:14:15 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:14:15 (UTC) |
commit | 0d59c780513da78033f4d9040475dee9db0256d4 (patch) (unidiff) | |
tree | 503d320b4aa3daae9982082e7b34e3e2c48bdfb7 /core/pim/datebook/datebookweeklst.cpp | |
parent | a0981652d61776d70f25980f035748b21339e946 (diff) | |
download | opie-0d59c780513da78033f4d9040475dee9db0256d4.zip opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.gz opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.bz2 |
run the optimize_connect script
the whole cvs is tagged with "before_optimize_connect" if there are problems you
can check the diff (but it had compiled and run here)
Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 42a1753..af40143 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -27,97 +27,97 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const ch | |||
27 | backmonth->setBackgroundMode( PaletteButton ); | 27 | backmonth->setBackgroundMode( PaletteButton ); |
28 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); | 28 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); |
29 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); | 29 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); |
30 | DateBookWeekLstHeaderBaseLayout->setMargin(0); | 30 | DateBookWeekLstHeaderBaseLayout->setMargin(0); |
31 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); | 31 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); |
32 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 32 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
33 | 33 | ||
34 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); | 34 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); |
35 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); | 35 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); |
36 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); | 36 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); |
37 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); | 37 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); |
38 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); | 38 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); |
39 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | 39 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); |
40 | bStartOnMonday=onM; | 40 | bStartOnMonday=onM; |
41 | } | 41 | } |
42 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | 42 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} |
43 | 43 | ||
44 | void DateBookWeekLstHeader::setDate(const QDate &d) { | 44 | void DateBookWeekLstHeader::setDate(const QDate &d) { |
45 | int year,week,dayofweek; | 45 | int year,week,dayofweek; |
46 | date=d; | 46 | date=d; |
47 | dayofweek=d.dayOfWeek(); | 47 | dayofweek=d.dayOfWeek(); |
48 | if(bStartOnMonday) | 48 | if(bStartOnMonday) |
49 | dayofweek--; | 49 | dayofweek--; |
50 | else if( dayofweek == 7 ) | 50 | else if( dayofweek == 7 ) |
51 | /* we already have the right day -7 would lead to the same week */ | 51 | /* we already have the right day -7 would lead to the same week */ |
52 | dayofweek = 0; | 52 | dayofweek = 0; |
53 | 53 | ||
54 | date=date.addDays(-dayofweek); | 54 | date=date.addDays(-dayofweek); |
55 | 55 | ||
56 | calcWeek(date,week,year,bStartOnMonday); | 56 | calcWeek(date,week,year,bStartOnMonday); |
57 | QDate start=date; | 57 | QDate start=date; |
58 | QDate stop=start.addDays(6); | 58 | QDate stop=start.addDays(6); |
59 | labelDate->setText( QString::number(start.day()) + "." + | 59 | labelDate->setText( QString::number(start.day()) + "." + |
60 | Calendar::nameOfMonth( start.month() ) + "-" + | 60 | Calendar::nameOfMonth( start.month() ) + "-" + |
61 | QString::number(stop.day()) + "." + | 61 | QString::number(stop.day()) + "." + |
62 | Calendar::nameOfMonth( stop.month()) +" ("+ | 62 | Calendar::nameOfMonth( stop.month()) +" ("+ |
63 | tr("w")+":"+QString::number( week ) +")"); | 63 | tr("w")+":"+QString::number( week ) +")"); |
64 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! | 64 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! |
65 | emit dateChanged(date); | 65 | emit dateChanged(date); |
66 | } | 66 | } |
67 | 67 | ||
68 | void DateBookWeekLstHeader::pickDate() { | 68 | void DateBookWeekLstHeader::pickDate() { |
69 | static QPopupMenu *m1 = 0; | 69 | static QPopupMenu *m1 = 0; |
70 | static DateBookMonth *picker = 0; | 70 | static DateBookMonth *picker = 0; |
71 | if ( !m1 ) { | 71 | if ( !m1 ) { |
72 | m1 = new QPopupMenu( this ); | 72 | m1 = new QPopupMenu( this ); |
73 | picker = new DateBookMonth( m1, 0, TRUE ); | 73 | picker = new DateBookMonth( m1, 0, TRUE ); |
74 | m1->insertItem( picker ); | 74 | m1->insertItem( picker ); |
75 | connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) ); | 75 | connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); |
76 | //connect( m1, SIGNAL( aboutToHide() ), | 76 | //connect( m1, SIGNAL( aboutToHide() ), |
77 | //this, SLOT( gotHide() ) ); | 77 | //this, SLOT( gotHide() ) ); |
78 | } | 78 | } |
79 | picker->setDate( date.year(), date.month(), date.day() ); | 79 | picker->setDate( date.year(), date.month(), date.day() ); |
80 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); | 80 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); |
81 | picker->setFocus(); | 81 | picker->setFocus(); |
82 | } | 82 | } |
83 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { | 83 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { |
84 | setDate(QDate(y,m,d)); | 84 | setDate(QDate(y,m,d)); |
85 | } | 85 | } |
86 | 86 | ||
87 | void DateBookWeekLstHeader::nextWeek() { | 87 | void DateBookWeekLstHeader::nextWeek() { |
88 | setDate(date.addDays(7)); | 88 | setDate(date.addDays(7)); |
89 | } | 89 | } |
90 | void DateBookWeekLstHeader::prevWeek() { | 90 | void DateBookWeekLstHeader::prevWeek() { |
91 | setDate(date.addDays(-7)); | 91 | setDate(date.addDays(-7)); |
92 | } | 92 | } |
93 | void DateBookWeekLstHeader::nextMonth() | 93 | void DateBookWeekLstHeader::nextMonth() |
94 | { | 94 | { |
95 | setDate(date.addDays(28)); | 95 | setDate(date.addDays(28)); |
96 | } | 96 | } |
97 | void DateBookWeekLstHeader::prevMonth() | 97 | void DateBookWeekLstHeader::prevMonth() |
98 | { | 98 | { |
99 | setDate(date.addDays(-28)); | 99 | setDate(date.addDays(-28)); |
100 | } | 100 | } |
101 | 101 | ||
102 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, | 102 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, |
103 | QWidget* parent, | 103 | QWidget* parent, |
104 | const char* name, | 104 | const char* name, |
105 | WFlags fl ) | 105 | WFlags fl ) |
106 | : DateBookWeekLstDayHdrBase(parent, name, fl) { | 106 | : DateBookWeekLstDayHdrBase(parent, name, fl) { |
107 | 107 | ||
108 | date=d; | 108 | date=d; |
109 | 109 | ||
110 | static const QString wdays=tr("MTWTFSSM", "Week days"); | 110 | static const QString wdays=tr("MTWTFSSM", "Week days"); |
111 | char day=wdays[d.dayOfWeek()-1]; | 111 | char day=wdays[d.dayOfWeek()-1]; |
112 | 112 | ||
113 | //dont use dayOfWeek() to save space ! | 113 | //dont use dayOfWeek() to save space ! |
114 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); | 114 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); |
115 | 115 | ||
116 | add->setText("+"); | 116 | add->setText("+"); |
117 | 117 | ||
118 | if (d == QDate::currentDate()) { | 118 | if (d == QDate::currentDate()) { |
119 | QPalette pal=label->palette(); | 119 | QPalette pal=label->palette(); |
120 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); | 120 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); |
121 | label->setPalette(pal); | 121 | label->setPalette(pal); |
122 | 122 | ||
123 | /* | 123 | /* |
@@ -190,205 +190,205 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | |||
190 | } | 190 | } |
191 | setText(QString(s) + " " + ev.description()); | 191 | setText(QString(s) + " " + ev.description()); |
192 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 192 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
193 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 193 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
194 | } | 194 | } |
195 | void DateBookWeekLstEvent::editMe() { | 195 | void DateBookWeekLstEvent::editMe() { |
196 | emit editEvent(event.event()); | 196 | emit editEvent(event.event()); |
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
200 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | 200 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, |
201 | const QDate &d, bool onM, | 201 | const QDate &d, bool onM, |
202 | QWidget* parent, | 202 | QWidget* parent, |
203 | const char* name, WFlags fl) | 203 | const char* name, WFlags fl) |
204 | : QWidget( parent, name, fl ) | 204 | : QWidget( parent, name, fl ) |
205 | { | 205 | { |
206 | Config config("DateBook"); | 206 | Config config("DateBook"); |
207 | config.setGroup("Main"); | 207 | config.setGroup("Main"); |
208 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); | 208 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); |
209 | qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); | 209 | qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); |
210 | 210 | ||
211 | bStartOnMonday=onM; | 211 | bStartOnMonday=onM; |
212 | setPalette(white); | 212 | setPalette(white); |
213 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | 213 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); |
214 | 214 | ||
215 | QVBoxLayout *layout = new QVBoxLayout( this ); | 215 | QVBoxLayout *layout = new QVBoxLayout( this ); |
216 | 216 | ||
217 | qBubbleSort(ev); | 217 | qBubbleSort(ev); |
218 | QValueListIterator<EffectiveEvent> it; | 218 | QValueListIterator<EffectiveEvent> it; |
219 | it=ev.begin(); | 219 | it=ev.begin(); |
220 | 220 | ||
221 | int dayOrder[7]; | 221 | int dayOrder[7]; |
222 | if (bStartOnMonday) { | 222 | if (bStartOnMonday) { |
223 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | 223 | for (int d=0; d<7; d++) dayOrder[d]=d+1; |
224 | } else { | 224 | } else { |
225 | for (int d=0; d<7; d++) dayOrder[d]=d; | 225 | for (int d=0; d<7; d++) dayOrder[d]=d; |
226 | dayOrder[0]=7; | 226 | dayOrder[0]=7; |
227 | } | 227 | } |
228 | 228 | ||
229 | // Calculate offset to first day of week. | 229 | // Calculate offset to first day of week. |
230 | int dayoffset=d.dayOfWeek(); | 230 | int dayoffset=d.dayOfWeek(); |
231 | if(bStartOnMonday) dayoffset--; | 231 | if(bStartOnMonday) dayoffset--; |
232 | else if( dayoffset == 7 ) dayoffset = 0; | 232 | else if( dayoffset == 7 ) dayoffset = 0; |
233 | 233 | ||
234 | for (int i=0; i<7; i++) { | 234 | for (int i=0; i<7; i++) { |
235 | // Header | 235 | // Header |
236 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); | 236 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); |
237 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 237 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
238 | connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 238 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
239 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 239 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
240 | layout->addWidget(hdr); | 240 | layout->addWidget(hdr); |
241 | 241 | ||
242 | // Events | 242 | // Events |
243 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 243 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { |
244 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. | 244 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. |
245 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); | 245 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); |
246 | layout->addWidget(l); | 246 | layout->addWidget(l); |
247 | connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 247 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
248 | } | 248 | } |
249 | it++; | 249 | it++; |
250 | } | 250 | } |
251 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 251 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | DateBookWeekLstView::~DateBookWeekLstView(){} | 254 | DateBookWeekLstView::~DateBookWeekLstView(){} |
255 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | 255 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} |
256 | 256 | ||
257 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 257 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
258 | QValueList<EffectiveEvent> &ev2, | 258 | QValueList<EffectiveEvent> &ev2, |
259 | QDate &d, bool onM, | 259 | QDate &d, bool onM, |
260 | QWidget* parent, | 260 | QWidget* parent, |
261 | const char* name, WFlags fl) | 261 | const char* name, WFlags fl) |
262 | : QWidget( parent, name, fl ) | 262 | : QWidget( parent, name, fl ) |
263 | { | 263 | { |
264 | QHBoxLayout *layout = new QHBoxLayout( this ); | 264 | QHBoxLayout *layout = new QHBoxLayout( this ); |
265 | 265 | ||
266 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | 266 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); |
267 | layout->addWidget(w); | 267 | layout->addWidget(w); |
268 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 268 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
269 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 269 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
270 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), | 270 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
271 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 271 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
272 | 272 | ||
273 | 273 | ||
274 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | 274 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); |
275 | layout->addWidget(w); | 275 | layout->addWidget(w); |
276 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 276 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
277 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 277 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
278 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 278 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
279 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 279 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
280 | } | 280 | } |
281 | 281 | ||
282 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | 282 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, |
283 | QWidget *parent, | 283 | QWidget *parent, |
284 | const char *name ) | 284 | const char *name ) |
285 | : QWidget( parent, name ), | 285 | : QWidget( parent, name ), |
286 | db( newDB ), | 286 | db( newDB ), |
287 | startTime( 0 ), | 287 | startTime( 0 ), |
288 | ampm( ap ), | 288 | ampm( ap ), |
289 | bStartOnMonday(onM) | 289 | bStartOnMonday(onM) |
290 | { | 290 | { |
291 | setFocusPolicy(StrongFocus); | 291 | setFocusPolicy(StrongFocus); |
292 | layout = new QVBoxLayout( this ); | 292 | layout = new QVBoxLayout( this ); |
293 | layout->setMargin(0); | 293 | layout->setMargin(0); |
294 | 294 | ||
295 | header=new DateBookWeekLstHeader(onM, this); | 295 | header=new DateBookWeekLstHeader(onM, this); |
296 | layout->addWidget( header ); | 296 | layout->addWidget( header ); |
297 | connect(header, SIGNAL(dateChanged(QDate &)), this, SLOT(dateChanged(QDate &))); | 297 | connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); |
298 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); | 298 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); |
299 | 299 | ||
300 | scroll=new QScrollView(this); | 300 | scroll=new QScrollView(this); |
301 | scroll->setResizePolicy(QScrollView::AutoOneFit); | 301 | scroll->setResizePolicy(QScrollView::AutoOneFit); |
302 | layout->addWidget(scroll); | 302 | layout->addWidget(scroll); |
303 | 303 | ||
304 | view=NULL; | 304 | view=NULL; |
305 | Config config("DateBook"); | 305 | Config config("DateBook"); |
306 | config.setGroup("Main"); | 306 | config.setGroup("Main"); |
307 | dbl=config.readBoolEntry("weeklst_dbl", false); | 307 | dbl=config.readBoolEntry("weeklst_dbl", false); |
308 | header->dbl->setOn(dbl); | 308 | header->dbl->setOn(dbl); |
309 | } | 309 | } |
310 | DateBookWeekLst::~DateBookWeekLst(){ | 310 | DateBookWeekLst::~DateBookWeekLst(){ |
311 | Config config("DateBook"); | 311 | Config config("DateBook"); |
312 | config.setGroup("Main"); | 312 | config.setGroup("Main"); |
313 | config.writeEntry("weeklst_dbl", dbl); | 313 | config.writeEntry("weeklst_dbl", dbl); |
314 | } | 314 | } |
315 | 315 | ||
316 | void DateBookWeekLst::setDate(const QDate &d) { | 316 | void DateBookWeekLst::setDate(const QDate &d) { |
317 | bdate=d; | 317 | bdate=d; |
318 | header->setDate(d); | 318 | header->setDate(d); |
319 | } | 319 | } |
320 | 320 | ||
321 | void DateBookWeekLst::setDbl(bool on) { | 321 | void DateBookWeekLst::setDbl(bool on) { |
322 | dbl=on; | 322 | dbl=on; |
323 | redraw(); | 323 | redraw(); |
324 | } | 324 | } |
325 | void DateBookWeekLst::redraw() {getEvents();} | 325 | void DateBookWeekLst::redraw() {getEvents();} |
326 | 326 | ||
327 | QDate DateBookWeekLst::date() { | 327 | QDate DateBookWeekLst::date() { |
328 | return bdate; | 328 | return bdate; |
329 | } | 329 | } |
330 | 330 | ||
331 | // return the date at the beginning of the week... | 331 | // return the date at the beginning of the week... |
332 | // copied from DateBookWeek | 332 | // copied from DateBookWeek |
333 | QDate DateBookWeekLst::weekDate() const | 333 | QDate DateBookWeekLst::weekDate() const |
334 | { | 334 | { |
335 | QDate d=bdate; | 335 | QDate d=bdate; |
336 | 336 | ||
337 | // Calculate offset to first day of week. | 337 | // Calculate offset to first day of week. |
338 | int dayoffset=d.dayOfWeek(); | 338 | int dayoffset=d.dayOfWeek(); |
339 | if(bStartOnMonday) dayoffset--; | 339 | if(bStartOnMonday) dayoffset--; |
340 | else if( dayoffset == 7 ) | 340 | else if( dayoffset == 7 ) |
341 | dayoffset = 0; | 341 | dayoffset = 0; |
342 | 342 | ||
343 | return d.addDays(-dayoffset); | 343 | return d.addDays(-dayoffset); |
344 | } | 344 | } |
345 | 345 | ||
346 | void DateBookWeekLst::getEvents() { | 346 | void DateBookWeekLst::getEvents() { |
347 | QDate start = weekDate(); //date(); | 347 | QDate start = weekDate(); //date(); |
348 | QDate stop = start.addDays(6); | 348 | QDate stop = start.addDays(6); |
349 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 349 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
350 | 350 | ||
351 | if (view) delete view; | 351 | if (view) delete view; |
352 | if (dbl) { | 352 | if (dbl) { |
353 | QDate start2=start.addDays(7); | 353 | QDate start2=start.addDays(7); |
354 | stop=start2.addDays(6); | 354 | stop=start2.addDays(6); |
355 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | 355 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); |
356 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); | 356 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); |
357 | } else { | 357 | } else { |
358 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); | 358 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); |
359 | } | 359 | } |
360 | 360 | ||
361 | connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 361 | connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
362 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 362 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
363 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 363 | connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
364 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 364 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
365 | 365 | ||
366 | scroll->addChild(view); | 366 | scroll->addChild(view); |
367 | view->show(); | 367 | view->show(); |
368 | scroll->updateScrollBars(); | 368 | scroll->updateScrollBars(); |
369 | } | 369 | } |
370 | 370 | ||
371 | void DateBookWeekLst::dateChanged(QDate &newdate) { | 371 | void DateBookWeekLst::dateChanged(QDate &newdate) { |
372 | bdate=newdate; | 372 | bdate=newdate; |
373 | getEvents(); | 373 | getEvents(); |
374 | } | 374 | } |
375 | 375 | ||
376 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | 376 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) |
377 | { | 377 | { |
378 | switch(e->key()) { | 378 | switch(e->key()) { |
379 | case Key_Up: | 379 | case Key_Up: |
380 | scroll->scrollBy(0, -20); | 380 | scroll->scrollBy(0, -20); |
381 | break; | 381 | break; |
382 | case Key_Down: | 382 | case Key_Down: |
383 | scroll->scrollBy(0, 20); | 383 | scroll->scrollBy(0, 20); |
384 | break; | 384 | break; |
385 | case Key_Left: | 385 | case Key_Left: |
386 | header->prevWeek(); | 386 | header->prevWeek(); |
387 | break; | 387 | break; |
388 | case Key_Right: | 388 | case Key_Right: |
389 | header->nextWeek(); | 389 | header->nextWeek(); |
390 | break; | 390 | break; |
391 | default: | 391 | default: |
392 | e->ignore(); | 392 | e->ignore(); |
393 | } | 393 | } |
394 | } | 394 | } |