summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/holiday/christian/chrisholiday.cpp8
-rw-r--r--core/pim/datebook/holiday/christian/chrisholiday.h2
-rw-r--r--core/pim/datebook/holiday/dummy/dummyholiday.cpp8
-rw-r--r--core/pim/datebook/holiday/dummy/dummyholiday.h2
4 files changed, 18 insertions, 2 deletions
diff --git a/core/pim/datebook/holiday/christian/chrisholiday.cpp b/core/pim/datebook/holiday/christian/chrisholiday.cpp
index 6ef102a..3427b73 100644
--- a/core/pim/datebook/holiday/christian/chrisholiday.cpp
+++ b/core/pim/datebook/holiday/christian/chrisholiday.cpp
@@ -1,87 +1,95 @@
1#include "chrisholiday.h" 1#include "chrisholiday.h"
2 2
3#include <qobject.h> 3#include <qobject.h>
4 4
5QString ChrisHoliday::description() 5QString ChrisHoliday::description()
6{ 6{
7 return QObject::tr("Christian holidays","holidays"); 7 return QObject::tr("Christian holidays","holidays");
8} 8}
9 9
10QStringList ChrisHoliday::entries(const QDate&aDate) 10QStringList ChrisHoliday::entries(const QDate&aDate)
11{ 11{
12 QStringList ret; 12 QStringList ret;
13 ret+=_internallist.entries(aDate); 13 ret+=_internallist.entries(aDate);
14 calcit(aDate.year()); 14 calcit(aDate.year());
15 tDayMap::Iterator it = _days.find(aDate); 15 tDayMap::Iterator it = _days.find(aDate);
16 if (it!=_days.end()) { 16 if (it!=_days.end()) {
17 ret+=*it; 17 ret+=*it;
18 } 18 }
19 19
20 return ret; 20 return ret;
21} 21}
22 22
23QStringList ChrisHoliday::entries(unsigned year, unsigned month, unsigned day) 23QStringList ChrisHoliday::entries(unsigned year, unsigned month, unsigned day)
24{ 24{
25 return entries(QDate(year,month,day)); 25 return entries(QDate(year,month,day));
26} 26}
27 27
28void ChrisHoliday::calcit(int year) 28void ChrisHoliday::calcit(int year)
29{ 29{
30 if (year==_lastyear) return; 30 if (year==_lastyear) return;
31 _lastyear = year; 31 _lastyear = year;
32 _days.clear(); 32 _days.clear();
33 calc_easter(); 33 calc_easter();
34 calc_christmas(); 34 calc_christmas();
35} 35}
36 36
37void ChrisHoliday::calc_christmas() 37void ChrisHoliday::calc_christmas()
38{ 38{
39 QDate cday(_lastyear,12,24); 39 QDate cday(_lastyear,12,24);
40 int diff; 40 int diff;
41 if ( (diff=cday.dayOfWeek())!=7) { 41 if ( (diff=cday.dayOfWeek())!=7) {
42 cday=cday.addDays(-diff); 42 cday=cday.addDays(-diff);
43 _days[cday].append(QObject::tr("4. Advent","holidays")); 43 _days[cday].append(QObject::tr("4. Advent","holidays"));
44 } 44 }
45 _days[cday.addDays(-7)].append(QObject::tr("3. Advent","holidays")); 45 _days[cday.addDays(-7)].append(QObject::tr("3. Advent","holidays"));
46 _days[cday.addDays(-14)].append(QObject::tr("2. Advent","holidays")); 46 _days[cday.addDays(-14)].append(QObject::tr("2. Advent","holidays"));
47 _days[cday.addDays(-21)].append(QObject::tr("1. Advent","holidays")); 47 _days[cday.addDays(-21)].append(QObject::tr("1. Advent","holidays"));
48} 48}
49 49
50void ChrisHoliday::calc_easter() 50void ChrisHoliday::calc_easter()
51{ 51{
52 unsigned long n = 0; 52 unsigned long n = 0;
53 unsigned long p = 0; 53 unsigned long p = 0;
54 54
55 if ( _lastyear > 1582 ) { 55 if ( _lastyear > 1582 ) {
56 unsigned long a = _lastyear%19; 56 unsigned long a = _lastyear%19;
57 unsigned long b = _lastyear/100; 57 unsigned long b = _lastyear/100;
58 unsigned long c = _lastyear%100; 58 unsigned long c = _lastyear%100;
59 unsigned long d = b/4; 59 unsigned long d = b/4;
60 unsigned long e = b%4; 60 unsigned long e = b%4;
61 unsigned long f = (b+8)/25; 61 unsigned long f = (b+8)/25;
62 unsigned long g = (b+f+1)/3; 62 unsigned long g = (b+f+1)/3;
63 unsigned long h = (19*a+b-d-g+15)%30; 63 unsigned long h = (19*a+b-d-g+15)%30;
64 unsigned long i = c/4; 64 unsigned long i = c/4;
65 unsigned long j = c%4; 65 unsigned long j = c%4;
66 unsigned long k = j%100; 66 unsigned long k = j%100;
67 unsigned long l = (32+2*e+2*i-h-k)%7; 67 unsigned long l = (32+2*e+2*i-h-k)%7;
68 unsigned long m = (a+11*h+22*l)/451; 68 unsigned long m = (a+11*h+22*l)/451;
69 n = (h+l-7*m+114)/31; 69 n = (h+l-7*m+114)/31;
70 p = (h+l-7*m+114)%31; 70 p = (h+l-7*m+114)%31;
71 } else { 71 } else {
72 unsigned long a = _lastyear%4; 72 unsigned long a = _lastyear%4;
73 unsigned long b = _lastyear%7; 73 unsigned long b = _lastyear%7;
74 unsigned long c = _lastyear%19; 74 unsigned long c = _lastyear%19;
75 unsigned long d = (19*c+15)%30; 75 unsigned long d = (19*c+15)%30;
76 unsigned long e = (2*a+4*b-d+34)%7; 76 unsigned long e = (2*a+4*b-d+34)%7;
77 n = (d+e+114)/31; 77 n = (d+e+114)/31;
78 p = (d+e+114)%31; 78 p = (d+e+114)%31;
79 } 79 }
80 p++; 80 p++;
81 QDate d(_lastyear,n,p); 81 QDate d(_lastyear,n,p);
82 _days[d].append(QObject::tr("Eastersunday","holidays")); 82 _days[d].append(QObject::tr("Eastersunday","holidays"));
83 _days[d.addDays(49)].append(QObject::tr("Whitsunday","holidays")); 83 _days[d.addDays(49)].append(QObject::tr("Whitsunday","holidays"));
84 _days[d.addDays(50)].append(QObject::tr("Whitmonday","holidays")); 84 _days[d.addDays(50)].append(QObject::tr("Whitmonday","holidays"));
85 _days[d.addDays(-46)].append(QObject::tr("Ash Wednesday","holidays")); 85 _days[d.addDays(-46)].append(QObject::tr("Ash Wednesday","holidays"));
86 _days[d.addDays(60)].append(QObject::tr("Corpus Christi","holidays")); 86 _days[d.addDays(60)].append(QObject::tr("Corpus Christi","holidays"));
87} 87}
88
89QMap<QDate,QStringList> ChrisHoliday::entries(const QDate&,const QDate&)
90{
91 QMap<QDate,QStringList> ret;
92 return ret;
93}
94
95EXPORT_HOLIDAY_PLUGIN(ChrisHoliday); \ No newline at end of file
diff --git a/core/pim/datebook/holiday/christian/chrisholiday.h b/core/pim/datebook/holiday/christian/chrisholiday.h
index 5f43e85..8dcf4c6 100644
--- a/core/pim/datebook/holiday/christian/chrisholiday.h
+++ b/core/pim/datebook/holiday/christian/chrisholiday.h
@@ -1,33 +1,33 @@
1#ifndef __DUMMY_HOLIDAY_H 1#ifndef __DUMMY_HOLIDAY_H
2#define __DUMMY_HOLIDAY_H 2#define __DUMMY_HOLIDAY_H
3 3
4#include "hlist.h" 4#include "hlist.h"
5 5
6#include <opie2/oholidayplugin.h> 6#include <opie2/oholidayplugin.h>
7#include <opie2/oholidaypluginif.h> 7#include <opie2/oholidaypluginif.h>
8 8
9#include <qmap.h> 9#include <qmap.h>
10 10
11class ChrisHoliday:public Opie::Datebook::HolidayPlugin 11class ChrisHoliday:public Opie::Datebook::HolidayPlugin
12{ 12{
13typedef QMap<QDate,QStringList> tDayMap; 13typedef QMap<QDate,QStringList> tDayMap;
14 14
15public: 15public:
16 ChrisHoliday():Opie::Datebook::HolidayPlugin(){_lastyear=0;} 16 ChrisHoliday():Opie::Datebook::HolidayPlugin(){_lastyear=0;}
17 virtual ~ChrisHoliday(){} 17 virtual ~ChrisHoliday(){}
18 18
19 virtual QString description(); 19 virtual QString description();
20 virtual QStringList entries(const QDate&); 20 virtual QStringList entries(const QDate&);
21 virtual QStringList entries(unsigned year, unsigned month, unsigned day); 21 virtual QStringList entries(unsigned year, unsigned month, unsigned day);
22 virtual QMap<QDate,QStringList> entries(const QDate&,const QDate&);
22protected: 23protected:
23 HList _internallist; 24 HList _internallist;
24 unsigned int _lastyear; 25 unsigned int _lastyear;
25 tDayMap _days; 26 tDayMap _days;
26 27
27 void calcit(int year); 28 void calcit(int year);
28 void calc_easter(); 29 void calc_easter();
29 void calc_christmas(); 30 void calc_christmas();
30}; 31};
31 32
32EXPORT_HOLIDAY_PLUGIN(ChrisHoliday);
33#endif 33#endif
diff --git a/core/pim/datebook/holiday/dummy/dummyholiday.cpp b/core/pim/datebook/holiday/dummy/dummyholiday.cpp
index dd00b9b..6429a8f 100644
--- a/core/pim/datebook/holiday/dummy/dummyholiday.cpp
+++ b/core/pim/datebook/holiday/dummy/dummyholiday.cpp
@@ -1,20 +1,28 @@
1#include "dummyholiday.h" 1#include "dummyholiday.h"
2 2
3#include <qobject.h> 3#include <qobject.h>
4 4
5QString DummyHoliday::description() 5QString DummyHoliday::description()
6{ 6{
7 return QObject::tr("Test holiday plugin","dummyholiday"); 7 return QObject::tr("Test holiday plugin","dummyholiday");
8} 8}
9 9
10QStringList DummyHoliday::entries(const QDate&aDate) 10QStringList DummyHoliday::entries(const QDate&aDate)
11{ 11{
12 return entries(0,0,aDate.day()); 12 return entries(0,0,aDate.day());
13} 13}
14 14
15QStringList DummyHoliday::entries(unsigned year, unsigned month, unsigned day) 15QStringList DummyHoliday::entries(unsigned year, unsigned month, unsigned day)
16{ 16{
17 QStringList ret; 17 QStringList ret;
18 if (day%2==0) ret.append(QObject::tr("You have a holiday!","dummyholiday")); 18 if (day%2==0) ret.append(QObject::tr("You have a holiday!","dummyholiday"));
19 return ret; 19 return ret;
20} 20}
21
22QMap<QDate,QStringList> DummyHoliday::entries(const QDate&,const QDate&)
23{
24 QMap<QDate,QStringList> ret;
25 return ret;
26}
27
28EXPORT_HOLIDAY_PLUGIN(DummyHoliday);
diff --git a/core/pim/datebook/holiday/dummy/dummyholiday.h b/core/pim/datebook/holiday/dummy/dummyholiday.h
index 9b28f24..7d86b20 100644
--- a/core/pim/datebook/holiday/dummy/dummyholiday.h
+++ b/core/pim/datebook/holiday/dummy/dummyholiday.h
@@ -1,19 +1,19 @@
1#ifndef __DUMMY_HOLIDAY_H 1#ifndef __DUMMY_HOLIDAY_H
2#define __DUMMY_HOLIDAY_H 2#define __DUMMY_HOLIDAY_H
3 3
4#include <opie2/oholidayplugin.h> 4#include <opie2/oholidayplugin.h>
5#include <opie2/oholidaypluginif.h> 5#include <opie2/oholidaypluginif.h>
6 6
7class DummyHoliday:public Opie::Datebook::HolidayPlugin 7class DummyHoliday:public Opie::Datebook::HolidayPlugin
8{ 8{
9public: 9public:
10 DummyHoliday():Opie::Datebook::HolidayPlugin(){} 10 DummyHoliday():Opie::Datebook::HolidayPlugin(){}
11 virtual ~DummyHoliday(){} 11 virtual ~DummyHoliday(){}
12 12
13 virtual QString description(); 13 virtual QString description();
14 virtual QStringList entries(const QDate&); 14 virtual QStringList entries(const QDate&);
15 virtual QStringList entries(unsigned year, unsigned month, unsigned day); 15 virtual QStringList entries(unsigned year, unsigned month, unsigned day);
16 virtual QMap<QDate,QStringList> entries(const QDate&,const QDate&);
16}; 17};
17 18
18EXPORT_HOLIDAY_PLUGIN(DummyHoliday);
19#endif 19#endif