KCalendarCore

todo.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  SPDX-FileCopyrightText: 2001-2003 Cornelius Schumacher <[email protected]>
5  SPDX-FileCopyrightText: 2009 Allen Winter <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 /**
10  @file
11  This file is part of the API for handling calendar data and
12  defines the Todo class.
13 
14  @brief
15  Provides a To-do in the sense of RFC2445.
16 
17  @author Cornelius Schumacher <[email protected]>
18  @author Allen Winter <[email protected]>
19 */
20 
21 #include "incidence_p.h"
22 #include "todo.h"
23 #include "recurrence.h"
24 #include "utils_p.h"
25 #include "visitor.h"
26 
27 #include "kcalendarcore_debug.h"
28 
29 #include <QTime>
30 
31 using namespace KCalendarCore;
32 
33 /**
34  Private class that helps to provide binary compatibility between releases.
35  @internal
36 */
37 //@cond PRIVATE
38 class KCalendarCore::TodoPrivate : public IncidencePrivate
39 {
40  // Due date of the to-do or its first recurrence if it recurs; invalid() <=> no defined due date.
41  QDateTime mDtDue;
42  QDateTime mDtRecurrence; // next occurrence (for recurring to-dos)
43  QDateTime mCompleted; // to-do completion date (if it has been completed)
44  int mPercentComplete = 0; // to-do percent complete [0,100]
45 
46 public:
47 
48  TodoPrivate() = default;
49  TodoPrivate(const TodoPrivate &other) = default;
50 
51  // Copy IncidencePrivate and IncidenceBasePrivate members,
52  // but default-initialize TodoPrivate members.
53  TodoPrivate(const Incidence &other)
54  : IncidencePrivate(other)
55  {
56  }
57 
58  void init(const TodoPrivate &other);
59 
60  void setDtDue(const QDateTime dd);
61  QDateTime dtDue() const
62  {
63  return mDtDue;
64  }
65 
66  void setDtRecurrence(const QDateTime dr);
67  QDateTime dtRecurrence() const
68  {
69  return mDtRecurrence;
70  }
71 
72  void setCompleted(const QDateTime dc);
73  QDateTime completed() const
74  {
75  return mCompleted;
76  }
77 
78  void setPercentComplete(const int pc);
79  int percentComplete() const
80  {
81  return mPercentComplete;
82  }
83 
84  /**
85  Returns true if the todo got a new date, else false will be returned.
86  */
87  bool recurTodo(Todo *todo);
88 
89  void deserialize(QDataStream &in);
90 
91  bool validStatus(Incidence::Status) override;
92 };
93 
94 void TodoPrivate::setDtDue(const QDateTime dd)
95 {
96  if (!identical(dd, mDtDue)) {
97  mDtDue = dd;
98  mDirtyFields.insert(IncidenceBase::FieldDtDue);
99  }
100 }
101 
102 void TodoPrivate::setDtRecurrence(const QDateTime dr)
103 {
104  if (!identical(dr, mDtRecurrence)) {
105  mDtRecurrence = dr;
106  mDirtyFields.insert(IncidenceBase::FieldRecurrenceId);
107  }
108 }
109 
110 void TodoPrivate::setCompleted(const QDateTime dc)
111 {
112  if (dc != mCompleted) {
113  mCompleted = dc.toUTC();
114  mDirtyFields.insert(IncidenceBase::FieldCompleted);
115  }
116 }
117 
118 void TodoPrivate::setPercentComplete(const int pc)
119 {
120  if (pc != mPercentComplete) {
121  mPercentComplete = pc;
122  mDirtyFields.insert(IncidenceBase::FieldPercentComplete);
123  }
124 }
125 
126 void TodoPrivate::init(const TodoPrivate &other)
127 {
128  mDtDue = other.mDtDue;
129  mDtRecurrence = other.mDtRecurrence;
130  mCompleted = other.mCompleted;
131  mPercentComplete = other.mPercentComplete;
132 }
133 
134 bool TodoPrivate::validStatus(Incidence::Status status)
135 {
136  constexpr unsigned validSet
137  = 1u << Incidence::StatusNone
142  return validSet & (1u << status);
143 }
144 
145 //@endcond
146 
147 Todo::Todo()
148  : Incidence(new TodoPrivate())
149 {
150 }
151 
152 Todo::Todo(const Todo &other)
153  : Incidence(other, new TodoPrivate(*(other.d_func())))
154 {
155 }
156 
157 Todo::Todo(const Incidence &other)
158  : Incidence(other, new TodoPrivate(other))
159 {
160 }
161 
162 Todo::~Todo() = default;
163 
164 Todo *Todo::clone() const
165 {
166  return new Todo(*this);
167 }
168 
170 {
171  Q_D(Todo);
172  if (&other != this) {
173  Incidence::assign(other);
174  const Todo *t = static_cast<const Todo *>(&other);
175  d->init(*(t->d_func()));
176  }
177  return *this;
178 }
179 
180 bool Todo::equals(const IncidenceBase &todo) const
181 {
182  if (!Incidence::equals(todo)) {
183  return false;
184  } else {
185  // If they weren't the same type IncidenceBase::equals would had returned false already
186  const Todo *t = static_cast<const Todo *>(&todo);
187  return identical(dtDue(), t->dtDue())
188  && hasDueDate() == t->hasDueDate()
189  && hasStartDate() == t->hasStartDate() && ((completed() == t->completed()) || (!completed().isValid() && !t->completed().isValid()))
191  }
192 }
193 
195 {
196  return TypeTodo;
197 }
198 
200 {
201  return QByteArrayLiteral("Todo");
202 }
203 
204 void Todo::setDtDue(const QDateTime &dtDue, bool first)
205 {
206  startUpdates();
207 
208  // int diffsecs = d->mDtDue.secsTo(dtDue);
209 
210  /*if (mReadOnly) return;
211  const Alarm::List& alarms = alarms();
212  for (Alarm *alarm = alarms.first(); alarm; alarm = alarms.next()) {
213  if (alarm->enabled()) {
214  alarm->setTime(alarm->time().addSecs(diffsecs));
215  }
216  }*/
217 
218  Q_D(Todo);
219  if (recurs() && !first) {
220  d->setDtRecurrence(dtDue);
221  } else {
222  d->setDtDue(dtDue);
223  }
224 
225  if (recurs() && dtDue.isValid() && (!dtStart().isValid() || dtDue < recurrence()->startDateTime())) {
226  qCDebug(KCALCORE_LOG) << "To-do recurrences are now calculated against DTSTART. Fixing legacy to-do.";
227  setDtStart(dtDue);
228  }
229 
230  /*const Alarm::List& alarms = alarms();
231  for (Alarm *alarm = alarms.first(); alarm; alarm = alarms.next())
232  alarm->setAlarmStart(d->mDtDue);*/
233  endUpdates();
234 }
235 
236 QDateTime Todo::dtDue(bool first) const
237 {
238  if (!hasDueDate()) {
239  return QDateTime();
240  }
241 
242  Q_D(const Todo);
243  const QDateTime start = IncidenceBase::dtStart();
244  if (recurs() && !first && d->dtRecurrence().isValid()) {
245  if (start.isValid()) {
246  // This is the normal case, recurring to-dos have a valid DTSTART.
247  const qint64 duration = start.daysTo(d->dtDue());
248  QDateTime dt = d->dtRecurrence().addDays(duration);
249  dt.setTime(d->dtDue().time());
250  return dt;
251  } else {
252  // This is a legacy case, where recurrence was calculated against DTDUE
253  return d->dtRecurrence();
254  }
255  }
256 
257  return d->dtDue();
258 }
259 
260 bool Todo::hasDueDate() const
261 {
262  Q_D(const Todo);
263  return d->dtDue().isValid();
264 }
265 
266 bool Todo::hasStartDate() const
267 {
268  return IncidenceBase::dtStart().isValid();
269 }
270 
272 {
273  return dtStart(/*first=*/false);
274 }
275 
276 QDateTime Todo::dtStart(bool first) const
277 {
278  if (!hasStartDate()) {
279  return QDateTime();
280  }
281 
282  Q_D(const Todo);
283  if (recurs() && !first && d->dtRecurrence().isValid()) {
284  return d->dtRecurrence();
285  } else {
286  return IncidenceBase::dtStart();
287  }
288 }
289 
290 bool Todo::isCompleted() const
291 {
292  Q_D(const Todo);
293  return d->percentComplete() == 100 || status() == StatusCompleted || hasCompletedDate();
294 }
295 
296 void Todo::setCompleted(bool completed)
297 {
298  update();
299  Q_D(Todo);
300  if (completed) {
301  d->setPercentComplete(100);
302  } else {
303  d->setPercentComplete(0);
304  if (hasCompletedDate()) {
305  d->setCompleted(QDateTime());
306  }
307  }
308  updated();
309 
310  setStatus(completed ? StatusCompleted : StatusNone); // Calls update()/updated().
311 }
312 
314 {
315  Q_D(const Todo);
316  if (hasCompletedDate()) {
317  return d->completed();
318  } else {
319  return QDateTime();
320  }
321 }
322 
323 void Todo::setCompleted(const QDateTime &completed)
324 {
325  Q_D(Todo);
326  if (!d->recurTodo(this)) { // May indirectly call update()/updated().
327  update();
328  d->setPercentComplete(100);
329  d->setCompleted(completed);
330  updated();
331  }
332  if (status() != StatusNone) {
333  setStatus(StatusCompleted); // Calls update()/updated()
334  }
335 }
336 
338 {
339  Q_D(const Todo);
340  return d->completed().isValid();
341 }
342 
344 {
345  Q_D(const Todo);
346  return d->percentComplete();
347 }
348 
349 void Todo::setPercentComplete(int percent)
350 {
351  if (percent > 100) {
352  percent = 100;
353  } else if (percent < 0) {
354  percent = 0;
355  }
356 
357  update();
358  Q_D(Todo);
359  d->setPercentComplete(percent);
360  if (percent != 100) {
361  d->setCompleted(QDateTime());
362  }
363  updated();
364  if (percent != 100 && status() == Incidence::StatusCompleted) {
365  setStatus(Incidence::StatusNone); // Calls update()/updated().
366  }
367 }
368 
369 bool Todo::isInProgress(bool first) const
370 {
371  if (isOverdue()) {
372  return false;
373  }
374 
375  Q_D(const Todo);
376  if (d->percentComplete() > 0) {
377  return true;
378  }
379 
380  if (hasStartDate() && hasDueDate()) {
381  if (allDay()) {
382  QDate currDate = QDate::currentDate();
383  if (dtStart(first).date() <= currDate && currDate < dtDue(first).date()) {
384  return true;
385  }
386  } else {
388  if (dtStart(first) <= currDate && currDate < dtDue(first)) {
389  return true;
390  }
391  }
392  }
393 
394  return false;
395 }
396 
397 bool Todo::isOpenEnded() const
398 {
399  if (!hasDueDate() && !isCompleted()) {
400  return true;
401  }
402  return false;
403 }
404 
405 bool Todo::isNotStarted(bool first) const
406 {
407  Q_D(const Todo);
408  if (d->percentComplete() > 0) {
409  return false;
410  }
411 
412  if (!hasStartDate()) {
413  return false;
414  }
415 
416  if (allDay()) {
417  if (dtStart(first).date() >= QDate::currentDate()) {
418  return false;
419  }
420  } else {
421  if (dtStart(first) >= QDateTime::currentDateTimeUtc()) {
422  return false;
423  }
424  }
425  return true;
426 }
427 
428 void Todo::shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone)
429 {
430  Q_D(Todo);
431  Incidence::shiftTimes(oldZone, newZone);
432  auto dt = d->dtDue().toTimeZone(oldZone);
433  dt.setTimeZone(newZone);
434  d->setDtDue(dt);
435  if (recurs()) {
436  auto dr = d->dtRecurrence().toTimeZone(oldZone);
437  dr.setTimeZone(newZone);
438  d->setDtRecurrence(dr);
439  }
440  if (hasCompletedDate()) {
441  auto dc = d->completed().toTimeZone(oldZone);
442  dc.setTimeZone(newZone);
443  d->setCompleted(dc);
444  }
445 }
446 
448 {
449  Q_D(Todo);
450  d->setDtRecurrence(dt);
451 }
452 
454 {
455  Q_D(const Todo);
456  auto dt = d->dtRecurrence();
457  if (!dt.isValid()) {
458  dt = IncidenceBase::dtStart();
459  }
460  if (!dt.isValid()) {
461  dt = d->dtDue();
462  }
463  return dt;
464 }
465 
466 bool Todo::recursOn(const QDate &date, const QTimeZone &timeZone) const
467 {
468  Q_D(const Todo);
469  QDate today = QDate::currentDate();
470  return Incidence::recursOn(date, timeZone) && !(date < today && d->dtRecurrence().date() < today && d->dtRecurrence() > recurrence()->startDateTime());
471 }
472 
473 bool Todo::isOverdue() const
474 {
475  if (!dtDue().isValid()) {
476  return false; // if it's never due, it can't be overdue
477  }
478 
479  const bool inPast = allDay() ? dtDue().date() < QDate::currentDate() : dtDue() < QDateTime::currentDateTimeUtc();
480 
481  return inPast && !isCompleted();
482 }
483 
484 void Todo::setAllDay(bool allday)
485 {
486  if (allday != allDay() && !mReadOnly) {
487  if (hasDueDate()) {
489  }
490  Incidence::setAllDay(allday);
491  }
492 }
493 
494 //@cond PRIVATE
495 bool TodoPrivate::recurTodo(Todo *todo)
496 {
497  if (todo && todo->recurs()) {
498  Recurrence *r = todo->recurrence();
499  const QDateTime recurrenceEndDateTime = r->endDateTime();
500  QDateTime nextOccurrenceDateTime = r->getNextDateTime(todo->dtStart());
501 
502  if ((r->duration() == -1 || (nextOccurrenceDateTime.isValid() && recurrenceEndDateTime.isValid() && nextOccurrenceDateTime <= recurrenceEndDateTime))) {
503  // We convert to the same timeSpec so we get the correct .date()
504  const auto rightNow = QDateTime::currentDateTimeUtc().toTimeZone(nextOccurrenceDateTime.timeZone());
505  const bool isDateOnly = todo->allDay();
506 
507  /* Now we search for the occurrence that's _after_ the currentUtcDateTime, or
508  * if it's dateOnly, the occurrrence that's _during or after today_.
509  * The reason we use "<" for date only, but "<=" for occurrences with time is that
510  * if it's date only, the user can still complete that occurrence today, so that's
511  * the current occurrence that needs completing.
512  */
513  while (!todo->recursAt(nextOccurrenceDateTime) || (!isDateOnly && nextOccurrenceDateTime <= rightNow)
514  || (isDateOnly && nextOccurrenceDateTime.date() < rightNow.date())) {
515  if (!nextOccurrenceDateTime.isValid() || (nextOccurrenceDateTime > recurrenceEndDateTime && r->duration() != -1)) {
516  return false;
517  }
518  nextOccurrenceDateTime = r->getNextDateTime(nextOccurrenceDateTime);
519  }
520 
521  todo->setDtRecurrence(nextOccurrenceDateTime);
522  todo->setCompleted(false);
523  todo->setRevision(todo->revision() + 1);
524 
525  return true;
526  }
527  }
528 
529  return false;
530 }
531 //@endcond
532 
533 bool Todo::accept(Visitor &v, const IncidenceBase::Ptr &incidence)
534 {
535  return v.visit(incidence.staticCast<Todo>());
536 }
537 
539 {
540  switch (role) {
542  return dtStart();
543  case RoleAlarmEndOffset:
544  return dtDue();
545  case RoleSort:
546  // Sorting to-dos first compares dtDue, then dtStart if
547  // dtDue doesn't exist
548  return hasDueDate() ? dtDue() : dtStart();
549  case RoleCalendarHashing:
550  return dtDue();
551  case RoleStartTimeZone:
552  return dtStart();
553  case RoleEndTimeZone:
554  return dtDue();
555  case RoleEndRecurrenceBase:
556  return dtDue();
557  case RoleDisplayStart:
558  case RoleDisplayEnd:
559  return dtDue().isValid() ? dtDue() : dtStart();
560  case RoleAlarm:
561  if (alarms().isEmpty()) {
562  return QDateTime();
563  } else {
564  Alarm::Ptr alarm = alarms().at(0);
565  if (alarm->hasStartOffset() && hasStartDate()) {
566  return dtStart();
567  } else if (alarm->hasEndOffset() && hasDueDate()) {
568  return dtDue();
569  } else {
570  // The application shouldn't add alarms on to-dos without dates.
571  return QDateTime();
572  }
573  }
574  case RoleRecurrenceStart:
575  if (dtStart().isValid()) {
576  return dtStart();
577  }
578  return dtDue(); // For the sake of backwards compatibility
579  // where we calculated recurrences based on dtDue
580  case RoleEnd:
581  return dtDue();
582  default:
583  return QDateTime();
584  }
585 }
586 
587 void Todo::setDateTime(const QDateTime &dateTime, DateTimeRole role)
588 {
589  switch (role) {
590  case RoleDnD:
592  break;
593  case RoleEnd:
594  setDtDue(dateTime, true);
595  break;
596  default:
597  qCDebug(KCALCORE_LOG) << "Unhandled role" << role;
598  }
599 }
600 
601 void Todo::virtual_hook(VirtualHook id, void *data)
602 {
603  Q_UNUSED(id);
604  Q_UNUSED(data);
605 }
606 
608 {
609  return Todo::todoMimeType();
610 }
611 
613 {
614  return QLatin1String("application/x-vnd.akonadi.calendar.todo");
615 }
616 
617 QLatin1String Todo::iconName(const QDateTime &recurrenceId) const
618 {
619  const bool usesCompletedTaskPixmap = isCompleted() || (recurs() && recurrenceId.isValid() && (recurrenceId < dtStart(/*first=*/false)));
620 
621  if (usesCompletedTaskPixmap) {
622  return QLatin1String("task-complete");
623  } else {
624  return QLatin1String("view-calendar-tasks");
625  }
626 }
627 
628 void Todo::serialize(QDataStream &out) const
629 {
630  Q_D(const Todo);
632  serializeQDateTimeAsKDateTime(out, d->dtDue());
633  serializeQDateTimeAsKDateTime(out, d->dtRecurrence());
634  serializeQDateTimeAsKDateTime(out, d->completed());
635  out << d->percentComplete();
636 }
637 
638 void TodoPrivate::deserialize(QDataStream &in)
639 {
640  deserializeKDateTimeAsQDateTime(in, mDtDue);
641  deserializeKDateTimeAsQDateTime(in, mDtRecurrence);
642  deserializeKDateTimeAsQDateTime(in, mCompleted);
643  in >> mPercentComplete;
644 }
645 
646 void Todo::deserialize(QDataStream &in)
647 {
648  Q_D(Todo);
650  d->deserialize(in);
651 }
652 
654 {
655  return true;
656 }
@ FieldDtDue
Field representing the DUE component.
void setPercentComplete(int percent)
Sets what percentage of the to-do is completed.
Definition: todo.cpp:349
QByteArray typeStr() const override
Prints the type of incidence as a string.
Status
The different types of overall incidence status or confirmation.
Definition: incidence.h:84
void serialize(QDataStream &out) const override
Sub-type specific serialization.
Definition: incidence.cpp:1207
void virtual_hook(VirtualHook id, void *data) override
Standard trick to add virtuals later.
Definition: todo.cpp:601
void setDtDue(const QDateTime &dtDue, bool first=false)
Sets due date and time.
~Todo() override
Destroys a to-do.
bool hasStartDate() const
Returns if the todo has a start datetime.
Definition: todo.cpp:266
QTimeZone timeZone() const const
@ RoleDisplayEnd
Role used for display purposes, represents the end boundary if an incidence supports dtEnd.
virtual bool visit(const Event::Ptr &event)
Reimplement this function in your concrete subclass of IncidenceBase::Visitor to perform actions on a...
Definition: visitor.cpp:25
bool recurs() const
Returns whether the event recurs at all.
Definition: incidence.cpp:607
@ StatusNone
No status.
Definition: incidence.h:85
QDateTime dateTime(DateTimeRole role) const override
Returns a date/time corresponding to the specified DateTimeRole.
Definition: todo.cpp:538
DateTimeRole
The different types of incidence date/times roles.
QDateTime dtStart() const override
Definition: todo.cpp:271
@ RoleStartTimeZone
Role for determining an incidence's starting timezone.
Recurrence * recurrence() const
Returns the recurrence rule associated with this incidence.
Definition: incidence.cpp:576
@ StatusInProcess
to-do in process
Definition: incidence.h:91
@ FieldPercentComplete
Field representing the PERCENT-COMPLETE component.
static QLatin1String todoMimeType()
Returns the Akonadi specific sub MIME type of a KCalendarCore::Todo.
Definition: todo.cpp:612
QDateTime endDateTime() const
Returns the date/time of the last recurrence.
Definition: recurrence.cpp:420
QCA_EXPORT void init()
QDateTime addDays(qint64 ndays) const const
Namespace for all KCalendarCore types.
Definition: alarm.h:36
IncidenceType type() const override
Returns the incidence type.
void setAllDay(bool allDay) override
Definition: todo.cpp:484
void update()
Call this to notify the observers after the IncidenceBase object will be changed.
int percentComplete() const
Returns what percentage of the to-do is completed.
Definition: todo.cpp:343
@ RoleAlarm
Role for determining the date/time of the first alarm.
KCALENDARCORE_EXPORT bool identical(QDateTime, QDateTime)
Compare two QDateTimes for extended equality.
bool equals(const IncidenceBase &todo) const override
Compare this with todo for equality.
void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone) override
Shift the times of the incidence so that they appear at the same clock time as before but in a new ti...
Definition: todo.cpp:428
void setDateTime(const QDateTime &dateTime, DateTimeRole role) override
Sets the date/time corresponding to the specified DateTimeRole.
Definition: todo.cpp:587
@ RoleAlarmStartOffset
Role for an incidence alarm's starting offset date/time.
IncidenceBase & assign(const IncidenceBase &other) override
Provides polymorfic assignment.
@ RoleSort
Role for an incidence's date/time used when sorting.
QDateTime currentDateTimeUtc()
void startUpdates()
Call this when a group of updates is going to be made.
Provides the abstract base class common to non-FreeBusy (Events, To-dos, Journals) calendar component...
Definition: incidence.h:59
@ TypeTodo
Type is a to-do.
void setAllDay(bool allDay) override
Definition: incidence.cpp:323
bool isInProgress(bool first) const
Returns true, if the to-do is in-progress (started, or >0% completed); otherwise return false.
Definition: todo.cpp:369
void setDtRecurrence(const QDateTime &dt)
Identify the earliest uncompleted occurrence of a recurring Todo.
Definition: todo.cpp:447
AKONADI_CALENDAR_EXPORT KCalendarCore::Incidence::Ptr incidence(const Akonadi::Item &item)
void setStatus(Status status)
Sets the incidence status to a standard Status value.
Definition: incidence.cpp:820
bool isOpenEnded() const
Returns true, if the to-do is open-ended (no due date); false otherwise.
Definition: todo.cpp:397
Todo * clone() const override
Returns an exact copy of this todo.
QDateTime toTimeZone(const QTimeZone &timeZone) const const
An abstract class that provides a common base for all calendar incidence classes.
Definition: incidencebase.h:98
void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone) override
Shift the times of the incidence so that they appear at the same clock time as before but in a new ti...
Definition: incidence.cpp:385
bool isNotStarted(bool first) const
Returns true, if the to-do has yet to be started (no start date and 0% completed); otherwise return f...
Definition: todo.cpp:405
Provides a To-do in the sense of RFC2445.
Definition: todo.h:33
Q_SCRIPTABLE Q_NOREPLY void start()
@ FieldCompleted
Field representing the COMPLETED component.
void updated()
Call this to notify the observers after the IncidenceBase object has changed.
QDateTime recurrenceId() const override
Returns the incidence recurrenceId.
Definition: incidence.cpp:1127
QDateTime dtDue(bool first=false) const
Returns the todo due datetime.
Definition: todo.cpp:236
const T & at(int i) const const
bool equals(const IncidenceBase &incidence) const override
Compares this with Incidence incidence for equality.
Definition: incidence.cpp:198
@ StatusCompleted
to-do completed
Definition: incidence.h:88
QLatin1String iconName(const QDateTime &recurrenceId={}) const override
Returns the name of the icon that best represents this incidence.
Definition: todo.cpp:617
void deserialize(QDataStream &in) override
Sub-type specific deserialization.
Definition: incidence.cpp:1235
Q_SCRIPTABLE CaptureState status()
@ RoleDisplayStart
Role for display purposes, represents the start boundary of an incidence.
bool hasDueDate() const
Returns if the todo has a due datetime.
Definition: todo.cpp:260
QDate currentDate()
bool recursOn(const QDate &date, const QTimeZone &timeZone) const override
Returns true if the date specified is one on which the to-do will recur.
Definition: todo.cpp:466
@ RoleCalendarHashing
Role for looking up an incidence in a Calendar.
This class provides the interface for a visitor of calendar components.
Definition: visitor.h:30
QDateTime startDateTime(const QVariant &elem)
QDateTime toUTC() const const
QLatin1String mimeType() const override
Returns the Akonadi specific sub MIME type of a KCalendarCore::IncidenceBase item,...
Definition: todo.cpp:607
@ RoleEnd
Role for determining an incidence's dtEnd, will return an invalid QDateTime if the incidence does not...
void setDtStart(const QDateTime &dt) override
Sets the incidence starting date/time.
Definition: incidence.cpp:376
@ StatusCanceled
event or to-do canceled; journal removed
Definition: incidence.h:90
int duration() const
Returns -1 if the event recurs infinitely, 0 if the end date is set, otherwise the total number of re...
Definition: recurrence.cpp:486
QDateTime completed() const
Returns the to-do was completion datetime.
Definition: todo.cpp:313
IncidenceType
The different types of incidences, per RFC2445.
@ FieldRecurrenceId
Field representing the RECURRENCE-ID component.
bool isValid(QStringView ifopt)
This class represents a recurrence rule for a calendar incidence.
Definition: recurrence.h:76
@ RoleEndTimeZone
Role for determining an incidence's ending timezone.
QDate date() const const
bool isValid() const const
@ RoleRecurrenceStart
Role for determining the start of the recurrence.
bool hasCompletedDate() const
Returns if the to-do has a completion datetime.
Definition: todo.cpp:337
IncidenceBase & assign(const IncidenceBase &other) override
Provides polymorfic assignment.
Definition: incidence.cpp:184
@ RoleDnD
Role for determining new start and end dates after a DnD.
QDateTime startDateTime() const
Return the start date/time of the recurrence (Time for all-day recurrences will be 0:00).
Definition: recurrence.cpp:171
bool isCompleted() const
Returns whether the todo is completed or not.
Definition: todo.cpp:290
void endUpdates()
Call this when a group of updates is complete, to notify observers that the instance has changed.
@ RoleAlarmEndOffset
Role for an incidence alarm's ending offset date/time.
QSharedPointer< X > staticCast() const const
@ StatusNeedsAction
to-do needs action
Definition: incidence.h:89
bool mReadOnly
Identifies a read-only incidence.
void setCompleted(bool completed)
Sets completion percentage and status.
Definition: todo.cpp:296
bool supportsGroupwareCommunication() const override
Definition: todo.cpp:653
Todo()
Constructs an empty to-do.
bool isOverdue() const
Returns true if this todo is overdue (e.g.
Definition: todo.cpp:473
void setFieldDirty(IncidenceBase::Field field)
Marks Field field as dirty.
void setTimeZone(const QTimeZone &toZone)
Alarm::List alarms() const
Returns a list of all incidence alarms.
Definition: incidence.cpp:888
AKONADI_CALENDAR_EXPORT KCalendarCore::Todo::Ptr todo(const Akonadi::Item &item)
Duration duration() const
Returns the length of the incidence duration.
void setTime(const QTime &time)
Q_D(Todo)
Private class that helps to provide binary compatibility between releases.
QDateTime getNextDateTime(const QDateTime &preDateTime) const
Returns the start date/time of the earliest recurrence with a start date/time after the specified dat...
QDateTime dtRecurrence() const
Returns an identifier for the earliest uncompleted occurrence of a recurring Todo.
Definition: todo.cpp:453
virtual bool recursOn(const QDate &date, const QTimeZone &timeZone) const
Returns true if the date specified is one on which the event will recur.
Definition: incidence.cpp:617
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 28 2023 03:53:12 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.