summaryrefslogtreecommitdiffstats
path: root/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan@kdab.com>2016-03-23 13:04:29 +0200
committerBrett Stottlemyer <bstottle@ford.com>2016-03-25 15:33:46 +0000
commita7ef4539f00e40857ca447d8cd200885be850503 (patch)
treeecb7f6ec52a1a813df7bd1449d487bc1cde47af0 /src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
parentb07a7ba7bc7cecbcb48762aeb77aad79f155cb98 (diff)
Split requests into smaller pieces and request current data first
The last requests are also the (currently) visible ones, therefore, requesting in reverse order will help to get the visible ones first. It happens when the user browse trough a list. Splitting the requests into smaller pieces (100 rows) will help to get the visible items faster. Change-Id: I49e5733f82ed2b60f583ef15fde4fdbf397693ed Reviewed-by: Continuous Integration (KDAB) <build@kdab.com> Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Diffstat (limited to 'src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp')
-rw-r--r--src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp b/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
index cad2a6f..05d6cc1 100644
--- a/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
+++ b/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
@@ -481,7 +481,7 @@ void QAbstractItemModelReplicaPrivate::fetchPendingData()
qCDebug(QT_REMOTEOBJECT_MODELS) << Q_FUNC_INFO << "m_requestedData.size=" << m_requestedData.size();
- QVector<RequestedData> finalRequests;
+ std::vector<RequestedData> finalRequests;
RequestedData curData;
Q_FOREACH (const RequestedData &data, m_requestedData) {
qCDebug(QT_REMOTEOBJECT_MODELS) << Q_FUNC_INFO << "REQUESTED start=" << data.start << "end=" << data.end << "roles=" << data.roles;
@@ -523,7 +523,8 @@ void QAbstractItemModelReplicaPrivate::fetchPendingData()
(qAbs(curIndStart.column - dataIndStart.column) == 1) ||
(qAbs(curIndEnd.row - dataIndEnd.row) == 1) ||
(qAbs(curIndEnd.column - dataIndEnd.column) == 1);
- if (firstRect.intersects(secondRect) || borders) {
+
+ if ((resEnd.row - resStart.row < 100) && (firstRect.intersects(secondRect) || borders)) {
IndexList start = curData.start;
start.pop_back();
start.push_back(resStart);
@@ -543,11 +544,11 @@ void QAbstractItemModelReplicaPrivate::fetchPendingData()
}
finalRequests.push_back(curData);
//qCDebug(QT_REMOTEOBJECT_MODELS) << "Final requests" << finalRequests;
- Q_FOREACH (const RequestedData &data, finalRequests) {
- qCDebug(QT_REMOTEOBJECT_MODELS) << Q_FUNC_INFO << "FINAL start=" << data.start << "end=" << data.end << "roles=" << data.roles;
+ for (auto it = finalRequests.rbegin(); it != finalRequests.rend(); ++it) {
+ qCDebug(QT_REMOTEOBJECT_MODELS) << Q_FUNC_INFO << "FINAL start=" << it->start << "end=" << it->end << "roles=" << it->roles;
- QRemoteObjectPendingReply<DataEntries> reply = replicaRowRequest(data.start, data.end, data.roles);
- RowWatcher *watcher = new RowWatcher(data.start, data.end, data.roles, reply);
+ QRemoteObjectPendingReply<DataEntries> reply = replicaRowRequest(it->start, it->end, it->roles);
+ RowWatcher *watcher = new RowWatcher(it->start, it->end, it->roles, reply);
m_pendingRequests.push_back(watcher);
connect(watcher, &RowWatcher::finished, this, &QAbstractItemModelReplicaPrivate::requestedData);
}