Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qplacesearchresult.cpp
Go to the documentation of this file.
1
// Copyright (C) 2015 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"qplacesearchresult.h"
5
#
include
"qplacesearchresult_p.h"
6
#
include
"qplaceresult.h"
7
#
include
<
QtCore
/
qnumeric
.
h
>
8
9
QT_USE_NAMESPACE
10
11
template
<> QPlaceSearchResultPrivate *QSharedDataPointer<QPlaceSearchResultPrivate>::clone()
12
{
13
return
d->clone();
14
}
15
16
inline
QPlaceSearchResultPrivate *QPlaceSearchResult::d_func()
17
{
18
return
static_cast
<QPlaceSearchResultPrivate *>(d_ptr.data());
19
}
20
21
inline
const
QPlaceSearchResultPrivate *QPlaceSearchResult::d_func()
const
22
{
23
return
static_cast
<
const
QPlaceSearchResultPrivate *>(d_ptr.constData());
24
}
25
26
bool
QPlaceSearchResultPrivate::compare(
const
QPlaceSearchResultPrivate *other)
const
27
{
28
return
title == other->title
29
&& icon == other->icon;
30
}
31
32
/*!
33
\class QPlaceSearchResult
34
\inmodule QtLocation
35
\ingroup QtLocation-places
36
\ingroup QtLocation-places-data
37
\since 5.6
38
39
\brief The QPlaceSearchResult class is the base class for search results.
40
41
A list of search results can be retrieved from the QPlaceSearchReply after it has
42
successfully completed the request. Common to all search results are the
43
\l {QPlaceSearchResult::title()} {title} and \l {QPlaceSearchResult::icon()}{icon},
44
which can be used to present the search result to the user.
45
46
The intended usage is that depending on the \l {QPlaceSearchResult::type()} {type},
47
the search result can be converted to a more detailed subclass like so:
48
49
\snippet places/requesthandler.h Convert search result
50
51
The implementation is handled in such a way that object slicing is not an issue.
52
It is not expected that client applications or backend plugins instantiate
53
a QPlaceSearchResult directly, but rather client applications simply convert
54
to search result subclasses and backend plugins only instantiate subclasses.
55
56
\sa QPlaceResult
57
*/
58
59
/*!
60
\enum QPlaceSearchResult::SearchResultType
61
62
Defines the type of search result
63
64
\value UnknownSearchResult The contents of the search result are unknown.
65
\value PlaceResult The search result contains a place.
66
\value ProposedSearchResult The search result contains a proposed search which may be relevant.
67
*/
68
69
/*!
70
Constructs a new search result.
71
*/
72
QPlaceSearchResult::QPlaceSearchResult()
73
: d_ptr(
new
QPlaceSearchResultPrivate)
74
{
75
}
76
77
/*!
78
Constructs a copy of \a other
79
*/
80
QPlaceSearchResult::QPlaceSearchResult(
const
QPlaceSearchResult &other)
81
:d_ptr(other.d_ptr)
82
{
83
}
84
85
/*!
86
Destroys the search result.
87
*/
88
QPlaceSearchResult::~QPlaceSearchResult()
89
{
90
}
91
92
/*!
93
Assigns \a other to this search result and returns a reference to this
94
search result.
95
*/
96
QPlaceSearchResult &QPlaceSearchResult::operator =(
const
QPlaceSearchResult &other)
97
{
98
if
(
this
== &other)
99
return
*
this
;
100
101
d_ptr = other.d_ptr;
102
return
*
this
;
103
}
104
105
/*!
106
Returns true if \a other is equal to this search result, otherwise
107
returns false.
108
*/
109
bool
QPlaceSearchResult::operator==(
const
QPlaceSearchResult &other)
const
110
{
111
// An unknown object is only equal to another unknown search result
112
if
(!d_ptr)
113
return
!other.d_ptr;
114
115
if
(type() != other.type())
116
return
false
;
117
118
return
d_ptr->compare(other.d_ptr);
119
}
120
121
/*!
122
\fn bool QPlaceSearchResult::operator!=(const QPlaceSearchResult &other) const
123
Returns true if \a other not equal to this search result, otherwise
124
returns false.
125
*/
126
127
/*!
128
Returns the result type.
129
*/
130
QPlaceSearchResult::SearchResultType QPlaceSearchResult::type()
const
131
{
132
if
(!d_ptr)
133
return
UnknownSearchResult;
134
return
d_ptr->type();
135
}
136
137
/*!
138
Returns the title of the search result. This string can be used to display the search result
139
to the user.
140
*/
141
QString QPlaceSearchResult::title()
const
142
{
143
Q_D(
const
QPlaceSearchResult);
144
return
d->title;
145
}
146
147
/*!
148
Sets the title of the search result to \a title.
149
*/
150
void
QPlaceSearchResult::setTitle(
const
QString &title)
151
{
152
Q_D(QPlaceSearchResult);
153
d->title = title;
154
}
155
156
/*!
157
Returns an icon that can be used to represent the search result.
158
*/
159
QPlaceIcon QPlaceSearchResult::icon()
const
160
{
161
Q_D(
const
QPlaceSearchResult);
162
return
d->icon;
163
}
164
165
/*!
166
Sets the icon of the search result to \a icon.
167
*/
168
void
QPlaceSearchResult::setIcon(
const
QPlaceIcon &icon)
169
{
170
Q_D(QPlaceSearchResult);
171
d->icon = icon;
172
}
173
174
/*!
175
\internal
176
Constructs a new search result from the given pointer \a d.
177
*/
178
QPlaceSearchResult::QPlaceSearchResult(QPlaceSearchResultPrivate *d)
179
:d_ptr(d)
180
{
181
}
QT_MANGLE_NAMESPACE(RunLoopModeTracker)
Definition
qeventdispatcher_cf.mm:51
qtlocation
src
location
places
qplacesearchresult.cpp
Generated on Mon Mar 10 2025 00:50:28 for Qt by
1.13.2