7#include <QtQml/QQmlEngine>
8#include <QtQml/QQmlInfo>
9#include <QtLocation/QGeoServiceProvider>
10#include <QtLocation/QPlaceSearchReply>
11#include <QtLocation/QPlaceManager>
12#include <QtLocation/QPlaceMatchRequest>
13#include <QtLocation/QPlaceMatchReply>
14#include <QtLocation/QPlaceResult>
15#include <QtLocation/QPlaceProposedSearchResult>
16#include <QtLocation/private/qplacesearchrequest_p.h>
371 if (searchModel && declCategory) {
373 searchModel->m_categories.
append(declCategory);
385 return searchModel->m_categories.
count();
394 if (searchModel && (searchModel->m_categories.
count() >
index) && (
index > -1))
395 return searchModel->m_categories.
at(
index);
406 searchModel->m_categories.
clear();
498 QLocation::VisibilityScope scope = QLocation::VisibilityScope(
visibilityScope);
500 if (m_visibilityScope == scope)
503 m_visibilityScope = scope;
512 return m_favoritesPlugin;
521 if (m_favoritesPlugin ==
plugin)
524 m_favoritesPlugin =
plugin;
526 if (m_favoritesPlugin) {
528 if (serviceProvider) {
547 return m_matchParameters;
555 if (m_matchParameters == parameters)
558 m_matchParameters = parameters;
569 return m_results.
count();
595 case SearchResultTypeRole:
634 roles.
insert(SearchResultTypeRole,
"type");
635 roles.
insert(TitleRole,
"title");
636 roles.
insert(IconRole,
"icon");
637 roles.
insert(DistanceRole,
"distance");
638 roles.
insert(PlaceRole,
"place");
639 roles.
insert(SponsoredRole,
"sponsored");
679 if (serviceProvider) {
683 this, &QDeclarativeSearchResultModel::placeUpdated);
685 this, &QDeclarativeSearchResultModel::placeRemoved);
695 if (serviceProvider) {
699 this, &QDeclarativeSearchResultModel::placeUpdated);
701 this, &QDeclarativeSearchResultModel::placeRemoved);
725 m_resultsBuffer.
clear();
736 if (!rpimpl->
related || !m_incremental)
738 m_resultsBuffer = searchReply->
results();
739 bool alreadyLoaded =
false;
741 alreadyLoaded =
true;
742 m_pages.
insert(rpimpl->
page, m_resultsBuffer);
747 if (!m_favoritesPlugin) {
752 if (!serviceProvider) {
759 if (!favoritesManager) {
766 if (m_matchParameters.
isEmpty()) {
776 request.setParameters(m_matchParameters);
779 request.setResults(m_resultsBuffer);
781 m_resultsBuffer.
clear();
791 updateLayout(matchReply->
places());
809 m_resultsBuffer.
clear();
820 if (!rpimpl->
related || !m_incremental)
822 m_resultsBuffer = searchReply->
results();
824 m_pages.
insert(rpimpl->
page, m_resultsBuffer);
855void QDeclarativeSearchResultModel::updateLayout(
const QList<QPlace> &favoritePlaces)
861 if (!m_resultsBuffer.
size())
865 m_results = resultsFromPages();
870 m_results = m_resultsBuffer;
873 m_resultsBuffer.
clear();
884 m_favoritesPlugin, m_places[
i]));
889 if (!
result.icon().isEmpty())
897 if (m_results.
count() != oldRowCount)
904void QDeclarativeSearchResultModel::placeUpdated(
const QString &placeId)
906 int row = getRow(placeId);
907 if (row < 0 || row > m_places.
count())
910 if (m_places.
at(
row))
917void QDeclarativeSearchResultModel::placeRemoved(
const QString &placeId)
919 int row = getRow(placeId);
920 if (row < 0 || row > m_places.
count())
924 delete m_places.
at(
row);
936 for (
const auto &
e : m_pages)
941void QDeclarativeSearchResultModel::removePageRow(
int row)
957int QDeclarativeSearchResultModel::getRow(
const QString &placeId)
const
962 else if (m_places.
at(
i)->
placeId() == placeId)
void endResetModel()
Completes a model reset operation.
void endRemoveRows()
Ends a row removal operation.
virtual QHash< int, QByteArray > roleNames() const
void endInsertRows()
Ends a row insertion operation.
void beginResetModel()
Begins a model reset operation.
QModelIndex createIndex(int row, int column, const void *data=nullptr) const
Creates a model index for the given row and column with the internal pointer ptr.
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Begins a row removal operation.
void beginInsertRows(const QModelIndex &parent, int first, int last)
Begins a row insertion operation.
QObject * parent() const
Returns a pointer to the parent object.
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
QByteArray & removeAt(qsizetype pos)
QGeoServiceProvider * sharedGeoServiceProvider() const
Q_INVOKABLE void getDetails()
\qmlmethod void Place::getDetails()
Q_INVOKABLE void update()
virtual void clearData(bool suppressSignal=false)
QDeclarativeGeoServiceProvider * plugin
virtual void initializePlugin(QDeclarativeGeoServiceProvider *plugin)
QDeclarativeGeoServiceProvider * m_plugin
void setPreviousPageRequest(const QPlaceSearchRequest &previous)
QPlaceSearchRequest m_request
void setNextPageRequest(const QPlaceSearchRequest &next)
void setStatus(Status status, const QString &errorString=QString())
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the data stored under the given role for the item referred to by the index.
void onContentUpdated() override
QDeclarativeSearchResultModel(QObject *parent=nullptr)
\qmltype PlaceSearchModel \instantiates QDeclarativeSearchResultModel \inqmlmodule QtLocation
Q_INVOKABLE void updateWith(int proposedSearchIndex)
\qmlmethod void PlaceSearchModel::updateWith(int proposedSearchIndex)
void setRelevanceHint(QDeclarativeSearchResultModel::RelevanceHint hint)
void setVisibilityScope(QDeclarativePlace::Visibility visibilityScope)
void queryFinished() override
QDeclarativeGeoServiceProvider * favoritesPlugin
void favoritesPluginChanged()
QVariantMap favoritesMatchParameters
void favoritesMatchParametersChanged()
void clearData(bool suppressSignal=false) override
RelevanceHint relevanceHint
QQmlListProperty< QDeclarativeCategory > categories
\qmlproperty list<Category> PlaceSearchModel::categories
void recommendationIdChanged()
void relevanceHintChanged()
static void categories_clear(QQmlListProperty< QDeclarativeCategory > *list)
void setSearchTerm(const QString &searchTerm)
static qsizetype categories_count(QQmlListProperty< QDeclarativeCategory > *list)
QPlaceReply * sendQuery(QPlaceManager *manager, const QPlaceSearchRequest &request) override
~QDeclarativeSearchResultModel()
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void setFavoritesMatchParameters(const QVariantMap ¶meters)
void setFavoritesPlugin(QDeclarativeGeoServiceProvider *plugin)
static QDeclarativeCategory * category_at(QQmlListProperty< QDeclarativeCategory > *list, qsizetype index)
static void categories_append(QQmlListProperty< QDeclarativeCategory > *list, QDeclarativeCategory *category)
void setRecommendationId(const QString &recommendationId)
void visibilityScopeChanged()
void initializePlugin(QDeclarativeGeoServiceProvider *plugin) override
QHash< int, QByteArray > roleNames() const override
QDeclarativePlace::Visibility visibilityScope
QPlaceManager * placeManager() const
Returns the QPlaceManager made available by the service provider.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
qsizetype size() const noexcept
bool isEmpty() const noexcept
void removeAt(qsizetype i)
const_reference at(qsizetype i) const noexcept
qsizetype count() const noexcept
void append(parameter_type t)
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue=T()) const
bool contains(const Key &key) const
NetworkError error() const
Returns the error that was found during the processing of this request.
void deleteLater()
\threadsafe
QPlaceMatchReply * matchingPlaces(const QPlaceMatchRequest &request) const
Returns a reply which contains a list of places which correspond/match those specified in the request...
QStringList childCategoryIds(const QString &parentId=QString()) const
Returns the child category identifiers of the category corresponding to parentId.
void placeUpdated(const QString &placeId)
This signal is emitted if a place has been modified in the manager's datastore.
QPlaceReply * initializeCategories()
Initializes the categories of the manager.
void dataChanged()
This signal is emitted by the manager if there are large scale changes to its underlying datastore an...
void placeRemoved(const QString &placeId)
This signal is emitted if a place has been removed from the manager's datastore.
QList< QPlace > places() const
Returns a list of matching places;.
static const QString AlternativeId
\variable QPlaceMatchRequest::AlternativeId The key to specify that matching is to be accomplished vi...
QPlaceSearchRequest searchRequest() const
Returns a place search request that can be used to perform an additional proposed search.
void finished()
This signal is emitted when this reply has finished processing.
void contentUpdated()
This signal is emitted when this reply has updated content available.
bool isSponsored() const
Returns true if the result is a sponsored result.
qreal distance() const
Returns the distance of the place to the search center.
QPlace place() const
Returns the place of the search result.
QPlaceSearchRequest request() const
Returns the search request that was used to generate this reply.
QList< QPlaceSearchResult > results() const
Returns a list of search results;.
QPlaceSearchRequest previousPageRequest() const
Returns a place search request which can be used to request the previous page of search results.
QPlaceSearchRequest nextPageRequest() const
Returns a place search request which can be used to request the next page of search results.
static const QPlaceSearchRequestPrivate * get(const QPlaceSearchRequest &request)
void setSearchTerm(const QString &term)
Sets the search term.
RelevanceHint
Defines hints to help rank place results.
QString searchTerm() const
Returns the search term.
void setRecommendationId(const QString &recommendationId)
Sets the placeId which will be used to search for recommendations.
QList< QPlaceCategory > categories() const
Return the categories to be used in the search request.
void setRelevanceHint(RelevanceHint hint)
Sets the relevance hint to be used when searching for a place.
QString recommendationId() const
Returns the place id which will be used to search for recommendations for similar places.
void setSearchContext(const QVariant &context)
Sets the search context to context.
void setCategories(const QList< QPlaceCategory > &categories)
Sets the search request to search from the list of given categories.
RelevanceHint relevanceHint() const
Returns the relevance hint of the request.
SearchResultType type() const
Returns the result type.
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
list append(new Employee("Blackpool", "Stephen"))
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLenum * categories
GLenum GLenum GLsizei void * row
#define QStringLiteral(str)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]
QNetworkAccessManager manager
QNetworkRequest request(url)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent