| 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 "qplacecategory.h" | 
| 38 | #include "qplacecategory_p.h" | 
| 39 | |
| 40 | QT_BEGIN_NAMESPACE | 
| 41 | |
| 42 | QPlaceCategoryPrivate::QPlaceCategoryPrivate() | 
| 43 | : visibility(QLocation::UnspecifiedVisibility) | 
| 44 | { | 
| 45 | } | 
| 46 | |
| 47 | QPlaceCategoryPrivate::QPlaceCategoryPrivate(const QPlaceCategoryPrivate &other) | 
| 48 | : QSharedData(other), categoryId(other.categoryId), name(other.name), visibility(other.visibility), | 
| 49 | icon(other.icon) | 
| 50 | { | 
| 51 | } | 
| 52 | |
| 53 | QPlaceCategoryPrivate::~QPlaceCategoryPrivate() | 
| 54 | { | 
| 55 | } | 
| 56 | |
| 57 | QPlaceCategoryPrivate &QPlaceCategoryPrivate::operator=(const QPlaceCategoryPrivate &other) | 
| 58 | { | 
| 59 | if (this == &other) | 
| 60 | return *this; | 
| 61 | |
| 62 | categoryId = other.categoryId; | 
| 63 | name = other.name; | 
| 64 | icon = other.icon; | 
| 65 | return *this; | 
| 66 | } | 
| 67 | |
| 68 | bool QPlaceCategoryPrivate::isEmpty() const | 
| 69 | { | 
| 70 | return categoryId.isEmpty() | 
| 71 | && name.isEmpty() | 
| 72 | && icon.isEmpty() | 
| 73 | && QLocation::UnspecifiedVisibility == visibility; | 
| 74 | } | 
| 75 | |
| 76 | /*! | 
| 77 | \class QPlaceCategory | 
| 78 | \inmodule QtLocation | 
| 79 | \ingroup QtLocation-places | 
| 80 | \ingroup QtLocation-places-data | 
| 81 | \since 5.6 | 
| 82 | |
| 83 | \brief The QPlaceCategory class represents a category that a \l QPlace can be associated with. | 
| 84 | |
| 85 | Categories are used to search for places based on the categories they are associated with. The | 
| 86 | list/tree of available categories can be obtained from \l QPlaceManager. The | 
| 87 | \l QPlaceSearchRequest::setCategories() function can be used to limit the search results to | 
| 88 | places with the specified categories. | 
| 89 | |
| 90 | If the \l QGeoServiceProvider supports it, categories can be created and removed. This | 
| 91 | functionality is available in the \l QPlaceManager class. | 
| 92 | */ | 
| 93 | |
| 94 | /*! | 
| 95 | \fn bool QPlaceCategory::operator!=(const QPlaceCategory &other) const | 
| 96 | |
| 97 | Returns true if \a other is not equal to this category; otherwise returns false. | 
| 98 | */ | 
| 99 | |
| 100 | /*! | 
| 101 | Constructs a category. | 
| 102 | */ | 
| 103 | QPlaceCategory::QPlaceCategory() | 
| 104 | : d(new QPlaceCategoryPrivate) | 
| 105 | { | 
| 106 | } | 
| 107 | |
| 108 | /*! | 
| 109 | Constructs a category which is a copy of \a other. | 
| 110 | */ | 
| 111 | QPlaceCategory::QPlaceCategory(const QPlaceCategory &other) | 
| 112 | :d(other.d) | 
| 113 | { | 
| 114 | } | 
| 115 | |
| 116 | /*! | 
| 117 | Destroys the category. | 
| 118 | */ | 
| 119 | QPlaceCategory::~QPlaceCategory() | 
| 120 | { | 
| 121 | } | 
| 122 | |
| 123 | /*! | 
| 124 | Assigns \a other to this category and returns a reference to this category. | 
| 125 | */ | 
| 126 | QPlaceCategory &QPlaceCategory::operator =(const QPlaceCategory &other) | 
| 127 | { | 
| 128 | if (this == &other) | 
| 129 | return *this; | 
| 130 | |
| 131 | d = other.d; | 
| 132 | return *this; | 
| 133 | } | 
| 134 | |
| 135 | /*! | 
| 136 | Returns true if \a other is equal to this category; otherwise returns false. | 
| 137 | */ | 
| 138 | bool QPlaceCategory::operator==(const QPlaceCategory &other) const | 
| 139 | { | 
| 140 | return d->categoryId == other.d->categoryId && | 
| 141 | d->name == other.d->name && | 
| 142 | (d->visibility == QLocation::UnspecifiedVisibility || | 
| 143 | other.d->visibility == QLocation::UnspecifiedVisibility || | 
| 144 | d->visibility == other.d->visibility) && | 
| 145 | d->icon == other.d->icon; | 
| 146 | } | 
| 147 | |
| 148 | /*! | 
| 149 | Returns the identifier of the category. The category identifier is a string which uniquely identifies this category | 
| 150 | within a particular \l QPlaceManager. The identifier is only meaningful to the QPlaceManager | 
| 151 | that generated it and is not transferable between managers. | 
| 152 | */ | 
| 153 | QString QPlaceCategory::categoryId() const | 
| 154 | { | 
| 155 | return d->categoryId; | 
| 156 | } | 
| 157 | |
| 158 | /*! | 
| 159 | Sets the \a identifier of the category. | 
| 160 | */ | 
| 161 | void QPlaceCategory::setCategoryId(const QString &identifier) | 
| 162 | { | 
| 163 | d->categoryId = identifier; | 
| 164 | } | 
| 165 | |
| 166 | /*! | 
| 167 | Returns the name of category. | 
| 168 | */ | 
| 169 | QString QPlaceCategory::name() const | 
| 170 | { | 
| 171 | return d->name; | 
| 172 | } | 
| 173 | |
| 174 | /*! | 
| 175 | Sets the \a name of the category. | 
| 176 | */ | 
| 177 | void QPlaceCategory::setName(const QString &name) | 
| 178 | { | 
| 179 | d->name = name; | 
| 180 | } | 
| 181 | |
| 182 | /*! | 
| 183 | Sets the \a visibility of the category. | 
| 184 | */ | 
| 185 | void QPlaceCategory::setVisibility(QLocation::Visibility visibility) | 
| 186 | { | 
| 187 | d->visibility = visibility; | 
| 188 | } | 
| 189 | |
| 190 | /*! | 
| 191 | Returns the visibility of the category. | 
| 192 | */ | 
| 193 | QLocation::Visibility QPlaceCategory::visibility() const | 
| 194 | { | 
| 195 | return d->visibility; | 
| 196 | } | 
| 197 | |
| 198 | /*! | 
| 199 | Returns the icon associated with the category. | 
| 200 | */ | 
| 201 | QPlaceIcon QPlaceCategory::icon() const | 
| 202 | { | 
| 203 | return d->icon; | 
| 204 | } | 
| 205 | |
| 206 | /*! | 
| 207 | Sets the \a icon of the category. | 
| 208 | */ | 
| 209 | void QPlaceCategory::setIcon(const QPlaceIcon &icon) | 
| 210 | { | 
| 211 | d->icon = icon; | 
| 212 | } | 
| 213 | |
| 214 | /*! | 
| 215 | Returns a boolean indicating whether the all the fields of the place category are empty or not. | 
| 216 | */ | 
| 217 | bool QPlaceCategory::isEmpty() const | 
| 218 | { | 
| 219 | return d->isEmpty(); | 
| 220 | } | 
| 221 | |
| 222 | QT_END_NAMESPACE | 
| 223 | 
