summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-17 13:50:01 (UTC)
committer alwin <alwin>2005-03-17 13:50:01 (UTC)
commitafee05f4b4c1e8dab8463e3423fcfc8f9d45aa8b (patch) (side-by-side diff)
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,27 +1,28 @@
#include "birthday.h"
#include <opie2/ocontactaccess.h>
+#include <qpe/event.h>
#include <qobject.h>
Birthday::Birthday()
:Opie::Datebook::HolidayPlugin()
{
m_contactdb = new Opie::OPimContactAccess("addressplugin");
/*
connect( m_contactdb, SIGNAL( signalChanged(const Opie::OPimContactAccess*) ),
this, SLOT( refresh(const Opie::OPimContactAccess*) ) );
*/
}
QString Birthday::description()
{
return QObject::tr("Birthdays","holidays");
}
QStringList Birthday::entries(const QDate&aDate)
{
QStringList ret;
if ( m_contactdb->hasQuerySettings( Opie::OPimContactAccess::DateDay ) ){
Opie::OPimContact querybirthdays,queryanniversary;
QString pre;
@@ -41,31 +42,118 @@ QStringList Birthday::entries(const QDate&aDate)
ret.append(pre);
}
m_list = m_contactdb->queryByExample( queryanniversary,Opie::OPimContactAccess::DateDay| Opie::OPimContactAccess::DateMonth);
if ( m_list.count() > 0 ){
pre = QObject::tr("Anniversary","holidays")+" ";
int z = 0;
for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
if (z) {
pre+=", ";
}
pre+=((*m_it).fullName());
++z;
}
ret.append(pre);
}
}
return ret;
}
QStringList Birthday::entries(unsigned year, unsigned month, unsigned day)
{
return entries(QDate(year,month,day));
}
-QMap<QDate,QStringList> Birthday::entries(const QDate&,const QDate&)
+QMap<QDate,QString> Birthday::_entries(const QDate&start,const QDate&end,bool anniversary)
+{
+ QMap<QDate,QString> ret;
+ QDate s = (start<end?start:end);
+ QDate e = (start<end?end:start);
+
+ int daysto = start.daysTo(end);
+ if (daysto < 0) {
+ daysto = end.daysTo(start);
+ }
+ if ( m_contactdb->hasQuerySettings(Opie::OPimContactAccess::DateDiff ) ){
+ Opie::OPimContact querybirthdays;
+ QString pre;
+ if (anniversary) {
+ querybirthdays.setAnniversary(e);
+ } else {
+ querybirthdays.setBirthday(e);
+ }
+ QMap<QDate,QString> collector;
+ QMap<QDate,QString>::ConstIterator sit;
+ m_list = m_contactdb->queryByExample( querybirthdays,Opie::OPimContactAccess::DateDiff,s);
+ QDate t;
+ if ( m_list.count() > 0 ){
+ if (anniversary) {
+ pre = QObject::tr("Anniversary","holidays");
+ } else {
+ pre = QObject::tr("Birthday","holidays");
+ }
+ for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
+ if (!anniversary) {
+ t.setYMD(e.year(),(*m_it).birthday().month(),(*m_it).birthday().day());
+ } else {
+ t.setYMD(e.year(),(*m_it).anniversary().month(),(*m_it).anniversary().day());
+ }
+ if (ret[t].isEmpty()) {
+ ret[t]=pre;
+ }
+ ret[t]+=" "+(*m_it).fullName();
+ }
+ }
+ }
+ return ret;
+}
+
+QMap<QDate,QStringList> Birthday::entries(const QDate&start,const QDate&end)
{
QMap<QDate,QStringList> ret;
+ QMap<QDate,QString> collector;
+ QMap<QDate,QString>::ConstIterator sit;
+
+ collector = _entries(start,end,false);
+ for (sit=collector.begin();sit!=collector.end();++sit) {
+ ret[sit.key()].append(sit.data());
+ }
+ collector = _entries(start,end,true);
+ for (sit=collector.begin();sit!=collector.end();++sit) {
+ ret[sit.key()].append(sit.data());
+ }
+ return ret;
+}
+
+QValueList<EffectiveEvent> Birthday::events(const QDate&start,const QDate&end)
+{
+ QValueList<EffectiveEvent> ret;
+ QMap<QDate,QString> collector;
+ QMap<QDate,QString>::ConstIterator sit;
+
+ collector = _entries(start,end,false);
+
+ for (sit=collector.begin();sit!=collector.end();++sit) {
+ Event ev;
+ ev.setAllDay(true);
+ ev.setStart(sit.key());
+ ev.setEnd(sit.key());
+ ev.setDescription(sit.data());
+ odebug << sit.key() << oendl;
+ ret.append(EffectiveEvent(ev,sit.key()));
+ }
+
+ collector = _entries(start,end,true);
+
+ for (sit=collector.begin();sit!=collector.end();++sit) {
+ Event ev;
+ ev.setAllDay(true);
+ ev.setStart(sit.key());
+ ev.setEnd(sit.key());
+ ev.setDescription(sit.data());
+ odebug << sit.key() << oendl;
+ ret.append(EffectiveEvent(ev,sit.key()));
+ }
return ret;
}
EXPORT_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
@@ -1,28 +1,30 @@
#ifndef __DUMMY_HOLIDAY_H
#define __DUMMY_HOLIDAY_H
#include <opie2/oholidayplugin.h>
#include <opie2/oholidaypluginif.h>
#include <opie2/ocontactaccess.h>
#include <qmap.h>
class Birthday:public Opie::Datebook::HolidayPlugin
{
typedef QMap<QDate,QStringList> tDayMap;
public:
Birthday();
virtual ~Birthday(){}
virtual QString description();
virtual QStringList entries(const QDate&);
virtual QStringList entries(unsigned year, unsigned month, unsigned day);
virtual QMap<QDate,QStringList> entries(const QDate&,const QDate&);
+ virtual QValueList<EffectiveEvent> events(const QDate&,const QDate&);
protected:
Opie::OPimContactAccess * m_contactdb;
Opie::OPimContactAccess::List m_list;
Opie::OPimContactAccess::List::Iterator m_it;
+ virtual QMap<QDate,QString> _entries(const QDate&,const QDate&,bool anniversary);
};
#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,27 +1,28 @@
#include "chrisholiday.h"
#include <qobject.h>
+#include <qpe/event.h>
QString ChrisHoliday::description()
{
return QObject::tr("Christian holidays","holidays");
}
QStringList ChrisHoliday::entries(const QDate&aDate)
{
QStringList ret;
ret+=_internallist.entries(aDate);
calcit(aDate.year());
tDayMap::Iterator it = _days.find(aDate);
if (it!=_days.end()) {
ret+=*it;
}
return ret;
}
QStringList ChrisHoliday::entries(unsigned year, unsigned month, unsigned day)
{
return entries(QDate(year,month,day));
}
@@ -66,31 +67,78 @@ void ChrisHoliday::calc_easter()
unsigned long k = j%100;
unsigned long l = (32+2*e+2*i-h-k)%7;
unsigned long m = (a+11*h+22*l)/451;
n = (h+l-7*m+114)/31;
p = (h+l-7*m+114)%31;
} else {
unsigned long a = _lastyear%4;
unsigned long b = _lastyear%7;
unsigned long c = _lastyear%19;
unsigned long d = (19*c+15)%30;
unsigned long e = (2*a+4*b-d+34)%7;
n = (d+e+114)/31;
p = (d+e+114)%31;
}
p++;
QDate d(_lastyear,n,p);
_days[d].append(QObject::tr("Eastersunday","holidays"));
_days[d.addDays(49)].append(QObject::tr("Whitsunday","holidays"));
_days[d.addDays(50)].append(QObject::tr("Whitmonday","holidays"));
_days[d.addDays(39)].append(QObject::tr("Ascension Day","holidays"));
_days[d.addDays(-46)].append(QObject::tr("Ash Wednesday","holidays"));
_days[d.addDays(60)].append(QObject::tr("Corpus Christi","holidays"));
}
-QMap<QDate,QStringList> ChrisHoliday::entries(const QDate&,const QDate&)
+QMap<QDate,QStringList> ChrisHoliday::entries(const QDate&start,const QDate&end)
{
QMap<QDate,QStringList> ret;
+ if (start==end) {
+ ret[start]=entries(start);
+ return ret;
+ }
+ QDate d;
+ int daysto;
+ if (end < start) {
+ d = end;
+ daysto = end.daysTo(start);
+ } else {
+ d = start;
+ daysto = start.daysTo(end);
+ }
+ QStringList temp;
+ for (int i=0;i<daysto;++i) {
+ temp = entries(d.addDays(i));
+ if (temp.count()==0) continue;
+ ret[d.addDays(i)]+=temp;
+ temp.clear();
+ }
+ return ret;
+}
+
+QValueList<EffectiveEvent> ChrisHoliday::events(const QDate&start,const QDate&end)
+{
+ QValueList<EffectiveEvent> ret;
+ QDate d = (start<end?start:end);
+ int daysto = start.daysTo(end);
+ if (daysto < 0) {
+ daysto = end.daysTo(start);
+ }
+
+ QStringList temp;
+ for (int i =0; i<daysto;++i) {
+ temp = entries(d.addDays(i));
+ if (temp.count()==0) {
+ continue;
+ }
+ for (unsigned j=0;j<temp.count();++j) {
+ Event ev;
+ ev.setDescription(temp[j]);
+ ev.setStart(d.addDays(i));
+ ev.setAllDay(true);
+ ret.append(EffectiveEvent(ev,d.addDays(i)));
+ }
+ }
+
return ret;
}
EXPORT_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
@@ -1,33 +1,35 @@
#ifndef __DUMMY_HOLIDAY_H
#define __DUMMY_HOLIDAY_H
#include "hlist.h"
#include <opie2/oholidayplugin.h>
#include <opie2/oholidaypluginif.h>
#include <qmap.h>
class ChrisHoliday:public Opie::Datebook::HolidayPlugin
{
typedef QMap<QDate,QStringList> tDayMap;
public:
ChrisHoliday():Opie::Datebook::HolidayPlugin(){_lastyear=0;}
virtual ~ChrisHoliday(){}
virtual QString description();
virtual QStringList entries(const QDate&);
virtual QStringList entries(unsigned year, unsigned month, unsigned day);
virtual QMap<QDate,QStringList> entries(const QDate&,const QDate&);
+ virtual QValueList<EffectiveEvent> events(const QDate&,const QDate&);
+
protected:
HList _internallist;
unsigned int _lastyear;
tDayMap _days;
void calcit(int year);
void calc_easter();
void calc_christmas();
};
#endif