From afee05f4b4c1e8dab8463e3423fcfc8f9d45aa8b Mon Sep 17 00:00:00 2001 From: alwin Date: Thu, 17 Mar 2005 13:50:01 +0000 Subject: inserted last missing stuff --- 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,6 +1,7 @@ #include "birthday.h" #include +#include #include @@ -62,9 +63,96 @@ QStringList Birthday::entries(unsigned year, unsigned month, unsigned day) return entries(QDate(year,month,day)); } -QMap Birthday::entries(const QDate&,const QDate&) +QMap Birthday::_entries(const QDate&start,const QDate&end,bool anniversary) +{ + QMap ret; + QDate s = (starthasQuerySettings(Opie::OPimContactAccess::DateDiff ) ){ + Opie::OPimContact querybirthdays; + QString pre; + if (anniversary) { + querybirthdays.setAnniversary(e); + } else { + querybirthdays.setBirthday(e); + } + QMap collector; + QMap::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 Birthday::entries(const QDate&start,const QDate&end) { QMap ret; + QMap collector; + QMap::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 Birthday::events(const QDate&start,const QDate&end) +{ + QValueList ret; + QMap collector; + QMap::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; } 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 @@ -19,10 +19,12 @@ public: virtual QStringList entries(const QDate&); virtual QStringList entries(unsigned year, unsigned month, unsigned day); virtual QMap entries(const QDate&,const QDate&); + virtual QValueList events(const QDate&,const QDate&); protected: Opie::OPimContactAccess * m_contactdb; Opie::OPimContactAccess::List m_list; Opie::OPimContactAccess::List::Iterator m_it; + virtual QMap _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,6 +1,7 @@ #include "chrisholiday.h" #include +#include QString ChrisHoliday::description() { @@ -87,9 +88,56 @@ void ChrisHoliday::calc_easter() _days[d.addDays(60)].append(QObject::tr("Corpus Christi","holidays")); } -QMap ChrisHoliday::entries(const QDate&,const QDate&) +QMap ChrisHoliday::entries(const QDate&start,const QDate&end) { QMap 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 ChrisHoliday::events(const QDate&start,const QDate&end) +{ + QValueList ret; + QDate d = (start entries(const QDate&,const QDate&); + virtual QValueList events(const QDate&,const QDate&); + protected: HList _internallist; unsigned int _lastyear; -- cgit v0.9.0.2