| 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 QtLocation module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
| 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 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or later as published by the Free |
| 28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
| 29 | ** the packaging of this file. Please review the following information to |
| 30 | ** ensure the GNU General Public License version 2.0 requirements will be |
| 31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
| 32 | ** |
| 33 | ** $QT_END_LICENSE$ |
| 34 | ** |
| 35 | ****************************************************************************/ |
| 36 | |
| 37 | #include "qplacesupplier.h" |
| 38 | #include "qplacesupplier_p.h" |
| 39 | |
| 40 | QT_USE_NAMESPACE |
| 41 | |
| 42 | QPlaceSupplierPrivate::QPlaceSupplierPrivate() : QSharedData() |
| 43 | { |
| 44 | } |
| 45 | |
| 46 | QPlaceSupplierPrivate::QPlaceSupplierPrivate(const QPlaceSupplierPrivate &other) |
| 47 | : QSharedData() |
| 48 | { |
| 49 | this->name = other.name; |
| 50 | this->supplierId = other.supplierId; |
| 51 | this->url = other.url; |
| 52 | this->icon = other.icon; |
| 53 | } |
| 54 | |
| 55 | QPlaceSupplierPrivate::~QPlaceSupplierPrivate() |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | bool QPlaceSupplierPrivate::operator==(const QPlaceSupplierPrivate &other) const |
| 60 | { |
| 61 | return ( |
| 62 | this->name == other.name |
| 63 | && this->supplierId == other.supplierId |
| 64 | && this->url == other.url |
| 65 | && this->icon == other.icon |
| 66 | ); |
| 67 | } |
| 68 | |
| 69 | bool QPlaceSupplierPrivate::isEmpty() const |
| 70 | { |
| 71 | return (name.isEmpty() |
| 72 | && supplierId.isEmpty() |
| 73 | && url.isEmpty() |
| 74 | && icon.isEmpty() |
| 75 | ); |
| 76 | } |
| 77 | |
| 78 | /*! |
| 79 | \class QPlaceSupplier |
| 80 | \inmodule QtLocation |
| 81 | \ingroup QtLocation-places |
| 82 | \ingroup QtLocation-places-data |
| 83 | \since 5.6 |
| 84 | |
| 85 | \brief The QPlaceSupplier class represents a supplier of a place or content associated |
| 86 | with a place. |
| 87 | |
| 88 | Each instance represents a set of data about a supplier, which can include |
| 89 | supplier's name, url and icon. The supplier is typically a business or organization. |
| 90 | |
| 91 | Note: The Places API only supports suppliers as 'retrieve-only' objects. Submitting |
| 92 | suppliers to a provider is not a supported use case. |
| 93 | */ |
| 94 | |
| 95 | /*! |
| 96 | Constructs a new supplier object. |
| 97 | */ |
| 98 | QPlaceSupplier::QPlaceSupplier() |
| 99 | : d(new QPlaceSupplierPrivate) |
| 100 | { |
| 101 | } |
| 102 | |
| 103 | /*! |
| 104 | Constructs a copy of \a other. |
| 105 | */ |
| 106 | QPlaceSupplier::QPlaceSupplier(const QPlaceSupplier &other) |
| 107 | :d(other.d) |
| 108 | { |
| 109 | } |
| 110 | |
| 111 | /*! |
| 112 | Destroys the supplier object. |
| 113 | */ |
| 114 | QPlaceSupplier::~QPlaceSupplier() |
| 115 | { |
| 116 | } |
| 117 | |
| 118 | /*! |
| 119 | Assigns \a other to this supplier and returns a reference to this |
| 120 | supplier. |
| 121 | */ |
| 122 | QPlaceSupplier &QPlaceSupplier::operator=(const QPlaceSupplier &other) |
| 123 | { |
| 124 | if (this == &other) |
| 125 | return *this; |
| 126 | |
| 127 | d = other.d; |
| 128 | return *this; |
| 129 | } |
| 130 | |
| 131 | /*! |
| 132 | Returns true if this supplier is equal to \a other, |
| 133 | otherwise returns false. |
| 134 | */ |
| 135 | bool QPlaceSupplier::operator==(const QPlaceSupplier &other) const |
| 136 | { |
| 137 | return (*(d.constData()) == *(other.d.constData())); |
| 138 | } |
| 139 | |
| 140 | /*! |
| 141 | \fn QPlaceSupplier::operator!=(const QPlaceSupplier &other) const |
| 142 | |
| 143 | Returns true if this supplier is not equal to \a other, |
| 144 | otherwise returns false. |
| 145 | */ |
| 146 | |
| 147 | /*! |
| 148 | Returns the name of the supplier which can be displayed to the user. |
| 149 | |
| 150 | The name can potentially be localized. The language is dependent on the |
| 151 | entity that sets it, typically this is the QPlaceManager. |
| 152 | The QPlaceManager::locales() field defines what language is used. |
| 153 | */ |
| 154 | QString QPlaceSupplier::name() const |
| 155 | { |
| 156 | return d->name; |
| 157 | } |
| 158 | |
| 159 | /*! |
| 160 | Sets the \a name of the supplier. |
| 161 | */ |
| 162 | void QPlaceSupplier::setName(const QString &name) |
| 163 | { |
| 164 | d->name = name; |
| 165 | } |
| 166 | |
| 167 | /*! |
| 168 | Returns the identifier of the supplier. The identifier is unique |
| 169 | to the manager backend which provided the supplier and is generally |
| 170 | not suitable for displaying to the user. |
| 171 | */ |
| 172 | QString QPlaceSupplier::supplierId() const |
| 173 | { |
| 174 | return d->supplierId; |
| 175 | } |
| 176 | |
| 177 | /*! |
| 178 | Sets the \a identifier of the supplier. |
| 179 | */ |
| 180 | void QPlaceSupplier::setSupplierId(const QString &identifier) |
| 181 | { |
| 182 | d->supplierId = identifier; |
| 183 | } |
| 184 | |
| 185 | /*! |
| 186 | Returns the URL of the supplier's website. |
| 187 | */ |
| 188 | QUrl QPlaceSupplier::url() const |
| 189 | { |
| 190 | return d->url; |
| 191 | } |
| 192 | |
| 193 | /*! |
| 194 | Sets the \a url of the supplier's website. |
| 195 | */ |
| 196 | void QPlaceSupplier::setUrl(const QUrl &url) |
| 197 | { |
| 198 | d->url = url; |
| 199 | } |
| 200 | |
| 201 | /*! |
| 202 | Returns the icon of the supplier. |
| 203 | */ |
| 204 | QPlaceIcon QPlaceSupplier::icon() const |
| 205 | { |
| 206 | return d->icon; |
| 207 | } |
| 208 | |
| 209 | /*! |
| 210 | Sets the \a icon of the supplier. |
| 211 | */ |
| 212 | void QPlaceSupplier::setIcon(const QPlaceIcon &icon) |
| 213 | { |
| 214 | d->icon = icon; |
| 215 | } |
| 216 | |
| 217 | /*! |
| 218 | Returns true if all fields of the place supplier are 0; otherwise returns false. |
| 219 | */ |
| 220 | bool QPlaceSupplier::isEmpty() const |
| 221 | { |
| 222 | return d->isEmpty(); |
| 223 | } |
| 224 | |