author | alwin <alwin> | 2005-03-16 15:04:15 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-16 15:04:15 (UTC) |
commit | d119025a69177c373d75d3fe5936e2319bb4455b (patch) (unidiff) | |
tree | 7315a34f0837fdc4b887482ed3a25c77804ee62e | |
parent | fcffc58d8058912d67cf223d3057cf4032f821cd (diff) | |
download | opie-d119025a69177c373d75d3fe5936e2319bb4455b.zip opie-d119025a69177c373d75d3fe5936e2319bb4455b.tar.gz opie-d119025a69177c373d75d3fe5936e2319bb4455b.tar.bz2 |
added (base) christian holidays
-rw-r--r-- | core/pim/datebook/holiday/christian/chrisholiday.cpp | 87 | ||||
-rw-r--r-- | core/pim/datebook/holiday/christian/chrisholiday.h | 33 | ||||
-rw-r--r-- | core/pim/datebook/holiday/christian/christian-holidays.pro | 20 | ||||
-rw-r--r-- | core/pim/datebook/holiday/christian/config.in | 4 | ||||
-rw-r--r-- | core/pim/datebook/holiday/christian/hlist.cpp | 18 | ||||
-rw-r--r-- | core/pim/datebook/holiday/christian/hlist.h | 16 | ||||
-rw-r--r-- | core/pim/datebook/holiday/dummy/config.in | 6 | ||||
-rw-r--r-- | packages | 1 |
8 files changed, 181 insertions, 4 deletions
diff --git a/core/pim/datebook/holiday/christian/chrisholiday.cpp b/core/pim/datebook/holiday/christian/chrisholiday.cpp new file mode 100644 index 0000000..6ef102a --- a/dev/null +++ b/core/pim/datebook/holiday/christian/chrisholiday.cpp | |||
@@ -0,0 +1,87 @@ | |||
1 | #include "chrisholiday.h" | ||
2 | |||
3 | #include <qobject.h> | ||
4 | |||
5 | QString ChrisHoliday::description() | ||
6 | { | ||
7 | return QObject::tr("Christian holidays","holidays"); | ||
8 | } | ||
9 | |||
10 | QStringList ChrisHoliday::entries(const QDate&aDate) | ||
11 | { | ||
12 | QStringList ret; | ||
13 | ret+=_internallist.entries(aDate); | ||
14 | calcit(aDate.year()); | ||
15 | tDayMap::Iterator it = _days.find(aDate); | ||
16 | if (it!=_days.end()) { | ||
17 | ret+=*it; | ||
18 | } | ||
19 | |||
20 | return ret; | ||
21 | } | ||
22 | |||
23 | QStringList ChrisHoliday::entries(unsigned year, unsigned month, unsigned day) | ||
24 | { | ||
25 | return entries(QDate(year,month,day)); | ||
26 | } | ||
27 | |||
28 | void ChrisHoliday::calcit(int year) | ||
29 | { | ||
30 | if (year==_lastyear) return; | ||
31 | _lastyear = year; | ||
32 | _days.clear(); | ||
33 | calc_easter(); | ||
34 | calc_christmas(); | ||
35 | } | ||
36 | |||
37 | void ChrisHoliday::calc_christmas() | ||
38 | { | ||
39 | QDate cday(_lastyear,12,24); | ||
40 | int diff; | ||
41 | if ( (diff=cday.dayOfWeek())!=7) { | ||
42 | cday=cday.addDays(-diff); | ||
43 | _days[cday].append(QObject::tr("4. Advent","holidays")); | ||
44 | } | ||
45 | _days[cday.addDays(-7)].append(QObject::tr("3. Advent","holidays")); | ||
46 | _days[cday.addDays(-14)].append(QObject::tr("2. Advent","holidays")); | ||
47 | _days[cday.addDays(-21)].append(QObject::tr("1. Advent","holidays")); | ||
48 | } | ||
49 | |||
50 | void ChrisHoliday::calc_easter() | ||
51 | { | ||
52 | unsigned long n = 0; | ||
53 | unsigned long p = 0; | ||
54 | |||
55 | if ( _lastyear > 1582 ) { | ||
56 | unsigned long a = _lastyear%19; | ||
57 | unsigned long b = _lastyear/100; | ||
58 | unsigned long c = _lastyear%100; | ||
59 | unsigned long d = b/4; | ||
60 | unsigned long e = b%4; | ||
61 | unsigned long f = (b+8)/25; | ||
62 | unsigned long g = (b+f+1)/3; | ||
63 | unsigned long h = (19*a+b-d-g+15)%30; | ||
64 | unsigned long i = c/4; | ||
65 | unsigned long j = c%4; | ||
66 | unsigned long k = j%100; | ||
67 | unsigned long l = (32+2*e+2*i-h-k)%7; | ||
68 | unsigned long m = (a+11*h+22*l)/451; | ||
69 | n = (h+l-7*m+114)/31; | ||
70 | p = (h+l-7*m+114)%31; | ||
71 | } else { | ||
72 | unsigned long a = _lastyear%4; | ||
73 | unsigned long b = _lastyear%7; | ||
74 | unsigned long c = _lastyear%19; | ||
75 | unsigned long d = (19*c+15)%30; | ||
76 | unsigned long e = (2*a+4*b-d+34)%7; | ||
77 | n = (d+e+114)/31; | ||
78 | p = (d+e+114)%31; | ||
79 | } | ||
80 | p++; | ||
81 | QDate d(_lastyear,n,p); | ||
82 | _days[d].append(QObject::tr("Eastersunday","holidays")); | ||
83 | _days[d.addDays(49)].append(QObject::tr("Whitsunday","holidays")); | ||
84 | _days[d.addDays(50)].append(QObject::tr("Whitmonday","holidays")); | ||
85 | _days[d.addDays(-46)].append(QObject::tr("Ash Wednesday","holidays")); | ||
86 | _days[d.addDays(60)].append(QObject::tr("Corpus Christi","holidays")); | ||
87 | } | ||
diff --git a/core/pim/datebook/holiday/christian/chrisholiday.h b/core/pim/datebook/holiday/christian/chrisholiday.h new file mode 100644 index 0000000..5f43e85 --- a/dev/null +++ b/core/pim/datebook/holiday/christian/chrisholiday.h | |||
@@ -0,0 +1,33 @@ | |||
1 | #ifndef __DUMMY_HOLIDAY_H | ||
2 | #define __DUMMY_HOLIDAY_H | ||
3 | |||
4 | #include "hlist.h" | ||
5 | |||
6 | #include <opie2/oholidayplugin.h> | ||
7 | #include <opie2/oholidaypluginif.h> | ||
8 | |||
9 | #include <qmap.h> | ||
10 | |||
11 | class ChrisHoliday:public Opie::Datebook::HolidayPlugin | ||
12 | { | ||
13 | typedef QMap<QDate,QStringList> tDayMap; | ||
14 | |||
15 | public: | ||
16 | ChrisHoliday():Opie::Datebook::HolidayPlugin(){_lastyear=0;} | ||
17 | virtual ~ChrisHoliday(){} | ||
18 | |||
19 | virtual QString description(); | ||
20 | virtual QStringList entries(const QDate&); | ||
21 | virtual QStringList entries(unsigned year, unsigned month, unsigned day); | ||
22 | protected: | ||
23 | HList _internallist; | ||
24 | unsigned int _lastyear; | ||
25 | tDayMap _days; | ||
26 | |||
27 | void calcit(int year); | ||
28 | void calc_easter(); | ||
29 | void calc_christmas(); | ||
30 | }; | ||
31 | |||
32 | EXPORT_HOLIDAY_PLUGIN(ChrisHoliday); | ||
33 | #endif | ||
diff --git a/core/pim/datebook/holiday/christian/christian-holidays.pro b/core/pim/datebook/holiday/christian/christian-holidays.pro new file mode 100644 index 0000000..1dfa8ab --- a/dev/null +++ b/core/pim/datebook/holiday/christian/christian-holidays.pro | |||
@@ -0,0 +1,20 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG -= moc | ||
3 | CONFIG += qt plugin | ||
4 | |||
5 | # Input | ||
6 | HEADERS = chrisholiday.h hlist.h | ||
7 | SOURCES = chrisholiday.cpp hlist.cpp | ||
8 | INTERFACES= | ||
9 | |||
10 | INCLUDEPATH += $(OPIEDIR)/include \ | ||
11 | ../ ../library | ||
12 | DEPENDPATH += $(OPIEDIR)/include \ | ||
13 | ../ ../library | ||
14 | |||
15 | LIBS+= -lqpe -lopiecore2 -lopieui2 | ||
16 | |||
17 | DESTDIR = $(OPIEDIR)/plugins/datebook/holiday | ||
18 | TARGET = chrisholidayplugin | ||
19 | |||
20 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/core/pim/datebook/holiday/christian/config.in b/core/pim/datebook/holiday/christian/config.in new file mode 100644 index 0000000..fc26330 --- a/dev/null +++ b/core/pim/datebook/holiday/christian/config.in | |||
@@ -0,0 +1,4 @@ | |||
1 | config DATEBOOK_CHRISTIAN_HOLIDAY | ||
2 | boolean "opie-datebook-christian-holidays" | ||
3 | default "y" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM | ||
diff --git a/core/pim/datebook/holiday/christian/hlist.cpp b/core/pim/datebook/holiday/christian/hlist.cpp new file mode 100644 index 0000000..795b075 --- a/dev/null +++ b/core/pim/datebook/holiday/christian/hlist.cpp | |||
@@ -0,0 +1,18 @@ | |||
1 | #include "hlist.h" | ||
2 | |||
3 | #include <qobject.h> | ||
4 | |||
5 | const QStringList HList::entries(const QDate&aDate)const | ||
6 | { | ||
7 | QStringList ret; | ||
8 | if (aDate.month()==12) { | ||
9 | if (aDate.day()==24) { | ||
10 | ret.append(QObject::tr("Christmas","holidays")); | ||
11 | } | ||
12 | } else if (aDate.month()==1) { | ||
13 | if (aDate.day()==1) { | ||
14 | ret.append(QObject::tr("New year","holidays")); | ||
15 | } | ||
16 | } | ||
17 | return ret; | ||
18 | } | ||
diff --git a/core/pim/datebook/holiday/christian/hlist.h b/core/pim/datebook/holiday/christian/hlist.h new file mode 100644 index 0000000..5904852 --- a/dev/null +++ b/core/pim/datebook/holiday/christian/hlist.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _HLIST_H | ||
2 | #define _HLIST_H | ||
3 | |||
4 | #include <qstringlist.h> | ||
5 | #include <qdatetime.h> | ||
6 | |||
7 | class HList | ||
8 | { | ||
9 | public: | ||
10 | HList(){}; | ||
11 | virtual ~HList(){}; | ||
12 | |||
13 | const QStringList entries(const QDate&)const; | ||
14 | }; | ||
15 | |||
16 | #endif | ||
diff --git a/core/pim/datebook/holiday/dummy/config.in b/core/pim/datebook/holiday/dummy/config.in index 373ff4a..ec85aa0 100644 --- a/core/pim/datebook/holiday/dummy/config.in +++ b/core/pim/datebook/holiday/dummy/config.in | |||
@@ -1,6 +1,4 @@ | |||
1 | config DATEBOOK_DUMMY_HOLIDAY | 1 | config DATEBOOK_DUMMY_HOLIDAY |
2 | boolean "opie-datebook-dummyholidayplugin" | 2 | boolean "opie-datebook-dummy-holidays" |
3 | default "n" | 3 | default "n" |
4 | comment "opie-datebook-dummyholidayplugin requires libopie2core, libopie2pim" | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM |
5 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2PIM | ||
6 | |||
@@ -32,6 +32,7 @@ CONFIG_DAGGER noncore/apps/dagger dagger.pro | |||
32 | CONFIG_DASHER inputmethods/dasherdasher.pro | 32 | CONFIG_DASHER inputmethods/dasherdasher.pro |
33 | CONFIG_DATEBOOK2 core/pim/datebook2datebook2.pro | 33 | CONFIG_DATEBOOK2 core/pim/datebook2datebook2.pro |
34 | CONFIG_DATEBOOK core/pim/datebookdatebook.pro | 34 | CONFIG_DATEBOOK core/pim/datebookdatebook.pro |
35 | CONFIG_DATEBOOK_CHRISTIAN_HOLIDAY core/pim/datebook/holiday/christian christian-holidays.pro | ||
35 | CONFIG_DATEBOOK_DUMMY_HOLIDAY core/pim/datebook/holiday/dummy dummy.pro | 36 | CONFIG_DATEBOOK_DUMMY_HOLIDAY core/pim/datebook/holiday/dummy dummy.pro |
36 | CONFIG_DECO_FLAT noncore/decorations/flatflat.pro | 37 | CONFIG_DECO_FLAT noncore/decorations/flatflat.pro |
37 | CONFIG_DECO_LIQUID noncore/decorations/liquidliquid.pro | 38 | CONFIG_DECO_LIQUID noncore/decorations/liquidliquid.pro |