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 "qorganizeritemoccurrencefetchrequest.h" |
35 | |
36 | #include "qorganizeritemrequests_p.h" |
37 | |
38 | QT_BEGIN_NAMESPACE_ORGANIZER |
39 | |
40 | /*! |
41 | \class QOrganizerItemOccurrenceFetchRequest |
42 | \brief The QOrganizerItemOccurrenceFetchRequest class allows a client to asynchronously fetch |
43 | occurrences generated by a recurring item. |
44 | \inmodule QtOrganizer |
45 | \ingroup organizer-requests |
46 | |
47 | This request will fetch both generated occurrences and persisted occurrences, which match the |
48 | specified criteria, of the given parent item. |
49 | */ |
50 | |
51 | /*! |
52 | Constructs a new organizer item occurrence fetch request whose parent is the specified \a parent. |
53 | */ |
54 | QOrganizerItemOccurrenceFetchRequest::QOrganizerItemOccurrenceFetchRequest(QObject *parent) |
55 | : QOrganizerAbstractRequest(new QOrganizerItemOccurrenceFetchRequestPrivate, parent) |
56 | { |
57 | } |
58 | |
59 | /*! |
60 | Frees memory in use by this request. |
61 | */ |
62 | QOrganizerItemOccurrenceFetchRequest::~QOrganizerItemOccurrenceFetchRequest() |
63 | { |
64 | } |
65 | |
66 | /*! |
67 | Sets the parent item, whose occurrences are to be fetched to \a item. |
68 | */ |
69 | void QOrganizerItemOccurrenceFetchRequest::setParentItem(const QOrganizerItem &item) |
70 | { |
71 | Q_D(QOrganizerItemOccurrenceFetchRequest); |
72 | QMutexLocker ml(&d->m_mutex); |
73 | d->m_generator = item; |
74 | } |
75 | |
76 | /*! |
77 | Sets the start period of the request to \a date. |
78 | |
79 | A default-constructed (invalid) start date time specifies an open start date time (matches anything |
80 | which occurs up until the end date time). |
81 | */ |
82 | void QOrganizerItemOccurrenceFetchRequest::setStartDate(const QDateTime &date) |
83 | { |
84 | Q_D(QOrganizerItemOccurrenceFetchRequest); |
85 | QMutexLocker ml(&d->m_mutex); |
86 | d->m_startDate = date; |
87 | } |
88 | |
89 | /*! |
90 | Sets the end period of the request to \a date. |
91 | |
92 | A default-constructed (invalid) end date time specifies an open end date time (matches anything |
93 | which occurs after the start date time). |
94 | */ |
95 | void QOrganizerItemOccurrenceFetchRequest::setEndDate(const QDateTime &date) |
96 | { |
97 | Q_D(QOrganizerItemOccurrenceFetchRequest); |
98 | QMutexLocker ml(&d->m_mutex); |
99 | d->m_endDate = date; |
100 | } |
101 | |
102 | /*! |
103 | Sets the maximum number of occurrences to fetch to \a maxCount. |
104 | |
105 | Note that backends will decide how many items are fetched if \a maxCount is negative. |
106 | */ |
107 | void QOrganizerItemOccurrenceFetchRequest::setMaxOccurrences(int maxCount) |
108 | { |
109 | Q_D(QOrganizerItemOccurrenceFetchRequest); |
110 | QMutexLocker ml(&d->m_mutex); |
111 | d->m_maxOccurrences = maxCount; |
112 | } |
113 | |
114 | /*! |
115 | Sets the fetch hint which may be used by the backend to optimize item retrieval to \a fetchHint. |
116 | |
117 | A client should not make changes to a item which has been retrieved using a fetch hint other than |
118 | the default fetch hint. Doing so will result in information loss when saving the item back to |
119 | the manager (as the "new" restricted item will replace the previously saved item in the backend). |
120 | */ |
121 | void QOrganizerItemOccurrenceFetchRequest::setFetchHint(const QOrganizerItemFetchHint &fetchHint) |
122 | { |
123 | Q_D(QOrganizerItemOccurrenceFetchRequest); |
124 | QMutexLocker ml(&d->m_mutex); |
125 | d->m_fetchHint = fetchHint; |
126 | } |
127 | |
128 | /*! |
129 | Returns the parent item, whose occurrences are to be fetched. |
130 | */ |
131 | QOrganizerItem QOrganizerItemOccurrenceFetchRequest::parentItem() const |
132 | { |
133 | Q_D(const QOrganizerItemOccurrenceFetchRequest); |
134 | QMutexLocker ml(&d->m_mutex); |
135 | return d->m_generator; |
136 | } |
137 | |
138 | /*! |
139 | Returns the date-time which is the lower bound for the range in which occurrences will be returned. |
140 | */ |
141 | QDateTime QOrganizerItemOccurrenceFetchRequest::startDate() const |
142 | { |
143 | Q_D(const QOrganizerItemOccurrenceFetchRequest); |
144 | QMutexLocker ml(&d->m_mutex); |
145 | return d->m_startDate; |
146 | } |
147 | |
148 | /*! |
149 | Returns the date-time which is the upper bound for the range in which occurrences will be returned. |
150 | */ |
151 | QDateTime QOrganizerItemOccurrenceFetchRequest::endDate() const |
152 | { |
153 | Q_D(const QOrganizerItemOccurrenceFetchRequest); |
154 | QMutexLocker ml(&d->m_mutex); |
155 | return d->m_endDate; |
156 | } |
157 | |
158 | /*! |
159 | Returns the maximum number of occurrences to return for the request. |
160 | */ |
161 | int QOrganizerItemOccurrenceFetchRequest::maxOccurrences() const |
162 | { |
163 | Q_D(const QOrganizerItemOccurrenceFetchRequest); |
164 | QMutexLocker ml(&d->m_mutex); |
165 | return d->m_maxOccurrences; |
166 | } |
167 | |
168 | /*! |
169 | Returns the list of organizer item occurrences retrieved by this request. |
170 | */ |
171 | QList<QOrganizerItem> QOrganizerItemOccurrenceFetchRequest::itemOccurrences() const |
172 | { |
173 | Q_D(const QOrganizerItemOccurrenceFetchRequest); |
174 | QMutexLocker ml(&d->m_mutex); |
175 | return d->m_organizeritems; |
176 | } |
177 | |
178 | /*! |
179 | Returns the fetch hint which may be used by the backend to optimize item retrieval. |
180 | |
181 | A client should not make changes to a item which has been retrieved using a fetch hint other than |
182 | the default fetch hint. Doing so will result in information loss when saving the item back to |
183 | the manager (as the "new" restricted item will replace the previously saved item in the backend). |
184 | */ |
185 | QOrganizerItemFetchHint QOrganizerItemOccurrenceFetchRequest::fetchHint() const |
186 | { |
187 | Q_D(const QOrganizerItemOccurrenceFetchRequest); |
188 | QMutexLocker ml(&d->m_mutex); |
189 | return d->m_fetchHint; |
190 | } |
191 | |
192 | #include "moc_qorganizeritemoccurrencefetchrequest.cpp" |
193 | |
194 | QT_END_NAMESPACE_ORGANIZER |
195 | |