Changeset View
Changeset View
Standalone View
Standalone View
src/period.cpp
Show All 30 Lines | |||||
31 | */ | 31 | */ | ||
32 | 32 | | |||
33 | #include "period.h" | 33 | #include "period.h" | ||
34 | #include "utils.h" | 34 | #include "utils.h" | ||
35 | 35 | | |||
36 | #include <QHash> | 36 | #include <QHash> | ||
37 | #include <QTimeZone> | 37 | #include <QTimeZone> | ||
38 | 38 | | |||
39 | using namespace KCalCore; | 39 | using namespace KCalendarCore; | ||
40 | 40 | | |||
41 | //@cond PRIVATE | 41 | //@cond PRIVATE | ||
42 | class Q_DECL_HIDDEN KCalCore::Period::Private | 42 | class Q_DECL_HIDDEN KCalendarCore::Period::Private | ||
43 | { | 43 | { | ||
44 | public: | 44 | public: | ||
45 | Private() : mHasDuration(false), mDailyDuration(false) {} | 45 | Private() : mHasDuration(false), mDailyDuration(false) {} | ||
46 | Private(const QDateTime &start, const QDateTime &end, bool hasDuration) | 46 | Private(const QDateTime &start, const QDateTime &end, bool hasDuration) | ||
47 | : mStart(start), | 47 | : mStart(start), | ||
48 | mEnd(end), | 48 | mEnd(end), | ||
49 | mHasDuration(hasDuration), | 49 | mHasDuration(hasDuration), | ||
50 | mDailyDuration(false) | 50 | mDailyDuration(false) | ||
51 | {} | 51 | {} | ||
52 | QDateTime mStart; // period starting date/time | 52 | QDateTime mStart; // period starting date/time | ||
53 | QDateTime mEnd; // period ending date/time | 53 | QDateTime mEnd; // period ending date/time | ||
54 | bool mHasDuration = false; // does period have a duration? | 54 | bool mHasDuration = false; // does period have a duration? | ||
55 | bool mDailyDuration = false; // duration is defined as number of days, not seconds | 55 | bool mDailyDuration = false; // duration is defined as number of days, not seconds | ||
56 | }; | 56 | }; | ||
57 | //@endcond | 57 | //@endcond | ||
58 | 58 | | |||
59 | Period::Period() : d(new KCalCore::Period::Private()) | 59 | Period::Period() : d(new KCalendarCore::Period::Private()) | ||
60 | { | 60 | { | ||
61 | } | 61 | } | ||
62 | 62 | | |||
63 | Period::Period(const QDateTime &start, const QDateTime &end) | 63 | Period::Period(const QDateTime &start, const QDateTime &end) | ||
64 | : d(new KCalCore::Period::Private(start, end, false)) | 64 | : d(new KCalendarCore::Period::Private(start, end, false)) | ||
65 | { | 65 | { | ||
66 | } | 66 | } | ||
67 | 67 | | |||
68 | Period::Period(const QDateTime &start, const Duration &duration) | 68 | Period::Period(const QDateTime &start, const Duration &duration) | ||
69 | : d(new KCalCore::Period::Private(start, duration.end(start), true)) | 69 | : d(new KCalendarCore::Period::Private(start, duration.end(start), true)) | ||
70 | { | 70 | { | ||
71 | d->mDailyDuration = duration.isDaily(); | 71 | d->mDailyDuration = duration.isDaily(); | ||
72 | } | 72 | } | ||
73 | 73 | | |||
74 | Period::Period(const Period &period) | 74 | Period::Period(const Period &period) | ||
75 | : d(new KCalCore::Period::Private(*period.d)) | 75 | : d(new KCalendarCore::Period::Private(*period.d)) | ||
76 | { | 76 | { | ||
77 | } | 77 | } | ||
78 | 78 | | |||
79 | Period::~Period() | 79 | Period::~Period() | ||
80 | { | 80 | { | ||
81 | delete d; | 81 | delete d; | ||
82 | } | 82 | } | ||
83 | 83 | | |||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 141 | { | |||
142 | if (oldZone.isValid() && newZone.isValid() && oldZone != newZone) { | 142 | if (oldZone.isValid() && newZone.isValid() && oldZone != newZone) { | ||
143 | d->mStart = d->mStart.toTimeZone(oldZone); | 143 | d->mStart = d->mStart.toTimeZone(oldZone); | ||
144 | d->mStart.setTimeZone(newZone); | 144 | d->mStart.setTimeZone(newZone); | ||
145 | d->mEnd = d->mEnd.toTimeZone(oldZone); | 145 | d->mEnd = d->mEnd.toTimeZone(oldZone); | ||
146 | d->mEnd.setTimeZone(newZone); | 146 | d->mEnd.setTimeZone(newZone); | ||
147 | } | 147 | } | ||
148 | } | 148 | } | ||
149 | 149 | | |||
150 | QDataStream &KCalCore::operator<<(QDataStream &stream, const KCalCore::Period &period) | 150 | QDataStream &KCalendarCore::operator<<(QDataStream &stream, const KCalendarCore::Period &period) | ||
151 | { | 151 | { | ||
152 | serializeQDateTimeAsKDateTime(stream, period.d->mStart); | 152 | serializeQDateTimeAsKDateTime(stream, period.d->mStart); | ||
153 | serializeQDateTimeAsKDateTime(stream, period.d->mEnd); | 153 | serializeQDateTimeAsKDateTime(stream, period.d->mEnd); | ||
154 | return stream << period.d->mDailyDuration | 154 | return stream << period.d->mDailyDuration | ||
155 | << period.d->mHasDuration; | 155 | << period.d->mHasDuration; | ||
156 | } | 156 | } | ||
157 | 157 | | |||
158 | QDataStream &KCalCore::operator>>(QDataStream &stream, KCalCore::Period &period) | 158 | QDataStream &KCalendarCore::operator>>(QDataStream &stream, KCalendarCore::Period &period) | ||
159 | { | 159 | { | ||
160 | deserializeKDateTimeAsQDateTime(stream, period.d->mStart); | 160 | deserializeKDateTimeAsQDateTime(stream, period.d->mStart); | ||
161 | deserializeKDateTimeAsQDateTime(stream, period.d->mEnd); | 161 | deserializeKDateTimeAsQDateTime(stream, period.d->mEnd); | ||
162 | stream >> period.d->mDailyDuration | 162 | stream >> period.d->mDailyDuration | ||
163 | >> period.d->mHasDuration; | 163 | >> period.d->mHasDuration; | ||
164 | return stream; | 164 | return stream; | ||
165 | } | 165 | } | ||
166 | 166 | | |||
167 | uint KCalCore::qHash(const KCalCore::Period &key) | 167 | uint KCalendarCore::qHash(const KCalendarCore::Period &key) | ||
168 | { | 168 | { | ||
169 | if (key.hasDuration()) { | 169 | if (key.hasDuration()) { | ||
170 | return qHash(key.duration()); | 170 | return qHash(key.duration()); | ||
171 | } else { | 171 | } else { | ||
172 | return qHash(key.start().toString() + key.end().toString()); | 172 | return qHash(key.start().toString() + key.end().toString()); | ||
173 | } | 173 | } | ||
174 | } | 174 | } |