summaryrefslogtreecommitdiff
path: root/src/location/places
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-12-22 18:17:19 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-07-05 06:09:56 +0000
commitf8df5799b68fcb8690462b6dce226e6ce9bac282 (patch)
treec88fbdc8b4bd28662cfe3c14d665c4744fc29057 /src/location/places
parent5ccc595db4e9282f6a58f8712550eda935a6eecb (diff)
downloadqtlocation-f8df5799b68fcb8690462b6dce226e6ce9bac282.tar.gz
Enable incremental updates in PlaceSearchModel
This way pages can be changed without resetting the model. To achieve this, new members into QPlaceSearchRequestPrivate are introduced, to keep the relationship between a request for one page, and the previous or the next page. In this way sparse population of the model becomes possible. Change-Id: Ic8db0281408f3500ba83f78c7e152ee0b68cd099 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/location/places')
-rw-r--r--src/location/places/places.pri1
-rw-r--r--src/location/places/qplacesearchrequest.cpp44
-rw-r--r--src/location/places/qplacesearchrequest.h2
-rw-r--r--src/location/places/qplacesearchrequest_p.h79
4 files changed, 103 insertions, 23 deletions
diff --git a/src/location/places/places.pri b/src/location/places/places.pri
index 1a3796fc..5a766b61 100644
--- a/src/location/places/places.pri
+++ b/src/location/places/places.pri
@@ -24,6 +24,7 @@ PUBLIC_HEADERS += \
places/qplacecontentrequest.h \
places/qplacematchrequest.h \
places/qplacesearchrequest.h \
+ places/qplacesearchrequest_p.h \
#reply classes
places/qplacereply.h \
places/qplacedetailsreply.h \
diff --git a/src/location/places/qplacesearchrequest.cpp b/src/location/places/qplacesearchrequest.cpp
index c2d993e3..49e782c5 100644
--- a/src/location/places/qplacesearchrequest.cpp
+++ b/src/location/places/qplacesearchrequest.cpp
@@ -35,37 +35,17 @@
****************************************************************************/
#include "qplacesearchrequest.h"
+#include "qplacesearchrequest_p.h"
#include "qgeocoordinate.h"
#include "qgeoshape.h"
#include <QtCore/QSharedData>
#include <QtCore/QList>
#include <QtCore/QVariant>
+#include <QDebug>
QT_BEGIN_NAMESPACE
-class QPlaceSearchRequestPrivate : public QSharedData
-{
-public:
- QPlaceSearchRequestPrivate();
- QPlaceSearchRequestPrivate(const QPlaceSearchRequestPrivate &other);
- ~QPlaceSearchRequestPrivate();
-
- QPlaceSearchRequestPrivate &operator=(const QPlaceSearchRequestPrivate &other);
- bool operator==(const QPlaceSearchRequestPrivate &other) const;
-
- void clear();
-
- QString searchTerm;
- QList<QPlaceCategory> categories;
- QGeoShape searchArea;
- QString recommendationId;
- QLocation::VisibilityScope visibilityScope;
- QPlaceSearchRequest::RelevanceHint relevanceHint;
- int limit;
- QVariant searchContext;
-};
-
QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate()
: QSharedData(),
visibilityScope(QLocation::UnspecifiedVisibility),
@@ -83,7 +63,9 @@ QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate(const QPlaceSearchRequest
visibilityScope(other.visibilityScope),
relevanceHint(other.relevanceHint),
limit(other.limit),
- searchContext(other.searchContext)
+ searchContext(other.searchContext),
+ related(other.related),
+ page(other.page)
{
}
@@ -102,6 +84,8 @@ QPlaceSearchRequestPrivate &QPlaceSearchRequestPrivate::operator=(const QPlaceSe
relevanceHint = other.relevanceHint;
limit = other.limit;
searchContext = other.searchContext;
+ related = other.related;
+ page = other.page;
}
return *this;
@@ -117,6 +101,8 @@ bool QPlaceSearchRequestPrivate::operator==(const QPlaceSearchRequestPrivate &ot
relevanceHint == other.relevanceHint &&
limit == other.limit &&
searchContext == other.searchContext;
+
+ // deliberately not testing related and page. comparing only the content.
}
void QPlaceSearchRequestPrivate::clear()
@@ -129,6 +115,18 @@ void QPlaceSearchRequestPrivate::clear()
visibilityScope = QLocation::UnspecifiedVisibility;
relevanceHint = QPlaceSearchRequest::UnspecifiedHint;
searchContext.clear();
+ related = false;
+ page = 0;
+}
+
+const QPlaceSearchRequestPrivate *QPlaceSearchRequestPrivate::get(const QPlaceSearchRequest &request)
+{
+ return request.d_ptr.constData();
+}
+
+QPlaceSearchRequestPrivate *QPlaceSearchRequestPrivate::get(QPlaceSearchRequest &request)
+{
+ return request.d_ptr.data();
}
/*!
diff --git a/src/location/places/qplacesearchrequest.h b/src/location/places/qplacesearchrequest.h
index 09654503..d6611017 100644
--- a/src/location/places/qplacesearchrequest.h
+++ b/src/location/places/qplacesearchrequest.h
@@ -98,6 +98,8 @@ private:
QSharedDataPointer<QPlaceSearchRequestPrivate> d_ptr;
inline QPlaceSearchRequestPrivate *d_func();
inline const QPlaceSearchRequestPrivate *d_func() const;
+
+ friend class QPlaceSearchRequestPrivate;
};
QT_END_NAMESPACE
diff --git a/src/location/places/qplacesearchrequest_p.h b/src/location/places/qplacesearchrequest_p.h
new file mode 100644
index 00000000..98a747b0
--- /dev/null
+++ b/src/location/places/qplacesearchrequest_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLACESEARCHREQUEST_P_H
+#define QPLACESEARCHREQUEST_P_H
+
+#include "qplacesearchrequest.h"
+#include "qgeocoordinate.h"
+#include "qgeoshape.h"
+
+#include <QtCore/QSharedData>
+#include <QtCore/QList>
+#include <QtLocation/private/qlocationglobal_p.h>
+#include <QtCore/QVariant>
+
+QT_BEGIN_NAMESPACE
+
+class Q_LOCATION_PRIVATE_EXPORT QPlaceSearchRequestPrivate : public QSharedData
+{
+public:
+ QPlaceSearchRequestPrivate();
+ QPlaceSearchRequestPrivate(const QPlaceSearchRequestPrivate &other);
+ ~QPlaceSearchRequestPrivate();
+
+ QPlaceSearchRequestPrivate &operator=(const QPlaceSearchRequestPrivate &other);
+ bool operator==(const QPlaceSearchRequestPrivate &other) const;
+
+ void clear();
+ static const QPlaceSearchRequestPrivate *get(const QPlaceSearchRequest &request);
+ static QPlaceSearchRequestPrivate *get(QPlaceSearchRequest &request);
+
+ QString searchTerm;
+ QList<QPlaceCategory> categories;
+ QGeoShape searchArea;
+ QString recommendationId;
+ QLocation::VisibilityScope visibilityScope;
+ QPlaceSearchRequest::RelevanceHint relevanceHint;
+ int limit;
+ QVariant searchContext;
+ bool related = false;
+ int page = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLACESEARCHREQUEST_P_H