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 "qorganizereventoccurrence.h"
35
36#include <QtCore/qdatetime.h>
37
38#include "qorganizereventtime.h"
39#include "qorganizeritemlocation.h"
40#include "qorganizeritemparent.h"
41
42QT_BEGIN_NAMESPACE_ORGANIZER
43
44/*!
45 \class QOrganizerEventOccurrence
46 \brief The QOrganizerEventOccurrence class provides an occurrence of an event.
47 \inmodule QtOrganizer
48 \ingroup organizer-items
49
50 An event occurrence is where the occurrence differs from the generating
51 event in some way. An occurrence which is retrieved from a manager may not
52 actually be persisted in that manager (for example, it may be generated
53 automatically from the recurrence rule of the parent event stored in the
54 manager), in which case it will have a zero-id and differ from the parent
55 event only in its start date. Alternatively, it may be persisted in the
56 manager (that is, the client has saved the occurrence previously) where it
57 is stored as an exception to its parent event.
58 */
59
60/*!
61 Sets the start date time of the event occurrence to \a startDateTime.
62 For all-day events, the time part is meaningless.
63 */
64void QOrganizerEventOccurrence::setStartDateTime(const QDateTime &startDateTime)
65{
66 QOrganizerEventTime etr = detail(detailType: QOrganizerItemDetail::TypeEventTime);
67 etr.setStartDateTime(startDateTime);
68 saveDetail(detail: &etr);
69}
70
71/*!
72 Returns the date time at which the event occurrence begins.
73 For all-day events, the time part can be set to any valid value.
74 */
75QDateTime QOrganizerEventOccurrence::startDateTime() const
76{
77 QOrganizerEventTime etr = detail(detailType: QOrganizerItemDetail::TypeEventTime);
78 return etr.startDateTime();
79}
80
81/*!
82 Sets the end date time of the event occurrence to \a endDateTime.
83 For all-day events, the time part can be set to any valid value, and the date is to be interpreted
84 as the inclusive end date.
85 */
86void QOrganizerEventOccurrence::setEndDateTime(const QDateTime &endDateTime)
87{
88 QOrganizerEventTime etr = detail(detailType: QOrganizerItemDetail::TypeEventTime);
89 etr.setEndDateTime(endDateTime);
90 saveDetail(detail: &etr);
91}
92
93/*!
94 Returns the date time at which the event occurrence ends.
95 For all-day events, the time part is meaningless, and the date is to be interpreted
96 as the inclusive end date.
97 */
98QDateTime QOrganizerEventOccurrence::endDateTime() const
99{
100 QOrganizerEventTime etr = detail(detailType: QOrganizerItemDetail::TypeEventTime);
101 return etr.endDateTime();
102}
103
104/*!
105 Sets the event occurrence's parent to be the event identified by the
106 given \a parentId.
107 */
108void QOrganizerEventOccurrence::setParentId(const QOrganizerItemId &parentId)
109{
110 QOrganizerItemParent origin = detail(detailType: QOrganizerItemDetail::TypeParent);
111 origin.setParentId(parentId);
112 saveDetail(detail: &origin);
113}
114
115/*!
116 Returns the id of the event which is this occurrence's parent.
117 */
118QOrganizerItemId QOrganizerEventOccurrence::parentId() const
119{
120 QOrganizerItemParent origin = detail(detailType: QOrganizerItemDetail::TypeParent);
121 return origin.parentId();
122}
123
124/*!
125 Sets the date at which this occurrence was originally going to occur,
126 to the given \a date.
127 */
128void QOrganizerEventOccurrence::setOriginalDate(const QDate &date)
129{
130 QOrganizerItemParent origin = detail(detailType: QOrganizerItemDetail::TypeParent);
131 origin.setOriginalDate(date);
132 saveDetail(detail: &origin);
133}
134
135/*!
136 Returns the date at which the occurrence was originally going to occur.
137 */
138QDate QOrganizerEventOccurrence::originalDate() const
139{
140 QOrganizerItemParent origin = detail(detailType: QOrganizerItemDetail::TypeParent);
141 return origin.originalDate();
142}
143
144/*!
145 Sets the priority of the event occurrence to \a priority.
146 */
147void QOrganizerEventOccurrence::setPriority(QOrganizerItemPriority::Priority priority)
148{
149 QOrganizerItemPriority pd = detail(detailType: QOrganizerItemDetail::TypePriority);
150 pd.setPriority(priority);
151 saveDetail(detail: &pd);
152}
153
154/*!
155 Returns the priority of the event occurrence.
156 */
157QOrganizerItemPriority::Priority QOrganizerEventOccurrence::priority() const
158{
159 QOrganizerItemPriority pd = detail(detailType: QOrganizerItemDetail::TypePriority);
160 return pd.priority();
161}
162
163/*!
164 Returns the label of the location at which the event occurrence is held.
165 */
166QString QOrganizerEventOccurrence::location() const
167{
168 QOrganizerItemLocation ld = detail(detailType: QOrganizerItemDetail::TypeLocation);
169 return ld.label();
170}
171
172/*!
173 Sets the label of the location at which the event occurrence is held to \a label.
174 */
175void QOrganizerEventOccurrence::setLocation(const QString &label)
176{
177 QOrganizerItemLocation ld = detail(detailType: QOrganizerItemDetail::TypeLocation);
178 ld.setLabel(label);
179 saveDetail(detail: &ld);
180}
181
182QT_END_NAMESPACE_ORGANIZER
183

source code of qtpim/src/organizer/items/qorganizereventoccurrence.cpp