Ejemplo n.º 1
0
int64_t DownloadSizeFinder::downloadOrQueue(const QString &url, QString *err)
{
    int64_t r = -2;
    *err = "";

    this->mutex.lock();
    if (this->files.contains(url)) {
        QString v = this->files.value(url);
        if (v.startsWith('*'))
            *err = v.mid(1);
        else
            r = v.toLongLong();
        this->mutex.unlock();
    } else {
        this->mutex.unlock();

        QFuture<DownloadFile> future = run(&threadPool, this,
                &DownloadSizeFinder::downloadRunnable, url);
        QFutureWatcher<DownloadFile>* w =
                new QFutureWatcher<DownloadFile>(this);
        connect(w, SIGNAL(finished()), this,
                SLOT(watcherFinished()));
        w->setFuture(future);
    }

    return r;
}
void QGalleryTrackerMetaDataEdit::commit()
{
    if (m_values.isEmpty()) {
        emit finished(this);
    } else {
        m_watcher = new QDBusPendingCallWatcher(m_metaDataInterface->asyncCall(
                QLatin1String("Set"),
                m_service,
                m_uri,
                QStringList(m_values.keys()),
                QStringList(m_values.values())), this);

        if (m_watcher->isFinished()) {
            watcherFinished(m_watcher);
        } else {
            connect(m_watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
                    this, SLOT(watcherFinished(QDBusPendingCallWatcher*)));
        }
    }
}