summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebook.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp78
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
@@ -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