当前位置: 首页>>代码示例>>C++>>正文


C++ Job::setAutoDelete方法代码示例

本文整理汇总了C++中kio::Job::setAutoDelete方法的典型用法代码示例。如果您正苦于以下问题:C++ Job::setAutoDelete方法的具体用法?C++ Job::setAutoDelete怎么用?C++ Job::setAutoDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kio::Job的用法示例。


在下文中一共展示了Job::setAutoDelete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 {
开发者ID:KDE,项目名称:kdeplasma-addons,代码行数:44,代码来源:imagesource.cpp


注:本文中的kio::Job::setAutoDelete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。