From 307ecafa73a7902aeadfeec9b5c2c064b68aed37 Mon Sep 17 00:00:00 2001 From: hakan Date: Sat, 09 Mar 2002 14:19:20 +0000 Subject: WeekLst extended to view two weeks at a time (opitonal) --- 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 @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -43,6 +44,7 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); + connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); onMonday=onM; } DateBookWeekLstHeader::~DateBookWeekLstHeader(){} @@ -156,6 +158,7 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, } setText(QString(s) + " " + ev.description()); connect(this, SIGNAL(clicked()), this, SLOT(editMe())); + setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); } void DateBookWeekLstEvent::editMe() { emit editEvent(event.event()); @@ -163,7 +166,7 @@ void DateBookWeekLstEvent::editMe() { DateBookWeekLstView::DateBookWeekLstView(QValueList &ev, - QDate &d, bool onM, + const QDate &d, bool onM, QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) @@ -215,6 +218,39 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList &ev, DateBookWeekLstView::~DateBookWeekLstView(){} void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} +DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList &ev1, + QValueList &ev2, + QDate &d, bool onM, + QWidget* parent, + 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(showDate(int,int,int)), + this, SIGNAL(showDate(int,int,int))); + connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, + const QString &)), + this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, + const QString &))); + + + 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(showDate(int,int,int)), + this, SIGNAL(showDate(int,int,int))); + connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, + const QString &)), + this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, + const QString &))); +} + DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, QWidget *parent, const char *name ) @@ -230,7 +266,10 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, header=new DateBookWeekLstHeader(onM, this); layout->addWidget( header ); - connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); + connect(header, SIGNAL(dateChanged(int,int)), + this, SLOT(dateChanged(int,int))); + connect(header, SIGNAL(setDbl(bool)), + this, SLOT(setDbl(bool))); scroll=new QScrollView(this); //scroll->setVScrollBarMode(QScrollView::AlwaysOn); @@ -239,8 +278,16 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, layout->addWidget(scroll); view=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"); + config.writeEntry("weeklst_dbl", dbl); } - void DateBookWeekLst::setDate(const QDate &d) { int w,y; @@ -249,6 +296,10 @@ void DateBookWeekLst::setDate(const QDate &d) { _week=w; header->setDate(date()); } +void DateBookWeekLst::setDbl(bool on) { + dbl=on; + redraw(); +} void DateBookWeekLst::redraw() {getEvents();} QDate DateBookWeekLst::date() const { @@ -270,7 +321,15 @@ void DateBookWeekLst::getEvents() { QValueList el = db->getEffectiveEvents(start, stop); if (view) delete view; - view=new DateBookWeekLstView(el,start,onMonday,scroll); + if (dbl) { + QDate start2=start.addDays(7); + stop=start2.addDays(6); + QValueList el2 = db->getEffectiveEvents(start2, stop); + + view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); + } else { + view=new DateBookWeekLstView(el,start,onMonday,scroll); + } connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h index 39c956d..b0b0417 100644 --- a/core/pim/datebook/datebookweeklst.h +++ b/core/pim/datebook/datebookweeklst.h @@ -31,6 +31,7 @@ public slots: void setDate(int y, int m, int d); signals: void dateChanged(int y, int w); + void setDbl(bool on); private: QDate date; bool onMonday; @@ -73,7 +74,7 @@ class DateBookWeekLstView: public QWidget { Q_OBJECT public: - DateBookWeekLstView(QValueList &ev, QDate &d, bool onM, + DateBookWeekLstView(QValueList &ev, const QDate &d, bool onM, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~DateBookWeekLstView(); @@ -88,6 +89,21 @@ protected slots: void keyPressEvent(QKeyEvent *); }; +class DateBookWeekLstDblView: public QWidget { + Q_OBJECT +public: + DateBookWeekLstDblView(QValueList &ev1, + QValueList &ev2, + QDate &d, bool onM, + QWidget* parent = 0, const char* name = 0, + WFlags fl = 0 ); +signals: + void editEvent(const Event &e); + void showDate(int y, int m, int d); + void addEvent(const QDateTime &start, const QDateTime &stop, + const QString &str); +}; + class DateBookWeekLst : public QWidget { Q_OBJECT @@ -96,6 +112,7 @@ public: DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, QWidget *parent = 0, const char *name = 0 ); + ~DateBookWeekLst(); void setDate( int y, int w ); void setDate(const QDate &d ); int week() const { return _week; }; @@ -104,8 +121,10 @@ public: public slots: void redraw(); void dateChanged(int y, int w); + protected slots: void keyPressEvent(QKeyEvent *); + void setDbl(bool on); signals: void showDate(int y, int m, int d); @@ -114,17 +133,18 @@ signals: void editEvent(const Event &e); private: - DateBookDB *db; - int startTime; - bool ampm; - bool onMonday; - int year, _week; - DateBookWeekLstHeader *header; - DateBookWeekLstView *view; - QVBoxLayout *layout; - QScrollView *scroll; - - void getEvents(); + DateBookDB *db; + int startTime; + bool ampm; + bool onMonday; + bool dbl; + int year, _week; + DateBookWeekLstHeader *header; + QWidget *view; + QVBoxLayout *layout; + QScrollView *scroll; + + void getEvents(); }; #endif diff --git a/core/pim/datebook/datebookweeklstheader.ui b/core/pim/datebook/datebookweeklstheader.ui index 666e896..9de64ae 100644 --- a/core/pim/datebook/datebookweeklstheader.ui +++ b/core/pim/datebook/datebookweeklstheader.ui @@ -10,9 +10,9 @@ geometry 0 - 51 - 535 - 25 + 183 + 447 + 45 @@ -35,7 +35,7 @@ margin - 0 + 11 spacing @@ -50,7 +50,7 @@ sizePolicy - 1 + 7 0 @@ -63,6 +63,10 @@ image0 + toggleButton + false + + autoRepeat true @@ -70,6 +74,14 @@ autoRaise true + + toggleButton + false + + + toolTip + + @@ -116,9 +128,21 @@ W: 00,00 + toggleButton + false + + autoRaise false + + toggleButton + false + + + toolTip + + @@ -142,6 +166,67 @@ + QToolButton + + name + dbl + + + sizePolicy + + 3 + 0 + + + + font + + 1 + + + + text + 2 + + + toggleButton + true + + + autoRaise + false + + + toggleButton + true + + + toolTip + + + + + + name + Spacer1_3_2 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + QLabel name @@ -164,10 +249,6 @@ text 00 Jan-00 Jan - - alignment - AlignCenter - hAlign -- cgit v0.9.0.2