summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-16 13:14:26 (UTC)
committer alwin <alwin>2005-03-16 13:14:26 (UTC)
commit3d43b9e40e562957e1a3fcbe9268634db45951ce (patch) (side-by-side diff)
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 @@
#include <opie2/odebug.h>
+#include <opie2/oholidaypluginif.h>
+#include <opie2/oholidayplugin.h>
@@ -51,2 +53,4 @@
#include <qwidgetstack.h>
+#include <qdir.h>
+#include <qtopia/qlibrary.h>
@@ -75,2 +79,4 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
odebug << "loading db t=" << t.elapsed() << oendl;
+ db_holiday = new DateBookHoliday();
+
loadSettings();
@@ -227,2 +233,3 @@ DateBook::~DateBook()
{
+ delete db_holiday;
}
@@ -514,3 +521,3 @@ void DateBook::initDay()
if ( !dayView ) {
- dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
+ dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" );
views->addWidget( dayView, DAY );
@@ -1075 +1082,70 @@ Event DateBookDBHack::eventByUID(int uid) {
}
+
+DateBookHoliday::DateBookHoliday()
+{
+ _pluginlist.clear();
+ init();
+}
+
+DateBookHoliday::~DateBookHoliday()
+{
+ deinit();
+}
+
+void DateBookHoliday::deinit()
+{
+ QValueList<HPlugin*>::Iterator it;
+ for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
+ HPlugin*_pl = *it;
+ // destructs itself?
+ _pl->_if->release();
+ _pl->_lib->unload();
+ delete _pl->_lib;
+ delete _pl;
+ }
+ _pluginlist.clear();
+}
+
+void DateBookHoliday::init()
+{
+ deinit();
+ QString path = QPEApplication::qpeDir() + "plugins/datebook/holiday";
+ QDir dir( path, "lib*.so" );
+ QStringList list = dir.entryList();
+ QStringList::Iterator it;
+ for (it=list.begin();it!=list.end();++it) {
+ Opie::Datebook::HolidayPluginIf*hif = 0;
+ QLibrary*lib=new QLibrary(path+"/"+*it);
+ if ((lib->queryInterface(IID_HOLIDAY_PLUGIN,(QUnknownInterface**)&hif) == QS_OK) && hif) {
+ Opie::Datebook::HolidayPlugin*pl = hif->plugin();
+ if (pl) {
+ HPlugin*_pl=new HPlugin;
+ _pl->_plugin = pl;
+ odebug << "Found holiday " << pl->description()<<oendl;
+ _pl->_lib = lib;
+ _pl->_if = hif;
+ _pluginlist.append(_pl);
+ } else {
+ }
+ } else {
+ delete lib;
+ }
+ }
+}
+
+QStringList DateBookHoliday::holidaylist(const QDate&aDate)
+{
+ QStringList ret;
+ QValueList<HPlugin*>::Iterator it;
+ for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
+ HPlugin*_pl = *it;
+ ret+=_pl->_plugin->entries(aDate);
+ }
+ return ret;
+}
+
+QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day)
+{
+ return holidaylist(QDate(year,month,day));
+}
+
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;
class Ir;
+class QLibrary;
+
+namespace Opie {
+namespace Datebook {
+ class HolidayPlugin;
+ class HolidayPluginIf;
+}
+}
@@ -44,2 +52,22 @@ class DateBookDBHack : public DateBookDB {
+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;
+};
+
class DateBook : public QMainWindow
@@ -112,2 +140,3 @@ private:
DateBookDBHack *db;
+ DateBookHoliday*db_holiday;
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 @@
+#include <opie2/oholidayplugin.h>
#include <qpe/resource.h>
@@ -228,3 +229,3 @@ void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */)
-DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name )
+DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name )
: QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 )
@@ -232,2 +233,3 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWid
widgetList.setAutoDelete( true );
+ _holiday_db = newHdb;
header = new DateBookDayHeader( startOnMonday, this, "day header" );
@@ -359,5 +361,13 @@ void DateBookDay::getEvents()
+ QStringList hdays = _holiday_db->holidaylist(currDate);
+ QStringList::Iterator sit;
+ QObject* object = 0;
+ for (sit=hdays.begin();sit!=hdays.end();++sit) {
+ object = m_allDays->addHoliday(*sit);
+ if (!object) continue;
+ /* not to do something with it */
+ }
QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate );
QValueListIterator<EffectiveEvent> it;
- QObject* object = 0;
+
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
public:
- DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,
+ DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,DateBookHoliday*newHdb,
QWidget *parent, const char *name );
void selectedDates( QDateTime &start, QDateTime &end );
+
QDate date() const;
@@ -233,2 +234,3 @@ private:
DateBookDayTimeMarker *timeMarker; //marker for current time
+ DateBookHoliday*_holiday_db;
};
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)
+DatebookAlldayDisp* DatebookdayAllday::addHoliday(const QString&e)
+{
+ DatebookAlldayDisp * lb;
+ lb = new DatebookAlldayDisp(e,m_MainFrame,NULL);
+ lb->show();
+ datebookdayalldayLayout->addWidget(lb);
+ subWidgets.append(lb);
+
+ connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&)));
+ ++item_count;
+
+ return lb;
+}
+
void DatebookdayAllday::removeAllEvents()
@@ -87,2 +101,22 @@ DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
setMinimumSize( QSize( 0, s ) );
+ m_holiday = false;
+}
+
+DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl)
+ : QLabel(parent,name,fl),m_Ev(),dateBook(0)
+{
+ QString strDesc = aholiday;
+ strDesc = strDesc.replace(QRegExp("<"),"&#60;");
+ Event ev;
+ ev.setDescription(strDesc);
+ ev.setAllDay(true);
+ m_Ev.setEvent(ev);
+ setBackgroundColor(yellow);
+ setText(strDesc);
+ setFrameStyle(QFrame::Raised|QFrame::Panel);
+
+ int s = QFontMetrics(font()).height()+4;
+ setMaximumHeight( s );
+ setMinimumSize( QSize( 0, s ) );
+ m_holiday = true;
}
@@ -95,2 +129,3 @@ void DatebookAlldayDisp::beam_single_event()
{
+ if (m_holiday) return;
// create an Event and beam it...
@@ -153,2 +188,3 @@ void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
QPopupMenu m;
+ if (!m_holiday) {
m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
@@ -158,2 +194,3 @@ void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 );
+ }
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:
DatebookAlldayDisp* addEvent(const EffectiveEvent&e);
+ DatebookAlldayDisp* addHoliday(const QString&e);
const unsigned int items()const{return item_count;}
@@ -47,2 +48,4 @@ public:
QWidget* parent=0,const char* name = 0, WFlags fl=0);
+ DatebookAlldayDisp(const QString&aholiday,
+ QWidget* parent=0,const char* name = 0, WFlags fl=0);
virtual ~DatebookAlldayDisp();
@@ -63,2 +66,3 @@ protected:
void beam_single_event();
+ bool m_holiday:1;
};
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 @@
+ config DATEBOOK_DUMMY_HOLIDAY
+ boolean "opie-datebook-dummyholidayplugin"
+ default "n"
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM
+
+ comment "opie-datebook-dummyholidayplugin requires libopie2core, libopie2ui, libopie2pim"
+ depends !( ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM )
+
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 @@
+TEMPLATE = lib
+CONFIG -= moc
+CONFIG += qt plugin
+
+# Input
+HEADERS = dummyholiday.h
+SOURCES = dummyholiday.cpp
+INTERFACES=
+
+INCLUDEPATH += $(OPIEDIR)/include \
+ ../ ../library
+DEPENDPATH += $(OPIEDIR)/include \
+ ../ ../library
+
+LIBS+= -lqpe -lopiecore2 -lopieui2
+
+DESTDIR = $(OPIEDIR)/plugins/datebook/holiday
+TARGET = dummyholidayplugin
+
+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 @@
+#include "dummyholiday.h"
+
+#include <qobject.h>
+
+QString DummyHoliday::description()
+{
+ return QObject::tr("Test holiday plugin","dummyholiday");
+}
+
+QStringList DummyHoliday::entries(const QDate&aDate)
+{
+ return entries(0,0,aDate.day());
+}
+
+QStringList DummyHoliday::entries(unsigned year, unsigned month, unsigned day)
+{
+ QStringList ret;
+ if (day%2==0) ret.append(QObject::tr("You have a holiday!","dummyholiday"));
+ return ret;
+}
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 @@
+#ifndef __DUMMY_HOLIDAY_H
+#define __DUMMY_HOLIDAY_H
+
+#include <opie2/oholidayplugin.h>
+#include <opie2/oholidaypluginif.h>
+
+class DummyHoliday:public Opie::Datebook::HolidayPlugin
+{
+public:
+ DummyHoliday():Opie::Datebook::HolidayPlugin(){}
+ virtual ~DummyHoliday(){}
+
+ virtual QString description();
+ virtual QStringList entries(const QDate&);
+ virtual QStringList entries(unsigned year, unsigned month, unsigned day);
+};
+
+EXPORT_HOLIDAY_PLUGIN(DummyHoliday);
+#endif