-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 67 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.h | 44 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklstheader.ui | 99 |
3 files changed, 185 insertions, 25 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 @@ -1,22 +1,23 @@ #include "datebookweeklst.h" #include "datebookweekheaderimpl.h" #include <qpe/calendar.h> #include <qpe/datebookdb.h> #include <qpe/event.h> #include <qpe/qpeapplication.h> #include <qpe/timestring.h> #include <qpe/datebookmonth.h> +#include <qpe/config.h> #include <qdatetime.h> #include <qheader.h> #include <qlabel.h> #include <qlayout.h> #include <qpainter.h> #include <qpopupmenu.h> #include <qtimer.h> #include <qstyle.h> #include <qtoolbutton.h> #include <qvbox.h> #include <qsizepolicy.h> @@ -34,24 +35,25 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, labelDate->setBackgroundMode( PaletteButton ); labelWeek->setBackgroundMode( PaletteButton ); forward->setBackgroundMode( PaletteButton ); back->setBackgroundMode( PaletteButton ); DateBookWeekLstHeaderBaseLayout->setSpacing(0); DateBookWeekLstHeaderBaseLayout->setMargin(0); //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 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(){} void DateBookWeekLstHeader::setDate(const QDate &d) { date=d; int year,week; calcWeek(d,week,year,onMonday); labelWeek->setText("W: " + QString::number(week)); QDate start=date; QDate stop=start.addDays(6); @@ -147,32 +149,33 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, char s[10]; if ( ev.startDate() != ev.date() ) { // multiday event (not first day) if ( ev.endDate() == ev.date() ) { // last day strcpy(s, "__|__"); } else { strcpy(s, " |---"); } } else { sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); } 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()); } DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, - QDate &d, bool onM, + const QDate &d, bool onM, QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { onMonday=onM; setPalette(white); setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); QVBoxLayout *layout = new QVBoxLayout( this ); qBubbleSort(ev); QValueListIterator<EffectiveEvent> it; @@ -206,80 +209,136 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, layout->addWidget(l); connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); it++; } layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); } } DateBookWeekLstView::~DateBookWeekLstView(){} void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} +DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, + QValueList<EffectiveEvent> &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 ) : QWidget( parent, name ), db( newDB ), startTime( 0 ), ampm( ap ), onMonday(onM) { setFocusPolicy(StrongFocus); layout = new QVBoxLayout( this ); layout->setMargin(0); 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); //scroll->setHScrollBarMode(QScrollView::AlwaysOff); scroll->setResizePolicy(QScrollView::AutoOneFit); 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; calcWeek(d,w,y,onMonday); year=y; _week=w; header->setDate(date()); } +void DateBookWeekLst::setDbl(bool on) { + dbl=on; + redraw(); +} void DateBookWeekLst::redraw() {getEvents();} QDate DateBookWeekLst::date() const { QDate d; d.setYMD(year,1,1); int dow= d.dayOfWeek(); if (!onMonday) if (dow==7) dow=1; else dow++; d=d.addDays( (_week-1)*7 - dow + 1 ); return d; } void DateBookWeekLst::getEvents() { QDate start = date(); QDate stop = start.addDays(6); QValueList<EffectiveEvent> 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<EffectiveEvent> 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 &))); connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &)), this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &))); scroll->addChild(view); view->show(); 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 @@ -22,24 +22,25 @@ public: DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~DateBookWeekLstHeader(); void setDate(const QDate &d); public slots: void nextWeek(); void prevWeek(); void pickDate(); void setDate(int y, int m, int d); signals: void dateChanged(int y, int w); + void setDbl(bool on); private: QDate date; bool onMonday; }; class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase { Q_OBJECT public: DateBookWeekLstDayHdr(const QDate &d, bool onM, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); @@ -64,68 +65,87 @@ public: signals: void editEvent(const Event &e); private slots: void editMe(); private: const EffectiveEvent event; }; class DateBookWeekLstView: public QWidget { Q_OBJECT public: - DateBookWeekLstView(QValueList<EffectiveEvent> &ev, QDate &d, bool onM, + DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~DateBookWeekLstView(); 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); private: bool onMonday; protected slots: void keyPressEvent(QKeyEvent *); }; +class DateBookWeekLstDblView: public QWidget { + Q_OBJECT +public: + DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, + QValueList<EffectiveEvent> &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 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; }; QDate date() const; 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); void addEvent(const QDateTime &start, const QDateTime &stop, const QString &str); 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 @@ -1,84 +1,96 @@ <!DOCTYPE UI><UI> <class>DateBookWeekLstHeaderBase</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>DateBookWeekLstHeaderBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> - <y>51</y> - <width>535</width> - <height>25</height> + <y>183</y> + <width>447</width> + <height>45</height> </rect> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>caption</name> <string>Form2</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <hbox> <property stdset="1"> <name>margin</name> - <number>0</number> + <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QToolButton</class> <property stdset="1"> <name>name</name> <cstring>back</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> - <hsizetype>1</hsizetype> + <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string></string> </property> <property stdset="1"> <name>pixmap</name> <pixmap>image0</pixmap> </property> <property stdset="1"> + <name>toggleButton</name> + <bool>false</bool> + </property> + <property stdset="1"> <name>autoRepeat</name> <bool>true</bool> </property> <property stdset="1"> <name>autoRaise</name> <bool>true</bool> </property> + <property stdset="1"> + <name>toggleButton</name> + <bool>false</bool> + </property> + <property> + <name>toolTip</name> + <string></string> + </property> </widget> <spacer> <property> <name>name</name> <cstring>Spacer1_3</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> <property stdset="1"> <name>sizeType</name> @@ -107,76 +119,145 @@ </property> <property stdset="1"> <name>font</name> <font> <bold>1</bold> </font> </property> <property stdset="1"> <name>text</name> <string>W: 00,00</string> </property> <property stdset="1"> + <name>toggleButton</name> + <bool>false</bool> + </property> + <property stdset="1"> <name>autoRaise</name> <bool>false</bool> </property> + <property stdset="1"> + <name>toggleButton</name> + <bool>false</bool> + </property> + <property> + <name>toolTip</name> + <string></string> + </property> </widget> <spacer> <property> <name>name</name> <cstring>Spacer1</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>dbl</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>font</name> + <font> + <bold>1</bold> + </font> + </property> + <property stdset="1"> + <name>text</name> + <string>2</string> + </property> + <property stdset="1"> + <name>toggleButton</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>autoRaise</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>toggleButton</name> + <bool>true</bool> + </property> + <property> + <name>toolTip</name> + <string></string> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer1_3_2</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>labelDate</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>3</hsizetype> <vsizetype>7</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>font</name> <font> <bold>1</bold> </font> </property> <property stdset="1"> <name>text</name> <string>00 Jan-00 Jan</string> </property> - <property stdset="1"> - <name>alignment</name> - <set>AlignCenter</set> - </property> <property> <name>hAlign</name> </property> </widget> <spacer> <property> <name>name</name> <cstring>Spacer1_2</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> |