|
|
@ -79,14 +79,33 @@ UBPersistenceManager::UBPersistenceManager(QObject *pParent) |
|
|
|
mThread = new QThread; |
|
|
|
mThread = new QThread; |
|
|
|
mWorker = new UBPersistenceWorker(); |
|
|
|
mWorker = new UBPersistenceWorker(); |
|
|
|
mWorker->moveToThread(mThread); |
|
|
|
mWorker->moveToThread(mThread); |
|
|
|
connect(mWorker, SIGNAL(error(QString)), this, SLOT(errorString(QString))); |
|
|
|
connect(mWorker, SIGNAL(error(QString)), |
|
|
|
connect(mThread, SIGNAL(started()), mWorker, SLOT(process())); |
|
|
|
this, SLOT(errorString(QString))); |
|
|
|
connect(mWorker, SIGNAL(finished()), mThread, SLOT(quit())); |
|
|
|
|
|
|
|
connect(mWorker, SIGNAL(finished()), this, SLOT(onWorkerFinished())); |
|
|
|
connect(mThread, SIGNAL(started()), |
|
|
|
connect(mWorker, SIGNAL(finished()), mWorker, SLOT(deleteLater())); |
|
|
|
mWorker, SLOT(process())); |
|
|
|
connect(mThread, SIGNAL(finished()), mThread, SLOT(deleteLater())); |
|
|
|
|
|
|
|
connect(mWorker,SIGNAL(sceneLoaded(QByteArray,UBDocumentProxy*,int)),this,SLOT(onSceneLoaded(QByteArray,UBDocumentProxy*,int))); |
|
|
|
connect(mWorker, SIGNAL(finished()), |
|
|
|
connect(mWorker,SIGNAL(scenePersisted(UBGraphicsScene*)),this,SLOT(onScenePersisted(UBGraphicsScene*))); |
|
|
|
mThread, SLOT(quit())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(mWorker, SIGNAL(finished()), |
|
|
|
|
|
|
|
this, SLOT(onWorkerFinished())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(mWorker, SIGNAL(finished()), |
|
|
|
|
|
|
|
mWorker, SLOT(deleteLater())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(mThread, SIGNAL(finished()), |
|
|
|
|
|
|
|
mThread, SLOT(deleteLater())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(mWorker, SIGNAL(sceneLoaded(QByteArray,UBDocumentProxy*,int)), |
|
|
|
|
|
|
|
this, SLOT(onSceneLoaded(QByteArray,UBDocumentProxy*,int))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(mWorker, SIGNAL(scenePersisted(UBGraphicsScene*)), |
|
|
|
|
|
|
|
this, SLOT(onScenePersisted(UBGraphicsScene*))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(mWorker, SIGNAL(metadataPersisted(UBDocumentProxy*)), |
|
|
|
|
|
|
|
this, SLOT(onMetadataPersisted(UBDocumentProxy*))); |
|
|
|
|
|
|
|
|
|
|
|
mThread->start(); |
|
|
|
mThread->start(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -114,6 +133,11 @@ void UBPersistenceManager::onScenePersisted(UBGraphicsScene* scene) |
|
|
|
scene = NULL; |
|
|
|
scene = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBPersistenceManager::onMetadataPersisted(UBDocumentProxy* proxy) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
delete proxy; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBPersistenceManager::onWorkerFinished() |
|
|
|
void UBPersistenceManager::onWorkerFinished() |
|
|
|
{ |
|
|
|
{ |
|
|
|
mIsWorkerFinished = true; |
|
|
|
mIsWorkerFinished = true; |
|
|
@ -752,14 +776,14 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, |
|
|
|
mSceneCache.insert(pDocumentProxy, pSceneIndex, pScene); |
|
|
|
mSceneCache.insert(pDocumentProxy, pSceneIndex, pScene); |
|
|
|
|
|
|
|
|
|
|
|
if (pDocumentProxy->isModified()) |
|
|
|
if (pDocumentProxy->isModified()) |
|
|
|
UBMetadataDcSubsetAdaptor::persist(pDocumentProxy); |
|
|
|
persistDocumentMetadata(pDocumentProxy, forceImmediateSaving); |
|
|
|
|
|
|
|
|
|
|
|
if (pScene->isModified()) |
|
|
|
if (pScene->isModified()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBThumbnailAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex); |
|
|
|
UBThumbnailAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex); |
|
|
|
if(forceImmediateSaving) |
|
|
|
if(forceImmediateSaving) |
|
|
|
UBSvgSubsetAdaptor::persistScene(pDocumentProxy,pScene,pSceneIndex); |
|
|
|
UBSvgSubsetAdaptor::persistScene(pDocumentProxy,pScene,pSceneIndex); |
|
|
|
else{ |
|
|
|
else { |
|
|
|
UBGraphicsScene* copiedScene = pScene->sceneDeepCopy(); |
|
|
|
UBGraphicsScene* copiedScene = pScene->sceneDeepCopy(); |
|
|
|
mWorker->saveScene(pDocumentProxy, copiedScene, pSceneIndex); |
|
|
|
mWorker->saveScene(pDocumentProxy, copiedScene, pSceneIndex); |
|
|
|
pScene->setModified(false); |
|
|
|
pScene->setModified(false); |
|
|
@ -769,13 +793,17 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBDocumentProxy* UBPersistenceManager::persistDocumentMetadata(UBDocumentProxy* pDocumentProxy) |
|
|
|
void UBPersistenceManager::persistDocumentMetadata(UBDocumentProxy* pDocumentProxy, bool forceImmediateSaving) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (forceImmediateSaving) { |
|
|
|
UBMetadataDcSubsetAdaptor::persist(pDocumentProxy); |
|
|
|
UBMetadataDcSubsetAdaptor::persist(pDocumentProxy); |
|
|
|
|
|
|
|
|
|
|
|
emit documentMetadataChanged(pDocumentProxy); |
|
|
|
emit documentMetadataChanged(pDocumentProxy); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return pDocumentProxy; |
|
|
|
else { |
|
|
|
|
|
|
|
UBDocumentProxy* copy = pDocumentProxy->deepCopy(); |
|
|
|
|
|
|
|
mWorker->saveMetadata(copy); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|