author | alwin <alwin> | 2005-03-16 20:10:47 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-16 20:10:47 (UTC) |
commit | ea80ab0e1d30bd52d87b7330a934e63354716f2e (patch) (unidiff) | |
tree | e6e3e902454d54240f553993ccba7a84017aaa11 /core/pim/datebook | |
parent | 176c8e8bb543603b68e853660db93d6068c52bfa (diff) | |
download | opie-ea80ab0e1d30bd52d87b7330a934e63354716f2e.zip opie-ea80ab0e1d30bd52d87b7330a934e63354716f2e.tar.gz opie-ea80ab0e1d30bd52d87b7330a934e63354716f2e.tar.bz2 |
added birthday display into datebook
-rw-r--r-- | core/pim/datebook/holiday/birthday/birthday.cpp | 56 | ||||
-rw-r--r-- | core/pim/datebook/holiday/birthday/birthday.h | 28 | ||||
-rw-r--r-- | core/pim/datebook/holiday/birthday/birthdays.pro | 20 | ||||
-rw-r--r-- | core/pim/datebook/holiday/birthday/config.in | 4 | ||||
-rw-r--r-- | core/pim/datebook/holiday/christian/chrisholiday.cpp | 2 | ||||
-rw-r--r-- | core/pim/datebook/holiday/config.in | 1 |
6 files changed, 110 insertions, 1 deletions
diff --git a/core/pim/datebook/holiday/birthday/birthday.cpp b/core/pim/datebook/holiday/birthday/birthday.cpp new file mode 100644 index 0000000..a32e0ea --- a/dev/null +++ b/core/pim/datebook/holiday/birthday/birthday.cpp | |||
@@ -0,0 +1,56 @@ | |||
1 | #include "birthday.h" | ||
2 | |||
3 | #include <opie2/ocontactaccess.h> | ||
4 | |||
5 | #include <qobject.h> | ||
6 | |||
7 | Birthday::Birthday() | ||
8 | :Opie::Datebook::HolidayPlugin() | ||
9 | { | ||
10 | m_contactdb = new Opie::OPimContactAccess("addressplugin"); | ||
11 | /* | ||
12 | connect( m_contactdb, SIGNAL( signalChanged(const Opie::OPimContactAccess*) ), | ||
13 | this, SLOT( refresh(const Opie::OPimContactAccess*) ) ); | ||
14 | */ | ||
15 | } | ||
16 | |||
17 | QString Birthday::description() | ||
18 | { | ||
19 | return QObject::tr("Birthdays","holidays"); | ||
20 | } | ||
21 | |||
22 | QStringList Birthday::entries(const QDate&aDate) | ||
23 | { | ||
24 | QStringList ret; | ||
25 | if ( m_contactdb->hasQuerySettings( Opie::OPimContactAccess::DateDay ) ){ | ||
26 | Opie::OPimContact querybirthdays; | ||
27 | querybirthdays.setBirthday(aDate); | ||
28 | m_list = m_contactdb->queryByExample( querybirthdays,Opie::OPimContactAccess::DateDay| Opie::OPimContactAccess::DateMonth); | ||
29 | if ( m_list.count() > 0 ){ | ||
30 | QString pre = QObject::tr("Birthday","holidays")+" "; | ||
31 | int z = 0; | ||
32 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { | ||
33 | if (z) { | ||
34 | pre+=", "; | ||
35 | } | ||
36 | pre+=((*m_it).fullName()); | ||
37 | ++z; | ||
38 | } | ||
39 | ret.append(pre); | ||
40 | } | ||
41 | } | ||
42 | return ret; | ||
43 | } | ||
44 | |||
45 | QStringList Birthday::entries(unsigned year, unsigned month, unsigned day) | ||
46 | { | ||
47 | return entries(QDate(year,month,day)); | ||
48 | } | ||
49 | |||
50 | QMap<QDate,QStringList> Birthday::entries(const QDate&,const QDate&) | ||
51 | { | ||
52 | QMap<QDate,QStringList> ret; | ||
53 | return ret; | ||
54 | } | ||
55 | |||
56 | EXPORT_HOLIDAY_PLUGIN(Birthday); | ||
diff --git a/core/pim/datebook/holiday/birthday/birthday.h b/core/pim/datebook/holiday/birthday/birthday.h new file mode 100644 index 0000000..5c9aacd --- a/dev/null +++ b/core/pim/datebook/holiday/birthday/birthday.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef __DUMMY_HOLIDAY_H | ||
2 | #define __DUMMY_HOLIDAY_H | ||
3 | |||
4 | #include <opie2/oholidayplugin.h> | ||
5 | #include <opie2/oholidaypluginif.h> | ||
6 | #include <opie2/ocontactaccess.h> | ||
7 | |||
8 | #include <qmap.h> | ||
9 | |||
10 | class Birthday:public Opie::Datebook::HolidayPlugin | ||
11 | { | ||
12 | typedef QMap<QDate,QStringList> tDayMap; | ||
13 | |||
14 | public: | ||
15 | Birthday(); | ||
16 | virtual ~Birthday(){} | ||
17 | |||
18 | virtual QString description(); | ||
19 | virtual QStringList entries(const QDate&); | ||
20 | virtual QStringList entries(unsigned year, unsigned month, unsigned day); | ||
21 | virtual QMap<QDate,QStringList> entries(const QDate&,const QDate&); | ||
22 | protected: | ||
23 | Opie::OPimContactAccess * m_contactdb; | ||
24 | Opie::OPimContactAccess::List m_list; | ||
25 | Opie::OPimContactAccess::List::Iterator m_it; | ||
26 | }; | ||
27 | |||
28 | #endif | ||
diff --git a/core/pim/datebook/holiday/birthday/birthdays.pro b/core/pim/datebook/holiday/birthday/birthdays.pro new file mode 100644 index 0000000..b78dbd1 --- a/dev/null +++ b/core/pim/datebook/holiday/birthday/birthdays.pro | |||
@@ -0,0 +1,20 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG -= moc | ||
3 | CONFIG += qt plugin | ||
4 | |||
5 | # Input | ||
6 | HEADERS = birthday.h | ||
7 | SOURCES = birthday.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 = birthdayplugin | ||
19 | |||
20 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/core/pim/datebook/holiday/birthday/config.in b/core/pim/datebook/holiday/birthday/config.in new file mode 100644 index 0000000..0a3f3ff --- a/dev/null +++ b/core/pim/datebook/holiday/birthday/config.in | |||
@@ -0,0 +1,4 @@ | |||
1 | config DATEBOOK_BIRTHDAYS_HOLIDAY | ||
2 | boolean "opie-datebook-birthdays" | ||
3 | default "y" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM | ||
diff --git a/core/pim/datebook/holiday/christian/chrisholiday.cpp b/core/pim/datebook/holiday/christian/chrisholiday.cpp index 3427b73..be16bd0 100644 --- a/core/pim/datebook/holiday/christian/chrisholiday.cpp +++ b/core/pim/datebook/holiday/christian/chrisholiday.cpp | |||
@@ -1,95 +1,95 @@ | |||
1 | #include "chrisholiday.h" | 1 | #include "chrisholiday.h" |
2 | 2 | ||
3 | #include <qobject.h> | 3 | #include <qobject.h> |
4 | 4 | ||
5 | QString ChrisHoliday::description() | 5 | QString ChrisHoliday::description() |
6 | { | 6 | { |
7 | return QObject::tr("Christian holidays","holidays"); | 7 | return QObject::tr("Christian holidays","holidays"); |
8 | } | 8 | } |
9 | 9 | ||
10 | QStringList ChrisHoliday::entries(const QDate&aDate) | 10 | QStringList 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 | ||
23 | QStringList ChrisHoliday::entries(unsigned year, unsigned month, unsigned day) | 23 | QStringList 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 | ||
28 | void ChrisHoliday::calcit(int year) | 28 | void 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 | ||
37 | void ChrisHoliday::calc_christmas() | 37 | void 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 | ||
50 | void ChrisHoliday::calc_easter() | 50 | void 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 | 88 | ||
89 | QMap<QDate,QStringList> ChrisHoliday::entries(const QDate&,const QDate&) | 89 | QMap<QDate,QStringList> ChrisHoliday::entries(const QDate&,const QDate&) |
90 | { | 90 | { |
91 | QMap<QDate,QStringList> ret; | 91 | QMap<QDate,QStringList> ret; |
92 | return ret; | 92 | return ret; |
93 | } | 93 | } |
94 | 94 | ||
95 | EXPORT_HOLIDAY_PLUGIN(ChrisHoliday); \ No newline at end of file | 95 | EXPORT_HOLIDAY_PLUGIN(ChrisHoliday); |
diff --git a/core/pim/datebook/holiday/config.in b/core/pim/datebook/holiday/config.in index e00f023..1912dbe 100644 --- a/core/pim/datebook/holiday/config.in +++ b/core/pim/datebook/holiday/config.in | |||
@@ -1,4 +1,5 @@ | |||
1 | menu "Holiday Plugins" | 1 | menu "Holiday Plugins" |
2 | source core/pim/datebook/holiday/birthday/config.in | ||
2 | source core/pim/datebook/holiday/christian/config.in | 3 | source core/pim/datebook/holiday/christian/config.in |
3 | source core/pim/datebook/holiday/dummy/config.in | 4 | source core/pim/datebook/holiday/dummy/config.in |
4 | endmenu | 5 | endmenu |