Fix to Sankore 636. Now copyes of video and audio items stops in the sate tomes when stops original items.

Generating of missing thumbnails no more crashes Sankore.

Improved performance of navigating between pages.
preferencesAboutTextFull
Aleksei Kanash 13 years ago
parent 6ec28ed726
commit 70db49550f
  1. 4
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 76
      src/adaptors/UBThumbnailAdaptor.cpp
  3. 1
      src/adaptors/UBThumbnailAdaptor.h
  4. 2
      src/domain/UBGraphicsAudioItem.cpp
  5. 2
      src/domain/UBGraphicsVideoItem.cpp

@ -1961,7 +1961,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::audioItemToLinkedAudio(UBGraphicsAud
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "position", QString("%1").arg(pos)); mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "position", QString("%1").arg(pos));
} }
QString audioFileHref = audioItem->mediaFileUrl().toString(); QString audioFileHref = audioItem->mediaFileUrl().toLocalFile();
mXmlWriter.writeAttribute(nsXLink, "href", audioFileHref); mXmlWriter.writeAttribute(nsXLink, "href", audioFileHref);
mXmlWriter.writeEndElement(); mXmlWriter.writeEndElement();
} }
@ -1986,7 +1986,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::videoItemToLinkedVideo(UBGraphicsVid
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "position", QString("%1").arg(pos)); mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "position", QString("%1").arg(pos));
} }
QString videoFileHref = videoItem->mediaFileUrl().toString(); QString videoFileHref = videoItem->mediaFileUrl().toLocalFile();
mXmlWriter.writeAttribute(nsXLink, "href", videoFileHref); mXmlWriter.writeAttribute(nsXLink, "href", videoFileHref);
mXmlWriter.writeEndElement(); mXmlWriter.writeEndElement();
} }

@ -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);

@ -29,6 +29,7 @@ private: UBThumbnailAdaptor() {}
public: public:
static void persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false); static void persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false);
static void generateMissingThumbnails(UBDocumentProxy* proxy);
static QList<QPixmap> load(UBDocumentProxy* proxy); static QList<QPixmap> load(UBDocumentProxy* proxy);
static QPixmap load(UBDocumentProxy* proxy, int index); static QPixmap load(UBDocumentProxy* proxy, int index);

@ -96,6 +96,8 @@ UBItem* UBGraphicsAudioItem::deepCopy() const
UBGraphicsAudioItem *copy = new UBGraphicsAudioItem(audioUrl, parentItem()); UBGraphicsAudioItem *copy = new UBGraphicsAudioItem(audioUrl, parentItem());
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), copy, SLOT(activeSceneChanged()));
copy->setPos(this->pos()); copy->setPos(this->pos());
copy->setTransform(this->transform()); copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsMovable, true);

@ -69,6 +69,8 @@ UBItem* UBGraphicsVideoItem::deepCopy() const
UBGraphicsVideoItem *copy = new UBGraphicsVideoItem(videoUrl, parentItem()); UBGraphicsVideoItem *copy = new UBGraphicsVideoItem(videoUrl, parentItem());
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), copy, SLOT(activeSceneChanged()));
copy->setPos(this->pos()); copy->setPos(this->pos());
copy->setTransform(this->transform()); copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsMovable, true);

Loading…
Cancel
Save