summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-17 13:50:01 (UTC)
committer alwin <alwin>2005-03-17 13:50:01 (UTC)
commitafee05f4b4c1e8dab8463e3423fcfc8f9d45aa8b (patch) (unidiff)
treea76984183d368187b6acc5cba014190e932832c5
parent8c3f9c35425a2f2dbbbee61e6aa3e9a312ccba0e (diff)
downloadopie-afee05f4b4c1e8dab8463e3423fcfc8f9d45aa8b.zip
opie-afee05f4b4c1e8dab8463e3423fcfc8f9d45aa8b.tar.gz
opie-afee05f4b4c1e8dab8463e3423fcfc8f9d45aa8b.tar.bz2
inserted last missing stuff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/holiday/birthday/birthday.cpp90
-rw-r--r--core/pim/datebook/holiday/birthday/birthday.h2
-rw-r--r--core/pim/datebook/holiday/christian/chrisholiday.cpp50
-rw-r--r--core/pim/datebook/holiday/christian/chrisholiday.h2
4 files changed, 142 insertions, 2 deletions
diff --git a/core/pim/datebook/holiday/birthday/birthday.cpp b/core/pim/datebook/holiday/birthday/birthday.cpp
index 98e2d40..74bcf8b 100644
--- a/core/pim/datebook/holiday/birthday/birthday.cpp
+++ b/core/pim/datebook/holiday/birthday/birthday.cpp
@@ -1,15 +1,16 @@
1#include "birthday.h" 1#include "birthday.h"
2 2
3#include <opie2/ocontactaccess.h> 3#include <opie2/ocontactaccess.h>
4#include <qpe/event.h>
4 5
5#include <qobject.h> 6#include <qobject.h>
6 7
7Birthday::Birthday() 8Birthday::Birthday()
8 :Opie::Datebook::HolidayPlugin() 9 :Opie::Datebook::HolidayPlugin()
9{ 10{
10 m_contactdb = new Opie::OPimContactAccess("addressplugin"); 11 m_contactdb = new Opie::OPimContactAccess("addressplugin");
11/* 12/*
12 connect( m_contactdb, SIGNAL( signalChanged(const Opie::OPimContactAccess*) ), 13 connect( m_contactdb, SIGNAL( signalChanged(const Opie::OPimContactAccess*) ),
13 this, SLOT( refresh(const Opie::OPimContactAccess*) ) ); 14 this, SLOT( refresh(const Opie::OPimContactAccess*) ) );
14*/ 15*/
15} 16}
@@ -53,19 +54,106 @@ QStringList Birthday::entries(const QDate&aDate)
53 } 54 }
54 ret.append(pre); 55 ret.append(pre);
55 } 56 }
56 } 57 }
57 return ret; 58 return ret;
58} 59}
59 60
60QStringList Birthday::entries(unsigned year, unsigned month, unsigned day) 61QStringList Birthday::entries(unsigned year, unsigned month, unsigned day)
61{ 62{
62 return entries(QDate(year,month,day)); 63 return entries(QDate(year,month,day));
63} 64}
64 65
65QMap<QDate,QStringList> Birthday::entries(const QDate&,const QDate&) 66QMap<QDate,QString> Birthday::_entries(const QDate&start,const QDate&end,bool anniversary)
67{
68 QMap<QDate,QString> ret;
69 QDate s = (start<end?start:end);
70 QDate e = (start<end?end:start);
71
72 int daysto = start.daysTo(end);
73 if (daysto < 0) {
74 daysto = end.daysTo(start);
75 }
76 if ( m_contactdb->hasQuerySettings(Opie::OPimContactAccess::DateDiff ) ){
77 Opie::OPimContact querybirthdays;
78 QString pre;
79 if (anniversary) {
80 querybirthdays.setAnniversary(e);
81 } else {
82 querybirthdays.setBirthday(e);
83 }
84 QMap<QDate,QString> collector;
85 QMap<QDate,QString>::ConstIterator sit;
86 m_list = m_contactdb->queryByExample( querybirthdays,Opie::OPimContactAccess::DateDiff,s);
87 QDate t;
88 if ( m_list.count() > 0 ){
89 if (anniversary) {
90 pre = QObject::tr("Anniversary","holidays");
91 } else {
92 pre = QObject::tr("Birthday","holidays");
93 }
94 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
95 if (!anniversary) {
96 t.setYMD(e.year(),(*m_it).birthday().month(),(*m_it).birthday().day());
97 } else {
98 t.setYMD(e.year(),(*m_it).anniversary().month(),(*m_it).anniversary().day());
99 }
100 if (ret[t].isEmpty()) {
101 ret[t]=pre;
102 }
103 ret[t]+=" "+(*m_it).fullName();
104 }
105 }
106 }
107 return ret;
108}
109
110QMap<QDate,QStringList> Birthday::entries(const QDate&start,const QDate&end)
66{ 111{
67 QMap<QDate,QStringList> ret; 112 QMap<QDate,QStringList> ret;
113 QMap<QDate,QString> collector;
114 QMap<QDate,QString>::ConstIterator sit;
115
116 collector = _entries(start,end,false);
117 for (sit=collector.begin();sit!=collector.end();++sit) {
118 ret[sit.key()].append(sit.data());
119 }
120 collector = _entries(start,end,true);
121 for (sit=collector.begin();sit!=collector.end();++sit) {
122 ret[sit.key()].append(sit.data());
123 }
124 return ret;
125}
126
127QValueList<EffectiveEvent> Birthday::events(const QDate&start,const QDate&end)
128{
129 QValueList<EffectiveEvent> ret;
130 QMap<QDate,QString> collector;
131 QMap<QDate,QString>::ConstIterator sit;
132
133 collector = _entries(start,end,false);
134
135 for (sit=collector.begin();sit!=collector.end();++sit) {
136 Event ev;
137 ev.setAllDay(true);
138 ev.setStart(sit.key());
139 ev.setEnd(sit.key());
140 ev.setDescription(sit.data());
141 odebug << sit.key() << oendl;
142 ret.append(EffectiveEvent(ev,sit.key()));
143 }
144
145 collector = _entries(start,end,true);
146
147 for (sit=collector.begin();sit!=collector.end();++sit) {
148 Event ev;
149 ev.setAllDay(true);
150 ev.setStart(sit.key());
151 ev.setEnd(sit.key());
152 ev.setDescription(sit.data());
153 odebug << sit.key() << oendl;
154 ret.append(EffectiveEvent(ev,sit.key()));
155 }
68 return ret; 156 return ret;
69} 157}
70 158
71EXPORT_HOLIDAY_PLUGIN(Birthday); 159EXPORT_HOLIDAY_PLUGIN(Birthday);
diff --git a/core/pim/datebook/holiday/birthday/birthday.h b/core/pim/datebook/holiday/birthday/birthday.h
index 5c9aacd..c308dd0 100644
--- a/core/pim/datebook/holiday/birthday/birthday.h
+++ b/core/pim/datebook/holiday/birthday/birthday.h
@@ -10,19 +10,21 @@
10class Birthday:public Opie::Datebook::HolidayPlugin 10class Birthday:public Opie::Datebook::HolidayPlugin
11{ 11{
12typedef QMap<QDate,QStringList> tDayMap; 12typedef QMap<QDate,QStringList> tDayMap;
13 13
14public: 14public:
15 Birthday(); 15 Birthday();
16 virtual ~Birthday(){} 16 virtual ~Birthday(){}
17 17
18 virtual QString description(); 18 virtual QString description();
19 virtual QStringList entries(const QDate&); 19 virtual QStringList entries(const QDate&);
20 virtual QStringList entries(unsigned year, unsigned month, unsigned day); 20 virtual QStringList entries(unsigned year, unsigned month, unsigned day);
21 virtual QMap<QDate,QStringList> entries(const QDate&,const QDate&); 21 virtual QMap<QDate,QStringList> entries(const QDate&,const QDate&);
22 virtual QValueList<EffectiveEvent> events(const QDate&,const QDate&);
22protected: 23protected:
23 Opie::OPimContactAccess * m_contactdb; 24 Opie::OPimContactAccess * m_contactdb;
24 Opie::OPimContactAccess::List m_list; 25 Opie::OPimContactAccess::List m_list;
25 Opie::OPimContactAccess::List::Iterator m_it; 26 Opie::OPimContactAccess::List::Iterator m_it;
27 virtual QMap<QDate,QString> _entries(const QDate&,const QDate&,bool anniversary);
26}; 28};
27 29
28#endif 30#endif
diff --git a/core/pim/datebook/holiday/christian/chrisholiday.cpp b/core/pim/datebook/holiday/christian/chrisholiday.cpp
index ef6516e..f8e310f 100644
--- a/core/pim/datebook/holiday/christian/chrisholiday.cpp
+++ b/core/pim/datebook/holiday/christian/chrisholiday.cpp
@@ -1,15 +1,16 @@
1#include "chrisholiday.h" 1#include "chrisholiday.h"
2 2
3#include <qobject.h> 3#include <qobject.h>
4#include <qpe/event.h>
4 5
5QString ChrisHoliday::description() 6QString ChrisHoliday::description()
6{ 7{
7 return QObject::tr("Christian holidays","holidays"); 8 return QObject::tr("Christian holidays","holidays");
8} 9}
9 10
10QStringList ChrisHoliday::entries(const QDate&aDate) 11QStringList ChrisHoliday::entries(const QDate&aDate)
11{ 12{
12 QStringList ret; 13 QStringList ret;
13 ret+=_internallist.entries(aDate); 14 ret+=_internallist.entries(aDate);
14 calcit(aDate.year()); 15 calcit(aDate.year());
15 tDayMap::Iterator it = _days.find(aDate); 16 tDayMap::Iterator it = _days.find(aDate);
@@ -78,19 +79,66 @@ void ChrisHoliday::calc_easter()
78 p = (d+e+114)%31; 79 p = (d+e+114)%31;
79 } 80 }
80 p++; 81 p++;
81 QDate d(_lastyear,n,p); 82 QDate d(_lastyear,n,p);
82 _days[d].append(QObject::tr("Eastersunday","holidays")); 83 _days[d].append(QObject::tr("Eastersunday","holidays"));
83 _days[d.addDays(49)].append(QObject::tr("Whitsunday","holidays")); 84 _days[d.addDays(49)].append(QObject::tr("Whitsunday","holidays"));
84 _days[d.addDays(50)].append(QObject::tr("Whitmonday","holidays")); 85 _days[d.addDays(50)].append(QObject::tr("Whitmonday","holidays"));
85 _days[d.addDays(39)].append(QObject::tr("Ascension Day","holidays")); 86 _days[d.addDays(39)].append(QObject::tr("Ascension Day","holidays"));
86 _days[d.addDays(-46)].append(QObject::tr("Ash Wednesday","holidays")); 87 _days[d.addDays(-46)].append(QObject::tr("Ash Wednesday","holidays"));
87 _days[d.addDays(60)].append(QObject::tr("Corpus Christi","holidays")); 88 _days[d.addDays(60)].append(QObject::tr("Corpus Christi","holidays"));
88} 89}
89 90
90QMap<QDate,QStringList> ChrisHoliday::entries(const QDate&,const QDate&) 91QMap<QDate,QStringList> ChrisHoliday::entries(const QDate&start,const QDate&end)
91{ 92{
92 QMap<QDate,QStringList> ret; 93 QMap<QDate,QStringList> ret;
94 if (start==end) {
95 ret[start]=entries(start);
96 return ret;
97 }
98 QDate d;
99 int daysto;
100 if (end < start) {
101 d = end;
102 daysto = end.daysTo(start);
103 } else {
104 d = start;
105 daysto = start.daysTo(end);
106 }
107 QStringList temp;
108 for (int i=0;i<daysto;++i) {
109 temp = entries(d.addDays(i));
110 if (temp.count()==0) continue;
111 ret[d.addDays(i)]+=temp;
112 temp.clear();
113 }
114 return ret;
115}
116
117QValueList<EffectiveEvent> ChrisHoliday::events(const QDate&start,const QDate&end)
118{
119 QValueList<EffectiveEvent> ret;
120 QDate d = (start<end?start:end);
121 int daysto = start.daysTo(end);
122 if (daysto < 0) {
123 daysto = end.daysTo(start);
124 }
125
126 QStringList temp;
127 for (int i =0; i<daysto;++i) {
128 temp = entries(d.addDays(i));
129 if (temp.count()==0) {
130 continue;
131 }
132 for (unsigned j=0;j<temp.count();++j) {
133 Event ev;
134 ev.setDescription(temp[j]);
135 ev.setStart(d.addDays(i));
136 ev.setAllDay(true);
137 ret.append(EffectiveEvent(ev,d.addDays(i)));
138 }
139 }
140
93 return ret; 141 return ret;
94} 142}
95 143
96EXPORT_HOLIDAY_PLUGIN(ChrisHoliday); 144EXPORT_HOLIDAY_PLUGIN(ChrisHoliday);
diff --git a/core/pim/datebook/holiday/christian/chrisholiday.h b/core/pim/datebook/holiday/christian/chrisholiday.h
index 9ae500e..1ecb813 100644
--- a/core/pim/datebook/holiday/christian/chrisholiday.h
+++ b/core/pim/datebook/holiday/christian/chrisholiday.h
@@ -11,23 +11,25 @@
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&); 22 virtual QMap<QDate,QStringList> entries(const QDate&,const QDate&);
23 virtual QValueList<EffectiveEvent> events(const QDate&,const QDate&);
24
23protected: 25protected:
24 HList _internallist; 26 HList _internallist;
25 unsigned int _lastyear; 27 unsigned int _lastyear;
26 tDayMap _days; 28 tDayMap _days;
27 29
28 void calcit(int year); 30 void calcit(int year);
29 void calc_easter(); 31 void calc_easter();
30 void calc_christmas(); 32 void calc_christmas();
31}; 33};
32 34
33#endif 35#endif