summaryrefslogtreecommitdiff
Unidiff
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
@@ -30,6 +30,8 @@
30#include "dateentryimpl.h" 30#include "dateentryimpl.h"
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>
35#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
@@ -49,6 +51,8 @@
49#include <qtl.h> 51#include <qtl.h>
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>
54#include <sys/types.h> 58#include <sys/types.h>
@@ -73,6 +77,8 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
73 t.start(); 77 t.start();
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") );
78 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 84 setIcon( Resource::loadPixmap( "datebook_icon" ) );
@@ -225,6 +231,7 @@ void DateBook::receive( const QCString &msg, const QByteArray &data )
225 231
226DateBook::~DateBook() 232DateBook::~DateBook()
227{ 233{
234 delete db_holiday;
228} 235}
229 236
230void DateBook::slotSettings() 237void DateBook::slotSettings()
@@ -512,7 +519,7 @@ void DateBook::showDay( int year, int month, int day )
512void DateBook::initDay() 519void 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 );
518 dayView->setStartViewTime( startTime ); 525 dayView->setStartViewTime( startTime );
@@ -1073,3 +1080,72 @@ Event DateBookDBHack::eventByUID(int uid) {
1073 Event ev; 1080 Event ev;
1074 return ev; // return at least 1081 return ev; // return at least
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
@@ -36,12 +36,40 @@ class DateBookMonth;
36class Event; 36class Event;
37class QDate; 37class QDate;
38class Ir; 38class Ir;
39class QLibrary;
40
41namespace Opie {
42namespace Datebook {
43 class HolidayPlugin;
44 class HolidayPluginIf;
45}
46}
39 47
40class DateBookDBHack : public DateBookDB { 48class DateBookDBHack : public DateBookDB {
41 public: 49 public:
42 Event eventByUID(int id); 50 Event eventByUID(int id);
43}; 51};
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
46{ 74{
47 Q_OBJECT 75 Q_OBJECT
@@ -110,6 +138,7 @@ private:
110 138
111private: 139private:
112 DateBookDBHack *db; 140 DateBookDBHack *db;
141 DateBookHoliday*db_holiday;
113 QWidgetStack *views; 142 QWidgetStack *views;
114 DateBookDay *dayView; 143 DateBookDay *dayView;
115 DateBookWeek *weekView; 144 DateBookWeek *weekView;
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
@@ -22,6 +22,7 @@
22#include "datebookdayheaderimpl.h" 22#include "datebookdayheaderimpl.h"
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>
27#include <qpe/ir.h> 28#include <qpe/ir.h>
@@ -226,10 +227,11 @@ void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */)
226 227
227//=========================================================================== 228//===========================================================================
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 )
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() );
235 237
@@ -357,9 +359,17 @@ void DateBookDay::getEvents()
357 m_allDays->hide(); // just in case 359 m_allDays->hide(); // just in case
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;
365 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. 375 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day.
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
@@ -180,9 +180,10 @@ class DateBookDay : public QVBox
180 180
181 friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB 181 friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB
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;
187 DateBookDayView *dayView() const { return view; } 188 DateBookDayView *dayView() const { return view; }
188 void setStartViewTime( int startHere ); 189 void setStartViewTime( int startHere );
@@ -231,6 +232,7 @@ private:
231 int rowStyle; 232 int rowStyle;
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
236#endif 238#endif
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
@@ -66,6 +66,20 @@ DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev)
66 return lb; 66 return lb;
67} 67}
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()
70{ 84{
71 subWidgets.clear(); 85 subWidgets.clear();
@@ -85,6 +99,26 @@ DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
85 int s = QFontMetrics(font()).height()+4; 99 int s = QFontMetrics(font()).height()+4;
86 setMaximumHeight( s ); 100 setMaximumHeight( s );
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}
89 123
90DatebookAlldayDisp::~DatebookAlldayDisp() 124DatebookAlldayDisp::~DatebookAlldayDisp()
@@ -93,6 +127,7 @@ DatebookAlldayDisp::~DatebookAlldayDisp()
93 127
94void DatebookAlldayDisp::beam_single_event() 128void 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 /*
98 * Start with the easy stuff. If start and end date is the same we can just use 133 * Start with the easy stuff. If start and end date is the same we can just use
@@ -151,11 +186,13 @@ void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
151 setBackgroundColor(green); 186 setBackgroundColor(green);
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 );
156 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); 192 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 );
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() );
161 setBackgroundColor(b); 198 setBackgroundColor(b);
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
@@ -24,6 +24,7 @@ public:
24 QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 24 QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
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
29public slots: 30public slots:
@@ -45,6 +46,8 @@ class DatebookAlldayDisp : public QLabel
45public: 46public:
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
50signals: 53signals:
@@ -61,6 +64,7 @@ protected:
61 DateBookDB* dateBook; 64 DateBookDB* dateBook;
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
66class DatebookEventDesc: public QLabel 70class DatebookEventDesc: public QLabel
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