void tst_QPlaceContentRequest::clearTest() { QPlaceContentRequest req; req.setContentType(QPlaceContent::ReviewType); req.setLimit(9000); req.setOffset(1); req.clear(); QVERIFY(req.contentType() == QPlaceContent::NoType); QVERIFY(req.limit() == -1); QVERIFY(req.offset() == 0); }
/*! \internal */ void QDeclarativePlaceContentModel::fetchMore(const QModelIndex &parent) { if (parent.isValid()) return; if (!m_place) return; if (m_reply) return; if (!m_place->plugin()) return; QDeclarativeGeoServiceProvider *plugin = m_place->plugin(); QGeoServiceProvider *serviceProvider = plugin->sharedGeoServiceProvider(); if (!serviceProvider) return; QPlaceManager *placeManager = serviceProvider->placeManager(); if (!placeManager) return; QPlaceContentRequest request; request.setContentType(m_type); if (m_contentCount == -1) { request.setOffset(0); request.setLimit(m_batchSize); } else { QPair<int, int> missing = findMissingKey(m_content); request.setOffset(missing.first); if (missing.second == -1) request.setLimit(m_batchSize); else request.setLimit(qMin(m_batchSize, missing.second - missing.first + 1)); } m_reply = placeManager->getPlaceContent(m_place->place().placeId(), request); connect(m_reply, SIGNAL(finished()), this, SLOT(fetchFinished()), Qt::QueuedConnection); }
void tst_QPlaceContentRequest::contentTest() { QPlaceContentRequest req; QCOMPARE(req.limit(), -1); QCOMPARE(req.offset(), 0); QCOMPARE(req.contentType(), QPlaceContent::NoType); //check that we can set the request fields req.setLimit(100); req.setOffset(5); req.setContentType(QPlaceContent::ImageType); QCOMPARE(req.limit(), 100); QCOMPARE(req.offset(), 5); QCOMPARE(req.contentType(), QPlaceContent::ImageType); //check that we assignment works correctly QPlaceContentRequest otherReq; otherReq.setLimit(10); otherReq.setOffset(15); otherReq.setContentType(QPlaceContent::ReviewType); req = otherReq; QCOMPARE(req.limit(), 10); QCOMPARE(req.offset(), 15); QCOMPARE(req.contentType(), QPlaceContent::ReviewType); QCOMPARE(req, otherReq); //check that comparison will fail if one the fields are different req.setLimit(9000); QVERIFY(req != otherReq); }
/*! Returns true if \a other is not equal to this content request, otherwise returns false. */ bool QPlaceContentRequest::operator!= (const QPlaceContentRequest &other) const { Q_D(const QPlaceContentRequest); return !(*d == *other.d_func()); }