37enum DateTimeComparison {
56 Equal = AtStart | Inside | AtEnd,
59 Outside = Before | AtStart | Inside | AtEnd | After,
64 StartsAt = AtStart | Inside | AtEnd | After,
69 EndsAt = Before | AtStart | Inside | AtEnd,
104DateTimeComparison compare(
const QDateTime &dt1,
bool isAllDay1,
const QDateTime &dt2,
bool isAllDay2)
115 start1 = dt1.
toUTC();
116 start2 = dt2.
toUTC();
122 if (isAllDay1 || isAllDay2) {
130 dt.setTime(
QTime(23, 59, 59, 999));
137 dt.setTime(
QTime(23, 59, 59, 999));
155 if (start1 == start2) {
156 return !isAllDay1 ? AtStart
157 : (end1 == end2) ? Equal
158 : (end1 < end2) ? static_cast<DateTimeComparison>(AtStart | Inside)
159 : static_cast<DateTimeComparison>(AtStart | Inside | AtEnd | After);
162 if (start1 < start2) {
163 return (end1 < start2) ? Before
164 : (end1 == end2) ?
static_cast<DateTimeComparison
>(Before | AtStart | Inside | AtEnd)
165 : (end1 == start2) ?
static_cast<DateTimeComparison
>(Before | AtStart)
166 : (end1 < end2) ? static_cast<DateTimeComparison>(Before | AtStart | Inside)
169 return (start1 > end2) ? After
170 : (start1 == end2) ? (end1 == end2 ? AtEnd :
static_cast<DateTimeComparison
>(AtEnd | After))
171 : (end1 == end2) ?
static_cast<DateTimeComparison
>(Inside | AtEnd)
172 : (end1 < end2) ? Inside
173 : static_cast<DateTimeComparison>(Inside | AtEnd | After);
176 return (start1 == start2) ? Equal : (start1 < start2) ? Before : After;
181 DateTimeComparison res = compare(e1->dtStart(), e1->allDay(), e2->dtStart(), e2->allDay());
183 return Events::summaryLessThan(e1, e2);
185 return (res & Before || res & AtStart);
191 DateTimeComparison res = compare(e1->dtStart(), e1->allDay(), e2->dtStart(), e2->allDay());
193 return Events::summaryMoreThan(e1, e2);
195 return (res & After || res & AtEnd);
211 DateTimeComparison res = compare(e1->dtEnd(), e1->allDay(), e2->dtEnd(), e2->allDay());
213 return Events::summaryLessThan(e1, e2);
215 return (res & Before || res & AtStart);
221 DateTimeComparison res = compare(e1->dtEnd(), e1->allDay(), e2->dtEnd(), e2->allDay());
223 return Events::summaryMoreThan(e1, e2);
225 return (res & After || res & AtEnd);
231 DateTimeComparison res = compare(j1->dtStart(), j1->allDay(), j2->dtStart(), j2->allDay());
232 return (res & Before || res & AtStart);
237 DateTimeComparison res = compare(j1->dtStart(), j1->allDay(), j2->dtStart(), j2->allDay());
238 return (res & After || res & AtEnd);
253 DateTimeComparison res = compare(t1->dtStart(), t1->allDay(), t2->dtStart(), t2->allDay());
255 return Todos::summaryLessThan(t1, t2);
257 return (res & Before || res & AtStart);
263 DateTimeComparison res = compare(t1->dtStart(), t1->allDay(), t2->dtStart(), t2->allDay());
265 return Todos::summaryMoreThan(t1, t2);
267 return (res & After || res & AtEnd);
273 if (!t1->hasDueDate() ) {
276 if (!t2->hasDueDate()) {
279 DateTimeComparison res = compare(t1->dtDue(), t1->allDay(), t2->dtDue(), t2->allDay());
281 return Todos::summaryLessThan(t1, t2);
283 return (res & Before || res & AtStart);
289 if (!t2->hasDueDate()) {
292 if (!t1->hasDueDate()) {
295 DateTimeComparison res = compare(t1->dtDue(), t1->allDay(), t2->dtDue(), t2->allDay());
297 return Todos::summaryMoreThan(t1, t2);
299 return (res & After || res & AtEnd);
305 if (t1->priority() < t2->priority()) {
307 }
else if (t1->priority() == t2->priority()) {
308 return Todos::summaryLessThan(t1, t2);
316 if (t1->priority() > t2->priority()) {
318 }
else if (t1->priority() == t2->priority()) {
319 return Todos::summaryMoreThan(t1, t2);
327 if (t1->percentComplete() < t2->percentComplete()) {
329 }
else if (t1->percentComplete() == t2->percentComplete()) {
330 return Todos::summaryLessThan(t1, t2);
338 if (t1->percentComplete() > t2->percentComplete()) {
340 }
else if (t1->percentComplete() == t2->percentComplete()) {
341 return Todos::summaryMoreThan(t1, t2);
359 DateTimeComparison res = compare(t1->created(), t1->allDay(), t2->created(), t2->allDay());
361 return Todos::summaryLessThan(t1, t2);
363 return (res & Before || res & AtStart);
369 DateTimeComparison res = compare(t1->created(), t1->allDay(), t2->created(), t2->allDay());
371 return Todos::summaryMoreThan(t1, t2);
373 return (res & After || res & AtEnd);
379 DateTimeComparison res = compare(i1->dateTime(Incidence::RoleSort), i1->allDay(), i2->dateTime(Incidence::RoleSort), i2->allDay());
381 return Incidences::summaryLessThan(i1, i2);
383 return (res & Before || res & AtStart);
389 DateTimeComparison res = compare(i1->dateTime(Incidence::RoleSort), i1->allDay(), i2->dateTime(Incidence::RoleSort), i2->allDay());
391 return Incidences::summaryMoreThan(i1, i2);
393 return (res & After || res & AtEnd);
399 DateTimeComparison res = compare(i1->created(), i1->allDay(), i2->created(), i2->allDay());
401 return Incidences::summaryLessThan(i1, i2);
403 return (res & Before || res & AtStart);
409 DateTimeComparison res = compare(i1->created(), i1->allDay(), i2->created(), i2->allDay());
411 return Incidences::summaryMoreThan(i1, i2);
413 return (res & After || res & AtEnd);
431 return Incidences::summaryLessThan(i1, i2);
441 return Incidences::summaryMoreThan(i1, i2);
Namespace for all KCalendarCore types.
int offsetFromUtc() const const
Qt::TimeSpec timeSpec() const const
QTimeZone timeZone() const const
QDateTime toUTC() const const
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)