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

source code of qtpim/src/organizer/requests/qorganizeritemfetchrequest.cpp