|
|
@ -91,92 +91,34 @@ const QPixmap* UBThumbnailAdaptor::get(UBDocumentProxy* proxy, int pageIndex) |
|
|
|
return pix; |
|
|
|
return pix; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBThumbnailAdaptor::load(UBDocumentProxy* proxy, QList<const QPixmap*>& list) |
|
|
|
void UBThumbnailAdaptor::updateDocumentToHandleZeroPage(UBDocumentProxy* proxy) |
|
|
|
{ |
|
|
|
{ |
|
|
|
generateMissingThumbnails(proxy); |
|
|
|
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){ |
|
|
|
|
|
|
|
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", 0); |
|
|
|
foreach(const QPixmap* pm, list) |
|
|
|
|
|
|
|
delete pm; |
|
|
|
|
|
|
|
list.clear(); |
|
|
|
|
|
|
|
for(int i=0; i<proxy->pageCount(); i++) |
|
|
|
|
|
|
|
list.append(get(proxy, i)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QList<QPixmap> thumbnails; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "Loadinf thumbnails for " << proxy->name(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
QFile file(fileName); |
|
|
|
if (file.exists()) { |
|
|
|
qDebug() << fileName; |
|
|
|
QPixmap pix; |
|
|
|
if(!file.exists()){ |
|
|
|
//Warning. Works only with modified Qt
|
|
|
|
UBPersistenceManager::persistenceManager()->persistDocumentScene(proxy,new UBGraphicsScene(proxy),0); |
|
|
|
#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; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index) |
|
|
|
void UBThumbnailAdaptor::load(UBDocumentProxy* proxy, QList<const QPixmap*>& list) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qDebug() << "Loadinf thumbnails for " << proxy->name(); |
|
|
|
updateDocumentToHandleZeroPage(proxy); |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
generateMissingThumbnails(proxy); |
|
|
|
|
|
|
|
|
|
|
|
//end compatibility with older format
|
|
|
|
foreach(const QPixmap* pm, list) |
|
|
|
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index); |
|
|
|
delete pm; |
|
|
|
|
|
|
|
list.clear(); |
|
|
|
QFile file(fileName); |
|
|
|
for(int i=0; i<proxy->pageCount(); i++) |
|
|
|
if (file.exists()) |
|
|
|
list.append(get(proxy, i)); |
|
|
|
{ |
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, int pageIndex, bool overrideModified) |
|
|
|
void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, int pageIndex, bool overrideModified) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "Persiste scene on path " << proxy->persistencePath() << ", index " << pageIndex; |
|
|
|
qDebug() << "Persist scene on path " << proxy->persistencePath() << ", index " << pageIndex; |
|
|
|
|
|
|
|
|
|
|
|
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex); |
|
|
|
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex); |
|
|
|
|
|
|
|
|
|
|
|