-rw-r--r-- | core/pim/datebook/datebook.cpp | 78 | ||||
-rw-r--r-- | core/pim/datebook/datebook.h | 29 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 14 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.h | 4 | ||||
-rw-r--r-- | core/pim/datebook/datebookdayallday.cpp | 37 | ||||
-rw-r--r-- | core/pim/datebook/datebookdayallday.h | 4 | ||||
-rw-r--r-- | core/pim/datebook/holiday/dummy/config.in | 8 | ||||
-rw-r--r-- | core/pim/datebook/holiday/dummy/dummy.pro | 20 | ||||
-rw-r--r-- | core/pim/datebook/holiday/dummy/dummyholiday.cpp | 20 | ||||
-rw-r--r-- | core/pim/datebook/holiday/dummy/dummyholiday.h | 19 |
10 files changed, 229 insertions, 4 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index a18a5b4..f6aab0c 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -31,4 +31,6 @@ | |||
31 | 31 | ||
32 | #include <opie2/odebug.h> | 32 | #include <opie2/odebug.h> |
33 | #include <opie2/oholidaypluginif.h> | ||
34 | #include <opie2/oholidayplugin.h> | ||
33 | 35 | ||
34 | #include <qpe/datebookmonth.h> | 36 | #include <qpe/datebookmonth.h> |
@@ -50,4 +52,6 @@ | |||
50 | #include <qtoolbar.h> | 52 | #include <qtoolbar.h> |
51 | #include <qwidgetstack.h> | 53 | #include <qwidgetstack.h> |
54 | #include <qdir.h> | ||
55 | #include <qtopia/qlibrary.h> | ||
52 | 56 | ||
53 | #include <sys/stat.h> | 57 | #include <sys/stat.h> |
@@ -74,4 +78,6 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
74 | db = new DateBookDBHack; | 78 | db = new DateBookDBHack; |
75 | odebug << "loading db t=" << t.elapsed() << oendl; | 79 | odebug << "loading db t=" << t.elapsed() << oendl; |
80 | db_holiday = new DateBookHoliday(); | ||
81 | |||
76 | loadSettings(); | 82 | loadSettings(); |
77 | setCaption( tr("Calendar") ); | 83 | setCaption( tr("Calendar") ); |
@@ -226,4 +232,5 @@ void DateBook::receive( const QCString &msg, const QByteArray &data ) | |||
226 | DateBook::~DateBook() | 232 | DateBook::~DateBook() |
227 | { | 233 | { |
234 | delete db_holiday; | ||
228 | } | 235 | } |
229 | 236 | ||
@@ -513,5 +520,5 @@ void DateBook::initDay() | |||
513 | { | 520 | { |
514 | if ( !dayView ) { | 521 | if ( !dayView ) { |
515 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); | 522 | dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" ); |
516 | views->addWidget( dayView, DAY ); | 523 | views->addWidget( dayView, DAY ); |
517 | dayView->setJumpToCurTime( bJumpToCurTime ); | 524 | dayView->setJumpToCurTime( bJumpToCurTime ); |
@@ -1074,2 +1081,71 @@ Event DateBookDBHack::eventByUID(int uid) { | |||
1074 | return ev; // return at least | 1081 | return ev; // return at least |
1075 | } | 1082 | } |
1083 | |||
1084 | DateBookHoliday::DateBookHoliday() | ||
1085 | { | ||
1086 | _pluginlist.clear(); | ||
1087 | init(); | ||
1088 | } | ||
1089 | |||
1090 | DateBookHoliday::~DateBookHoliday() | ||
1091 | { | ||
1092 | deinit(); | ||
1093 | } | ||
1094 | |||
1095 | void DateBookHoliday::deinit() | ||
1096 | { | ||
1097 | QValueList<HPlugin*>::Iterator it; | ||
1098 | for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { | ||
1099 | HPlugin*_pl = *it; | ||
1100 | // destructs itself? | ||
1101 | _pl->_if->release(); | ||
1102 | _pl->_lib->unload(); | ||
1103 | delete _pl->_lib; | ||
1104 | delete _pl; | ||
1105 | } | ||
1106 | _pluginlist.clear(); | ||
1107 | } | ||
1108 | |||
1109 | void DateBookHoliday::init() | ||
1110 | { | ||
1111 | deinit(); | ||
1112 | QString path = QPEApplication::qpeDir() + "plugins/datebook/holiday"; | ||
1113 | QDir dir( path, "lib*.so" ); | ||
1114 | QStringList list = dir.entryList(); | ||
1115 | QStringList::Iterator it; | ||
1116 | for (it=list.begin();it!=list.end();++it) { | ||
1117 | Opie::Datebook::HolidayPluginIf*hif = 0; | ||
1118 | QLibrary*lib=new QLibrary(path+"/"+*it); | ||
1119 | if ((lib->queryInterface(IID_HOLIDAY_PLUGIN,(QUnknownInterface**)&hif) == QS_OK) && hif) { | ||
1120 | Opie::Datebook::HolidayPlugin*pl = hif->plugin(); | ||
1121 | if (pl) { | ||
1122 | HPlugin*_pl=new HPlugin; | ||
1123 | _pl->_plugin = pl; | ||
1124 | odebug << "Found holiday " << pl->description()<<oendl; | ||
1125 | _pl->_lib = lib; | ||
1126 | _pl->_if = hif; | ||
1127 | _pluginlist.append(_pl); | ||
1128 | } else { | ||
1129 | } | ||
1130 | } else { | ||
1131 | delete lib; | ||
1132 | } | ||
1133 | } | ||
1134 | } | ||
1135 | |||
1136 | QStringList DateBookHoliday::holidaylist(const QDate&aDate) | ||
1137 | { | ||
1138 | QStringList ret; | ||
1139 | QValueList<HPlugin*>::Iterator it; | ||
1140 | for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { | ||
1141 | HPlugin*_pl = *it; | ||
1142 | ret+=_pl->_plugin->entries(aDate); | ||
1143 | } | ||
1144 | return ret; | ||
1145 | } | ||
1146 | |||
1147 | QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day) | ||
1148 | { | ||
1149 | return holidaylist(QDate(year,month,day)); | ||
1150 | } | ||
1151 | |||
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index d7cfb33..54ffcfb 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h | |||
@@ -37,4 +37,12 @@ class Event; | |||
37 | class QDate; | 37 | class QDate; |
38 | class Ir; | 38 | class Ir; |
39 | class QLibrary; | ||
40 | |||
41 | namespace Opie { | ||
42 | namespace Datebook { | ||
43 | class HolidayPlugin; | ||
44 | class HolidayPluginIf; | ||
45 | } | ||
46 | } | ||
39 | 47 | ||
40 | class DateBookDBHack : public DateBookDB { | 48 | class DateBookDBHack : public DateBookDB { |
@@ -43,4 +51,24 @@ class DateBookDBHack : public DateBookDB { | |||
43 | }; | 51 | }; |
44 | 52 | ||
53 | class DateBookHoliday | ||
54 | { | ||
55 | public: | ||
56 | DateBookHoliday(); | ||
57 | virtual ~DateBookHoliday(); | ||
58 | |||
59 | QStringList holidaylist(const QDate&); | ||
60 | QStringList holidaylist(unsigned year, unsigned month, unsigned day); | ||
61 | protected: | ||
62 | void init(); | ||
63 | void deinit(); | ||
64 | |||
65 | struct HPlugin { | ||
66 | Opie::Datebook::HolidayPlugin*_plugin; | ||
67 | QLibrary*_lib; | ||
68 | Opie::Datebook::HolidayPluginIf*_if; | ||
69 | }; | ||
70 | QValueList<HPlugin*>_pluginlist; | ||
71 | }; | ||
72 | |||
45 | class DateBook : public QMainWindow | 73 | class DateBook : public QMainWindow |
46 | { | 74 | { |
@@ -111,4 +139,5 @@ private: | |||
111 | private: | 139 | private: |
112 | DateBookDBHack *db; | 140 | DateBookDBHack *db; |
141 | DateBookHoliday*db_holiday; | ||
113 | QWidgetStack *views; | 142 | QWidgetStack *views; |
114 | DateBookDay *dayView; | 143 | DateBookDay *dayView; |
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index ca63dc5..dfe39e5 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -23,4 +23,5 @@ | |||
23 | #include "datebookdayallday.h" | 23 | #include "datebookdayallday.h" |
24 | 24 | ||
25 | #include <opie2/oholidayplugin.h> | ||
25 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
26 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
@@ -227,8 +228,9 @@ void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */) | |||
227 | //=========================================================================== | 228 | //=========================================================================== |
228 | 229 | ||
229 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) | 230 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name ) |
230 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) | 231 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) |
231 | { | 232 | { |
232 | widgetList.setAutoDelete( true ); | 233 | widgetList.setAutoDelete( true ); |
234 | _holiday_db = newHdb; | ||
233 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); | 235 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); |
234 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | 236 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); |
@@ -358,7 +360,15 @@ void DateBookDay::getEvents() | |||
358 | m_allDays->removeAllEvents(); | 360 | m_allDays->removeAllEvents(); |
359 | 361 | ||
362 | QStringList hdays = _holiday_db->holidaylist(currDate); | ||
363 | QStringList::Iterator sit; | ||
364 | QObject* object = 0; | ||
365 | for (sit=hdays.begin();sit!=hdays.end();++sit) { | ||
366 | object = m_allDays->addHoliday(*sit); | ||
367 | if (!object) continue; | ||
368 | /* not to do something with it */ | ||
369 | } | ||
360 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); | 370 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); |
361 | QValueListIterator<EffectiveEvent> it; | 371 | QValueListIterator<EffectiveEvent> it; |
362 | QObject* object = 0; | 372 | |
363 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { | 373 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { |
364 | EffectiveEvent ev=*it; | 374 | EffectiveEvent ev=*it; |
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h index c8cb26b..3e44364 100644 --- a/core/pim/datebook/datebookday.h +++ b/core/pim/datebook/datebookday.h | |||
@@ -181,7 +181,8 @@ class DateBookDay : public QVBox | |||
181 | friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB | 181 | friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB |
182 | public: | 182 | public: |
183 | DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, | 183 | DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,DateBookHoliday*newHdb, |
184 | QWidget *parent, const char *name ); | 184 | QWidget *parent, const char *name ); |
185 | void selectedDates( QDateTime &start, QDateTime &end ); | 185 | void selectedDates( QDateTime &start, QDateTime &end ); |
186 | |||
186 | QDate date() const; | 187 | QDate date() const; |
187 | DateBookDayView *dayView() const { return view; } | 188 | DateBookDayView *dayView() const { return view; } |
@@ -232,4 +233,5 @@ private: | |||
232 | DateBookDayWidget *selectedWidget; //actual selected widget (obviously) | 233 | DateBookDayWidget *selectedWidget; //actual selected widget (obviously) |
233 | DateBookDayTimeMarker *timeMarker;//marker for current time | 234 | DateBookDayTimeMarker *timeMarker;//marker for current time |
235 | DateBookHoliday*_holiday_db; | ||
234 | }; | 236 | }; |
235 | 237 | ||
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp index a0aefd3..3c3f482 100644 --- a/core/pim/datebook/datebookdayallday.cpp +++ b/core/pim/datebook/datebookdayallday.cpp | |||
@@ -67,4 +67,18 @@ DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) | |||
67 | } | 67 | } |
68 | 68 | ||
69 | DatebookAlldayDisp* DatebookdayAllday::addHoliday(const QString&e) | ||
70 | { | ||
71 | DatebookAlldayDisp * lb; | ||
72 | lb = new DatebookAlldayDisp(e,m_MainFrame,NULL); | ||
73 | lb->show(); | ||
74 | datebookdayalldayLayout->addWidget(lb); | ||
75 | subWidgets.append(lb); | ||
76 | |||
77 | connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); | ||
78 | ++item_count; | ||
79 | |||
80 | return lb; | ||
81 | } | ||
82 | |||
69 | void DatebookdayAllday::removeAllEvents() | 83 | void DatebookdayAllday::removeAllEvents() |
70 | { | 84 | { |
@@ -86,4 +100,24 @@ DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, | |||
86 | setMaximumHeight( s ); | 100 | setMaximumHeight( s ); |
87 | setMinimumSize( QSize( 0, s ) ); | 101 | setMinimumSize( QSize( 0, s ) ); |
102 | m_holiday = false; | ||
103 | } | ||
104 | |||
105 | DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl) | ||
106 | : QLabel(parent,name,fl),m_Ev(),dateBook(0) | ||
107 | { | ||
108 | QString strDesc = aholiday; | ||
109 | strDesc = strDesc.replace(QRegExp("<"),"<"); | ||
110 | Event ev; | ||
111 | ev.setDescription(strDesc); | ||
112 | ev.setAllDay(true); | ||
113 | m_Ev.setEvent(ev); | ||
114 | setBackgroundColor(yellow); | ||
115 | setText(strDesc); | ||
116 | setFrameStyle(QFrame::Raised|QFrame::Panel); | ||
117 | |||
118 | int s = QFontMetrics(font()).height()+4; | ||
119 | setMaximumHeight( s ); | ||
120 | setMinimumSize( QSize( 0, s ) ); | ||
121 | m_holiday = true; | ||
88 | } | 122 | } |
89 | 123 | ||
@@ -94,4 +128,5 @@ DatebookAlldayDisp::~DatebookAlldayDisp() | |||
94 | void DatebookAlldayDisp::beam_single_event() | 128 | void DatebookAlldayDisp::beam_single_event() |
95 | { | 129 | { |
130 | if (m_holiday) return; | ||
96 | // create an Event and beam it... | 131 | // create an Event and beam it... |
97 | /* | 132 | /* |
@@ -152,4 +187,5 @@ void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) | |||
152 | update(); | 187 | update(); |
153 | QPopupMenu m; | 188 | QPopupMenu m; |
189 | if (!m_holiday) { | ||
154 | m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); | 190 | m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); |
155 | m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); | 191 | m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); |
@@ -157,4 +193,5 @@ void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) | |||
157 | if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); | 193 | if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); |
158 | if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); | 194 | if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); |
195 | } | ||
159 | m.insertItem( tr( "Info"),6); | 196 | m.insertItem( tr( "Info"),6); |
160 | int r = m.exec( e->globalPos() ); | 197 | int r = m.exec( e->globalPos() ); |
diff --git a/core/pim/datebook/datebookdayallday.h b/core/pim/datebook/datebookdayallday.h index f5867e5..4f5cffa 100644 --- a/core/pim/datebook/datebookdayallday.h +++ b/core/pim/datebook/datebookdayallday.h | |||
@@ -25,4 +25,5 @@ public: | |||
25 | ~DatebookdayAllday(); | 25 | ~DatebookdayAllday(); |
26 | DatebookAlldayDisp* addEvent(const EffectiveEvent&e); | 26 | DatebookAlldayDisp* addEvent(const EffectiveEvent&e); |
27 | DatebookAlldayDisp* addHoliday(const QString&e); | ||
27 | const unsigned int items()const{return item_count;} | 28 | const unsigned int items()const{return item_count;} |
28 | 29 | ||
@@ -46,4 +47,6 @@ public: | |||
46 | DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e, | 47 | DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e, |
47 | QWidget* parent=0,const char* name = 0, WFlags fl=0); | 48 | QWidget* parent=0,const char* name = 0, WFlags fl=0); |
49 | DatebookAlldayDisp(const QString&aholiday, | ||
50 | QWidget* parent=0,const char* name = 0, WFlags fl=0); | ||
48 | virtual ~DatebookAlldayDisp(); | 51 | virtual ~DatebookAlldayDisp(); |
49 | 52 | ||
@@ -62,4 +65,5 @@ protected: | |||
62 | void mousePressEvent( QMouseEvent *e ); | 65 | void mousePressEvent( QMouseEvent *e ); |
63 | void beam_single_event(); | 66 | void beam_single_event(); |
67 | bool m_holiday:1; | ||
64 | }; | 68 | }; |
65 | 69 | ||
diff --git a/core/pim/datebook/holiday/dummy/config.in b/core/pim/datebook/holiday/dummy/config.in new file mode 100644 index 0000000..caa90bc --- a/dev/null +++ b/core/pim/datebook/holiday/dummy/config.in | |||
@@ -0,0 +1,8 @@ | |||
1 | config DATEBOOK_DUMMY_HOLIDAY | ||
2 | boolean "opie-datebook-dummyholidayplugin" | ||
3 | default "n" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM | ||
5 | |||
6 | comment "opie-datebook-dummyholidayplugin requires libopie2core, libopie2ui, libopie2pim" | ||
7 | depends !( ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM ) | ||
8 | |||
diff --git a/core/pim/datebook/holiday/dummy/dummy.pro b/core/pim/datebook/holiday/dummy/dummy.pro new file mode 100644 index 0000000..768bb77 --- a/dev/null +++ b/core/pim/datebook/holiday/dummy/dummy.pro | |||
@@ -0,0 +1,20 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG -= moc | ||
3 | CONFIG += qt plugin | ||
4 | |||
5 | # Input | ||
6 | HEADERS = dummyholiday.h | ||
7 | SOURCES = dummyholiday.cpp | ||
8 | INTERFACES= | ||
9 | |||
10 | INCLUDEPATH += $(OPIEDIR)/include \ | ||
11 | ../ ../library | ||
12 | DEPENDPATH += $(OPIEDIR)/include \ | ||
13 | ../ ../library | ||
14 | |||
15 | LIBS+= -lqpe -lopiecore2 -lopieui2 | ||
16 | |||
17 | DESTDIR = $(OPIEDIR)/plugins/datebook/holiday | ||
18 | TARGET = dummyholidayplugin | ||
19 | |||
20 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/core/pim/datebook/holiday/dummy/dummyholiday.cpp b/core/pim/datebook/holiday/dummy/dummyholiday.cpp new file mode 100644 index 0000000..dd00b9b --- a/dev/null +++ b/core/pim/datebook/holiday/dummy/dummyholiday.cpp | |||
@@ -0,0 +1,20 @@ | |||
1 | #include "dummyholiday.h" | ||
2 | |||
3 | #include <qobject.h> | ||
4 | |||
5 | QString DummyHoliday::description() | ||
6 | { | ||
7 | return QObject::tr("Test holiday plugin","dummyholiday"); | ||
8 | } | ||
9 | |||
10 | QStringList DummyHoliday::entries(const QDate&aDate) | ||
11 | { | ||
12 | return entries(0,0,aDate.day()); | ||
13 | } | ||
14 | |||
15 | QStringList DummyHoliday::entries(unsigned year, unsigned month, unsigned day) | ||
16 | { | ||
17 | QStringList ret; | ||
18 | if (day%2==0) ret.append(QObject::tr("You have a holiday!","dummyholiday")); | ||
19 | return ret; | ||
20 | } | ||
diff --git a/core/pim/datebook/holiday/dummy/dummyholiday.h b/core/pim/datebook/holiday/dummy/dummyholiday.h new file mode 100644 index 0000000..9b28f24 --- a/dev/null +++ b/core/pim/datebook/holiday/dummy/dummyholiday.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef __DUMMY_HOLIDAY_H | ||
2 | #define __DUMMY_HOLIDAY_H | ||
3 | |||
4 | #include <opie2/oholidayplugin.h> | ||
5 | #include <opie2/oholidaypluginif.h> | ||
6 | |||
7 | class DummyHoliday:public Opie::Datebook::HolidayPlugin | ||
8 | { | ||
9 | public: | ||
10 | DummyHoliday():Opie::Datebook::HolidayPlugin(){} | ||
11 | virtual ~DummyHoliday(){} | ||
12 | |||
13 | virtual QString description(); | ||
14 | virtual QStringList entries(const QDate&); | ||
15 | virtual QStringList entries(unsigned year, unsigned month, unsigned day); | ||
16 | }; | ||
17 | |||
18 | EXPORT_HOLIDAY_PLUGIN(DummyHoliday); | ||
19 | #endif | ||