author | alwin <alwin> | 2005-03-16 13:14:26 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-16 13:14:26 (UTC) |
commit | 3d43b9e40e562957e1a3fcbe9268634db45951ce (patch) (side-by-side diff) | |
tree | 637f67a6768f6a90e7834b96100f6c70bb66950b /core/pim/datebook/datebook.cpp | |
parent | 4fef85eb55dbef5f8546caee084e4f0ce51081d3 (diff) | |
download | opie-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 (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 78 |
1 files changed, 77 insertions, 1 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 @@ #include "dateentryimpl.h" #include <opie2/odebug.h> +#include <opie2/oholidaypluginif.h> +#include <opie2/oholidayplugin.h> #include <qpe/datebookmonth.h> #include <qpe/qpeapplication.h> @@ -49,6 +51,8 @@ #include <qtl.h> #include <qtoolbar.h> #include <qwidgetstack.h> +#include <qdir.h> +#include <qtopia/qlibrary.h> #include <sys/stat.h> #include <sys/types.h> @@ -73,6 +77,8 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) t.start(); db = new DateBookDBHack; odebug << "loading db t=" << t.elapsed() << oendl; + db_holiday = new DateBookHoliday(); + loadSettings(); setCaption( tr("Calendar") ); setIcon( Resource::loadPixmap( "datebook_icon" ) ); @@ -225,6 +231,7 @@ void DateBook::receive( const QCString &msg, const QByteArray &data ) DateBook::~DateBook() { + delete db_holiday; } void DateBook::slotSettings() @@ -512,7 +519,7 @@ void DateBook::showDay( int year, int month, int day ) 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 ); dayView->setJumpToCurTime( bJumpToCurTime ); dayView->setStartViewTime( startTime ); @@ -1073,3 +1080,72 @@ Event DateBookDBHack::eventByUID(int uid) { Event ev; return ev; // return at least } + +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)); +} + |