|
|
|
@ -50,6 +50,11 @@ |
|
|
|
|
#include "adaptors/UBThumbnailAdaptor.h" |
|
|
|
|
#include "adaptors/UBMetadataDcSubsetAdaptor.h" |
|
|
|
|
|
|
|
|
|
#include "domain/UBGraphicsMediaItem.h" |
|
|
|
|
#include "domain/UBGraphicsWidgetItem.h" |
|
|
|
|
#include "domain/UBGraphicsPixmapItem.h" |
|
|
|
|
#include "domain/UBGraphicsSvgItem.h" |
|
|
|
|
|
|
|
|
|
#include "board/UBBoardController.h" |
|
|
|
|
#include "board/UBBoardPaletteManager.h" |
|
|
|
|
|
|
|
|
@ -694,6 +699,77 @@ void UBPersistenceManager::duplicateDocumentScene(UBDocumentProxy* proxy, int in |
|
|
|
|
|
|
|
|
|
copyPage(proxy, index , index + 1); |
|
|
|
|
|
|
|
|
|
//TODO: write a proper way to handle object on disk
|
|
|
|
|
UBGraphicsScene *scene = loadDocumentScene(proxy, index + 1); |
|
|
|
|
|
|
|
|
|
foreach(QGraphicsItem* item, scene->items()) |
|
|
|
|
{ |
|
|
|
|
UBGraphicsMediaItem *mediaItem = qgraphicsitem_cast<UBGraphicsMediaItem*> (item); |
|
|
|
|
|
|
|
|
|
if (mediaItem){ |
|
|
|
|
QString source = mediaItem->mediaFileUrl().toLocalFile(); |
|
|
|
|
QString destination = source; |
|
|
|
|
QUuid newUuid = QUuid::createUuid(); |
|
|
|
|
QString fileName = QFileInfo(source).completeBaseName(); |
|
|
|
|
destination = destination.replace(fileName,newUuid.toString()); |
|
|
|
|
QFile::copy(source,destination); |
|
|
|
|
mediaItem->setMediaFileUrl(QUrl::fromLocalFile(destination)); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsWidgetItem* widget = qgraphicsitem_cast<UBGraphicsWidgetItem*>(item); |
|
|
|
|
if(widget){ |
|
|
|
|
QUuid newUUid = QUuid::createUuid(); |
|
|
|
|
QString newUUidString = newUUid.toString().remove("{").remove("}"); |
|
|
|
|
QString actualUuidString = widget->uuid().toString().remove("{").remove("}"); |
|
|
|
|
|
|
|
|
|
QString widgetSourcePath = proxy->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/{" + actualUuidString + "}.wgt"; |
|
|
|
|
QString screenshotSourcePath = proxy->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + actualUuidString + ".png"; |
|
|
|
|
|
|
|
|
|
QString widgetDestinationPath = widgetSourcePath; |
|
|
|
|
widgetDestinationPath = widgetDestinationPath.replace(actualUuidString,newUUidString); |
|
|
|
|
QString screenshotDestinationPath = screenshotSourcePath; |
|
|
|
|
screenshotDestinationPath = screenshotDestinationPath.replace(actualUuidString,newUUidString); |
|
|
|
|
|
|
|
|
|
UBFileSystemUtils::copyDir(widgetSourcePath,widgetDestinationPath); |
|
|
|
|
QFile::copy(screenshotSourcePath,screenshotDestinationPath); |
|
|
|
|
|
|
|
|
|
widget->setUuid(newUUid); |
|
|
|
|
|
|
|
|
|
widget->widgetUrl(QUrl::fromLocalFile(widgetDestinationPath)); |
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsPixmapItem* pixmapItem = qgraphicsitem_cast<UBGraphicsPixmapItem*>(item); |
|
|
|
|
if(pixmapItem){ |
|
|
|
|
QString source = proxy->persistencePath() + "/" + UBPersistenceManager::imageDirectory + "/" + pixmapItem->uuid().toString() + ".png"; |
|
|
|
|
QString destination = source; |
|
|
|
|
QUuid newUuid = QUuid::createUuid(); |
|
|
|
|
QString fileName = QFileInfo(source).completeBaseName(); |
|
|
|
|
destination = destination.replace(fileName,newUuid.toString()); |
|
|
|
|
QFile::copy(source,destination); |
|
|
|
|
pixmapItem->setUuid(newUuid); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsSvgItem* svgItem = qgraphicsitem_cast<UBGraphicsSvgItem*>(item); |
|
|
|
|
if(svgItem){ |
|
|
|
|
QString source = proxy->persistencePath() + "/" + UBPersistenceManager::imageDirectory + "/" + svgItem->uuid().toString() + ".svg"; |
|
|
|
|
QString destination = source; |
|
|
|
|
QUuid newUuid = QUuid::createUuid(); |
|
|
|
|
QString fileName = QFileInfo(source).completeBaseName(); |
|
|
|
|
destination = destination.replace(fileName,newUuid.toString()); |
|
|
|
|
QFile::copy(source,destination); |
|
|
|
|
svgItem->setUuid(newUuid); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
scene->setModified(true); |
|
|
|
|
|
|
|
|
|
persistDocumentScene(proxy,scene, index + 1); |
|
|
|
|
|
|
|
|
|
proxy->incPageCount(); |
|
|
|
|
|
|
|
|
|
emit documentSceneCreated(proxy, index + 1); |
|
|
|
|