1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtOrganizer module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
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 Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
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 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
42
#include "qorganizeritemfetchhint_p.h"
44
#include <QtCore/QDataStream>
45
#ifndef QT_NO_DEBUG_STREAM
46
#include <QtCore/qdebug.h>
47
#endif // QT_NO_DEBUG_STREAM
49
QT_BEGIN_NAMESPACE_ORGANIZER
52
\class QOrganizerItemFetchHint
53
\brief The QOrganizerItemFetchHint class provides hints to the manager about which organizer item
54
information needs to be retrieved.
56
\ingroup organizer-filters
58
All of the hints may be ignored at the discretion of the manager, however if a manager
59
is able to optimize retrieval of organizer items due to hints, it may do so. If a manager
60
ignores a hint, it must retrieve the full set of data that the hint refers to.
62
The fetch hint contains:
64
\li a list of detail definition names which the client is interested
65
in (empty if interested in all detail definitions)
66
\li some optimization flags which allow the client to tell the backend if they are
67
not interested in binary blobs (images etc).
70
Important note: if certain organizer item is retrieved with fetch hint set, normal saving will
71
result in the loss of information that is not retrieved. Partial save should be used to avoid
76
\enum QOrganizerItemFetchHint::OptimizationHint
78
This enum defines flags which may be set to inform the backend that the client does
79
not require certain information.
81
\value AllRequired Tells the backend that all information is required.
82
\value NoActionPreferences Tells the backend that the client does not require retrieved
83
organizer items to include a cache of action preferences.
84
\value NoBinaryBlobs Tells the backend that the client does not require retrieved
85
organizer items to include binary blobs such as thumbnail images.
89
Constructs a new organizer item fetch hint which requests that the backend fetch all information.
91
QOrganizerItemFetchHint::QOrganizerItemFetchHint()
92
: d(new QOrganizerItemFetchHintPrivate)
97
Constructs a new organizer item fetch hint as a copy of \a other.
99
QOrganizerItemFetchHint::QOrganizerItemFetchHint(const QOrganizerItemFetchHint &other)
105
Frees any memory in use by the fetch hint.
107
QOrganizerItemFetchHint::~QOrganizerItemFetchHint()
112
Assigns this fetch hint to the \a other.
114
QOrganizerItemFetchHint& QOrganizerItemFetchHint::operator=(const QOrganizerItemFetchHint &other)
121
Returns the list of detail types that identify details which should be retrieved by the manager
124
\sa setDetailTypesHint()
126
QList<QOrganizerItemDetail::DetailType> QOrganizerItemFetchHint::detailTypesHint() const
128
return d->m_detailTypesHint;
132
Sets the list of detail types to \a detailTypes that identify details which should be retrieved'
133
by the manager when fetching items.
135
\sa detailTypesHint()
137
void QOrganizerItemFetchHint::setDetailTypesHint(const QList<QOrganizerItemDetail::DetailType> &detailTypes)
139
d->m_detailTypesHint = detailTypes;
143
Returns the optimization hint flags specified by the client.
145
\sa setOptimizationHints()
147
QOrganizerItemFetchHint::OptimizationHints QOrganizerItemFetchHint::optimizationHints() const
149
return d->m_optimizationHints;
153
Sets the optimization hint flags specified by the client to \a hints.
155
\sa optimizationHints()
157
void QOrganizerItemFetchHint::setOptimizationHints(OptimizationHints hints)
159
d->m_optimizationHints = hints;
162
#ifndef QT_NO_DATASTREAM
164
\relates QOrganizerItemFetchHint
165
Streams \a hint to the data stream \a out.
167
QDataStream &operator<<(QDataStream &out, const QOrganizerItemFetchHint &hint)
169
quint8 formatVersion = 1;
170
return out << formatVersion
171
<< hint.detailTypesHint()
172
<< static_cast<quint32>(hint.optimizationHints());
176
\relates QOrganizerItemFetchHint
177
Streams \a hint in from the data stream \a in.
179
QDataStream &operator>>(QDataStream &in, QOrganizerItemFetchHint &hint)
181
quint8 formatVersion;
183
if (formatVersion == 1) {
184
QList<quint32> detailTypesHint;
185
quint32 optimizations;
186
in >> detailTypesHint >> optimizations;
188
QList<QOrganizerItemDetail::DetailType> types;
189
foreach (quint32 detailType, detailTypesHint)
190
types.append(static_cast<QOrganizerItemDetail::DetailType>(detailType));
191
hint.setDetailTypesHint(types);
193
hint.setOptimizationHints(static_cast<QOrganizerItemFetchHint::OptimizationHints>(optimizations));
195
in.setStatus(QDataStream::ReadCorruptData);
199
#endif // QT_NO_DATASTREAM
201
#ifndef QT_NO_DEBUG_STREAM
203
\relates QOrganizerItemFetchHint
204
Outputs \a hint to the debug stream \a dbg.
206
QDebug operator<<(QDebug dbg, const QOrganizerItemFetchHint &hint)
208
dbg.nospace() << "QOrganizerItemFetchHint(";
209
dbg.nospace() << "detailDefinitionsHint=";
210
dbg.nospace() << hint.detailTypesHint();
211
dbg.nospace() << ",";
212
dbg.nospace() << "optimizationHints=";
213
dbg.nospace() << static_cast<quint32>(hint.optimizationHints());
214
dbg.nospace() << ")";
215
return dbg.maybeSpace();
217
#endif // QT_NO_DEBUG_STREAM
219
QT_END_NAMESPACE_ORGANIZER