コード例 #1
0
void RenderCache::renderSheet(int sheetNum)
{
    if (mItems.contains(sheetNum))
        emit sheetReady(mItems.value(sheetNum), sheetNum);
    else
        mRender->renderSheet(sheetNum);

    int start = qMax(0, sheetNum - CACHE_PRE);
    int end = qMin(project->previewSheetCount()-1, sheetNum + CACHE_POST);

    for (int i=start; i<sheetNum; ++i)
    {
        if (!mItems.contains(i))
            mRender->renderSheet(i);
    }

    for (int i=sheetNum+1; i<=end; ++i)
    {
        if (!mItems.contains(i))
            mRender->renderSheet(i);
    }

    // Remove old values ........................
    QHash<int, QImage>::iterator it = mItems.begin();
    while (it != mItems.end())
    {
        if (it.key() < start || it.key() > end)
            it = mItems.erase(it);
        else
            ++it;
    }
}
コード例 #2
0
QImage RenderWorker::renderSheet(int sheetNum)
{
    if (!mPopplerDoc)
        return QImage();

    mBusy = true;
    QImage img = doRenderSheet(mPopplerDoc, sheetNum, mResolution);
    emit sheetReady(img, sheetNum);
    mBusy = false;
    return img;
}
コード例 #3
0
void RenderCache::onSheetReady(QImage img, int sheetNum)
{
    mItems.insert(sheetNum, img);
    emit sheetReady(img, sheetNum);
}