void QGalleryTrackerTypeResultSetPrivate::queryFinished(const QDBusPendingCall &call) { const int oldCount = count; if (call.isError()) { q_func()->finish(QDocumentGallery::ConnectionError); return; } else if (!accumulative) { QDBusPendingReply<int> reply(call); count = reply.value(); if (refresh) { refresh = false; queryCount(); } } else { QDBusPendingReply<QVector<QStringList> > reply(call); const QVector<QStringList> counts = reply.value(); typedef QVector<QStringList>::const_iterator iterator; for (iterator it = counts.begin(), end = counts.end(); it != end; ++it) workingCount += it->value(1).toInt(); if (refresh) { refresh = false; currentOffset = 0; workingCount = 0; queryCount(); } else { currentOffset += counts.count(); if (counts.count() != 0) { if (count > workingCount) count = workingCount; if (canceled) q_func()->QGalleryAbstractResponse::cancel(); else queryCount(); } else { count = workingCount; } } } if (count != oldCount) emit q_func()->metaDataChanged(0, 1, QList<int>() << 0); if (!queryWatcher) q_func()->finish(); }
inline bool isEmpty() const { return queryCount() == 1; }
void QGalleryTrackerTypeResultSetPrivate::queryFinished(const QDBusPendingCall &call) { const int oldCount = count; if (call.isError()) { q_func()->finish(QDocumentGallery::ConnectionError); return; } else if (!accumulative) { QDBusPendingReply<QVector<QStringList> > reply(call); if (queryMethod == QLatin1String("SparqlQuery")) { QVector<QStringList> v = reply.value(); count = v[0].first().toInt(); } else { /* * Process reply to org.freedesktop.Tracker.Statistics.Get -method. Value is a list of list of two strings: * type1 count1 * type2 count2 * ... * where typeX corresponds to the service name ( i.e. ontology class name, e.g. "nfo:FileDataObject" ). * Search through the list and find the requested service and extract the count from the second string. */ QVector<QStringList> v = reply.value(); QVector<QStringList>::const_iterator pos = qFind( v, QGalleryTrackerType(service )); if (pos != v.constEnd()) count = (*pos).last().toInt(); // TODO Do we need this? if (refresh) { refresh = false; queryCount(); } } } else { QDBusPendingReply<QVector<QStringList> > reply(call); const QVector<QStringList> counts = reply.value(); typedef QVector<QStringList>::const_iterator iterator; for (iterator it = counts.begin(), end = counts.end(); it != end; ++it) workingCount += it->value(1).toInt(); if (refresh) { refresh = false; currentOffset = 0; workingCount = 0; queryCount(); } else { currentOffset += counts.count(); if (counts.count() != 0) { if (count > workingCount) count = workingCount; if (cancelled) q_func()->QGalleryAbstractResponse::cancel(); else queryCount(); } else { count = workingCount; } } } if (count != oldCount) emit q_func()->metaDataChanged(0, 1, QList<int>() << 0); if (!queryWatcher) q_func()->finish(); }
virtual bool isEmpty() { return queryCount() == 1; }