-rw-r--r-- | core/pim/datebook/datebook.cpp | 45 | ||||
-rw-r--r-- | core/pim/datebook/datebook.h | 37 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 5 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.h | 6 | ||||
-rw-r--r-- | core/pim/datebook/datebookdayallday.cpp | 12 | ||||
-rw-r--r-- | core/pim/datebook/datebooktypes.h | 59 | ||||
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 489 | ||||
-rw-r--r-- | core/pim/datebook/datebookweek.h | 9 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 597 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.h | 93 |
10 files changed, 718 insertions, 634 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index f6aab0c..36c4bd7 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -77,5 +77,6 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) t.start(); - db = new DateBookDBHack; + db = new DateBookDBHoliday; odebug << "loading db t=" << t.elapsed() << oendl; db_holiday = new DateBookHoliday(); + db->db_holiday=db_holiday; @@ -1151 +1152,43 @@ QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned +QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) +{ + QValueList<EffectiveEvent> ret; + QValueList<HPlugin*>::Iterator it; + for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { + HPlugin*_pl = *it; + ret+=_pl->_plugin->events(from,to); + } + return ret; +} + +QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ) +{ + return DateBookDBHack::getEffectiveEvents(from,to); +} + +QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start) +{ + return DateBookDBHack::getEffectiveEvents(start); +} + +QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start) +{ + return getEffectiveEvents(start.date(),start.date()); +} + +QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) +{ + QValueList<EffectiveEvent> ret; + odebug << "Ueberlagert 1" << oendl; + if (db_holiday) { + ret+=db_holiday->getEffectiveEvents(from,to); + } + ret+=getEffectiveEventsNoHoliday(from,to); + return ret; +} + +QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start) +{ + odebug << "Ueberlagert 2" << oendl; + return DateBookDBHack::getEffectiveEvents(start); +} diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index 54ffcfb..3d7f5b5 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h @@ -22,2 +22,4 @@ +#include "datebooktypes.h" + #include <qpe/datebookdb.h> @@ -38,35 +40,2 @@ class QDate; class Ir; -class QLibrary; - -namespace Opie { -namespace Datebook { - class HolidayPlugin; - class HolidayPluginIf; -} -} - -class DateBookDBHack : public DateBookDB { - public: - Event eventByUID(int id); -}; - -class DateBookHoliday -{ -public: - DateBookHoliday(); - virtual ~DateBookHoliday(); - - QStringList holidaylist(const QDate&); - QStringList holidaylist(unsigned year, unsigned month, unsigned day); -protected: - void init(); - void deinit(); - - struct HPlugin { - Opie::Datebook::HolidayPlugin*_plugin; - QLibrary*_lib; - Opie::Datebook::HolidayPluginIf*_if; - }; - QValueList<HPlugin*>_pluginlist; -}; @@ -139,3 +108,3 @@ private: private: - DateBookDBHack *db; + DateBookDBHoliday *db; DateBookHoliday*db_holiday; diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index dfe39e5..00ddd05 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp @@ -21,2 +21,3 @@ #include "datebookday.h" +#include "datebooktypes.h" #include "datebookdayheaderimpl.h" @@ -229,3 +230,3 @@ void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */) -DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name ) +DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name ) : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) @@ -369,3 +370,3 @@ void DateBookDay::getEvents() } - QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); + QValueList<EffectiveEvent> eventList = db->getEffectiveEventsNoHoliday( currDate, currDate ); QValueListIterator<EffectiveEvent> it; diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h index 3e44364..3b75eba 100644 --- a/core/pim/datebook/datebookday.h +++ b/core/pim/datebook/datebookday.h @@ -30,2 +30,3 @@ #include "datebook.h" +#include "datebooktypes.h" #include <qlineedit.h> @@ -34,2 +35,3 @@ class DateBookDayHeader; class DateBookDB; +class DateBookDBHoliday; class DatebookdayAllday; @@ -182,3 +184,3 @@ class DateBookDay : public QVBox public: - DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,DateBookHoliday*newHdb, + DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb,DateBookHoliday*newHdb, QWidget *parent, const char *name ); @@ -227,3 +229,3 @@ private: DatebookdayAllday *m_allDays; - DateBookDB *db; + DateBookDBHoliday *db; WidgetListClass widgetList; //reimplemented QList for sorting widgets by height diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp index 3c3f482..5b40246 100644 --- a/core/pim/datebook/datebookdayallday.cpp +++ b/core/pim/datebook/datebookdayallday.cpp @@ -32,3 +32,4 @@ DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const cha setFrameStyle(QFrame::NoFrame|QFrame::Plain); - setResizePolicy( QScrollView::Default ); + //setResizePolicy( QScrollView::Default ); + setResizePolicy(QScrollView::AutoOneFit); setHScrollBarMode( AlwaysOff ); @@ -113,5 +114,9 @@ DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,co m_Ev.setEvent(ev); - setBackgroundColor(yellow); setText(strDesc); - setFrameStyle(QFrame::Raised|QFrame::Panel); + + setAlignment(AlignHCenter); + setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum)); + + //setFrameStyle(QFrame::Raised|QFrame::Panel); + //setBackgroundColor(yellow); @@ -120,2 +125,3 @@ DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,co setMinimumSize( QSize( 0, s ) ); + m_holiday = true; diff --git a/core/pim/datebook/datebooktypes.h b/core/pim/datebook/datebooktypes.h new file mode 100644 index 0000000..9eb7e89 --- a/dev/null +++ b/core/pim/datebook/datebooktypes.h @@ -0,0 +1,59 @@ +#ifndef _DATEBOOK_TYPES_H
+#define _DATEBOOK_TYPES_H
+
+#include <qpe/datebookdb.h>
+
+#include <qvaluelist.h>
+#include <qstringlist.h>
+
+namespace Opie {
+namespace Datebook {
+ class HolidayPlugin;
+ class HolidayPluginIf;
+}
+}
+
+class QLibrary;
+
+class DateBookDBHack : virtual public DateBookDB {
+ public:
+ virtual ~DateBookDBHack(){}
+ Event eventByUID(int id);
+};
+
+class DateBookHoliday
+{
+public:
+ DateBookHoliday();
+ virtual ~DateBookHoliday();
+
+ QStringList holidaylist(const QDate&);
+ QStringList holidaylist(unsigned year, unsigned month, unsigned day);
+ virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
+ virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
+
+protected:
+ void init();
+ void deinit();
+
+ struct HPlugin {
+ Opie::Datebook::HolidayPlugin*_plugin;
+ QLibrary*_lib;
+ Opie::Datebook::HolidayPluginIf*_if;
+ };
+ QValueList<HPlugin*>_pluginlist;
+};
+
+class DateBookDBHoliday:virtual public DateBookDBHack {
+public:
+ DateBookDBHoliday():DateBookDBHack(){db_holiday=0;}
+ virtual ~DateBookDBHoliday(){}
+ virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
+ virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
+ virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to );
+ virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start);
+
+ DateBookHoliday*db_holiday;
+};
+
+#endif
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index 7503751..a509d89 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp @@ -21,2 +21,3 @@ #include "datebookweekheaderimpl.h" +#include "datebooktypes.h" @@ -54,3 +55,3 @@ void DateBookWeekItem::setGeometry( int x, int y, int w, int h ) DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday, - QWidget *parent, const char *name ) + QWidget *parent, const char *name ) : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ), @@ -74,3 +75,3 @@ DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday, QObject::connect(qApp, SIGNAL(clockChanged(bool)), - this, SLOT(slotChangeClock(bool))); + this, SLOT(slotChangeClock(bool))); @@ -87,3 +88,3 @@ void DateBookWeekView::initNames() if ( bFirst ) { - if ( bOnMonday ) { + if ( bOnMonday ) { for ( int i = 1; i<=7; i++ ) { @@ -92,3 +93,3 @@ void DateBookWeekView::initNames() - } else { + } else { header->addLabel( Calendar::nameOfDay( 7 ) ); @@ -98,6 +99,6 @@ void DateBookWeekView::initNames() } - bFirst = false; + bFirst = false; } else { - // we are change things... - if ( bOnMonday ) { + // we are change things... + if ( bOnMonday ) { for ( int i = 1; i<=7; i++ ) { @@ -106,3 +107,3 @@ void DateBookWeekView::initNames() - } else { + } else { header->setLabel( 1, Calendar::nameOfDay( 7 ) ); @@ -112,3 +113,3 @@ void DateBookWeekView::initNames() - } + } } @@ -120,12 +121,12 @@ void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) { - items.clear(); - QValueListIterator<EffectiveEvent> it; - for ( it = ev.begin(); it != ev.end(); ++it ) { - DateBookWeekItem *i = new DateBookWeekItem( *it ); - if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) { // Skip events ending at 00:00 starting at another day. - positionItem( i ); - items.append( i ); - } - } - viewport()->update(); + items.clear(); + QValueListIterator<EffectiveEvent> it; + for ( it = ev.begin(); it != ev.end(); ++it ) { + DateBookWeekItem *i = new DateBookWeekItem( *it ); + if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) { // Skip events ending at 00:00 starting at another day. + positionItem( i ); + items.append( i ); + } + } + viewport()->update(); } @@ -152,7 +153,7 @@ static inline int db_round30min( int m ) if ( m < 15 ) - m = 0; + m = 0; else if ( m < 45 ) - m = 1; + m = 1; else - m = 2; + m = 2; @@ -164,3 +165,3 @@ void DateBookWeekView::alterDay( int day ) if ( !bOnMonday ) { - day--; + day--; } @@ -186,7 +187,7 @@ void DateBookWeekView::positionItem( DateBookWeekItem *i ) if ( ev.event().type() == Event::AllDay ) { - h = (48 * rowHeight) / 2; - y = 0; - } else { - h=y2-y; - if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; + h = (48 * rowHeight) / 2; + y = 0; + } else { + h=y2-y; + if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; } @@ -195,6 +196,6 @@ void DateBookWeekView::positionItem( DateBookWeekItem *i ) if ( !bOnMonday ) { - if ( dow == 7 ) - dow = 1; - else - dow++; + if ( dow == 7 ) + dow = 1; + else + dow++; } @@ -204,5 +205,5 @@ void DateBookWeekView::positionItem( DateBookWeekItem *i ) do { - i->setGeometry( x, y, Width, h ); - isect = intersects( i ); - x += Width - 1; + i->setGeometry( x, y, Width, h ); + isect = intersects( i ); + x += Width - 1; } while ( isect && x < xlim ); @@ -220,8 +221,8 @@ DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) for ( ; it.current(); ++it ) { - DateBookWeekItem *i = it.current(); - if ( i != item ) { - if ( i->geometry().intersects( geom ) ) { - return i; - } - } + DateBookWeekItem *i = it.current(); + if ( i != item ) { + if ( i->geometry().intersects( geom ) ) { + return i; + } + } } @@ -235,8 +236,8 @@ void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) for ( ; it.current(); ++it ) { - DateBookWeekItem *i = it.current(); - if ( i->geometry().contains( e->pos() ) ) { - showingEvent = true; - emit signalShowEvent( i->event() ); - break; - } + DateBookWeekItem *i = it.current(); + if ( i->geometry().contains( e->pos() ) ) { + showingEvent = true; + emit signalShowEvent( i->event() ); + break; + } } @@ -247,11 +248,11 @@ void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e ) if ( showingEvent ) { - showingEvent = false; - emit signalHideEvent(); + showingEvent = false; + emit signalHideEvent(); } else { - int d = header->sectionAt( e->pos().x() ); - if ( d > 0 ) { -// if ( !bOnMonday ) -// d--; - emit showDay( d ); - } + int d = header->sectionAt( e->pos().x() ); + if ( d > 0 ) { +// if ( !bOnMonday ) +// d--; + emit showDay( d ); + } } @@ -264,3 +265,3 @@ void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch for ( int i = 1; i <= 7; i++ ) - p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch ); + p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch ); @@ -268,30 +269,30 @@ void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch for ( int t = 0; t < 24; t++ ) { - int y = t*rowHeight; - if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { - QString s; - if ( ampm ) { - if ( t == 0 ) - s = QString::number( 12 ); - else if ( t == 12 ) - s = QString::number(12) + tr( "p" ); - else if ( t > 12 ) { - if ( t - 12 < 10 ) - s = " "; - else - s = ""; - s += QString::number( t - 12 ) + tr("p"); - } else { - if ( 12 - t < 3 ) - s = ""; - else - s = " "; - s += QString::number( t ); - } - } else { - s = QString::number( t ); - if ( s.length() == 1 ) - s.prepend( "0" ); - } - p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); - } + int y = t*rowHeight; + if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { + QString s; + if ( ampm ) { + if ( t == 0 ) + s = QString::number( 12 ); + else if ( t == 12 ) + s = QString::number(12) + tr( "p" ); + else if ( t > 12 ) { + if ( t - 12 < 10 ) + s = " "; + else + s = ""; + s += QString::number( t - 12 ) + tr("p"); + } else { + if ( 12 - t < 3 ) + s = ""; + else + s = " "; + s += QString::number( t ); + } + } else { + s = QString::number( t ); + if ( s.length() == 1 ) + s.prepend( "0" ); + } + p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); + } } @@ -300,7 +301,7 @@ void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch for ( ; it.current(); ++it ) { - DateBookWeekItem *i = it.current(); - if ( i->geometry().intersects( ur ) ) { - p->setBrush( i->color() ); - p->drawRect( i->geometry() ); - } + DateBookWeekItem *i = it.current(); + if ( i->geometry().intersects( ur ) ) { + p->setBrush( i->color() ); + p->drawRect( i->geometry() ); + } } @@ -318,3 +319,3 @@ void DateBookWeekView::resizeEvent( QResizeEvent *e ) header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(), - visibleWidth(), header->sizeHint().height() ); + visibleWidth(), header->sizeHint().height() ); setMargins( 0, header->sizeHint().height(), 0, 0 ); @@ -330,3 +331,3 @@ void DateBookWeekView::resizeEvent( QResizeEvent *e ) for ( int i = 1; i < 7; i++ ) - header->resizeSection( i, sw ); + header->resizeSection( i, sw ); header->resizeSection( 7, avail - hourWidth - sw*6 ); @@ -342,4 +343,4 @@ void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) -DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, - QWidget *parent, const char *name ) +DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDBHoliday *newDB, + QWidget *parent, const char *name ) : QWidget( parent, name ), @@ -350,24 +351,24 @@ DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, { - setFocusPolicy(StrongFocus); - QVBoxLayout *vb = new QVBoxLayout( this ); - header = new DateBookWeekHeader( bStartOnMonday, this ); - view = new DateBookWeekView( ampm, startOnMonday, this ); - vb->addWidget( header ); - vb->addWidget( view ); + setFocusPolicy(StrongFocus); + QVBoxLayout *vb = new QVBoxLayout( this ); + header = new DateBookWeekHeader( bStartOnMonday, this ); + view = new DateBookWeekView( ampm, startOnMonday, this ); + vb->addWidget( header ); + vb->addWidget( view ); - lblDesc = new QLabel( this, "event label" ); - lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); - lblDesc->setBackgroundColor( yellow ); - lblDesc->hide(); + lblDesc = new QLabel( this, "event label" ); + lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); + lblDesc->setBackgroundColor( yellow ); + lblDesc->hide(); - tHide = new QTimer( this ); + tHide = new QTimer( this ); - connect( view, SIGNAL( showDay(int) ), this, SLOT( showDay(int) ) ); - connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); - connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); - connect( header, SIGNAL( dateChanged(QDate&) ), this, SLOT( dateChanged(QDate&) ) ); - connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); - connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); - connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); - setDate(QDate::currentDate()); + connect( view, SIGNAL( showDay(int) ), this, SLOT( showDay(int) ) ); + connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); + connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); + connect( header, SIGNAL( dateChanged(QDate&) ), this, SLOT( dateChanged(QDate&) ) ); + connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); + connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); + connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); + setDate(QDate::currentDate()); } @@ -377,16 +378,16 @@ void DateBookWeek::keyPressEvent(QKeyEvent *e) switch(e->key()) { - case Key_Up: - view->scrollBy(0, -20); - break; - case Key_Down: - view->scrollBy(0, 20); - break; - case Key_Left: - setDate(date().addDays(-7)); - break; - case Key_Right: - setDate(date().addDays(7)); - break; - default: - e->ignore(); + case Key_Up: + view->scrollBy(0, -20); + break; + case Key_Down: + view->scrollBy(0, 20); + break; + case Key_Left: + setDate(date().addDays(-7)); + break; + case Key_Right: + setDate(date().addDays(7)); + break; + default: + e->ignore(); } @@ -396,12 +397,12 @@ void DateBookWeek::showDay( int day ) { - QDate d=bdate; + QDate d=bdate; - // Calculate offset to first day of week. - int dayoffset=d.dayOfWeek() % 7; + // Calculate offset to first day of week. + int dayoffset=d.dayOfWeek() % 7; - if(bStartOnMonday) dayoffset--; + if(bStartOnMonday) dayoffset--; - day--; - d=d.addDays(day-dayoffset); - emit showDate( d.year(), d.month(), d.day() ); + day--; + d=d.addDays(day-dayoffset); + emit showDate( d.year(), d.month(), d.day() ); } @@ -410,3 +411,3 @@ void DateBookWeek::setDate( int y, int m, int d ) { - setDate(QDate(y, m, d)); + setDate(QDate(y, m, d)); } @@ -415,5 +416,5 @@ void DateBookWeek::setDate(QDate newdate) { - bdate=newdate; - dow = newdate.dayOfWeek(); - header->setDate( newdate ); + bdate=newdate; + dow = newdate.dayOfWeek(); + header->setDate( newdate ); } @@ -422,4 +423,4 @@ void DateBookWeek::dateChanged( QDate &newdate ) { - bdate=newdate; - getEvents(); + bdate=newdate; + getEvents(); } @@ -428,3 +429,3 @@ QDate DateBookWeek::date() const { - return bdate; + return bdate; } @@ -433,8 +434,8 @@ void DateBookWeek::getEvents() { - QDate startWeek = weekDate(); + QDate startWeek = weekDate(); - QDate endWeek = startWeek.addDays( 6 ); - QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); - view->showEvents( eventList ); - view->moveToHour( startTime ); + QDate endWeek = startWeek.addDays( 6 ); + QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); + view->showEvents( eventList ); + view->moveToHour( startTime ); } @@ -442,3 +443,3 @@ void DateBookWeek::getEvents() void DateBookWeek::generateAllDayTooltext( QString& text ) { - text += "<b>" + tr("This is an all day event.") + "</b><br>"; + text += "<b>" + tr("This is an all day event.") + "</b><br>"; } @@ -446,13 +447,13 @@ void DateBookWeek::generateAllDayTooltext( QString& text ) { void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { - str += "<b>" + QObject::tr("Start") + "</b>: "; - str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); - if( ev.startDate()!=ev.endDate() ) { - str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; - } - str += "<br>"; - str += "<b>" + QObject::tr("End") + "</b>: "; - str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); - if( ev.startDate()!=ev.endDate() ) { - str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; - } + str += "<b>" + QObject::tr("Start") + "</b>: "; + str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); + if( ev.startDate()!=ev.endDate() ) { + str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; + } + str += "<br>"; + str += "<b>" + QObject::tr("End") + "</b>: "; + str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); + if( ev.startDate()!=ev.endDate() ) { + str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; + } } @@ -469,5 +470,5 @@ void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) while ( where != -1 ) { - strDesc.remove( where, 1 ); - strDesc.insert( where, "<" ); - where = strDesc.find( "<", where ); + strDesc.remove( where, 1 ); + strDesc.insert( where, "<" ); + where = strDesc.find( "<", where ); } @@ -479,5 +480,5 @@ void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) // while ( where != -1 ) { -// strCat.remove( where, 1 ); -// strCat.insert( where, "<" ); -// where = strCat.find( "<", where ); +// strCat.remove( where, 1 ); +// strCat.insert( where, "<" ); +// where = strCat.find( "<", where ); // } @@ -486,5 +487,5 @@ void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) while ( where != -1 ) { - strLocation.remove( where, 1 ); - strLocation.insert( where, "<" ); - where = strLocation.find( "<", where ); + strLocation.remove( where, 1 ); + strLocation.insert( where, "<" ); + where = strLocation.find( "<", where ); } @@ -494,5 +495,5 @@ void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) while ( where != -1 ) { - strNote.remove( where, 1 ); - strNote.insert( where, "<" ); - where = strNote.find( "<", where ); + strNote.remove( where, 1 ); + strNote.insert( where, "<" ); + where = strNote.find( "<", where ); } @@ -503,3 +504,3 @@ void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) + "<br>" + TimeString::longDateString( ev.date() ) - + "<br>"; + + "<br>"; @@ -542,10 +543,10 @@ void DateBookWeek::slotYearChanged( int y ) { - int totWeek; - QDate d( y, 12, 31 ); - int throwAway; - calcWeek( d, totWeek, throwAway, bStartOnMonday ); - while ( totWeek == 1 ) { - d = d.addDays( -1 ); - calcWeek( d, totWeek, throwAway, bStartOnMonday ); - } + int totWeek; + QDate d( y, 12, 31 ); + int throwAway; + calcWeek( d, totWeek, throwAway, bStartOnMonday ); + while ( totWeek == 1 ) { + d = d.addDays( -1 ); + calcWeek( d, totWeek, throwAway, bStartOnMonday ); + } } @@ -554,6 +555,6 @@ void DateBookWeek::slotWeekChanged( bool onMonday ) { - bStartOnMonday = onMonday; - view->setStartOfWeek( bStartOnMonday ); - header->setStartOfWeek( bStartOnMonday ); - redraw(); + bStartOnMonday = onMonday; + view->setStartOfWeek( bStartOnMonday ); + header->setStartOfWeek( bStartOnMonday ); + redraw(); } @@ -562,3 +563,3 @@ void DateBookWeek::slotClockChanged( bool ap ) { - ampm = ap; + ampm = ap; } @@ -568,11 +569,11 @@ QDate DateBookWeek::weekDate() const { - QDate d=bdate; + QDate d=bdate; - // Calculate offset to first day of week. - int dayoffset=d.dayOfWeek(); - if(bStartOnMonday) dayoffset--; - else if( dayoffset == 7 ) - dayoffset = 0; + // Calculate offset to first day of week. + int dayoffset=d.dayOfWeek(); + if(bStartOnMonday) dayoffset--; + else if( dayoffset == 7 ) + dayoffset = 0; - return d.addDays(-dayoffset); + return d.addDays(-dayoffset); } @@ -602,3 +603,3 @@ QDate DateBookWeek::weekDate() const bool calcWeek( const QDate &d, int &week, int &year, - bool startOnMonday ) + bool startOnMonday ) { @@ -613,58 +614,58 @@ bool calcWeek( const QDate &d, int &week, int &year, if ( !d.isValid() ) - return false; + return false; if ( startOnMonday ) { - // find the Jan1Weekday; - if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) { - yearNumber = d.year() - 1; - if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) ) - weekNumber = 53; - else - weekNumber = 52; - } else - yearNumber = d.year(); - if ( yearNumber == d.year() ) { - int totalDays = 365; - if ( QDate::leapYear(yearNumber) ) - totalDays++; - if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek) ) - || (jan1WeekDay == 7) && (totalDays - d.dayOfYear()) < 3) { - yearNumber++; - weekNumber = 1; - } - } - if ( yearNumber == d.year() ) { - int j = d.dayOfYear() + (7 - dayOfWeek) + ( jan1WeekDay - 1 ); - weekNumber = j / 7; - if ( jan1WeekDay > 4 ) - weekNumber--; - } + // find the Jan1Weekday; + if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) { + yearNumber = d.year() - 1; + if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) ) + weekNumber = 53; + else + weekNumber = 52; + } else + yearNumber = d.year(); + if ( yearNumber == d.year() ) { + int totalDays = 365; + if ( QDate::leapYear(yearNumber) ) + totalDays++; + if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek) ) + || (jan1WeekDay == 7) && (totalDays - d.dayOfYear()) < 3) { + yearNumber++; + weekNumber = 1; + } + } + if ( yearNumber == d.year() ) { + int j = d.dayOfYear() + (7 - dayOfWeek) + ( jan1WeekDay - 1 ); + weekNumber = j / 7; + if ( jan1WeekDay > 4 ) + weekNumber--; + } } else { - // it's better to keep these cases separate... - if ( d.dayOfYear() <= (7 - jan1WeekDay) && jan1WeekDay > 4 - && jan1WeekDay != 7 ) { - yearNumber = d.year() - 1; - if ( jan1WeekDay == 6 - || (jan1WeekDay == 7 && QDate::leapYear(yearNumber) ) ) { - weekNumber = 53; - }else - weekNumber = 52; - } else - yearNumber = d.year(); - if ( yearNumber == d.year() ) { - int totalDays = 365; - if ( QDate::leapYear( yearNumber ) ) - totalDays++; - if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek % 7)) ) { - yearNumber++; - weekNumber = 1; - } - } - if ( yearNumber == d.year() ) { - int j = d.dayOfYear() + (7 - dayOfWeek % 7) + ( jan1WeekDay - 1 ); - weekNumber = j / 7; - if ( jan1WeekDay > 4 ) { - weekNumber--; - } - } + // it's better to keep these cases separate... + if ( d.dayOfYear() <= (7 - jan1WeekDay) && jan1WeekDay > 4 + && jan1WeekDay != 7 ) { + yearNumber = d.year() - 1; + if ( jan1WeekDay == 6 + || (jan1WeekDay == 7 && QDate::leapYear(yearNumber) ) ) { + weekNumber = 53; + }else + weekNumber = 52; + } else + yearNumber = d.year(); + if ( yearNumber == d.year() ) { + int totalDays = 365; + if ( QDate::leapYear( yearNumber ) ) + totalDays++; + if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek % 7)) ) { + yearNumber++; + weekNumber = 1; + } + } + if ( yearNumber == d.year() ) { + int j = d.dayOfYear() + (7 - dayOfWeek % 7) + ( jan1WeekDay - 1 ); + weekNumber = j / 7; + if ( jan1WeekDay > 4 ) { + weekNumber--; + } + } } diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h index c273e30..ddf54ed 100644 --- a/core/pim/datebook/datebookweek.h +++ b/core/pim/datebook/datebookweek.h @@ -30,2 +30,3 @@ class DateBookDB; +class DateBookDBHoliday; class DateBookWeekHeader; @@ -60,3 +61,3 @@ public: DateBookWeekView( bool ampm, bool weekOnMonday, QWidget *parent = 0, - const char *name = 0 ); + const char *name = 0 ); @@ -102,4 +103,4 @@ class DateBookWeek : public QWidget public: - DateBookWeek( bool ampm, bool weekOnMonday, DateBookDB *newDB, - QWidget *parent = 0, const char *name = 0 ); + DateBookWeek( bool ampm, bool weekOnMonday, DateBookDBHoliday *newDB, + QWidget *parent = 0, const char *name = 0 ); void setDate( int y, int m, int d ); @@ -155,3 +156,3 @@ private: DateBookWeekView *view; - DateBookDB *db; + DateBookDBHoliday *db; QLabel *lblDesc; diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 771aa00..0555bc7 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp @@ -4,2 +4,3 @@ #include "datebook.h" +#include "datebooktypes.h" @@ -22,24 +23,24 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const ch { - setBackgroundMode( PaletteButton ); - labelDate->setBackgroundMode( PaletteButton ); - forwardweek->setBackgroundMode( PaletteButton ); - forwardweek->setPixmap( Resource::loadPixmap("forward") ); - forwardmonth->setBackgroundMode( PaletteButton ); - forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); - backweek->setBackgroundMode( PaletteButton ); - backweek->setPixmap( Resource::loadPixmap("back") ); - backmonth->setBackgroundMode( PaletteButton ); - backmonth->setPixmap( Resource::loadPixmap("fastback") ); - DateBookWeekLstHeaderBaseLayout->setSpacing(0); - DateBookWeekLstHeaderBaseLayout->setMargin(0); - //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); - setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - - connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); - connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); - connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); - connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); - connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); - connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); - bStartOnMonday=onM; + setBackgroundMode( PaletteButton ); + labelDate->setBackgroundMode( PaletteButton ); + forwardweek->setBackgroundMode( PaletteButton ); + forwardweek->setPixmap( Resource::loadPixmap("forward") ); + forwardmonth->setBackgroundMode( PaletteButton ); + forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); + backweek->setBackgroundMode( PaletteButton ); + backweek->setPixmap( Resource::loadPixmap("back") ); + backmonth->setBackgroundMode( PaletteButton ); + backmonth->setPixmap( Resource::loadPixmap("fastback") ); + DateBookWeekLstHeaderBaseLayout->setSpacing(0); + DateBookWeekLstHeaderBaseLayout->setMargin(0); + //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); + setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + + connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); + connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); + connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); + connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); + connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); + connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); + bStartOnMonday=onM; } @@ -48,23 +49,23 @@ DateBookWeekLstHeader::~DateBookWeekLstHeader(){} void DateBookWeekLstHeader::setDate(const QDate &d) { - int year,week,dayofweek; - date=d; - dayofweek=d.dayOfWeek(); - if(bStartOnMonday) - dayofweek--; - else if( dayofweek == 7 ) - /* we already have the right day -7 would lead to the same week */ - dayofweek = 0; - - date=date.addDays(-dayofweek); - - calcWeek(date,week,year,bStartOnMonday); - QDate start=date; - QDate stop=start.addDays(6); - labelDate->setText( QString::number(start.day()) + "." + - Calendar::nameOfMonth( start.month() ) + "-" + - QString::number(stop.day()) + "." + + int year,week,dayofweek; + date=d; + dayofweek=d.dayOfWeek(); + if(bStartOnMonday) + dayofweek--; + else if( dayofweek == 7 ) + /* we already have the right day -7 would lead to the same week */ + dayofweek = 0; + + date=date.addDays(-dayofweek); + + calcWeek(date,week,year,bStartOnMonday); + QDate start=date; + QDate stop=start.addDays(6); + labelDate->setText( QString::number(start.day()) + "." + + Calendar::nameOfMonth( start.month() ) + "-" + + QString::number(stop.day()) + "." + Calendar::nameOfMonth( stop.month()) +" ("+ - tr("w")+":"+QString::number( week ) +")"); - date = d; // bugfix: 0001126 - date has to be the selected date, not monday! - emit dateChanged(date); + tr("w")+":"+QString::number( week ) +")"); + date = d; // bugfix: 0001126 - date has to be the selected date, not monday! + emit dateChanged(date); } @@ -72,18 +73,18 @@ void DateBookWeekLstHeader::setDate(const QDate &d) { void DateBookWeekLstHeader::pickDate() { - static QPopupMenu *m1 = 0; - static DateBookMonth *picker = 0; - if ( !m1 ) { - m1 = new QPopupMenu( this ); - picker = new DateBookMonth( m1, 0, TRUE ); - m1->insertItem( picker ); - connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); - //connect( m1, SIGNAL( aboutToHide() ), - //this, SLOT( gotHide() ) ); - } - picker->setDate( date.year(), date.month(), date.day() ); - m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); - picker->setFocus(); + static QPopupMenu *m1 = 0; + static DateBookMonth *picker = 0; + if ( !m1 ) { + m1 = new QPopupMenu( this ); + picker = new DateBookMonth( m1, 0, TRUE ); + m1->insertItem( picker ); + connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); + //connect( m1, SIGNAL( aboutToHide() ), + //this, SLOT( gotHide() ) ); + } + picker->setDate( date.year(), date.month(), date.day() ); + m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); + picker->setFocus(); } void DateBookWeekLstHeader::setDate(int y, int m, int d) { - setDate(QDate(y,m,d)); + setDate(QDate(y,m,d)); } @@ -91,6 +92,6 @@ void DateBookWeekLstHeader::setDate(int y, int m, int d) { void DateBookWeekLstHeader::nextWeek() { - setDate(date.addDays(7)); + setDate(date.addDays(7)); } void DateBookWeekLstHeader::prevWeek() { - setDate(date.addDays(-7)); + setDate(date.addDays(-7)); } @@ -98,3 +99,3 @@ void DateBookWeekLstHeader::nextMonth() { - setDate(date.addDays(28)); + setDate(date.addDays(28)); } @@ -102,3 +103,3 @@ void DateBookWeekLstHeader::prevMonth() { - setDate(date.addDays(-28)); + setDate(date.addDays(-28)); } @@ -106,14 +107,14 @@ void DateBookWeekLstHeader::prevMonth() DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, - QWidget* parent, - const char* name, - WFlags fl ) + QWidget* parent, + const char* name, + WFlags fl ) : DateBookWeekLstDayHdrBase(parent, name, fl) { - date=d; + date=d; - static const QString wdays=tr("MTWTFSSM", "Week days"); - char day=wdays[d.dayOfWeek()-1]; + static const QString wdays=tr("MTWTFSSM", "Week days"); + char day=wdays[d.dayOfWeek()-1]; //dont use dayOfWeek() to save space ! - label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); + label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); @@ -121,21 +122,21 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, - if (d == QDate::currentDate()) { - QPalette pal=label->palette(); - pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); - label->setPalette(pal); - - /* - QFont f=label->font(); - f.setItalic(true); - label->setFont(f); - label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); - */ - } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday - QPalette pal=label->palette(); - pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); - label->setPalette(pal); - } - - connect (label, SIGNAL(clicked()), this, SLOT(showDay())); - connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); + if (d == QDate::currentDate()) { + QPalette pal=label->palette(); + pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); + label->setPalette(pal); + + /* + QFont f=label->font(); + f.setItalic(true); + label->setFont(f); + label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); + */ + } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday + QPalette pal=label->palette(); + pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); + label->setPalette(pal); + } + + connect (label, SIGNAL(clicked()), this, SLOT(showDay())); + connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); } @@ -143,3 +144,3 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, void DateBookWeekLstDayHdr::showDay() { - emit showDate(date.year(), date.month(), date.day()); + emit showDate(date.year(), date.month(), date.day()); } @@ -155,47 +156,47 @@ void DateBookWeekLstDayHdr::newEvent() { DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, - int weeklistviewconfig, - QWidget* parent, - const char* name, - WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) + int weeklistviewconfig, + QWidget* parent, + const char* name, + WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) { - // old values... lastday = "__|__", middle=" |---", Firstday="00:00", - QString s,start,middle,end,day; - - odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; - if(weeklistviewconfig==NONE) { // No times displayed. -// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); -// middle.sprintf("<--->"); -// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); -// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); - } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. - start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); - middle.sprintf(" |---"); - end.sprintf("__|__"); - day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); - } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. - start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); - middle.sprintf("<--->"); - end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); - day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); - } - - if(ev.event().type() == Event::Normal) { - if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. - s=day; - } else if(ev.startDate()==ev.date()) { // start event. - s=start; - } else if(ev.endDate()==ev.date()) { // end event. - s=end; - } else { // middle day. - s=middle; - } - } else { - s=""; - } - setText(QString(s) + " " + ev.description()); -// connect(this, SIGNAL(clicked()), this, SLOT(editMe())); - setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); + // old values... lastday = "__|__", middle=" |---", Firstday="00:00", + QString s,start,middle,end,day; + + odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; + if(weeklistviewconfig==NONE) { // No times displayed. +// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); +// middle.sprintf("<--->"); +// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); +// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); + } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. + start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); + middle.sprintf(" |---"); + end.sprintf("__|__"); + day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); + } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. + start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); + middle.sprintf("<--->"); + end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); + day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); + } + + if(ev.event().type() == Event::Normal) { + if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. + s=day; + } else if(ev.startDate()==ev.date()) { // start event. + s=start; + } else if(ev.endDate()==ev.date()) { // end event. + s=end; + } else { // middle day. + s=middle; + } + } else { + s=""; + } + 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()); + emit editEvent(event.event()); } @@ -212,3 +213,3 @@ void DateBookWeekLstEvent::beamMe() { - emit beamEvent( event.event() ); + emit beamEvent( event.event() ); } @@ -216,9 +217,9 @@ void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) { - popmenue = new QPopupMenu; - popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); - popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); - popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); - if(Ir::supported()) - popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); - popmenue->popup( mapToGlobal( e->pos() )); + popmenue = new QPopupMenu; + popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); + popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); + popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); + if(Ir::supported()) + popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); + popmenue->popup( mapToGlobal( e->pos() )); } @@ -226,57 +227,57 @@ void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, - const QDate &d, bool onM, - QWidget* parent, - const char* name, WFlags fl) + const QDate &d, bool onM, + QWidget* parent, + const char* name, WFlags fl) : QWidget( parent, name, fl ) { - Config config("DateBook"); - config.setGroup("Main"); - int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); - odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; - - bStartOnMonday=onM; - setPalette(white); - setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); - - QVBoxLayout *layout = new QVBoxLayout( this ); - - qBubbleSort(ev); - QValueListIterator<EffectiveEvent> it; - it=ev.begin(); - - int dayOrder[7]; - if (bStartOnMonday) { - for (int d=0; d<7; d++) dayOrder[d]=d+1; - } else { - for (int d=0; d<7; d++) dayOrder[d]=d; - dayOrder[0]=7; - } - - // Calculate offset to first day of week. - int dayoffset=d.dayOfWeek(); - if(bStartOnMonday) dayoffset--; - else if( dayoffset == 7 ) dayoffset = 0; - - for (int i=0; i<7; i++) { - // Header - DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); - connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); - connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), - this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); - layout->addWidget(hdr); - - // Events - while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { - if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. - DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); - layout->addWidget(l); - connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); - connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); - connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); - connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); - connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); - } - it++; - } - layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); + Config config("DateBook"); + config.setGroup("Main"); + int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); + odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; + + bStartOnMonday=onM; + setPalette(white); + setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); + + QVBoxLayout *layout = new QVBoxLayout( this ); + + qBubbleSort(ev); + QValueListIterator<EffectiveEvent> it; + it=ev.begin(); + + int dayOrder[7]; + if (bStartOnMonday) { + for (int d=0; d<7; d++) dayOrder[d]=d+1; + } else { + for (int d=0; d<7; d++) dayOrder[d]=d; + dayOrder[0]=7; + } + + // Calculate offset to first day of week. + int dayoffset=d.dayOfWeek(); + if(bStartOnMonday) dayoffset--; + else if( dayoffset == 7 ) dayoffset = 0; + + for (int i=0; i<7; i++) { + // Header + DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); + connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); + connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), + this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); + layout->addWidget(hdr); + + // Events + while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { + if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. + DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); + layout->addWidget(l); + connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); + connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); + connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); + connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); + connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); + } + it++; + } + layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); } @@ -287,37 +288,37 @@ 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) + 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(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); - connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); - connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); - connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); - connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); - connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), - this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,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(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); - connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); - connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); - connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); - connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); - connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), - this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); + 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(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); + connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); + connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); + connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); + connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); + connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), + this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,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(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); + connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); + connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); + connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); + connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); + connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), + this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); } -DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, - QWidget *parent, - const char *name ) +DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, + QWidget *parent, + const char *name ) : QWidget( parent, name ), @@ -328,25 +329,25 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, { - setFocusPolicy(StrongFocus); - layout = new QVBoxLayout( this ); - layout->setMargin(0); - - header=new DateBookWeekLstHeader(onM, this); - layout->addWidget( header ); - connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); - connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); - - scroll=new QScrollView(this); - 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); + setFocusPolicy(StrongFocus); + layout = new QVBoxLayout( this ); + layout->setMargin(0); + + header=new DateBookWeekLstHeader(onM, this); + layout->addWidget( header ); + connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); + connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); + + scroll=new QScrollView(this); + 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); + Config config("DateBook"); + config.setGroup("Main"); + config.writeEntry("weeklst_dbl", dbl); } @@ -354,4 +355,4 @@ DateBookWeekLst::~DateBookWeekLst(){ void DateBookWeekLst::setDate(const QDate &d) { - bdate=d; - header->setDate(d); + bdate=d; + header->setDate(d); } @@ -359,4 +360,4 @@ void DateBookWeekLst::setDate(const QDate &d) { void DateBookWeekLst::setDbl(bool on) { - dbl=on; - redraw(); + dbl=on; + redraw(); } @@ -365,3 +366,3 @@ void DateBookWeekLst::redraw() {getEvents();} QDate DateBookWeekLst::date() { - return bdate; + return bdate; } @@ -372,11 +373,11 @@ QDate DateBookWeekLst::weekDate() const { - QDate d=bdate; + QDate d=bdate; - // Calculate offset to first day of week. - int dayoffset=d.dayOfWeek(); - if(bStartOnMonday) dayoffset--; - else if( dayoffset == 7 ) - dayoffset = 0; + // Calculate offset to first day of week. + int dayoffset=d.dayOfWeek(); + if(bStartOnMonday) dayoffset--; + else if( dayoffset == 7 ) + dayoffset = 0; - return d.addDays(-dayoffset); + return d.addDays(-dayoffset); } @@ -384,28 +385,28 @@ QDate DateBookWeekLst::weekDate() const void DateBookWeekLst::getEvents() { - QDate start = weekDate(); //date(); - QDate stop = start.addDays(6); - QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); - - if (view) delete view; - if (dbl) { - QDate start2=start.addDays(7); - stop=start2.addDays(6); - QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); - view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); - } else { - view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); - } - - connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); - connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); - connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); - connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); - connect (view, SIGNAL(redraw()), this, SLOT(redraw())); - connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); - connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), - this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); - - scroll->addChild(view); - view->show(); - scroll->updateScrollBars(); + QDate start = weekDate(); //date(); + QDate stop = start.addDays(7); + QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); + + if (view) delete view; + if (dbl) { + QDate start2=start.addDays(8); + stop=start2.addDays(7); + QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); + view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); + } else { + view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); + } + + connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); + connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); + connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); + connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); + connect (view, SIGNAL(redraw()), this, SLOT(redraw())); + connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); + connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), + this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); + + scroll->addChild(view); + view->show(); + scroll->updateScrollBars(); } @@ -413,4 +414,4 @@ void DateBookWeekLst::getEvents() { void DateBookWeekLst::dateChanged(QDate &newdate) { - bdate=newdate; - getEvents(); + bdate=newdate; + getEvents(); } @@ -419,18 +420,18 @@ void DateBookWeekLst::keyPressEvent(QKeyEvent *e) { - switch(e->key()) { - case Key_Up: - scroll->scrollBy(0, -20); - break; - case Key_Down: - scroll->scrollBy(0, 20); - break; - case Key_Left: - header->prevWeek(); - break; - case Key_Right: - header->nextWeek(); - break; - default: - e->ignore(); - } + switch(e->key()) { + case Key_Up: + scroll->scrollBy(0, -20); + break; + case Key_Down: + scroll->scrollBy(0, 20); + break; + case Key_Left: + header->prevWeek(); + break; + case Key_Right: + header->nextWeek(); + break; + default: + e->ignore(); + } } diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h index 3bc7f2f..38d7777 100644 --- a/core/pim/datebook/datebookweeklst.h +++ b/core/pim/datebook/datebookweeklst.h @@ -16,2 +16,3 @@ class QDateTime; class DateBookDB; +class DateBookDBHoliday; @@ -22,3 +23,3 @@ public: DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, - WFlags fl = 0 ); + WFlags fl = 0 ); ~DateBookWeekLstHeader(); @@ -27,15 +28,15 @@ public: public slots: - void nextWeek(); - void prevWeek(); - void nextMonth(); - void prevMonth(); - void pickDate(); - void setDate(int y, int m, int d); + void nextWeek(); + void prevWeek(); + void nextMonth(); + void prevMonth(); + void pickDate(); + void setDate(int y, int m, int d); signals: - void dateChanged(QDate &newdate); - void setDbl(bool on); + void dateChanged(QDate &newdate); + void setDbl(bool on); private: - QDate date; -// bool onMonday; - bool bStartOnMonday; + QDate date; +// bool onMonday; + bool bStartOnMonday; }; @@ -47,4 +48,4 @@ public: DateBookWeekLstDayHdr(const QDate &d, bool onM, - QWidget* parent = 0, const char* name = 0, - WFlags fl = 0 ); + QWidget* parent = 0, const char* name = 0, + WFlags fl = 0 ); public slots: @@ -55,3 +56,3 @@ signals: void addEvent(const QDateTime &start, const QDateTime &stop, - const QString &str, const QString &location); + const QString &str, const QString &location); private: @@ -65,4 +66,4 @@ public: DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, - QWidget* parent = 0, const char* name = 0, - WFlags fl = 0); + QWidget* parent = 0, const char* name = 0, + WFlags fl = 0); signals: @@ -90,18 +91,18 @@ public: DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, - QWidget* parent = 0, const char* name = 0, - WFlags fl = 0 ); + QWidget* parent = 0, const char* name = 0, + WFlags fl = 0 ); ~DateBookWeekLstView(); signals: - void editEvent(const Event &e); - void duplicateEvent(const Event &e); - void removeEvent(const Event &e); - void beamEvent(const Event &e); - void redraw(); - void showDate(int y, int m, int d); - void addEvent(const QDateTime &start, const QDateTime &stop, - const QString &str, const QString &location); + void editEvent(const Event &e); + void duplicateEvent(const Event &e); + void removeEvent(const Event &e); + void beamEvent(const Event &e); + void redraw(); + void showDate(int y, int m, int d); + void addEvent(const QDateTime &start, const QDateTime &stop, + const QString &str, const QString &location); private: - bool bStartOnMonday; + bool bStartOnMonday; protected slots: - void keyPressEvent(QKeyEvent *); + void keyPressEvent(QKeyEvent *); }; @@ -112,6 +113,6 @@ public: DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, - QValueList<EffectiveEvent> &ev2, - QDate &d, bool onM, - QWidget* parent = 0, const char* name = 0, - WFlags fl = 0 ); + QValueList<EffectiveEvent> &ev2, + QDate &d, bool onM, + QWidget* parent = 0, const char* name = 0, + WFlags fl = 0 ); signals: @@ -124,3 +125,3 @@ signals: void addEvent(const QDateTime &start, const QDateTime &stop, - const QString &str, const QString &location); + const QString &str, const QString &location); }; @@ -132,5 +133,5 @@ class DateBookWeekLst : public QWidget public: - DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, - QWidget *parent = 0, - const char *name = 0 ); + DateBookWeekLst( bool ampm, bool onM, DateBookDBHoliday *newDB, + QWidget *parent = 0, + const char *name = 0 ); ~DateBookWeekLst(); @@ -151,12 +152,12 @@ protected slots: signals: - void showDate(int y, int m, int d); - void addEvent(const QDateTime &start, const QDateTime &stop, - const QString &str, const QString &location); - void editEvent(const Event &e); - void duplicateEvent(const Event &e); - void removeEvent(const Event &e); - void beamEvent(const Event &e); + void showDate(int y, int m, int d); + void addEvent(const QDateTime &start, const QDateTime &stop, + const QString &str, const QString &location); + void editEvent(const Event &e); + void duplicateEvent(const Event &e); + void removeEvent(const Event &e); + void beamEvent(const Event &e); private: - DateBookDB *db; + DateBookDBHoliday *db; int startTime; @@ -165,3 +166,3 @@ private: bool dbl; - QDate bdate; + QDate bdate; int year, _week,dow; |