summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-16 13:14:26 (UTC)
committer alwin <alwin>2005-03-16 13:14:26 (UTC)
commit3d43b9e40e562957e1a3fcbe9268634db45951ce (patch) (unidiff)
tree637f67a6768f6a90e7834b96100f6c70bb66950b
parent4fef85eb55dbef5f8546caee084e4f0ce51081d3 (diff)
downloadopie-3d43b9e40e562957e1a3fcbe9268634db45951ce.zip
opie-3d43b9e40e562957e1a3fcbe9268634db45951ce.tar.gz
opie-3d43b9e40e562957e1a3fcbe9268634db45951ce.tar.bz2
ho.
in dayview a holiday will displayed (if plugin found) generated a straight forward dummy-holiday-plugin for testing the stuff.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp78
-rw-r--r--core/pim/datebook/datebook.h29
-rw-r--r--core/pim/datebook/datebookday.cpp14
-rw-r--r--core/pim/datebook/datebookday.h4
-rw-r--r--core/pim/datebook/datebookdayallday.cpp37
-rw-r--r--core/pim/datebook/datebookdayallday.h4
-rw-r--r--core/pim/datebook/holiday/dummy/config.in8
-rw-r--r--core/pim/datebook/holiday/dummy/dummy.pro20
-rw-r--r--core/pim/datebook/holiday/dummy/dummyholiday.cpp20
-rw-r--r--core/pim/datebook/holiday/dummy/dummyholiday.h19
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
@@ -32,2 +32,4 @@
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33#include <opie2/oholidaypluginif.h>
34#include <opie2/oholidayplugin.h>
33 35
@@ -51,2 +53,4 @@
51#include <qwidgetstack.h> 53#include <qwidgetstack.h>
54#include <qdir.h>
55#include <qtopia/qlibrary.h>
52 56
@@ -75,2 +79,4 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
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();
@@ -227,2 +233,3 @@ DateBook::~DateBook()
227{ 233{
234 delete db_holiday;
228} 235}
@@ -514,3 +521,3 @@ void DateBook::initDay()
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 );
@@ -1075 +1082,70 @@ Event DateBookDBHack::eventByUID(int uid) {
1075} 1082}
1083
1084DateBookHoliday::DateBookHoliday()
1085{
1086 _pluginlist.clear();
1087 init();
1088}
1089
1090DateBookHoliday::~DateBookHoliday()
1091{
1092 deinit();
1093}
1094
1095void 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
1109void 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
1136QStringList 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
1147QStringList 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
@@ -38,2 +38,10 @@ class QDate;
38class Ir; 38class Ir;
39class QLibrary;
40
41namespace Opie {
42namespace Datebook {
43 class HolidayPlugin;
44 class HolidayPluginIf;
45}
46}
39 47
@@ -44,2 +52,22 @@ class DateBookDBHack : public DateBookDB {
44 52
53class DateBookHoliday
54{
55public:
56 DateBookHoliday();
57 virtual ~DateBookHoliday();
58
59 QStringList holidaylist(const QDate&);
60 QStringList holidaylist(unsigned year, unsigned month, unsigned day);
61protected:
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
45class DateBook : public QMainWindow 73class DateBook : public QMainWindow
@@ -112,2 +140,3 @@ private:
112 DateBookDBHack *db; 140 DateBookDBHack *db;
141 DateBookHoliday*db_holiday;
113 QWidgetStack *views; 142 QWidgetStack *views;
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
@@ -24,2 +24,3 @@
24 24
25#include <opie2/oholidayplugin.h>
25#include <qpe/resource.h> 26#include <qpe/resource.h>
@@ -228,3 +229,3 @@ void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */)
228 229
229DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) 230DateBookDay::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 )
@@ -232,2 +233,3 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWid
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" );
@@ -359,5 +361,13 @@ void DateBookDay::getEvents()
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 ) {
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
@@ -182,5 +182,6 @@ class DateBookDay : public QVBox
182public: 182public:
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;
@@ -233,2 +234,3 @@ private:
233 DateBookDayTimeMarker *timeMarker;//marker for current time 234 DateBookDayTimeMarker *timeMarker;//marker for current time
235 DateBookHoliday*_holiday_db;
234}; 236};
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
@@ -68,2 +68,16 @@ DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev)
68 68
69DatebookAlldayDisp* 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
69void DatebookdayAllday::removeAllEvents() 83void DatebookdayAllday::removeAllEvents()
@@ -87,2 +101,22 @@ DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
87 setMinimumSize( QSize( 0, s ) ); 101 setMinimumSize( QSize( 0, s ) );
102 m_holiday = false;
103}
104
105DatebookAlldayDisp::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("<"),"&#60;");
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}
@@ -95,2 +129,3 @@ 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...
@@ -153,2 +188,3 @@ void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
153 QPopupMenu m; 188 QPopupMenu m;
189 if (!m_holiday) {
154 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); 190 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
@@ -158,2 +194,3 @@ void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
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);
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
@@ -26,2 +26,3 @@ public:
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;}
@@ -47,2 +48,4 @@ public:
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();
@@ -63,2 +66,3 @@ protected:
63 void beam_single_event(); 66 void beam_single_event();
67 bool m_holiday:1;
64}; 68};
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 @@
1TEMPLATE = lib
2CONFIG -= moc
3CONFIG += qt plugin
4
5# Input
6HEADERS = dummyholiday.h
7SOURCES = dummyholiday.cpp
8INTERFACES=
9
10INCLUDEPATH += $(OPIEDIR)/include \
11 ../ ../library
12DEPENDPATH += $(OPIEDIR)/include \
13 ../ ../library
14
15LIBS+= -lqpe -lopiecore2 -lopieui2
16
17DESTDIR = $(OPIEDIR)/plugins/datebook/holiday
18TARGET = dummyholidayplugin
19
20include( $(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
5QString DummyHoliday::description()
6{
7 return QObject::tr("Test holiday plugin","dummyholiday");
8}
9
10QStringList DummyHoliday::entries(const QDate&aDate)
11{
12 return entries(0,0,aDate.day());
13}
14
15QStringList 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
7class DummyHoliday:public Opie::Datebook::HolidayPlugin
8{
9public:
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
18EXPORT_HOLIDAY_PLUGIN(DummyHoliday);
19#endif