void LepheProtocol::fetch(const QString &id)
{
    // Did we get a complete URL or just an id. Insert a call to the php-script
    QString link = QLatin1String(LEPHE_BASE) + QLatin1String(LEPHE_RAW);

    if (id.startsWith(QLatin1String("http://")))
        link.append(id.mid(id.lastIndexOf(QLatin1Char('/')) + 1));
    else
        link.append(id);

    _fetchReply = httpGet(link);
    connect(_fetchReply, SIGNAL(finished), this, SLOT(fetchFinished()));
    _fetchId = id;
}
void PasteBinDotComProtocol::fetch(const QString &id)
{
    // Did we get a complete URL or just an id. Insert a call to the php-script
    QString link = QLatin1String(PASTEBIN_BASE) + QLatin1String(PASTEBIN_RAW);
    link.append(QLatin1String("?i="));

    if (id.startsWith(QLatin1String("http://")))
        link.append(id.mid(id.lastIndexOf(QLatin1Char('/')) + 1));
    else
        link.append(id);

    if (debug)
        qDebug() << "fetch: sending " << link;

    m_fetchReply = httpGet(link);
    connect(m_fetchReply, SIGNAL(finished()), this, SLOT(fetchFinished()));
    m_fetchId = id;
}
/*!
    \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);
}
Exemple #4
0
ScanDialog::ScanDialog(QWidget *parent)
    : QDialog(parent)
{
    setupUi(this);

    itemsTree->setColumnHidden(1, true);

    readSettings();

    mgr= new QHttpManager(this);
    mgr->setProgressBar(progressBar);

    connect(mgr, SIGNAL(fetchLink(QString)),
        this, SLOT(onFetchLink(QString)));

    connect(mgr, SIGNAL(fetchFinished()),
        this, SLOT(onFetchFinished()));

    connect(mgr, SIGNAL(fetchError(QString)),
        this, SLOT(onFetchError(QString)));

    // Enable drops.
    setAcceptDrops(true);
}
Exemple #5
0
void
ScanDialog::onFetchFinished() {

    if (mgr->errorOccurred()) {
        resetUI();
        return;
    }

    QStringList found;
    Scan::youtube(mgr->getData(), found);

    const int size = found.size();

    if (size == 0) {
        Util::appendLog(logEdit, tr("Nothing found."));
        resetUI();
        return;
    }

    Util::appendLog(logEdit,
        QString(tr("Found %1 video links.")).arg(size));

    if ( !titlesBox->checkState() ) {

        for (int i=0; i<size; ++i) {
            QTreeWidgetItem *item = new QTreeWidgetItem(itemsTree);
            item->setCheckState(0, Qt::Unchecked);
            for (int j=0; j<2; ++j)
                item->setText(j, found[i]);
        }

        resetUI();
        Util::appendLog(logEdit, tr("Done."));
    }
    else {
        Util::appendLog(logEdit,
            tr("Fetch titles for the found videos."));

        mgrt = new QHttpManager(this);

        connect(mgrt, SIGNAL(fetchLink(QString)),
            this, SLOT(onFetchLink(QString)));

        connect(mgrt, SIGNAL(fetchError(QString)),
            this, SLOT(onFetchError(QString)));

        // Note the use of a different slot here.

        connect(mgrt, SIGNAL(fetchFinished()),
            this, SLOT(onFetchTitlesFinished()));

        // Do not set progressbar for this manager.
        // We'll use fetched/expected for that instead.

        fetchedTitles   = -1;
        expectedTitles  = size;

        progressBar->setValue(fetchedTitles);
        progressBar->setMaximum(expectedTitles);

        videoLinks = found;

        progressBar->setTextVisible(true);

        emit onFetchTitlesFinished(); // Start iteration.
    }
}