Example #1
0
void DBPediaQuery::launchQuery(const QString &query, const QString &requestKey)
{
    //Construct dbpedia url
    QString dbPediaSPARQL = QString(QUrl::toPercentEncoding(query));
    QString dbPediaUrlString= QString("http://dbpedia.org/sparql/?format=application/xml&query=%1").arg(dbPediaSPARQL);
    KUrl dbPediaUrl = KUrl(dbPediaUrlString);

    //Add query url to request collection
    m_requests.insert(requestKey, dbPediaUrl);

    //Prepare download target location
    QString targetFileName = QString("bangarang/%1.tmp")
                                .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
    KUrl dbPediaDownloadUrl = KUrl(KStandardDirs::locateLocal("data", targetFileName, true));
    QFile downloadTarget(dbPediaDownloadUrl.path());
    downloadTarget.remove();

    //Launch query
    KIO::CopyJob *copyJob = KIO::copy(dbPediaUrl, dbPediaDownloadUrl, KIO::Overwrite | KIO::HideProgressInfo);
    copyJob->setAutoDelete(true);
    connect (copyJob,
             SIGNAL(copyingDone(KIO::Job*,KUrl,KUrl,time_t,bool,bool)),
             this,
             SLOT(resultsReturned(KIO::Job*,KUrl,KUrl,time_t,bool,bool)));
    copyJob->setUiDelegate(0);
}
Example #2
0
void Downloader::download(const QUrl &from, const QUrl &to)
{
    if (to.isLocalFile()) {
        QFile fileTarget(to.path());
        fileTarget.remove();
    }
    KIO::CopyJob *copyJob = KIO::copyAs(from, to, KIO::Overwrite | KIO::HideProgressInfo);
    copyJob->setUiDelegate(0);
    copyJob->setAutoDelete(true);
    connect (copyJob, 
             SIGNAL(copyingDone(KIO::Job*,QUrl,QUrl,time_t,bool,bool)),
             this,
             SLOT(copyingDone(KIO::Job*,QUrl,QUrl,time_t,bool,bool)));
}