fixed a bug where grouped items with file dependencies would not be properly copied when copying a page from a document to another

preferencesAboutTextFull
Clément Fauconnier 3 years ago
parent 9169146e27
commit bbf134d1fe
  1. 92
      src/domain/UBGraphicsScene.cpp
  2. 1
      src/domain/UBGraphicsScene.h

@ -2473,9 +2473,53 @@ void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQua
}
}
QList<QUrl> UBGraphicsScene::relativeDependenciesOfItem(QGraphicsItem* item) const
{
QList<QUrl> relativePaths;
UBGraphicsVideoItem *videoItem = dynamic_cast<UBGraphicsVideoItem*> (item);
if (videoItem){
QString completeFileName = QFileInfo(videoItem->mediaFileUrl().toLocalFile()).fileName();
QString path = UBPersistenceManager::videoDirectory + "/";
relativePaths << QUrl(path + completeFileName);
return relativePaths;
}
UBGraphicsAudioItem *audioItem = dynamic_cast<UBGraphicsAudioItem*> (item);
if (audioItem){
QString completeFileName = QFileInfo(audioItem->mediaFileUrl().toLocalFile()).fileName();
QString path = UBPersistenceManager::audioDirectory + "/";
relativePaths << QUrl(path + completeFileName);
return relativePaths;
}
UBGraphicsWidgetItem* widget = dynamic_cast<UBGraphicsWidgetItem*>(item);
if(widget){
QString widgetPath = UBPersistenceManager::widgetDirectory + "/" + widget->uuid().toString() + ".wgt";
QString screenshotPath = UBPersistenceManager::widgetDirectory + "/" + widget->uuid().toString().remove("{").remove("}") + ".png";
relativePaths << QUrl(widgetPath);
relativePaths << QUrl(screenshotPath);
return relativePaths;
}
UBGraphicsPixmapItem* pixmapItem = dynamic_cast<UBGraphicsPixmapItem*>(item);
if(pixmapItem){
relativePaths << QUrl(UBPersistenceManager::imageDirectory + "/" + pixmapItem->uuid().toString() + ".png");
return relativePaths;
}
UBGraphicsSvgItem* svgItem = dynamic_cast<UBGraphicsSvgItem*>(item);
if(svgItem){
relativePaths << QUrl(UBPersistenceManager::imageDirectory + "/" + svgItem->uuid().toString() + ".svg");
return relativePaths;
}
return relativePaths;
}
QList<QUrl> UBGraphicsScene::relativeDependencies() const
{
QList<QUrl> relativePathes;
QList<QUrl> relativePaths;
QListIterator<QGraphicsItem*> itItems(mFastAccessItems);
@ -2483,45 +2527,19 @@ QList<QUrl> UBGraphicsScene::relativeDependencies() const
{
QGraphicsItem* item = itItems.next();
UBGraphicsVideoItem *videoItem = qgraphicsitem_cast<UBGraphicsVideoItem*> (item);
if (videoItem){
QString completeFileName = QFileInfo(videoItem->mediaFileUrl().toLocalFile()).fileName();
QString path = UBPersistenceManager::videoDirectory + "/";
relativePathes << QUrl(path + completeFileName);
continue;
}
UBGraphicsAudioItem *audioItem = qgraphicsitem_cast<UBGraphicsAudioItem*> (item);
if (audioItem){
QString completeFileName = QFileInfo(audioItem->mediaFileUrl().toLocalFile()).fileName();
QString path = UBPersistenceManager::audioDirectory + "/";
relativePathes << QUrl(path + completeFileName);
continue;
}
UBGraphicsWidgetItem* widget = qgraphicsitem_cast<UBGraphicsWidgetItem*>(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<UBGraphicsPixmapItem*>(item);
if(pixmapItem){
relativePathes << QUrl(UBPersistenceManager::imageDirectory + "/" + pixmapItem->uuid().toString() + ".png");
continue;
}
UBGraphicsSvgItem* svgItem = qgraphicsitem_cast<UBGraphicsSvgItem*>(item);
if(svgItem){
relativePathes << QUrl(UBPersistenceManager::imageDirectory + "/" + svgItem->uuid().toString() + ".svg");
continue;
UBGraphicsGroupContainerItem* groupItem = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
if(groupItem)
{
for (auto child : groupItem->childItems())
{
relativePaths << relativeDependenciesOfItem(child);
}
}
else
relativePaths << relativeDependenciesOfItem(item);
}
return relativePathes;
return relativePaths;
}
QSize UBGraphicsScene::nominalSize()

@ -303,6 +303,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
virtual void setRenderingQuality(UBItem::RenderingQuality pRenderingQuality, UBItem::CacheBehavior cacheBehavior);
QList<QUrl> relativeDependenciesOfItem(QGraphicsItem* item) const;
QList<QUrl> relativeDependencies() const;
QSize nominalSize();

Loading…
Cancel
Save