|
|
@ -33,18 +33,14 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "core/memcheck.h" |
|
|
|
#include "core/memcheck.h" |
|
|
|
|
|
|
|
|
|
|
|
QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy) |
|
|
|
void UBThumbnailAdaptor::generateMissingThumbnails(UBDocumentProxy* proxy) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QList<QPixmap> thumbnails; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!proxy || proxy->persistencePath().isEmpty()) |
|
|
|
|
|
|
|
return thumbnails; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int existingPageCount = proxy->pageCount(); |
|
|
|
int existingPageCount = proxy->pageCount(); |
|
|
|
|
|
|
|
|
|
|
|
QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", existingPageCount); |
|
|
|
for (int iPageNo = 0; iPageNo < existingPageCount; ++iPageNo) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", iPageNo); |
|
|
|
|
|
|
|
|
|
|
|
QFile thumbFile(thumbFileName); |
|
|
|
QFile thumbFile(thumbFileName); |
|
|
|
|
|
|
|
|
|
|
|
if (!thumbFile.exists()) |
|
|
|
if (!thumbFile.exists()) |
|
|
@ -53,9 +49,7 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy) |
|
|
|
|
|
|
|
|
|
|
|
int thumbCount = 0; |
|
|
|
int thumbCount = 0; |
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0 ; i < existingPageCount; i++) |
|
|
|
UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, iPageNo); |
|
|
|
{ |
|
|
|
|
|
|
|
UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, i); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (scene) |
|
|
|
if (scene) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -64,24 +58,25 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy) |
|
|
|
if (displayMessage && thumbCount == 1) |
|
|
|
if (displayMessage && thumbCount == 1) |
|
|
|
UBApplication::showMessage(tr("Generating preview thumbnails ...")); |
|
|
|
UBApplication::showMessage(tr("Generating preview thumbnails ...")); |
|
|
|
|
|
|
|
|
|
|
|
persistScene(proxy->persistencePath(), scene, i); |
|
|
|
persistScene(proxy->persistencePath(), scene, iPageNo); |
|
|
|
} |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
if(i==0){ |
|
|
|
|
|
|
|
// we are working a document without zero page but on a system that enable it
|
|
|
|
|
|
|
|
// we have to create an empty zero scene
|
|
|
|
|
|
|
|
scene = new UBGraphicsScene(proxy); |
|
|
|
|
|
|
|
UBSvgSubsetAdaptor::persistScene(proxy,scene,0); |
|
|
|
|
|
|
|
persistScene(proxy->persistencePath(),scene,i); |
|
|
|
|
|
|
|
thumbCount++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (displayMessage && thumbCount > 0) |
|
|
|
if (displayMessage && thumbCount > 0) |
|
|
|
UBApplication::showMessage(tr("%1 thumbnails generated ...").arg(thumbCount)); |
|
|
|
UBApplication::showMessage(tr("%1 thumbnails generated ...").arg(thumbCount)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
//end compatibility with older format
|
|
|
|
|
|
|
|
|
|
|
@ -113,39 +108,10 @@ QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int existingPageCount = proxy->pageCount(); |
|
|
|
int existingPageCount = proxy->pageCount(); |
|
|
|
|
|
|
|
|
|
|
|
if (!proxy || proxy->persistencePath().size() == 0 || index < 0 || index >= existingPageCount) |
|
|
|
if (!proxy || proxy->persistencePath().size() == 0 || index < 0 || index > existingPageCount) |
|
|
|
return QPixmap(); |
|
|
|
return QPixmap(); |
|
|
|
//compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails
|
|
|
|
//compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails
|
|
|
|
|
|
|
|
generateMissingThumbnails(proxy); |
|
|
|
QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", existingPageCount); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFile thumbFile(thumbFileName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!thumbFile.exists()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool displayMessage = (existingPageCount > 5); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int thumbCount = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0 ; i < existingPageCount; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, i); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (scene) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
thumbCount++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (displayMessage && thumbCount == 1) |
|
|
|
|
|
|
|
UBApplication::showMessage(tr("Generating preview thumbnails ...")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
persistScene(proxy->persistencePath(), scene, i); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (displayMessage && thumbCount > 0) |
|
|
|
|
|
|
|
UBApplication::showMessage(tr("%1 thumbnails generated ...").arg(thumbCount)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end compatibility with older format
|
|
|
|
//end compatibility with older format
|
|
|
|
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index); |
|
|
|
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index); |
|
|
|