| 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 "qdeclarativeorganizeritemfetchhint_p.h" |
| 35 | |
| 36 | #include <QtCore/qset.h> |
| 37 | |
| 38 | QTORGANIZER_USE_NAMESPACE |
| 39 | |
| 40 | QT_BEGIN_NAMESPACE |
| 41 | |
| 42 | /*! |
| 43 | \qmltype FetchHint |
| 44 | \instantiates QDeclarativeOrganizerItemFetchHint |
| 45 | \brief The FetchHint element provides hints to the manager about which organizer item |
| 46 | information needs to be retrieved in an asynchronous fetch request or a synchronous |
| 47 | function call. |
| 48 | \inqmlmodule QtOrganizer |
| 49 | \ingroup qml-organizer-filters |
| 50 | */ |
| 51 | |
| 52 | /*! |
| 53 | \qmlsignal FetchHint::onFetchHintChanged() |
| 54 | |
| 55 | This signal is emitted, when any of the FetchHint's properties have been changed. |
| 56 | */ |
| 57 | |
| 58 | /*! |
| 59 | \internal |
| 60 | */ |
| 61 | QDeclarativeOrganizerItemFetchHint::QDeclarativeOrganizerItemFetchHint(QObject *parent) |
| 62 | : QObject(parent) |
| 63 | { |
| 64 | } |
| 65 | |
| 66 | /*! |
| 67 | \qmlproperty enumeration FetchHint::optimizationHints |
| 68 | |
| 69 | This property holds the optimization hint flags specified by the client. |
| 70 | |
| 71 | \list |
| 72 | \li AllRequired Tells the backend that all information is required. |
| 73 | \li NoActionPreferences Tells the backend that the client does not require retrieved |
| 74 | organizer items to include a cache of action preferences. |
| 75 | \li NoBinaryBlobs Tells the backend that the client does not require retrieved |
| 76 | organizer items to include binary blobs such as thumbnail images. |
| 77 | \endlist |
| 78 | */ |
| 79 | QDeclarativeOrganizerItemFetchHint::OptimizationHints QDeclarativeOrganizerItemFetchHint::optimizationHints() const |
| 80 | { |
| 81 | OptimizationHints hints; |
| 82 | hints = ~hints & (int)d.optimizationHints(); |
| 83 | return hints; |
| 84 | } |
| 85 | |
| 86 | void QDeclarativeOrganizerItemFetchHint::setOptimizationHints(OptimizationHints hints) |
| 87 | { |
| 88 | if (hints != d.optimizationHints()) { |
| 89 | QOrganizerItemFetchHint::OptimizationHints newHints; |
| 90 | newHints = ~newHints & (int)hints; |
| 91 | d.setOptimizationHints(newHints); |
| 92 | emit fetchHintChanged(); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | /*! |
| 97 | \qmlproperty list<int> FetchHint::detailTypesHint |
| 98 | |
| 99 | This property holds a list of organizer item detail types |
| 100 | the manager should (at a minimum) retrieve when fetching contacts. |
| 101 | */ |
| 102 | QList<int> QDeclarativeOrganizerItemFetchHint::detailTypesHint() const |
| 103 | { |
| 104 | QList<int> savedList; |
| 105 | foreach (const QOrganizerItemDetail::DetailType &detailTypeHint, d.detailTypesHint()) |
| 106 | savedList << static_cast<int>(detailTypeHint); |
| 107 | |
| 108 | return savedList; |
| 109 | } |
| 110 | |
| 111 | void QDeclarativeOrganizerItemFetchHint::setDetailTypesHint(const QList<int> &detailTypes) |
| 112 | { |
| 113 | if (detailTypes.toSet() != detailTypesHint().toSet()) { |
| 114 | QList<QOrganizerItemDetail::DetailType> convertedDetailTypes; |
| 115 | foreach (const int detailType, detailTypes) |
| 116 | convertedDetailTypes << static_cast<QOrganizerItemDetail::DetailType>(detailType); |
| 117 | |
| 118 | d.setDetailTypesHint(convertedDetailTypes); |
| 119 | emit fetchHintChanged(); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | /*! |
| 124 | \internal |
| 125 | */ |
| 126 | QOrganizerItemFetchHint QDeclarativeOrganizerItemFetchHint::fetchHint() const |
| 127 | { |
| 128 | return d; |
| 129 | } |
| 130 | |
| 131 | /*! |
| 132 | \internal |
| 133 | */ |
| 134 | void QDeclarativeOrganizerItemFetchHint::setFetchHint(const QOrganizerItemFetchHint &fetchHint) |
| 135 | { |
| 136 | d = fetchHint; |
| 137 | emit fetchHintChanged(); |
| 138 | } |
| 139 | |
| 140 | #include "moc_qdeclarativeorganizeritemfetchhint_p.cpp" |
| 141 | |
| 142 | QT_END_NAMESPACE |
| 143 |
