本文整理汇总了C++中kio::Job::start方法的典型用法代码示例。如果您正苦于以下问题:C++ Job::start方法的具体用法?C++ Job::start怎么用?C++ Job::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kio::Job
的用法示例。
在下文中一共展示了Job::start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadImage
void ImageSource::loadImage(const QString &who, const KUrl &url)
{
if (who.isEmpty()) {
return;
}
if (!m_imageCache) {
m_imageCache = new KImageCache("plasma_engine_preview", 10485760); // Re-use previewengine's cache
}
// Make sure we only start one job per user
if (m_loadedPersons.contains(who)) {
return;
}
const QString cacheKey = who + "@" + url.pathOrUrl();
// Check if the image is in the cache, if so return it
QImage preview = QImage(QSize(48, 48), QImage::Format_ARGB32_Premultiplied);
preview.fill(Qt::transparent);
if (m_imageCache->findImage(cacheKey, &preview)) {
// cache hit
//kDebug() << "cache hit: " << cacheKey;
setData(who, polishImage(preview));
Q_EMIT dataChanged();
checkForUpdate();
return;
}
if (!url.isValid()) {
return;
}
m_loadedPersons << who;
//FIXME: since kio_http bombs the system with too many request put a temporary
// arbitrary limit here, revert as soon as BUG 192625 is fixed
// Note: seems fixed.
if (m_runningJobs < 500) {
m_runningJobs++;
KIO::Job *job = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
job->setAutoDelete(true);
m_jobs[job] = who;
connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(recv(KIO::Job*,QByteArray)));
connect(job, SIGNAL(result(KJob*)), this, SLOT(result(KJob*)));
job->start();
} else {
示例2: homeDir
OfxHttpRequest::OfxHttpRequest(const QString& type, const QUrl &url, const QByteArray &postData, const QMap<QString, QString>& metaData, const QUrl& dst, bool showProgressInfo) :
d(new Private),
m_dst(dst),
m_postJob(0),
m_getJob(0)
{
m_eventLoop = new QEventLoop(qApp->activeWindow());
QDir homeDir(QDir::home());
if (homeDir.exists("ofxlog.txt")) {
d->m_fpTrace.setFileName(QString("%1/ofxlog.txt").arg(QDir::homePath()));
d->m_fpTrace.open(QIODevice::WriteOnly | QIODevice::Append);
}
KIO::JobFlag jobFlags = KIO::DefaultFlags;
if (!showProgressInfo)
jobFlags = KIO::HideProgressInfo;
KIO::Job* job;
if(type.toLower() == QStringLiteral("get")) {
job = m_getJob = KIO::copy(url, dst, jobFlags);
} else {
job = m_postJob = KIO::http_post(url, postData, jobFlags);
m_postJob->addMetaData("content-type", "Content-type: application/x-ofx");
m_postJob->addMetaData(metaData);
connect(job, SIGNAL(data(KIO::Job*,QByteArray)), this, SLOT(slotOfxData(KIO::Job*,QByteArray)));
connect(job, SIGNAL(connected(KIO::Job*)), this, SLOT(slotOfxConnected(KIO::Job*)));
}
if (d->m_fpTrace.isOpen()) {
QTextStream ts(&d->m_fpTrace);
ts << "url: " << url.toDisplayString() << "\n";
ts << "request:\n" << QString(postData) << "\n" << "response:\n";
}
connect(job, SIGNAL(result(KJob*)), this, SLOT(slotOfxFinished(KJob*)));
job->start();
qDebug("Starting eventloop");
if (m_eventLoop)
m_eventLoop->exec();
qDebug("Ending eventloop");
}