diff --git a/src/adaptors/UBImportAdaptor.cpp b/src/adaptors/UBImportAdaptor.cpp index 0a842f3e..790c809a 100644 --- a/src/adaptors/UBImportAdaptor.cpp +++ b/src/adaptors/UBImportAdaptor.cpp @@ -53,27 +53,3 @@ UBDocumentBasedImportAdaptor::UBDocumentBasedImportAdaptor(QObject *parent) { // NOOP } - - -/* -UBDocumentProxy* UBImportAdaptor::importFile(const QFile& pFile, const QString& pGroup) -{ - QString documentName = QFileInfo(pFile.fileName()).completeBaseName(); - - UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName); - - bool result = addFileToDocument(newDocument, pFile); - - if (result) - { - UBPersistenceManager::persistenceManager()->persistDocumentMetadata(newDocument); - } - else - { - UBPersistenceManager::persistenceManager()->deleteDocument(newDocument); - newDocument = 0; - } - - return newDocument; -} -*/ \ No newline at end of file diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index ccb6d859..f36b657c 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -255,7 +255,7 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName, } doc->setMetaData(UBSettings::documentVersion, UBSettings::currentFileVersion); - QString currentDate = UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()); + QString currentDate = UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()); doc->setMetaData(UBSettings::documentUpdatedAt,currentDate); doc->setMetaData(UBSettings::documentDate,currentDate); @@ -396,12 +396,14 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL foreach(int index, compactedIndexes) { + // trig the reload of the thumbnails emit documentSceneWillBeDeleted(proxy, index); } QString sourceGroupName = proxy->metaData(UBSettings::documentGroupName).toString(); QString sourceName = proxy->metaData(UBSettings::documentName).toString(); UBDocumentProxy *trashDocProxy = createDocument(UBSettings::trashedDocumentGroupNamePrefix + sourceGroupName, sourceName, false); + generatePathIfNeeded(trashDocProxy); foreach(int index, compactedIndexes) { @@ -418,7 +420,7 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL QDir d = fi.dir(); d.mkpath(d.absolutePath()); - QFile::copy(source, target); + Q_ASSERT(QFile::rename(source, target)); } insertDocumentSceneAt(trashDocProxy, scene, trashDocProxy->pageCount()); diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index e80a8561..b0d0b158 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -2088,11 +2088,39 @@ QList UBGraphicsScene::relativeDependencies() const while (itItems.hasNext()) { - UBGraphicsMediaItem *videoItem = qgraphicsitem_cast (itItems.next()); + QGraphicsItem* item = itItems.next(); + UBGraphicsMediaItem *mediaItem = qgraphicsitem_cast (item); - if (videoItem && videoItem->mediaFileUrl().isRelative()) - { - relativePathes << videoItem->mediaFileUrl(); + if (mediaItem){ + QString completeFileName = QFileInfo(mediaItem->mediaFileUrl().toLocalFile()).fileName(); + QString path; + if(mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Video) + path = UBPersistenceManager::videoDirectory + "/"; + else + path = UBPersistenceManager::audioDirectory + "/"; + relativePathes << QUrl(path + completeFileName); + continue; + } + + UBGraphicsWidgetItem* widget = qgraphicsitem_cast(item); + if(widget){ + QString widgetPath = UBPersistenceManager::widgetDirectory + "/" + widget->uuid().toString() + ".wgt"; + QString screenshotPath = UBPersistenceManager::widgetDirectory + "/" + widget->uuid().toString().remove("{").remove("}") + ".png"; + relativePathes << QUrl(widgetPath); + relativePathes << QUrl(screenshotPath); + continue; + } + + UBGraphicsPixmapItem* pixmapItem = qgraphicsitem_cast(item); + if(pixmapItem){ + relativePathes << QUrl(UBPersistenceManager::imageDirectory + "/" + pixmapItem->uuid().toString() + ".png"); + continue; + } + + UBGraphicsSvgItem* svgItem = qgraphicsitem_cast(item); + if(svgItem){ + relativePathes << QUrl(UBPersistenceManager::imageDirectory + "/" + svgItem->uuid().toString() + ".svg"); + continue; } } diff --git a/src/domain/UBGraphicsWidgetItem.h b/src/domain/UBGraphicsWidgetItem.h index 65da2bd7..344f05cf 100644 --- a/src/domain/UBGraphicsWidgetItem.h +++ b/src/domain/UBGraphicsWidgetItem.h @@ -130,7 +130,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe type_WIN = 1, // 0001 type_MAC = 2, // 0010 type_UNIX = 4, // 0100 - type_ALL = 7, // 0111 + type_ALL = 7 // 0111 }; bool mFirstReleaseAfterMove;