Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index dc141c0..7083bc5 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -5,12 +5,13 @@ | |||
5 | #include <qpe/calendar.h> | 5 | #include <qpe/calendar.h> |
6 | #include <qpe/datebookdb.h> | 6 | #include <qpe/datebookdb.h> |
7 | #include <qpe/event.h> | 7 | #include <qpe/event.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/timestring.h> | 9 | #include <qpe/timestring.h> |
10 | #include <qpe/datebookmonth.h> | 10 | #include <qpe/datebookmonth.h> |
11 | #include <qpe/config.h> | ||
11 | 12 | ||
12 | #include <qdatetime.h> | 13 | #include <qdatetime.h> |
13 | #include <qheader.h> | 14 | #include <qheader.h> |
14 | #include <qlabel.h> | 15 | #include <qlabel.h> |
15 | #include <qlayout.h> | 16 | #include <qlayout.h> |
16 | #include <qpainter.h> | 17 | #include <qpainter.h> |
@@ -40,12 +41,13 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, | |||
40 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); | 41 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); |
41 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 42 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
42 | 43 | ||
43 | connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); | 44 | connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); |
44 | connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); | 45 | connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); |
45 | connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); | 46 | connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); |
47 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | ||
46 | onMonday=onM; | 48 | onMonday=onM; |
47 | } | 49 | } |
48 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | 50 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} |
49 | void DateBookWeekLstHeader::setDate(const QDate &d) { | 51 | void DateBookWeekLstHeader::setDate(const QDate &d) { |
50 | date=d; | 52 | date=d; |
51 | 53 | ||
@@ -153,20 +155,21 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | |||
153 | } | 155 | } |
154 | } else { | 156 | } else { |
155 | sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); | 157 | sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); |
156 | } | 158 | } |
157 | setText(QString(s) + " " + ev.description()); | 159 | setText(QString(s) + " " + ev.description()); |
158 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 160 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
161 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | ||
159 | } | 162 | } |
160 | void DateBookWeekLstEvent::editMe() { | 163 | void DateBookWeekLstEvent::editMe() { |
161 | emit editEvent(event.event()); | 164 | emit editEvent(event.event()); |
162 | } | 165 | } |
163 | 166 | ||
164 | 167 | ||
165 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | 168 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, |
166 | QDate &d, bool onM, | 169 | const QDate &d, bool onM, |
167 | QWidget* parent, | 170 | QWidget* parent, |
168 | const char* name, WFlags fl) | 171 | const char* name, WFlags fl) |
169 | : QWidget( parent, name, fl ) | 172 | : QWidget( parent, name, fl ) |
170 | { | 173 | { |
171 | onMonday=onM; | 174 | onMonday=onM; |
172 | setPalette(white); | 175 | setPalette(white); |
@@ -212,12 +215,45 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | |||
212 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 215 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
213 | } | 216 | } |
214 | } | 217 | } |
215 | DateBookWeekLstView::~DateBookWeekLstView(){} | 218 | DateBookWeekLstView::~DateBookWeekLstView(){} |
216 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | 219 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} |
217 | 220 | ||
221 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | ||
222 | QValueList<EffectiveEvent> &ev2, | ||
223 | QDate &d, bool onM, | ||
224 | QWidget* parent, | ||
225 | const char* name, WFlags fl) | ||
226 | : QWidget( parent, name, fl ) | ||
227 | { | ||
228 | QHBoxLayout *layout = new QHBoxLayout( this ); | ||
229 | |||
230 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | ||
231 | layout->addWidget(w); | ||
232 | connect (w, SIGNAL(editEvent(const Event &)), | ||
233 | this, SIGNAL(editEvent(const Event &))); | ||
234 | connect (w, SIGNAL(showDate(int,int,int)), | ||
235 | this, SIGNAL(showDate(int,int,int))); | ||
236 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | ||
237 | const QString &)), | ||
238 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | ||
239 | const QString &))); | ||
240 | |||
241 | |||
242 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | ||
243 | layout->addWidget(w); | ||
244 | connect (w, SIGNAL(editEvent(const Event &)), | ||
245 | this, SIGNAL(editEvent(const Event &))); | ||
246 | connect (w, SIGNAL(showDate(int,int,int)), | ||
247 | this, SIGNAL(showDate(int,int,int))); | ||
248 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | ||
249 | const QString &)), | ||
250 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | ||
251 | const QString &))); | ||
252 | } | ||
253 | |||
218 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | 254 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, |
219 | QWidget *parent, | 255 | QWidget *parent, |
220 | const char *name ) | 256 | const char *name ) |
221 | : QWidget( parent, name ), | 257 | : QWidget( parent, name ), |
222 | db( newDB ), | 258 | db( newDB ), |
223 | startTime( 0 ), | 259 | startTime( 0 ), |
@@ -227,31 +263,46 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | |||
227 | setFocusPolicy(StrongFocus); | 263 | setFocusPolicy(StrongFocus); |
228 | layout = new QVBoxLayout( this ); | 264 | layout = new QVBoxLayout( this ); |
229 | layout->setMargin(0); | 265 | layout->setMargin(0); |
230 | 266 | ||
231 | header=new DateBookWeekLstHeader(onM, this); | 267 | header=new DateBookWeekLstHeader(onM, this); |
232 | layout->addWidget( header ); | 268 | layout->addWidget( header ); |
233 | connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); | 269 | connect(header, SIGNAL(dateChanged(int,int)), |
270 | this, SLOT(dateChanged(int,int))); | ||
271 | connect(header, SIGNAL(setDbl(bool)), | ||
272 | this, SLOT(setDbl(bool))); | ||
234 | 273 | ||
235 | scroll=new QScrollView(this); | 274 | scroll=new QScrollView(this); |
236 | //scroll->setVScrollBarMode(QScrollView::AlwaysOn); | 275 | //scroll->setVScrollBarMode(QScrollView::AlwaysOn); |
237 | //scroll->setHScrollBarMode(QScrollView::AlwaysOff); | 276 | //scroll->setHScrollBarMode(QScrollView::AlwaysOff); |
238 | scroll->setResizePolicy(QScrollView::AutoOneFit); | 277 | scroll->setResizePolicy(QScrollView::AutoOneFit); |
239 | layout->addWidget(scroll); | 278 | layout->addWidget(scroll); |
240 | 279 | ||
241 | view=NULL; | 280 | view=NULL; |
281 | Config config("DateBook"); | ||
282 | config.setGroup("Main"); | ||
283 | dbl=config.readBoolEntry("weeklst_dbl", false); | ||
284 | header->dbl->setOn(dbl); | ||
285 | } | ||
286 | DateBookWeekLst::~DateBookWeekLst(){ | ||
287 | Config config("DateBook"); | ||
288 | config.setGroup("Main"); | ||
289 | config.writeEntry("weeklst_dbl", dbl); | ||
242 | } | 290 | } |
243 | |||
244 | 291 | ||
245 | void DateBookWeekLst::setDate(const QDate &d) { | 292 | void DateBookWeekLst::setDate(const QDate &d) { |
246 | int w,y; | 293 | int w,y; |
247 | calcWeek(d,w,y,onMonday); | 294 | calcWeek(d,w,y,onMonday); |
248 | year=y; | 295 | year=y; |
249 | _week=w; | 296 | _week=w; |
250 | header->setDate(date()); | 297 | header->setDate(date()); |
251 | } | 298 | } |
299 | void DateBookWeekLst::setDbl(bool on) { | ||
300 | dbl=on; | ||
301 | redraw(); | ||
302 | } | ||
252 | void DateBookWeekLst::redraw() {getEvents();} | 303 | void DateBookWeekLst::redraw() {getEvents();} |
253 | 304 | ||
254 | QDate DateBookWeekLst::date() const { | 305 | QDate DateBookWeekLst::date() const { |
255 | QDate d; | 306 | QDate d; |
256 | d.setYMD(year,1,1); | 307 | d.setYMD(year,1,1); |
257 | 308 | ||
@@ -267,13 +318,21 @@ QDate DateBookWeekLst::date() const { | |||
267 | void DateBookWeekLst::getEvents() { | 318 | void DateBookWeekLst::getEvents() { |
268 | QDate start = date(); | 319 | QDate start = date(); |
269 | QDate stop = start.addDays(6); | 320 | QDate stop = start.addDays(6); |
270 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 321 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
271 | 322 | ||
272 | if (view) delete view; | 323 | if (view) delete view; |
324 | if (dbl) { | ||
325 | QDate start2=start.addDays(7); | ||
326 | stop=start2.addDays(6); | ||
327 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | ||
328 | |||
329 | view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); | ||
330 | } else { | ||
273 | view=new DateBookWeekLstView(el,start,onMonday,scroll); | 331 | view=new DateBookWeekLstView(el,start,onMonday,scroll); |
332 | } | ||
274 | 333 | ||
275 | connect (view, SIGNAL(editEvent(const Event &)), | 334 | connect (view, SIGNAL(editEvent(const Event &)), |
276 | this, SIGNAL(editEvent(const Event &))); | 335 | this, SIGNAL(editEvent(const Event &))); |
277 | connect (view, SIGNAL(showDate(int,int,int)), | 336 | connect (view, SIGNAL(showDate(int,int,int)), |
278 | this, SIGNAL(showDate(int,int,int))); | 337 | this, SIGNAL(showDate(int,int,int))); |
279 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | 338 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, |