Exemplo n.º 1
0
QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index)
{
    int existingPageCount = proxy->pageCount();

    if (!proxy || proxy->persistencePath().size() == 0 || index < 0 || index > existingPageCount)
        return QPixmap();
    //compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails
    generateMissingThumbnails(proxy);

    //end compatibility with older format
    QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index);

    QFile file(fileName);
    if (file.exists())
    {
        QPixmap pix;
        //Warning. Works only with modified Qt
#ifdef Q_WS_X11
        pix.load(fileName, 0, Qt::AutoColor);
#else
        pix.load(fileName, 0, Qt::AutoColor, false);
#endif
        return pix;
    }
    return QPixmap();
}
Exemplo n.º 2
0
void UBThumbnailAdaptor::load(UBDocumentProxy* proxy, QList<const QPixmap*>& list)
{
    generateMissingThumbnails(proxy);

    foreach(const QPixmap* pm, list){
        delete pm;
        pm = NULL;
    }
void UBThumbnailAdaptor::load(UBDocumentProxy* proxy, QList<const QPixmap*>& list)
{
    updateDocumentToHandleZeroPage(proxy);
    generateMissingThumbnails(proxy);

    foreach(const QPixmap* pm, list)
        delete pm;
    list.clear();
    for(int i=0; proxy && i<proxy->pageCount(); i++)
        list.append(get(proxy, i));
}
Exemplo n.º 4
0
const QPixmap* UBThumbnailAdaptor::get(UBDocumentProxy* proxy, int pageIndex)
{
    QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex);

    QFile file(fileName);
    if (!file.exists())
    {
        generateMissingThumbnails(proxy);
    }

    QPixmap* pix = new QPixmap();
    if (file.exists())
    {
        //Warning. Works only with modified Qt
#ifdef Q_OS_LINUX
        pix->load(fileName, 0, Qt::AutoColor);
#else
        pix->load(fileName, 0, Qt::AutoColor);
#endif
    }
    return pix;
}
Exemplo n.º 5
0
QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
{
    QList<QPixmap> thumbnails;

    if (!proxy || proxy->persistencePath().isEmpty())
        return thumbnails;

    //compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails
    generateMissingThumbnails(proxy);

    //end compatibility with older format

    bool moreToProcess = true;
    int pageCount = UBApplication::boardController->sceneIndexFromPage(0);

    while (moreToProcess) {
        pageCount++;
        QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageCount);

        QFile file(fileName);
        if (file.exists()) {
            QPixmap pix;
            //Warning. Works only with modified Qt
#ifdef Q_WS_X11
            //pix.load(fileName, 0, Qt::AutoColor);
            pix.load(fileName, 0);
#else
            pix.load(fileName, 0, Qt::AutoColor, false);
#endif
            thumbnails.append(pix);
        } else {
            moreToProcess = false;
        }
    }
    return thumbnails;
}