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 "qorganizeritemfetchbyidrequest.h"
35
36#include "qorganizeritemrequests_p.h"
37
38QT_BEGIN_NAMESPACE_ORGANIZER
39
40/*!
41 \class QOrganizerItemFetchByIdRequest
42 \brief The QOrganizerItemFetchByIdRequest class allows a client to asynchronously
43 fetch items from a backend, given a list of item IDs.
44 \inmodule QtOrganizer
45 \ingroup organizer-requests
46
47 The items fetched by the backend should have a one-to-one correspondence to the IDs passed into
48 this class. That is, the nth item in the returned list should have an ID which is equal to the
49 nth ID in the list of IDs. Any invalid ID should correspond to an empty QOrganizerItem.
50 */
51
52/*!
53 Constructs a new item fetch by ID request whose parent is the specified \a parent.
54*/
55QOrganizerItemFetchByIdRequest::QOrganizerItemFetchByIdRequest(QObject *parent)
56 : QOrganizerAbstractRequest(new QOrganizerItemFetchByIdRequestPrivate, parent)
57{
58}
59
60/*!
61 Frees any memory used by this request.
62*/
63QOrganizerItemFetchByIdRequest::~QOrganizerItemFetchByIdRequest()
64{
65}
66
67/*!
68 Sets the list of IDs of the items that the backend should retrieve to \a ids.
69 */
70void QOrganizerItemFetchByIdRequest::setIds(const QList<QOrganizerItemId> &ids)
71{
72 Q_D(QOrganizerItemFetchByIdRequest);
73 QMutexLocker ml(&d->m_mutex);
74 d->m_ids = ids;
75}
76
77/*!
78 Sets the fetch hint which may be used by the backend to optimize item retrieval to \a fetchHint.
79
80 A client should not make changes to a item which has been retrieved using a fetch hint other than
81 the default fetch hint. Doing so will result in information loss when saving the item back to
82 the manager (as the "new" restricted item will replace the previously saved item in the backend).
83 */
84void QOrganizerItemFetchByIdRequest::setFetchHint(const QOrganizerItemFetchHint &fetchHint)
85{
86 Q_D(QOrganizerItemFetchByIdRequest);
87 QMutexLocker ml(&d->m_mutex);
88 d->m_fetchHint = fetchHint;
89}
90
91/*!
92 Returns the list of IDs of the items that the backend should retrieve.
93 */
94QList<QOrganizerItemId> QOrganizerItemFetchByIdRequest::ids() const
95{
96 Q_D(const QOrganizerItemFetchByIdRequest);
97 QMutexLocker ml(&d->m_mutex);
98 return d->m_ids;
99}
100
101/*!
102 Returns the fetch hint which may be used by the backend to optimize item retrieval.
103
104 A client should not make changes to a item which has been retrieved using a fetch hint other than
105 the default fetch hint. Doing so will result in information loss when saving the item back to
106 the manager (as the "new" restricted item will replace the previously saved item in the backend).
107 */
108QOrganizerItemFetchHint QOrganizerItemFetchByIdRequest::fetchHint() const
109{
110 Q_D(const QOrganizerItemFetchByIdRequest);
111 QMutexLocker ml(&d->m_mutex);
112 return d->m_fetchHint;
113}
114
115/*!
116 Returns the list of items retrieved by this request.
117*/
118QList<QOrganizerItem> QOrganizerItemFetchByIdRequest::items() const
119{
120 Q_D(const QOrganizerItemFetchByIdRequest);
121 QMutexLocker ml(&d->m_mutex);
122 return d->m_items;
123}
124
125/*!
126 Returns the map of input definition list indices to errors which occurred.
127*/
128QMap<int, QOrganizerManager::Error> QOrganizerItemFetchByIdRequest::errorMap() const
129{
130 Q_D(const QOrganizerItemFetchByIdRequest);
131 QMutexLocker ml(&d->m_mutex);
132 return d->m_errors;
133}
134
135#include "moc_qorganizeritemfetchbyidrequest.cpp"
136
137QT_END_NAMESPACE_ORGANIZER
138

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