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. 68
      src/domain/UBGraphicsScene.cpp
  2. 1
      src/domain/UBGraphicsScene.h

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

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

Loading…
Cancel
Save