1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtOrganizer module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#include "qdeclarativeorganizeritem_p.h"
35
36#include <QtQml/qqmlengine.h>
37
38#include "qdeclarativeorganizermodel_p.h"
39
40QTORGANIZER_USE_NAMESPACE
41
42QT_BEGIN_NAMESPACE
43
44/*!
45 \qmltype OrganizerItem
46 \instantiates QDeclarativeOrganizerItem
47 \brief The OrganizerItem element represents the in-memory version of a organizer item.
48 \inqmlmodule QtOrganizer
49 \ingroup qml-organizer-main
50
51 A OrganizerItem has a number of mandatory details. Different subclasses of OrganizerItem
52 (i.e., Event, EventOccurrence, Journal, Todo, TodoOccurrence, Note) may have more mandatory details.
53
54 Most frequently-used details can also be accessed through convenient properties, e.g. displayLabel,
55 while all details can be accessed through detail(), details(), saveDetail(), among others.
56
57 \sa Event, EventOccurrence, Journal, Todo, TodoOccurrence, Note, {QOrganizerManager}, {QOrganizerItem}
58 */
59
60/*!
61 \qmlsignal OrganizerItem::onItemChanged()
62
63 This signal is emitted, when any of the OrganizerItem's or child element's (like Event, Todo etc) properties have been changed.
64 */
65
66/*!
67 \internal
68 */
69QDeclarativeOrganizerItem::QDeclarativeOrganizerItem(QObject *parent)
70 : QObject(parent)
71 , m_modified(false)
72{
73}
74
75/*!
76 \internal
77 */
78QDeclarativeOrganizerItem::~QDeclarativeOrganizerItem()
79{
80 clearDetails();
81}
82
83// basic information
84/*!
85 \qmlproperty bool OrganizerItem::modified
86
87 This property holds the dirty flag of the OrganizerItem object.
88
89 \sa save
90 */
91bool QDeclarativeOrganizerItem::modified() const
92{
93 return m_modified;
94}
95
96/*!
97 \qmlproperty enum OrganizerItem::itemType
98
99 This property holds the type of the OrganizerItem object.
100 */
101QDeclarativeOrganizerItemType::ItemType QDeclarativeOrganizerItem::itemType() const
102{
103 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
104 if (QDeclarativeOrganizerItemDetail::ItemType == detail->type())
105 return static_cast<QDeclarativeOrganizerItemType *>(detail)->itemType();
106 }
107 return QDeclarativeOrganizerItemType::Undefined;
108}
109
110/*!
111 \qmlproperty list<Detail> OrganizerItem::itemDetails
112
113 This property holds the details of the OrganizerItem object.
114 */
115QQmlListProperty<QDeclarativeOrganizerItemDetail> QDeclarativeOrganizerItem::itemDetails()
116{
117 return QQmlListProperty<QDeclarativeOrganizerItemDetail>(this, 0,
118 &QDeclarativeOrganizerItem::_q_detail_append,
119 &QDeclarativeOrganizerItem::_q_detail_count,
120 &QDeclarativeOrganizerItem::_q_detail_at,
121 &QDeclarativeOrganizerItem::_q_detail_clear);
122}
123
124/*!
125 \qmlproperty string OrganizerItem::itemId
126
127 This property holds the id of the OrganizerItem object.
128 */
129QString QDeclarativeOrganizerItem::itemId() const
130{
131 return m_id.toString();
132}
133
134/*!
135 \qmlproperty string OrganizerItem::manager
136
137 This property holds the manager uri which the \l OrganizerItem object comes from.
138 */
139QString QDeclarativeOrganizerItem::manager() const
140{
141 return m_id.managerUri();
142}
143
144/*!
145 \qmlproperty string OrganizerItem::collectionId
146
147 This property holds the id of collection where the item belongs to.
148 */
149QString QDeclarativeOrganizerItem::collectionId() const
150{
151 return m_collectionId.toString();
152}
153
154void QDeclarativeOrganizerItem::setCollectionId(const QString &collectionId)
155{
156 QOrganizerCollectionId newCollectionId(QOrganizerCollectionId::fromString(idString: collectionId));
157
158 // in case invalid collectionId-string, fromString() will return default collectionId-string
159 // instead of the intended collectionId-string
160 if (newCollectionId.toString() == collectionId && m_collectionId.toString() != collectionId) {
161 m_collectionId = newCollectionId;
162 m_modified = true;
163 emit itemChanged();
164 }
165}
166
167// convenient access to most frequently used details
168/*!
169 \qmlproperty string OrganizerItem::description
170
171 This property holds the description text of the organizer item.
172 */
173QString QDeclarativeOrganizerItem::description() const
174{
175 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
176 if (QDeclarativeOrganizerItemDetail::Description == detail->type())
177 return static_cast<QDeclarativeOrganizerItemDescription *>(detail)->description();
178 }
179 return QString::null;
180}
181
182void QDeclarativeOrganizerItem::setDescription(const QString &description)
183{
184 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
185 if (QDeclarativeOrganizerItemDetail::Description == detail->type()) {
186 QDeclarativeOrganizerItemDescription *desc = static_cast<QDeclarativeOrganizerItemDescription *>(detail);
187 if (desc->description() != description) {
188 desc->setDescription(description);
189 m_modified = true;
190 emit itemChanged();
191 }
192 return;
193 }
194 }
195
196 QDeclarativeOrganizerItemDescription *desc = new QDeclarativeOrganizerItemDescription(this);
197 desc->setDescription(description);
198 m_details.append(t: desc);
199 m_modified = true;
200 emit itemChanged();
201}
202
203/*!
204 \qmlproperty string OrganizerItem::displayLabel
205
206 This property holds the display label of the organizer item.
207 */
208QString QDeclarativeOrganizerItem::displayLabel() const
209{
210 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
211 if (QDeclarativeOrganizerItemDetail::DisplayLabel == detail->type())
212 return static_cast<QDeclarativeOrganizerItemDisplayLabel *>(detail)->label();
213 }
214 return QString::null;
215}
216
217void QDeclarativeOrganizerItem::setDisplayLabel(const QString &label)
218{
219 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
220 if (QDeclarativeOrganizerItemDetail::DisplayLabel == detail->type()) {
221 QDeclarativeOrganizerItemDisplayLabel *displayLabel = static_cast<QDeclarativeOrganizerItemDisplayLabel *>(detail);
222 if (displayLabel->label() != label) {
223 displayLabel->setLabel(label);
224 m_modified = true;
225 emit itemChanged();
226 }
227 return;
228 }
229 }
230
231 QDeclarativeOrganizerItemDisplayLabel *displayLabel = new QDeclarativeOrganizerItemDisplayLabel(this);
232 displayLabel->setLabel(label);
233 m_details.append(t: displayLabel);
234 m_modified = true;
235 emit itemChanged();
236}
237
238/*!
239 \qmlproperty string OrganizerItem::guid
240
241 This property holds the GUID string of the organizer item.
242 */
243QString QDeclarativeOrganizerItem::guid() const
244{
245 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
246 if (QDeclarativeOrganizerItemDetail::Guid == detail->type())
247 return static_cast<QDeclarativeOrganizerItemGuid *>(detail)->guid();
248 }
249 return QString::null;
250}
251
252void QDeclarativeOrganizerItem::setGuid(const QString &guid)
253{
254 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
255 if (QDeclarativeOrganizerItemDetail::Guid == detail->type()) {
256 QDeclarativeOrganizerItemGuid *itemGuid = static_cast<QDeclarativeOrganizerItemGuid *>(detail);
257 if (itemGuid->guid() != guid) {
258 itemGuid->setGuid(guid);
259 m_modified = true;
260 emit itemChanged();
261 }
262 return;
263 }
264 }
265
266 QDeclarativeOrganizerItemGuid *itemGuid = new QDeclarativeOrganizerItemGuid(this);
267 itemGuid->setGuid(guid);
268 m_details.append(t: itemGuid);
269 m_modified = true;
270 emit itemChanged();
271}
272
273// functions
274/*!
275 \qmlmethod Detail OrganizerItem::detail(type)
276
277 Returns the first detail stored in the organizer item with the given \a type.
278
279 \sa Detail::type
280 */
281QDeclarativeOrganizerItemDetail *QDeclarativeOrganizerItem::detail(int type)
282{
283 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
284 if (type == detail->type()) {
285 QDeclarativeOrganizerItemDetail *itemDetail = QDeclarativeOrganizerItemDetailFactory::createItemDetail(type: detail->type());
286 QQmlEngine::setObjectOwnership(itemDetail, QQmlEngine::JavaScriptOwnership);
287 itemDetail->setDetail(detail->detail());
288 return itemDetail;
289 }
290 }
291 return 0;
292}
293
294/*!
295 \qmlmethod list<Detail> OrganizerItem::details(type)
296
297 Returns all the details stored in the organizer item with the given \a type.
298
299 \sa Detail::type
300 */
301QVariantList QDeclarativeOrganizerItem::details(int type)
302{
303 QVariantList list;
304 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
305 if (type == detail->type()) {
306 QDeclarativeOrganizerItemDetail *itemDetail = QDeclarativeOrganizerItemDetailFactory::createItemDetail(type: detail->type());
307 QQmlEngine::setObjectOwnership(itemDetail, QQmlEngine::JavaScriptOwnership);
308 itemDetail->setDetail(detail->detail());
309 list.append(t: QVariant::fromValue(value: (QObject*)itemDetail));
310 }
311 }
312 return list;
313}
314
315/*!
316 \qmlmethod void OrganizerItem::setDetail(detail)
317
318 Saves the given \a detail in the organizer item, and sets its id.
319 */
320void QDeclarativeOrganizerItem::setDetail(QDeclarativeOrganizerItemDetail *detail)
321{
322 if (_q_setDetail(detail))
323 emit itemChanged();
324}
325
326/*!
327 \qmlmethod void OrganizerItem::removeDetail(detail)
328
329 Removes given \a detail from the organizer item.
330 */
331void QDeclarativeOrganizerItem::removeDetail(QDeclarativeOrganizerItemDetail *detail)
332{
333 if (_q_removeDetail(detail))
334 emit itemChanged();
335}
336
337/*!
338 \qmlmethod OrganizerItem::clearDetails()
339
340 Removes all details from the organizer item.
341
342 \sa removeDetail
343 */
344void QDeclarativeOrganizerItem::clearDetails()
345{
346 if (_q_clearDetails())
347 emit itemChanged();
348}
349
350/*!
351 \qmlmethod OrganizerItem::save()
352
353 Saves this OrganizerItem if the item has been modified.
354
355 \sa modified
356 */
357void QDeclarativeOrganizerItem::save()
358{
359 if (m_modified) {
360 QDeclarativeOrganizerModel *model = qobject_cast<QDeclarativeOrganizerModel *>(object: parent());
361 if (model) {
362 model->saveItem(item: this);
363 m_modified = false;
364 }
365 }
366}
367
368// non-QML APIs, used by model only
369/*!
370 \internal
371 */
372void QDeclarativeOrganizerItem::setItem(const QOrganizerItem &item)
373{
374 m_id = item.id();
375 m_collectionId = item.collectionId();
376
377 foreach (QDeclarativeOrganizerItemDetail *detail, m_details)
378 delete detail;
379 m_details.clear();
380 QList<QOrganizerItemDetail> details(item.details());
381 foreach (const QOrganizerItemDetail &detail, details) {
382 QDeclarativeOrganizerItemDetail *itemDetail = QDeclarativeOrganizerItemDetailFactory::createItemDetail(type: static_cast<QDeclarativeOrganizerItemDetail::DetailType>(detail.type()));
383 itemDetail->setDetail(detail);
384 m_details.append(t: itemDetail);
385 }
386
387 m_modified = false;
388 emit itemChanged();
389}
390
391/*!
392 \internal
393 */
394QOrganizerItem QDeclarativeOrganizerItem::item() const
395{
396 QOrganizerItem item;
397 item.setId(m_id);
398 item.setCollectionId(m_collectionId);
399 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
400 QOrganizerItemDetail itemDetail = detail->detail();
401 item.saveDetail(detail: &itemDetail);
402 }
403 return item;
404}
405
406/*!
407 \internal
408 */
409bool QDeclarativeOrganizerItem::generatedOccurrence() const
410{
411 QDeclarativeOrganizerItemType::ItemType type = itemType();
412 return (m_id.isNull() && (type == QDeclarativeOrganizerItemType::EventOccurrence || type == QDeclarativeOrganizerItemType::TodoOccurrence));
413}
414
415/*!
416 \internal
417 */
418QDateTime QDeclarativeOrganizerItem::itemStartTime() const
419{
420 switch (itemType()) {
421 case QDeclarativeOrganizerItemType::Event:
422 return static_cast<const QDeclarativeOrganizerEvent*>(this)->startDateTime();
423 case QDeclarativeOrganizerItemType::EventOccurrence:
424 return static_cast<const QDeclarativeOrganizerEventOccurrence*>(this)->startDateTime();
425 case QDeclarativeOrganizerItemType::Todo:
426 return static_cast<const QDeclarativeOrganizerTodo*>(this)->startDateTime();
427 case QDeclarativeOrganizerItemType::TodoOccurrence:
428 return static_cast<const QDeclarativeOrganizerTodoOccurrence*>(this)->startDateTime();
429 case QDeclarativeOrganizerItemType::Journal:
430 return static_cast<const QDeclarativeOrganizerJournal*>(this)->dateTime();
431 case QDeclarativeOrganizerItemType::Note:
432 default:
433 break;
434 }
435 return QDateTime();
436}
437
438/*!
439 \internal
440 */
441QDateTime QDeclarativeOrganizerItem::itemEndTime() const
442{
443 switch (itemType()) {
444 case QDeclarativeOrganizerItemType::Event:
445 return static_cast<const QDeclarativeOrganizerEvent*>(this)->endDateTime();
446 case QDeclarativeOrganizerItemType::EventOccurrence:
447 return static_cast<const QDeclarativeOrganizerEventOccurrence*>(this)->endDateTime();
448 case QDeclarativeOrganizerItemType::Todo:
449 return static_cast<const QDeclarativeOrganizerTodo*>(this)->dueDateTime();
450 case QDeclarativeOrganizerItemType::TodoOccurrence:
451 return static_cast<const QDeclarativeOrganizerTodoOccurrence*>(this)->dueDateTime();
452 case QDeclarativeOrganizerItemType::Journal:
453 //there is no end time for journal item, make it 30mins later for display purpose
454 return static_cast<const QDeclarativeOrganizerJournal*>(this)->dateTime().addSecs(secs: 60*30);
455 case QDeclarativeOrganizerItemType::Note:
456 default:
457 break;
458 }
459 return QDateTime();
460}
461
462// call-back functions for list property
463/*!
464 \internal
465 */
466void QDeclarativeOrganizerItem::_q_detail_append(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property, QDeclarativeOrganizerItemDetail *value)
467{
468 QDeclarativeOrganizerItem *object = qobject_cast<QDeclarativeOrganizerItem *>(object: property->object);
469 if (object)
470 object->m_details.append(t: value);
471}
472
473/*!
474 \internal
475 */
476QDeclarativeOrganizerItemDetail *QDeclarativeOrganizerItem::_q_detail_at(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property, int index)
477{
478 QDeclarativeOrganizerItem *object = qobject_cast<QDeclarativeOrganizerItem *>(object: property->object);
479 if (object)
480 return object->m_details.at(i: index);
481 else
482 return 0;
483}
484
485/*!
486 \internal
487 */
488void QDeclarativeOrganizerItem::_q_detail_clear(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property)
489{
490 QDeclarativeOrganizerItem *object = qobject_cast<QDeclarativeOrganizerItem *>(object: property->object);
491 if (object) {
492 foreach (QDeclarativeOrganizerItemDetail *obj, object->m_details)
493 delete obj;
494 object->m_details.clear();
495 }
496}
497
498/*!
499 \internal
500 */
501int QDeclarativeOrganizerItem::_q_detail_count(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property)
502{
503 QDeclarativeOrganizerItem *object = qobject_cast<QDeclarativeOrganizerItem *>(object: property->object);
504 if (object)
505 return object->m_details.size();
506 else
507 return 0;
508}
509
510/*!
511 \internal
512 */
513bool QDeclarativeOrganizerItem::_q_removeDetail(QDeclarativeOrganizerItemDetail *detail)
514{
515 if (!detail)
516 return false;
517
518 int key = detail->detail().key();
519 int i = 0;
520 bool removed = false;
521 foreach (QDeclarativeOrganizerItemDetail *itemDetail, m_details) {
522 if (key == itemDetail->detail().key()) {
523 delete itemDetail;
524 m_details.removeAt(i);
525 removed = true;
526 }
527 ++i;
528 }
529 return removed;
530}
531
532/*!
533 \internal
534 */
535bool QDeclarativeOrganizerItem::_q_setDetail(QDeclarativeOrganizerItemDetail *detail)
536{
537 if (!detail)
538 return false;
539
540 bool found(false);
541 int key = detail->detail().key();
542 foreach (QDeclarativeOrganizerItemDetail *itemDetail, m_details) {
543 if (key == itemDetail->detail().key()) {
544 itemDetail->setDetail(detail->detail());
545 found = true;
546 }
547 }
548 if (!found) {
549 QDeclarativeOrganizerItemDetail *itemDetail = QDeclarativeOrganizerItemDetailFactory::createItemDetail(type: detail->type());
550 itemDetail->setDetail(detail->detail());
551 m_details.append(t: itemDetail);
552 }
553 m_modified = true;
554 return true;
555}
556
557/*!
558 \internal
559 */
560bool QDeclarativeOrganizerItem::_q_clearDetails()
561{
562 bool ret = false;
563 if (!m_details.empty()) {
564 foreach (QDeclarativeOrganizerItemDetail *detail, m_details)
565 delete detail;
566 m_details.clear();
567 m_modified = true;
568 ret = true;
569 }
570 return ret;
571}
572
573
574/*!
575 \qmltype Event
576 \instantiates QDeclarativeOrganizerEvent
577 \brief The Event element provides an event in time which may reoccur.
578 \inqmlmodule QtOrganizer
579 \ingroup qml-organizer-items
580
581 \sa OrganizerItem, EventOccurrence, Journal, Todo, TodoOccurrence, Note, {QOrganizerEvent}
582*/
583
584/*!
585 \qmlsignal Event::onItemChanged()
586
587 \sa OrganizerItem::onItemChanged
588*/
589
590/*!
591 \internal
592 */
593QDeclarativeOrganizerEvent::QDeclarativeOrganizerEvent(QObject *parent)
594 : QDeclarativeOrganizerItem(parent)
595{
596 connect(asender: this, SIGNAL(valueChanged()), SIGNAL(itemChanged()));
597 setItem(QOrganizerEvent());
598}
599
600/*!
601 \qmlmethod void Event::setDetail(detail)
602
603 Saves the given \a detail in the organizer event, and sets its id.
604 */
605void QDeclarativeOrganizerEvent::setDetail(QDeclarativeOrganizerItemDetail *detail)
606{
607 if (_q_setDetail(detail))
608 emit valueChanged();
609}
610
611/*!
612 \qmlmethod void Event::removeDetail(detail)
613
614 Removes given \a detail from the organizer event.
615 */
616void QDeclarativeOrganizerEvent::removeDetail(QDeclarativeOrganizerItemDetail *detail)
617{
618 if (_q_removeDetail(detail))
619 emit valueChanged();
620}
621
622/*!
623 \qmlmethod Event::clearDetails()
624
625 Removes all details from the organizer event.
626
627 \sa removeDetail()
628 */
629void QDeclarativeOrganizerEvent::clearDetails()
630{
631 if (_q_clearDetails())
632 emit valueChanged();
633}
634
635/*!
636 \qmlproperty list<Detail> Event::attendees
637
638 This property holds the attendees list of the event.
639 */
640QQmlListProperty<QDeclarativeOrganizerEventAttendee> QDeclarativeOrganizerEvent::attendees()
641{
642 return QQmlListProperty<QDeclarativeOrganizerEventAttendee>(this, 0,
643 &QDeclarativeOrganizerEvent::_q_attendee_append,
644 &QDeclarativeOrganizerEvent::_q_attendee_count,
645 &QDeclarativeOrganizerEvent::_q_attendee_at,
646 &QDeclarativeOrganizerEvent::_q_attendee_clear);
647}
648
649// call-back functions for list property
650/*!
651 \internal
652 */
653void QDeclarativeOrganizerEvent::_q_attendee_append(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property, QDeclarativeOrganizerEventAttendee *value)
654{
655 QDeclarativeOrganizerEvent *object = qobject_cast<QDeclarativeOrganizerEvent *>(object: property->object);
656 if (object)
657 object->setDetail(value);
658}
659
660/*!
661 \internal
662 */
663QDeclarativeOrganizerEventAttendee *QDeclarativeOrganizerEvent::_q_attendee_at(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property, int index)
664{
665 QDeclarativeOrganizerEvent *object = qobject_cast<QDeclarativeOrganizerEvent *>(object: property->object);
666 QDeclarativeOrganizerEventAttendee *ret = 0;
667 int i = 0;
668 foreach (QDeclarativeOrganizerItemDetail *detail, object->m_details) {
669 if (QDeclarativeOrganizerItemDetail::EventAttendee == detail->type()) {
670 if (i == index) {
671 ret = qobject_cast<QDeclarativeOrganizerEventAttendee *>(object: detail);
672 break;
673 } else {
674 ++i;
675 }
676 }
677 }
678 return ret;
679}
680
681/*!
682 \internal
683 */
684void QDeclarativeOrganizerEvent::_q_attendee_clear(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property)
685{
686 QDeclarativeOrganizerEvent *object = qobject_cast<QDeclarativeOrganizerEvent *>(object: property->object);
687 if (object) {
688 int i = 0;
689 bool removed = false;
690 foreach (QDeclarativeOrganizerItemDetail *obj, object->m_details) {
691 if (obj->type() == QDeclarativeOrganizerItemDetail::EventAttendee) {
692 delete obj;
693 object->m_details.removeAt(i);
694 removed = true;
695 } else {// Index should not increase if some thing is removed
696 ++i;
697 }
698 }
699 if (removed)
700 emit object->valueChanged();
701 }
702}
703
704/*!
705 \internal
706 */
707int QDeclarativeOrganizerEvent::_q_attendee_count(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property)
708{
709 QDeclarativeOrganizerEvent *object = qobject_cast<QDeclarativeOrganizerEvent *>(object: property->object);
710 int ret = 0;
711 if (object) {
712 foreach (QDeclarativeOrganizerItemDetail *detail, object->m_details) {
713 if (QDeclarativeOrganizerItemDetail::EventAttendee == detail->type())
714 ++ret;
715 }
716 }
717 return ret;
718}
719
720/*!
721 \qmlproperty bool Event::allDay
722
723 This property indicates whether the time-of-day component of the event's start date-time or end date-time is
724 insignificant. If allDay is true, the time-of-day component is considered insignificant, and the event will
725 be an all-day item.
726 */
727void QDeclarativeOrganizerEvent::setAllDay(bool allDay)
728{
729 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
730 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type()) {
731 QDeclarativeOrganizerEventTime *eventTime = static_cast<QDeclarativeOrganizerEventTime *>(detail);
732 if (eventTime->isAllDay() != allDay) {
733 eventTime->setAllDay(allDay);
734 m_modified = true;
735 emit valueChanged();
736 }
737 return;
738 }
739 }
740
741 QDeclarativeOrganizerEventTime *eventTime = new QDeclarativeOrganizerEventTime(this);
742 eventTime->setAllDay(allDay);
743 m_details.append(t: eventTime);
744 m_modified = true;
745 emit valueChanged();
746}
747
748bool QDeclarativeOrganizerEvent::isAllDay() const
749{
750 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
751 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type())
752 return static_cast<QDeclarativeOrganizerEventTime *>(detail)->isAllDay();
753 }
754 return false;
755}
756
757/*!
758 \qmlproperty date Event::startDateTime
759
760 This property holds the start date time of the event.
761 */
762void QDeclarativeOrganizerEvent::setStartDateTime(const QDateTime &datetime)
763{
764 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
765 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type()) {
766 QDeclarativeOrganizerEventTime *eventTime = static_cast<QDeclarativeOrganizerEventTime *>(detail);
767 if (eventTime->startDateTime() != datetime) {
768 eventTime->setStartDateTime(datetime);
769 m_modified = true;
770 emit valueChanged();
771 }
772 return;
773 }
774 }
775
776 QDeclarativeOrganizerEventTime *eventTime = new QDeclarativeOrganizerEventTime(this);
777 eventTime->setStartDateTime(datetime);
778 m_details.append(t: eventTime);
779 m_modified = true;
780 emit valueChanged();
781}
782
783QDateTime QDeclarativeOrganizerEvent::startDateTime() const
784{
785 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
786 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type())
787 return static_cast<QDeclarativeOrganizerEventTime *>(detail)->startDateTime();
788 }
789 return QDateTime();
790}
791
792/*!
793 \qmlproperty date Event::endDateTime
794
795 This property holds the end date time of the event.
796 */
797void QDeclarativeOrganizerEvent::setEndDateTime(const QDateTime& datetime)
798{
799 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
800 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type()) {
801 QDeclarativeOrganizerEventTime *eventTime = static_cast<QDeclarativeOrganizerEventTime *>(detail);
802 if (eventTime->endDateTime() != datetime) {
803 eventTime->setEndDateTime(datetime);
804 m_modified = true;
805 emit valueChanged();
806 }
807 return;
808 }
809 }
810
811 QDeclarativeOrganizerEventTime *eventTime = new QDeclarativeOrganizerEventTime(this);
812 eventTime->setEndDateTime(datetime);
813 m_details.append(t: eventTime);
814 m_modified = true;
815 emit valueChanged();
816}
817
818QDateTime QDeclarativeOrganizerEvent::endDateTime() const
819{
820 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
821 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type())
822 return static_cast<QDeclarativeOrganizerEventTime *>(detail)->endDateTime();
823 }
824 return QDateTime();
825}
826
827/*!
828 \qmlproperty enumeration Event::priority
829
830 This property holds the priority of the event. The value can be one of:
831 \list
832 \li Priority.Unknown
833 \li Priority.Highest
834 \li Priority.ExtremelyHigh
835 \li Priority.VeryHigh
836 \li Priority.High
837 \li Priority.Medium
838 \li Priority.Low
839 \li Priority.VeryLow
840 \li Priority.ExtremelyLow
841 \li Priority.Lowest
842 \endlist
843 */
844void QDeclarativeOrganizerEvent::setPriority(QDeclarativeOrganizerItemPriority::Priority priority)
845{
846 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
847 if (QDeclarativeOrganizerItemDetail::Priority == detail->type()) {
848 QDeclarativeOrganizerItemPriority *itemPriority = static_cast<QDeclarativeOrganizerItemPriority *>(detail);
849 if (itemPriority->priority() != priority) {
850 itemPriority->setPriority(priority);
851 m_modified = true;
852 emit valueChanged();
853 }
854 return;
855 }
856 }
857
858 QDeclarativeOrganizerItemPriority *itemPriority = new QDeclarativeOrganizerItemPriority(this);
859 itemPriority->setPriority(priority);
860 m_details.append(t: itemPriority);
861 m_modified = true;
862 emit valueChanged();
863}
864
865QDeclarativeOrganizerItemPriority::Priority QDeclarativeOrganizerEvent::priority() const
866{
867 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
868 if (QDeclarativeOrganizerItemDetail::Priority == detail->type())
869 return static_cast<QDeclarativeOrganizerItemPriority *>(detail)->priority();
870 }
871 return QDeclarativeOrganizerItemPriority::Unknown;
872}
873
874/*!
875 \qmlproperty string Event::location
876
877 This property holds the label of the location at which the event occurs.
878 */
879
880void QDeclarativeOrganizerEvent::setLocation(const QString &location)
881{
882 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
883 if (QDeclarativeOrganizerItemDetail::Location == detail->type()) {
884 QDeclarativeOrganizerItemLocation *itemLocation = static_cast<QDeclarativeOrganizerItemLocation *>(detail);
885 if (itemLocation->label() != location) {
886 itemLocation->setLabel(location);
887 m_modified = true;
888 emit valueChanged();
889 }
890 return;
891 }
892 }
893
894 QDeclarativeOrganizerItemLocation *itemLocation = new QDeclarativeOrganizerItemLocation(this);
895 itemLocation->setLabel(location);
896 m_details.append(t: itemLocation);
897 m_modified = true;
898 emit valueChanged();
899}
900
901QString QDeclarativeOrganizerEvent::location() const
902{
903 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
904 if (QDeclarativeOrganizerItemDetail::Location == detail->type())
905 return static_cast<QDeclarativeOrganizerItemLocation *>(detail)->label();
906 }
907 return QString::null;
908}
909
910/*!
911 \qmlproperty Recurrence Event::recurrence
912
913 This property holds the recurrence element of the event item.
914 */
915QDeclarativeOrganizerItemRecurrence *QDeclarativeOrganizerEvent::recurrence()
916{
917 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
918 if (QDeclarativeOrganizerItemDetail::Recurrence == detail->type())
919 return static_cast<QDeclarativeOrganizerItemRecurrence *>(detail);
920 }
921
922 QDeclarativeOrganizerItemRecurrence *detail = new QDeclarativeOrganizerItemRecurrence;
923 m_details.append(t: detail);
924 m_modified = true;
925 emit valueChanged();
926 return detail;
927}
928
929
930/*!
931 \qmltype EventOccurrence
932 \instantiates QDeclarativeOrganizerEventOccurrence
933 \brief The EventOccurrence element provides an occurrence of an event.
934 \inqmlmodule QtOrganizer
935 \ingroup qml-organizer-items
936
937 \sa OrganizerItem, Event, Journal, Todo, TodoOccurrence, Note, {QOrganizerEventOccurrence}
938 */
939
940/*!
941 \qmlsignal EventOccurrence::onItemChanged()
942
943 \sa OrganizerItem::onItemChanged
944*/
945
946/*!
947 \internal
948 */
949QDeclarativeOrganizerEventOccurrence::QDeclarativeOrganizerEventOccurrence(QObject *parent)
950 : QDeclarativeOrganizerItem(parent)
951{
952 connect(asender: this, SIGNAL(valueChanged()), SIGNAL(itemChanged()));
953 setItem (QOrganizerEventOccurrence());
954}
955
956/*!
957 \qmlproperty date EventOccurrence::originalDate
958
959 This property holds the date at which the occurrence was originally going to occur.
960 */
961void QDeclarativeOrganizerEventOccurrence::setOriginalDate(const QDateTime &date)
962{
963 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
964 if (QDeclarativeOrganizerItemDetail::Parent == detail->type()) {
965 QDeclarativeOrganizerItemParent *parent = static_cast<QDeclarativeOrganizerItemParent *>(detail);
966 if (parent->originalDate() != date) {
967 parent->setOriginalDate(date);
968 m_modified = true;
969 emit valueChanged();
970 }
971 return;
972 }
973 }
974
975 QDeclarativeOrganizerItemParent *parent = new QDeclarativeOrganizerItemParent(this);
976 parent->setOriginalDate(date);
977 m_details.append(t: parent);
978 m_modified = true;
979 emit valueChanged();
980}
981
982QDateTime QDeclarativeOrganizerEventOccurrence::originalDate() const
983{
984 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
985 if (QDeclarativeOrganizerItemDetail::Parent == detail->type())
986 return static_cast<QDeclarativeOrganizerItemParent *>(detail)->originalDate();
987 }
988 return QDateTime();
989}
990
991/*!
992 \qmlproperty date EventOccurrence::startDateTime
993
994 This property holds the start date time of the event occurrence.
995 */
996void QDeclarativeOrganizerEventOccurrence::setStartDateTime(const QDateTime &datetime)
997{
998 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
999 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type()) {
1000 QDeclarativeOrganizerEventTime *eventTime = static_cast<QDeclarativeOrganizerEventTime *>(detail);
1001 if (eventTime->startDateTime() != datetime) {
1002 eventTime->setStartDateTime(datetime);
1003 m_modified = true;
1004 emit valueChanged();
1005 }
1006 return;
1007 }
1008 }
1009
1010 QDeclarativeOrganizerEventTime *eventTime = new QDeclarativeOrganizerEventTime(this);
1011 eventTime->setStartDateTime(datetime);
1012 m_details.append(t: eventTime);
1013 m_modified = true;
1014 emit valueChanged();
1015}
1016
1017QDateTime QDeclarativeOrganizerEventOccurrence::startDateTime() const
1018{
1019 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1020 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type())
1021 return static_cast<QDeclarativeOrganizerEventTime *>(detail)->startDateTime();
1022 }
1023 return QDateTime();
1024}
1025
1026/*!
1027 \qmlproperty date EventOccurrence::endDateTime
1028
1029 This property holds the date time at which the event occurrence ends.
1030 */
1031void QDeclarativeOrganizerEventOccurrence::setEndDateTime(const QDateTime &datetime)
1032{
1033 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1034 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type()) {
1035 QDeclarativeOrganizerEventTime *eventTime = static_cast<QDeclarativeOrganizerEventTime *>(detail);
1036 if (eventTime->endDateTime() != datetime) {
1037 eventTime->setEndDateTime(datetime);
1038 m_modified = true;
1039 emit valueChanged();
1040 }
1041 return;
1042 }
1043 }
1044
1045 QDeclarativeOrganizerEventTime *eventTime = new QDeclarativeOrganizerEventTime(this);
1046 eventTime->setEndDateTime(datetime);
1047 m_details.append(t: eventTime);
1048 m_modified = true;
1049 emit valueChanged();
1050}
1051
1052QDateTime QDeclarativeOrganizerEventOccurrence::endDateTime() const
1053{
1054 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1055 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type())
1056 return static_cast<QDeclarativeOrganizerEventTime *>(detail)->endDateTime();
1057 }
1058 return QDateTime();
1059}
1060
1061/*!
1062 \qmlproperty enumeration EventOccurrence::priority
1063
1064 This property holds the priority of the event occurrence. The value can be one of:
1065 \list
1066 \li Priority.Unknown
1067 \li Priority.Highest
1068 \li Priority.ExtremelyHigh
1069 \li Priority.VeryHigh
1070 \li Priority.High
1071 \li Priority.Medium
1072 \li Priority.Low
1073 \li Priority.VeryLow
1074 \li Priority.ExtremelyLow
1075 \li Priority.Lowest
1076 \endlist
1077 */
1078void QDeclarativeOrganizerEventOccurrence::setPriority(QDeclarativeOrganizerItemPriority::Priority priority)
1079{
1080 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1081 if (QDeclarativeOrganizerItemDetail::Priority == detail->type()) {
1082 QDeclarativeOrganizerItemPriority *itemPriority = static_cast<QDeclarativeOrganizerItemPriority *>(detail);
1083 if (itemPriority->priority() != priority) {
1084 itemPriority->setPriority(priority);
1085 m_modified = true;
1086 emit valueChanged();
1087 }
1088 return;
1089 }
1090 }
1091
1092 QDeclarativeOrganizerItemPriority *itemPriority = new QDeclarativeOrganizerItemPriority(this);
1093 itemPriority->setPriority(priority);
1094 m_details.append(t: itemPriority);
1095 m_modified = true;
1096 emit valueChanged();
1097}
1098
1099QDeclarativeOrganizerItemPriority::Priority QDeclarativeOrganizerEventOccurrence::priority() const
1100{
1101 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1102 if (QDeclarativeOrganizerItemDetail::Priority == detail->type())
1103 return static_cast<QDeclarativeOrganizerItemPriority *>(detail)->priority();
1104 }
1105 return QDeclarativeOrganizerItemPriority::Unknown;
1106}
1107
1108/*!
1109 \qmlproperty string EventOccurrence::location
1110
1111 This property holds the label of the location at which the event occurrence is held.
1112 */
1113void QDeclarativeOrganizerEventOccurrence::setLocation(const QString &location)
1114{
1115 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1116 if (QDeclarativeOrganizerItemDetail::Location == detail->type()) {
1117 QDeclarativeOrganizerItemLocation *itemLocation = static_cast<QDeclarativeOrganizerItemLocation *>(detail);
1118 if (itemLocation->label() != location) {
1119 itemLocation->setLabel(location);
1120 m_modified = true;
1121 emit valueChanged();
1122 }
1123 return;
1124 }
1125 }
1126
1127 QDeclarativeOrganizerItemLocation *itemLocation = new QDeclarativeOrganizerItemLocation(this);
1128 itemLocation->setLabel(location);
1129 m_details.append(t: itemLocation);
1130 m_modified = true;
1131 emit valueChanged();
1132}
1133
1134QString QDeclarativeOrganizerEventOccurrence::location() const
1135{
1136 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1137 if (QDeclarativeOrganizerItemDetail::Location == detail->type())
1138 return static_cast<QDeclarativeOrganizerItemLocation *>(detail)->label();
1139 }
1140 return QString::null;
1141}
1142
1143/*!
1144 \qmlproperty int EventOccurrence::parentId
1145
1146 This property holds the id of the event which is this occurrence's parent.
1147 */
1148void QDeclarativeOrganizerEventOccurrence::setParentId(const QString &parentId)
1149{
1150 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1151 if (QDeclarativeOrganizerItemDetail::Parent == detail->type()) {
1152 QDeclarativeOrganizerItemParent *parent = static_cast<QDeclarativeOrganizerItemParent *>(detail);
1153 if (parent->parentId() != parentId) {
1154 parent->setParentId(parentId);
1155 m_modified = true;
1156 emit valueChanged();
1157 }
1158 return;
1159 }
1160 }
1161
1162 QDeclarativeOrganizerItemParent *parent = new QDeclarativeOrganizerItemParent(this);
1163 parent->setParentId(parentId);
1164 m_details.append(t: parent);
1165 m_modified = true;
1166 emit valueChanged();
1167}
1168
1169QString QDeclarativeOrganizerEventOccurrence::parentId() const
1170{
1171 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1172 if (QDeclarativeOrganizerItemDetail::Parent == detail->type())
1173 return static_cast<QDeclarativeOrganizerItemParent *>(detail)->parentId();
1174 }
1175 return QString::null;
1176}
1177
1178/*!
1179 \qmlproperty bool EventOccurrence::allDay
1180
1181 This property indicates whether the time-of-day component of the event occurrence's start date-time or end date-time is
1182 insignificant. If allDay is true, the time-of-day component is considered insignificant, and the event occurrence will
1183 be an all-day item.
1184 */
1185void QDeclarativeOrganizerEventOccurrence::setAllDay(bool allDay)
1186{
1187 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1188 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type()) {
1189 QDeclarativeOrganizerEventTime *eventTime = static_cast<QDeclarativeOrganizerEventTime *>(detail);
1190 if (eventTime->isAllDay() != allDay) {
1191 eventTime->setAllDay(allDay);
1192 m_modified = true;
1193 emit valueChanged();
1194 }
1195 return;
1196 }
1197 }
1198
1199 QDeclarativeOrganizerEventTime *eventTime = new QDeclarativeOrganizerEventTime(this);
1200 eventTime->setAllDay(allDay);
1201 m_details.append(t: eventTime);
1202 m_modified = true;
1203 emit valueChanged();
1204}
1205
1206bool QDeclarativeOrganizerEventOccurrence::isAllDay() const
1207{
1208 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1209 if (QDeclarativeOrganizerItemDetail::EventTime == detail->type())
1210 return static_cast<QDeclarativeOrganizerEventTime *>(detail)->isAllDay();
1211 }
1212 return false;
1213}
1214
1215/*!
1216 \qmltype Journal
1217 \instantiates QDeclarativeOrganizerJournal
1218 \brief The Journal element provides a journal which is associated with a particular point in time.
1219 \inqmlmodule QtOrganizer
1220 \ingroup qml-organizer-items
1221
1222 \sa OrganizerItem, Event, EventOccurrence, Todo, TodoOccurrence, Note, {QOrganizerJournal}
1223 */
1224
1225/*!
1226 \qmlsignal Journal::onItemChanged()
1227
1228 \sa OrganizerItem::onItemChanged
1229*/
1230
1231/*!
1232 \internal
1233 */
1234QDeclarativeOrganizerJournal::QDeclarativeOrganizerJournal(QObject *parent)
1235 : QDeclarativeOrganizerItem(parent)
1236{
1237 connect(asender: this, SIGNAL(valueChanged()), SIGNAL(itemChanged()));
1238 setItem (QOrganizerJournal());
1239}
1240
1241/*!
1242 \qmlproperty date Journal::dateTime
1243
1244 This property holds the date time associated with this journal.
1245 */
1246void QDeclarativeOrganizerJournal::setDateTime(const QDateTime &dateTime)
1247{
1248 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1249 if (QDeclarativeOrganizerItemDetail::JournalTime == detail->type()) {
1250 QDeclarativeOrganizerJournalTime *journalTime = static_cast<QDeclarativeOrganizerJournalTime *>(detail);
1251 if (journalTime->entryDateTime() != dateTime) {
1252 journalTime->setEntryDateTime(dateTime);
1253 m_modified = true;
1254 emit valueChanged();
1255 }
1256 return;
1257 }
1258 }
1259
1260 QDeclarativeOrganizerJournalTime *journalTime = new QDeclarativeOrganizerJournalTime(this);
1261 journalTime->setEntryDateTime(dateTime);
1262 m_details.append(t: journalTime);
1263 m_modified = true;
1264 emit valueChanged();
1265}
1266
1267QDateTime QDeclarativeOrganizerJournal::dateTime() const
1268{
1269 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1270 if (QDeclarativeOrganizerItemDetail::JournalTime == detail->type())
1271 return static_cast<QDeclarativeOrganizerJournalTime *>(detail)->entryDateTime();
1272 }
1273 return QDateTime();
1274}
1275
1276
1277/*!
1278 \qmltype Note
1279 \instantiates QDeclarativeOrganizerNote
1280 \brief The Note element provides a note which is not associated with any particular point in time.
1281 \inqmlmodule QtOrganizer
1282 \ingroup qml-organizer-items
1283
1284 \sa OrganizerItem, Event, EventOccurrence, Journal, Todo, TodoOccurrence, {QOrganizerNote}
1285 */
1286
1287/*!
1288 \qmlsignal Note::onItemChanged()
1289
1290 \sa OrganizerItem::onItemChanged
1291*/
1292
1293/*!
1294 \internal
1295 */
1296QDeclarativeOrganizerNote::QDeclarativeOrganizerNote(QObject *parent)
1297 : QDeclarativeOrganizerItem(parent)
1298{
1299 connect(asender: this, SIGNAL(valueChanged()), SIGNAL(itemChanged()));
1300 setItem(QOrganizerNote());
1301}
1302
1303
1304/*!
1305 \qmltype Todo
1306 \instantiates QDeclarativeOrganizerTodo
1307 \brief The Todo element provides a task which should be completed.
1308 \inqmlmodule QtOrganizer
1309 \ingroup qml-organizer-items
1310
1311 \sa OrganizerItem, Event, EventOccurrence, Journal, TodoOccurrence, Note, {QOrganizerTodo}
1312*/
1313
1314/*!
1315 \qmlsignal Todo::onItemChanged()
1316
1317 \sa OrganizerItem::onItemChanged
1318*/
1319
1320/*!
1321 \internal
1322 */
1323QDeclarativeOrganizerTodo::QDeclarativeOrganizerTodo(QObject *parent)
1324 : QDeclarativeOrganizerItem(parent)
1325{
1326 connect(asender: this, SIGNAL(valueChanged()), SIGNAL(itemChanged()));
1327 setItem(QOrganizerTodo());
1328}
1329
1330/*!
1331 \qmlproperty bool Todo::allDay
1332
1333 This property indicates whether the time-of-day component of the Todo's start date-time or due date-time is
1334 insignificant. If allDay is true, the time-of-day component is considered insignificant, and the todo will
1335 be an all-day item.
1336 */
1337void QDeclarativeOrganizerTodo::setAllDay(bool allDay)
1338{
1339 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1340 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type()) {
1341 QDeclarativeOrganizerTodoTime *todoTime = static_cast<QDeclarativeOrganizerTodoTime *>(detail);
1342 if (todoTime->isAllDay() != allDay) {
1343 todoTime->setAllDay(allDay);
1344 m_modified = true;
1345 emit valueChanged();
1346 }
1347 return;
1348 }
1349 }
1350
1351 QDeclarativeOrganizerTodoTime *todoTime = new QDeclarativeOrganizerTodoTime(this);
1352 todoTime->setAllDay(allDay);
1353 m_details.append(t: todoTime);
1354 m_modified = true;
1355 emit valueChanged();
1356}
1357
1358bool QDeclarativeOrganizerTodo::isAllDay() const
1359{
1360 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1361 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type())
1362 return static_cast<QDeclarativeOrganizerTodoTime *>(detail)->isAllDay();
1363 }
1364 return false;
1365}
1366
1367/*!
1368 \qmlproperty int Todo::percentageComplete
1369
1370 This property holds the percentage of progress completed on the task described by the todo item.
1371 */
1372void QDeclarativeOrganizerTodo::setPercentageComplete(int percentageComplete)
1373{
1374 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1375 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type()) {
1376 QDeclarativeOrganizerTodoProgress *todoProgress = static_cast<QDeclarativeOrganizerTodoProgress *>(detail);
1377 if (todoProgress->percentageComplete() != percentageComplete) {
1378 todoProgress->setPercentageComplete(percentageComplete);
1379 m_modified = true;
1380 emit valueChanged();
1381 }
1382 return;
1383 }
1384 }
1385
1386 QDeclarativeOrganizerTodoProgress *todoProgress = new QDeclarativeOrganizerTodoProgress(this);
1387 todoProgress->setPercentageComplete(percentageComplete);
1388 m_details.append(t: todoProgress);
1389 m_modified = true;
1390 emit valueChanged();
1391}
1392
1393int QDeclarativeOrganizerTodo::percentageComplete() const
1394{
1395 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1396 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type())
1397 return static_cast<QDeclarativeOrganizerTodoProgress *>(detail)->percentageComplete();
1398 }
1399 return 0;
1400}
1401
1402/*!
1403 \qmlproperty date Todo::startDateTime
1404
1405 This property holds the date time at which the task should be started.
1406 */
1407void QDeclarativeOrganizerTodo::setStartDateTime(const QDateTime &dateTime)
1408{
1409 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1410 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type()) {
1411 QDeclarativeOrganizerTodoTime *todoTime = static_cast<QDeclarativeOrganizerTodoTime *>(detail);
1412 if (todoTime->startDateTime() != dateTime) {
1413 todoTime->setStartDateTime(dateTime);
1414 m_modified = true;
1415 emit valueChanged();
1416 }
1417 return;
1418 }
1419 }
1420
1421 QDeclarativeOrganizerTodoTime *todoTime = new QDeclarativeOrganizerTodoTime(this);
1422 todoTime->setStartDateTime(dateTime);
1423 m_details.append(t: todoTime);
1424 m_modified = true;
1425 emit valueChanged();
1426}
1427
1428QDateTime QDeclarativeOrganizerTodo::startDateTime() const
1429{
1430 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1431 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type())
1432 return static_cast<QDeclarativeOrganizerTodoTime *>(detail)->startDateTime();
1433 }
1434 return QDateTime();
1435}
1436
1437/*!
1438 \qmlproperty date Todo::dueDateTime
1439
1440 This property holds the date time by which the task should be completed.
1441 */
1442void QDeclarativeOrganizerTodo::setDueDateTime(const QDateTime &dateTime)
1443{
1444 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1445 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type()) {
1446 QDeclarativeOrganizerTodoTime *todoTime = static_cast<QDeclarativeOrganizerTodoTime *>(detail);
1447 if (todoTime->dueDateTime() != dateTime) {
1448 todoTime->setDueDateTime(dateTime);
1449 m_modified = true;
1450 emit valueChanged();
1451 }
1452 return;
1453 }
1454 }
1455
1456 QDeclarativeOrganizerTodoTime *todoTime = new QDeclarativeOrganizerTodoTime(this);
1457 todoTime->setDueDateTime(dateTime);
1458 m_details.append(t: todoTime);
1459 m_modified = true;
1460 emit valueChanged();
1461}
1462
1463QDateTime QDeclarativeOrganizerTodo::dueDateTime() const
1464{
1465 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1466 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type())
1467 return static_cast<QDeclarativeOrganizerTodoTime *>(detail)->dueDateTime();
1468 }
1469 return QDateTime();
1470}
1471
1472/*!
1473 \qmlproperty date Todo::finishedDateTime
1474
1475 This property holds the date and time at which the task was completed, if known.
1476 */
1477void QDeclarativeOrganizerTodo::setFinishedDateTime(const QDateTime &dateTime)
1478{
1479 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1480 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type()) {
1481 QDeclarativeOrganizerTodoProgress *todoProgress = static_cast<QDeclarativeOrganizerTodoProgress *>(detail);
1482 if (todoProgress->finishedDateTime() != dateTime) {
1483 todoProgress->setFinishedDateTime(dateTime);
1484 m_modified = true;
1485 emit valueChanged();
1486 }
1487 return;
1488 }
1489 }
1490
1491 QDeclarativeOrganizerTodoProgress *todoProgress = new QDeclarativeOrganizerTodoProgress(this);
1492 todoProgress->setFinishedDateTime(dateTime);
1493 m_details.append(t: todoProgress);
1494 m_modified = true;
1495 emit valueChanged();
1496}
1497
1498QDateTime QDeclarativeOrganizerTodo::finishedDateTime() const
1499{
1500 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1501 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type())
1502 return static_cast<QDeclarativeOrganizerTodoProgress *>(detail)->finishedDateTime();
1503 }
1504 return QDateTime();
1505}
1506
1507/*!
1508 \qmlproperty enumeration Todo::priority
1509
1510 This property holds the priority of the todo item. The value can be one of:
1511 \list
1512 \li Priority.Unknown
1513 \li Priority.Highest
1514 \li Priority.ExtremelyHigh
1515 \li Priority.VeryHigh
1516 \li Priority.High
1517 \li Priority.Medium
1518 \li Priority.Low
1519 \li Priority.VeryLow
1520 \li Priority.ExtremelyLow
1521 \li Priority.Lowest
1522 \endlist
1523 */
1524void QDeclarativeOrganizerTodo::setPriority(QDeclarativeOrganizerItemPriority::Priority priority)
1525{
1526 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1527 if (QDeclarativeOrganizerItemDetail::Priority == detail->type()) {
1528 QDeclarativeOrganizerItemPriority *itemPriority = static_cast<QDeclarativeOrganizerItemPriority *>(detail);
1529 if (itemPriority->priority() != priority) {
1530 itemPriority->setPriority(priority);
1531 m_modified = true;
1532 emit valueChanged();
1533 }
1534 return;
1535 }
1536 }
1537
1538 QDeclarativeOrganizerItemPriority *itemPriority = new QDeclarativeOrganizerItemPriority(this);
1539 itemPriority->setPriority(priority);
1540 m_details.append(t: itemPriority);
1541 m_modified = true;
1542 emit valueChanged();
1543}
1544
1545QDeclarativeOrganizerItemPriority::Priority QDeclarativeOrganizerTodo::priority() const
1546{
1547 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1548 if (QDeclarativeOrganizerItemDetail::Priority == detail->type())
1549 return static_cast<QDeclarativeOrganizerItemPriority *>(detail)->priority();
1550 }
1551 return QDeclarativeOrganizerItemPriority::Unknown;
1552}
1553
1554/*!
1555 \qmlproperty enumeration Todo::status
1556
1557 This property holds the progress status of the task described by the todo. The value can be one of:
1558 \list
1559 \li TodoProgress.NotStarted
1560 \li TodoProgress.InProgress
1561 \li TodoProgress.Complete
1562 \endlist
1563 */
1564void QDeclarativeOrganizerTodo::setStatus(QDeclarativeOrganizerTodoProgress::StatusType status)
1565{
1566 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1567 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type()) {
1568 QDeclarativeOrganizerTodoProgress *todoProgress = static_cast<QDeclarativeOrganizerTodoProgress *>(detail);
1569 if (todoProgress->status() != status) {
1570 todoProgress->setStatus(status);
1571 m_modified = true;
1572 emit valueChanged();
1573 }
1574 return;
1575 }
1576 }
1577
1578 QDeclarativeOrganizerTodoProgress *todoProgress = new QDeclarativeOrganizerTodoProgress(this);
1579 todoProgress->setStatus(status);
1580 m_details.append(t: todoProgress);
1581 m_modified = true;
1582 emit valueChanged();
1583}
1584
1585QDeclarativeOrganizerTodoProgress::StatusType QDeclarativeOrganizerTodo::status() const
1586{
1587 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1588 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type())
1589 return static_cast<QDeclarativeOrganizerTodoProgress *>(detail)->status();
1590 }
1591 return QDeclarativeOrganizerTodoProgress::NotStarted;
1592}
1593
1594/*!
1595 \qmlproperty Recurrence Todo::recurrence
1596
1597 This property holds the recurrence element of the todo item.
1598 */
1599QDeclarativeOrganizerItemRecurrence* QDeclarativeOrganizerTodo::recurrence()
1600{
1601 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1602 if (QDeclarativeOrganizerItemDetail::Recurrence == detail->type())
1603 return static_cast<QDeclarativeOrganizerItemRecurrence *>(detail);
1604 }
1605
1606 QDeclarativeOrganizerItemRecurrence *detail = new QDeclarativeOrganizerItemRecurrence;
1607 m_details.append(t: detail);
1608 m_modified = true;
1609 emit valueChanged();
1610 return detail;
1611}
1612
1613
1614/*!
1615 \qmltype TodoOccurrence
1616 \instantiates QDeclarativeOrganizerTodoOccurrence
1617 \brief The TodoOccurrence element provides an occurrence of an event.
1618 \inqmlmodule QtOrganizer
1619 \ingroup qml-organizer-items
1620
1621 \sa OrganizerItem, Event, EventOccurrence, Journal, Todo, Note, {QOrganizerTodoOccurrence}
1622 */
1623
1624/*!
1625 \qmlsignal TodoOccurrence::onItemChanged()
1626
1627 \sa OrganizerItem::onItemChanged
1628*/
1629
1630QDeclarativeOrganizerTodoOccurrence::QDeclarativeOrganizerTodoOccurrence(QObject *parent)
1631 : QDeclarativeOrganizerItem(parent)
1632{
1633 connect(asender: this, SIGNAL(valueChanged()), SIGNAL(itemChanged()));
1634 setItem(QOrganizerTodoOccurrence());
1635}
1636
1637/*!
1638 \qmlproperty bool TodoOccurrence::allDay
1639
1640 This property indicates whether the time-of-day component of the todo occurrence's start date-time or due date-time is
1641 insignificant. If allDay is true, the time-of-day component is considered insignificant, and the todo occurrence will
1642 be an all-day item.
1643 */
1644void QDeclarativeOrganizerTodoOccurrence::setAllDay(bool allDay)
1645{
1646 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1647 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type()) {
1648 QDeclarativeOrganizerTodoTime *todoTime = static_cast<QDeclarativeOrganizerTodoTime *>(detail);
1649 if (todoTime->isAllDay() != allDay) {
1650 todoTime->setAllDay(allDay);
1651 m_modified = true;
1652 emit valueChanged();
1653 }
1654 return;
1655 }
1656 }
1657
1658 QDeclarativeOrganizerTodoTime *todoTime = new QDeclarativeOrganizerTodoTime(this);
1659 todoTime->setAllDay(allDay);
1660 m_details.append(t: todoTime);
1661 m_modified = true;
1662 emit valueChanged();
1663}
1664
1665bool QDeclarativeOrganizerTodoOccurrence::isAllDay() const
1666{
1667 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1668 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type())
1669 return static_cast<QDeclarativeOrganizerTodoTime *>(detail)->isAllDay();
1670 }
1671 return false;
1672}
1673
1674/*!
1675 \qmlproperty int TodoOccurrence::percentageComplete
1676
1677 This property holds the percentage of progress completed on the task described by the todo item.
1678 */
1679void QDeclarativeOrganizerTodoOccurrence::setPercentageComplete(int percentageComplete)
1680{
1681 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1682 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type()) {
1683 QDeclarativeOrganizerTodoProgress *todoProgress = static_cast<QDeclarativeOrganizerTodoProgress *>(detail);
1684 if (todoProgress->percentageComplete() != percentageComplete) {
1685 todoProgress->setPercentageComplete(percentageComplete);
1686 m_modified = true;
1687 emit valueChanged();
1688 }
1689 return;
1690 }
1691 }
1692
1693 QDeclarativeOrganizerTodoProgress *todoProgress = new QDeclarativeOrganizerTodoProgress(this);
1694 todoProgress->setPercentageComplete(percentageComplete);
1695 m_details.append(t: todoProgress);
1696 m_modified = true;
1697 emit valueChanged();
1698}
1699
1700int QDeclarativeOrganizerTodoOccurrence::percentageComplete() const
1701{
1702 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1703 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type())
1704 return static_cast<QDeclarativeOrganizerTodoProgress *>(detail)->percentageComplete();
1705 }
1706 return 0;
1707}
1708
1709/*!
1710 \qmlproperty date TodoOccurrence::originalDate
1711
1712 This property holds the date at which the occurrence was originally going to occur.
1713 */
1714void QDeclarativeOrganizerTodoOccurrence::setOriginalDate(const QDateTime &date)
1715{
1716 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1717 if (QDeclarativeOrganizerItemDetail::Parent == detail->type()) {
1718 QDeclarativeOrganizerItemParent *parent = static_cast<QDeclarativeOrganizerItemParent *>(detail);
1719 if (parent->originalDate() != date) {
1720 parent->setOriginalDate(date);
1721 m_modified = true;
1722 emit valueChanged();
1723 }
1724 return;
1725 }
1726 }
1727
1728 QDeclarativeOrganizerItemParent *parent = new QDeclarativeOrganizerItemParent(this);
1729 parent->setOriginalDate(date);
1730 m_details.append(t: parent);
1731 m_modified = true;
1732 emit valueChanged();
1733}
1734
1735QDateTime QDeclarativeOrganizerTodoOccurrence::originalDate() const
1736{
1737 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1738 if (QDeclarativeOrganizerItemDetail::Parent == detail->type())
1739 return static_cast<QDeclarativeOrganizerItemParent *>(detail)->originalDate();
1740 }
1741 return QDateTime();
1742}
1743
1744/*!
1745 \qmlproperty date TodoOccurrence::startDateTime
1746
1747 This property holds the date time at which the task should be started.
1748 */
1749void QDeclarativeOrganizerTodoOccurrence::setStartDateTime(const QDateTime &dateTime)
1750{
1751 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1752 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type()) {
1753 QDeclarativeOrganizerTodoTime *todoTime = static_cast<QDeclarativeOrganizerTodoTime *>(detail);
1754 if (todoTime->startDateTime() != dateTime) {
1755 todoTime->setStartDateTime(dateTime);
1756 m_modified = true;
1757 emit valueChanged();
1758 }
1759 return;
1760 }
1761 }
1762
1763 QDeclarativeOrganizerTodoTime *todoTime = new QDeclarativeOrganizerTodoTime(this);
1764 todoTime->setStartDateTime(dateTime);
1765 m_details.append(t: todoTime);
1766 m_modified = true;
1767 emit valueChanged();
1768}
1769
1770QDateTime QDeclarativeOrganizerTodoOccurrence::startDateTime() const
1771{
1772 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1773 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type())
1774 return static_cast<QDeclarativeOrganizerTodoTime *>(detail)->startDateTime();
1775 }
1776 return QDateTime();
1777}
1778/*!
1779 \qmlproperty date TodoOccurrence::dueDateTime
1780
1781 This property holds the date time by which the task should be completed.
1782 */
1783void QDeclarativeOrganizerTodoOccurrence::setDueDateTime(const QDateTime &dateTime)
1784{
1785 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1786 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type()) {
1787 QDeclarativeOrganizerTodoTime *todoTime = static_cast<QDeclarativeOrganizerTodoTime *>(detail);
1788 if (todoTime->dueDateTime() != dateTime) {
1789 todoTime->setDueDateTime(dateTime);
1790 m_modified = true;
1791 emit valueChanged();
1792 }
1793 return;
1794 }
1795 }
1796
1797 QDeclarativeOrganizerTodoTime *todoTime = new QDeclarativeOrganizerTodoTime(this);
1798 todoTime->setDueDateTime(dateTime);
1799 m_details.append(t: todoTime);
1800 m_modified = true;
1801 emit valueChanged();
1802}
1803
1804QDateTime QDeclarativeOrganizerTodoOccurrence::dueDateTime() const
1805{
1806 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1807 if (QDeclarativeOrganizerItemDetail::TodoTime == detail->type())
1808 return static_cast<QDeclarativeOrganizerTodoTime *>(detail)->dueDateTime();
1809 }
1810 return QDateTime();
1811}
1812
1813/*!
1814 \qmlproperty date TodoOccurrence::finishedDateTime
1815
1816 This property holds the date and time at which the task was completed, if known.
1817 */
1818void QDeclarativeOrganizerTodoOccurrence::setFinishedDateTime(const QDateTime &dateTime)
1819{
1820 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1821 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type()) {
1822 QDeclarativeOrganizerTodoProgress *todoProgress = static_cast<QDeclarativeOrganizerTodoProgress *>(detail);
1823 if (todoProgress->finishedDateTime() != dateTime) {
1824 todoProgress->setFinishedDateTime(dateTime);
1825 m_modified = true;
1826 emit valueChanged();
1827 }
1828 return;
1829 }
1830 }
1831
1832 QDeclarativeOrganizerTodoProgress *todoProgress = new QDeclarativeOrganizerTodoProgress(this);
1833 todoProgress->setFinishedDateTime(dateTime);
1834 m_details.append(t: todoProgress);
1835 m_modified = true;
1836 emit valueChanged();
1837}
1838
1839QDateTime QDeclarativeOrganizerTodoOccurrence::finishedDateTime() const
1840{
1841 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1842 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type())
1843 return static_cast<QDeclarativeOrganizerTodoProgress *>(detail)->finishedDateTime();
1844 }
1845 return QDateTime();
1846}
1847
1848/*!
1849 \qmlproperty enumeration TodoOccurrence::priority
1850
1851 This property holds the priority of the todo occurrence. The value can be one of:
1852 \list
1853 \li Priority.Unknown
1854 \li Priority.Highest
1855 \li Priority.ExtremelyHigh
1856 \li Priority.VeryHigh
1857 \li Priority.High
1858 \li Priority.Medium
1859 \li Priority.Low
1860 \li Priority.VeryLow
1861 \li Priority.ExtremelyLow
1862 \li Priority.Lowest
1863 \endlist
1864 */
1865void QDeclarativeOrganizerTodoOccurrence::setPriority(QDeclarativeOrganizerItemPriority::Priority priority)
1866{
1867 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1868 if (QDeclarativeOrganizerItemDetail::Priority == detail->type()) {
1869 QDeclarativeOrganizerItemPriority *itemPriority = static_cast<QDeclarativeOrganizerItemPriority *>(detail);
1870 if (itemPriority->priority() != priority) {
1871 itemPriority->setPriority(priority);
1872 m_modified = true;
1873 emit valueChanged();
1874 }
1875 return;
1876 }
1877 }
1878
1879 QDeclarativeOrganizerItemPriority *itemPriority = new QDeclarativeOrganizerItemPriority(this);
1880 itemPriority->setPriority(priority);
1881 m_details.append(t: itemPriority);
1882 m_modified = true;
1883 emit valueChanged();
1884}
1885
1886QDeclarativeOrganizerItemPriority::Priority QDeclarativeOrganizerTodoOccurrence::priority() const
1887{
1888 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1889 if (QDeclarativeOrganizerItemDetail::Priority == detail->type())
1890 return static_cast<QDeclarativeOrganizerItemPriority *>(detail)->priority();
1891 }
1892 return QDeclarativeOrganizerItemPriority::Unknown;
1893}
1894
1895/*!
1896 \qmlproperty enumeration TodoOccurrence::status
1897
1898 This property holds the progress status of the task described by the todo occurrence. The value can be one of:
1899 \list
1900 \li TodoProgress.NotStarted
1901 \li TodoProgress.InProgress
1902 \li TodoProgress.Complete
1903 \endlist
1904 */
1905void QDeclarativeOrganizerTodoOccurrence::setStatus(QDeclarativeOrganizerTodoProgress::StatusType status)
1906{
1907 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1908 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type()) {
1909 QDeclarativeOrganizerTodoProgress *todoProgress = static_cast<QDeclarativeOrganizerTodoProgress *>(detail);
1910 if (todoProgress->status() != status) {
1911 todoProgress->setStatus(status);
1912 m_modified = true;
1913 emit valueChanged();
1914 }
1915 return;
1916 }
1917 }
1918
1919 QDeclarativeOrganizerTodoProgress *todoProgress = new QDeclarativeOrganizerTodoProgress(this);
1920 todoProgress->setStatus(status);
1921 m_details.append(t: todoProgress);
1922 m_modified = true;
1923 emit valueChanged();
1924}
1925
1926QDeclarativeOrganizerTodoProgress::StatusType QDeclarativeOrganizerTodoOccurrence::status() const
1927{
1928 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1929 if (QDeclarativeOrganizerItemDetail::TodoProgress == detail->type())
1930 return static_cast<QDeclarativeOrganizerTodoProgress *>(detail)->status();
1931 }
1932 return QDeclarativeOrganizerTodoProgress::NotStarted;
1933}
1934
1935/*!
1936 \qmlproperty int TodoOccurrence::parentId
1937
1938 This property holds the id of the todo which is this occurrence's parent.
1939 */
1940void QDeclarativeOrganizerTodoOccurrence::setParentId(const QString &parentId)
1941{
1942 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1943 if (QDeclarativeOrganizerItemDetail::Parent == detail->type()) {
1944 QDeclarativeOrganizerItemParent *parent = static_cast<QDeclarativeOrganizerItemParent *>(detail);
1945 if (parent->parentId() != parentId) {
1946 parent->setParentId(parentId);
1947 m_modified = true;
1948 emit valueChanged();
1949 }
1950 return;
1951 }
1952 }
1953
1954 QDeclarativeOrganizerItemParent *parent = new QDeclarativeOrganizerItemParent(this);
1955 parent->setParentId(parentId);
1956 m_details.append(t: parent);
1957 m_modified = true;
1958 emit valueChanged();
1959}
1960
1961QString QDeclarativeOrganizerTodoOccurrence::parentId() const
1962{
1963 foreach (QDeclarativeOrganizerItemDetail *detail, m_details) {
1964 if (QDeclarativeOrganizerItemDetail::Parent == detail->type())
1965 return static_cast<QDeclarativeOrganizerItemParent *>(detail)->parentId();
1966 }
1967 return QString::null;
1968}
1969
1970#include "moc_qdeclarativeorganizeritem_p.cpp"
1971
1972QT_END_NAMESPACE
1973

source code of qtpim/src/imports/organizer/qdeclarativeorganizeritem.cpp