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 QPlaceCategoryPrivate()42QPlaceCategoryPrivate::QPlaceCategoryPrivate() 43 : visibility(QLocation::UnspecifiedVisibility) 44 { 45 } 46 QPlaceCategoryPrivate(const QPlaceCategoryPrivate & other)47QPlaceCategoryPrivate::QPlaceCategoryPrivate(const QPlaceCategoryPrivate &other) 48 : QSharedData(other), categoryId(other.categoryId), name(other.name), visibility(other.visibility), 49 icon(other.icon) 50 { 51 } 52 ~QPlaceCategoryPrivate()53QPlaceCategoryPrivate::~QPlaceCategoryPrivate() 54 { 55 } 56 operator =(const QPlaceCategoryPrivate & other)57QPlaceCategoryPrivate &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 isEmpty() const68bool 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 */ QPlaceCategory()103QPlaceCategory::QPlaceCategory() 104 : d(new QPlaceCategoryPrivate) 105 { 106 } 107 108 /*! 109 Constructs a category which is a copy of \a other. 110 */ QPlaceCategory(const QPlaceCategory & other)111QPlaceCategory::QPlaceCategory(const QPlaceCategory &other) 112 :d(other.d) 113 { 114 } 115 116 /*! 117 Destroys the category. 118 */ ~QPlaceCategory()119QPlaceCategory::~QPlaceCategory() 120 { 121 } 122 123 /*! 124 Assigns \a other to this category and returns a reference to this category. 125 */ operator =(const QPlaceCategory & other)126QPlaceCategory &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 */ operator ==(const QPlaceCategory & other) const138bool 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 */ categoryId() const153QString QPlaceCategory::categoryId() const 154 { 155 return d->categoryId; 156 } 157 158 /*! 159 Sets the \a identifier of the category. 160 */ setCategoryId(const QString & identifier)161void QPlaceCategory::setCategoryId(const QString &identifier) 162 { 163 d->categoryId = identifier; 164 } 165 166 /*! 167 Returns the name of category. 168 */ name() const169QString QPlaceCategory::name() const 170 { 171 return d->name; 172 } 173 174 /*! 175 Sets the \a name of the category. 176 */ setName(const QString & name)177void QPlaceCategory::setName(const QString &name) 178 { 179 d->name = name; 180 } 181 182 /*! 183 Sets the \a visibility of the category. 184 */ setVisibility(QLocation::Visibility visibility)185void QPlaceCategory::setVisibility(QLocation::Visibility visibility) 186 { 187 d->visibility = visibility; 188 } 189 190 /*! 191 Returns the visibility of the category. 192 */ visibility() const193QLocation::Visibility QPlaceCategory::visibility() const 194 { 195 return d->visibility; 196 } 197 198 /*! 199 Returns the icon associated with the category. 200 */ icon() const201QPlaceIcon QPlaceCategory::icon() const 202 { 203 return d->icon; 204 } 205 206 /*! 207 Sets the \a icon of the category. 208 */ setIcon(const QPlaceIcon & icon)209void 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 */ isEmpty() const217bool QPlaceCategory::isEmpty() const 218 { 219 return d->isEmpty(); 220 } 221 222 QT_END_NAMESPACE 223