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 @@ | |||
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 | ||
226 | DateBook::~DateBook() | 232 | DateBook::~DateBook() |
227 | { | 233 | { |
234 | delete db_holiday; | ||
228 | } | 235 | } |
229 | 236 | ||
230 | void DateBook::slotSettings() | 237 | void DateBook::slotSettings() |
@@ -512,7 +519,7 @@ void DateBook::showDay( int year, int month, int day ) | |||
512 | void DateBook::initDay() | 519 | void 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 | |||
1084 | DateBookHoliday::DateBookHoliday() | ||
1085 | { | ||
1086 | _pluginlist.clear(); | ||
1087 | init(); | ||
1088 | } | ||
1089 | |||
1090 | DateBookHoliday::~DateBookHoliday() | ||
1091 | { | ||
1092 | deinit(); | ||
1093 | } | ||
1094 | |||
1095 | void 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 | |||
1109 | void 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 | |||
1136 | QStringList 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 | |||
1147 | QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day) | ||
1148 | { | ||
1149 | return holidaylist(QDate(year,month,day)); | ||
1150 | } | ||
1151 | |||