|
|
@ -537,7 +537,7 @@ void UBBoardController::duplicateScene() |
|
|
|
duplicateScene(mActiveSceneIndex); |
|
|
|
duplicateScene(mActiveSceneIndex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item) |
|
|
|
UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item, bool bAsync) |
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!item) |
|
|
|
if (!item) |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
@ -568,7 +568,10 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item) |
|
|
|
if (srcFile.isEmpty()) |
|
|
|
if (srcFile.isEmpty()) |
|
|
|
srcFile = item->sourceUrl().toString(); |
|
|
|
srcFile = item->sourceUrl().toString(); |
|
|
|
|
|
|
|
|
|
|
|
QString contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(srcFile); |
|
|
|
QString contentTypeHeader; |
|
|
|
|
|
|
|
if (!srcFile.isEmpty()) |
|
|
|
|
|
|
|
contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(srcFile); |
|
|
|
|
|
|
|
|
|
|
|
if(NULL != qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(commonItem)) |
|
|
|
if(NULL != qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(commonItem)) |
|
|
|
itemMimeType = UBMimeType::Group; |
|
|
|
itemMimeType = UBMimeType::Group; |
|
|
|
else
|
|
|
|
else
|
|
|
@ -593,9 +596,13 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item) |
|
|
|
if (mitem) |
|
|
|
if (mitem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
sourceUrl = mitem->mediaFileUrl(); |
|
|
|
sourceUrl = mitem->mediaFileUrl(); |
|
|
|
|
|
|
|
if (bAsync) |
|
|
|
|
|
|
|
{ |
|
|
|
downloadURL(sourceUrl, srcFile, itemPos, QSize(itemSize.width(), itemSize.height()), false, false);
|
|
|
|
downloadURL(sourceUrl, srcFile, itemPos, QSize(itemSize.width(), itemSize.height()), false, false);
|
|
|
|
|
|
|
|
return NULL; // async operation
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}return NULL; // async operation
|
|
|
|
}break; |
|
|
|
|
|
|
|
|
|
|
|
case UBMimeType::VectorImage: |
|
|
|
case UBMimeType::VectorImage: |
|
|
|
{ |
|
|
|
{ |
|
|
@ -623,33 +630,30 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsGroupContainerItem* groupItem = dynamic_cast<UBGraphicsGroupContainerItem*>(item); |
|
|
|
UBGraphicsGroupContainerItem* groupItem = dynamic_cast<UBGraphicsGroupContainerItem*>(item); |
|
|
|
UBGraphicsGroupContainerItem* duplicatedGroup = NULL; |
|
|
|
UBGraphicsGroupContainerItem* duplicatedGroup = NULL; |
|
|
|
if(groupItem){ |
|
|
|
|
|
|
|
QTransform groupTransform = groupItem->transform(); |
|
|
|
|
|
|
|
groupItem->resetTransform(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QGraphicsItem*> duplicatedItems; |
|
|
|
QList<QGraphicsItem*> children = groupItem->childItems(); |
|
|
|
QList<QGraphicsItem*> children = groupItem->childItems(); |
|
|
|
foreach(QGraphicsItem* pIt, children){ |
|
|
|
foreach(QGraphicsItem* pIt, children){ |
|
|
|
UBItem* pItem = dynamic_cast<UBItem*>(pIt); |
|
|
|
UBItem* pItem = dynamic_cast<UBItem*>(pIt); |
|
|
|
if(NULL != pItem){ |
|
|
|
if(pItem){ // we diong sync duplication of all childs.
|
|
|
|
duplicateItem(pItem); |
|
|
|
QGraphicsItem * itemToGroup = dynamic_cast<QGraphicsItem *>(duplicateItem(pItem, false)); |
|
|
|
|
|
|
|
if (itemToGroup) |
|
|
|
|
|
|
|
duplicatedItems.append(itemToGroup); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
groupItem->setTransform(groupTransform); |
|
|
|
duplicatedGroup = mActiveScene->createGroup(duplicatedItems); |
|
|
|
|
|
|
|
duplicatedGroup->setTransform(groupItem->transform()); |
|
|
|
groupItem->setSelected(false); |
|
|
|
groupItem->setSelected(false); |
|
|
|
UBApplication::mainWindow->actionGroupItems->trigger(); |
|
|
|
|
|
|
|
QList<QGraphicsItem*> selItems = mActiveScene->selectedItems(); |
|
|
|
|
|
|
|
if(!selItems.empty()){ |
|
|
|
|
|
|
|
// I don't like this solution but for now this is the only way I found.
|
|
|
|
|
|
|
|
// Normally, at this state, only the duplicated group should be selected
|
|
|
|
|
|
|
|
duplicatedGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(selItems.at(0)); |
|
|
|
|
|
|
|
if(NULL != duplicatedGroup){ |
|
|
|
|
|
|
|
duplicatedGroup->setTransform(groupTransform); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
retItem = dynamic_cast<UBGraphicsItem *>(duplicatedGroup); |
|
|
|
retItem = dynamic_cast<UBGraphicsItem *>(duplicatedGroup); |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
QGraphicsItem * itemToAdd = dynamic_cast<QGraphicsItem *>(retItem); |
|
|
|
|
|
|
|
if (itemToAdd) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mActiveScene->addItem(itemToAdd); |
|
|
|
|
|
|
|
itemToAdd->setSelected(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
|
|
|
|
case UBMimeType::UNKNOWN: |
|
|
|
case UBMimeType::UNKNOWN: |
|
|
|
{ |
|
|
|
{ |
|
|
@ -668,7 +672,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item) |
|
|
|
if (retItem) |
|
|
|
if (retItem) |
|
|
|
return retItem; |
|
|
|
return retItem; |
|
|
|
|
|
|
|
|
|
|
|
UBItem *createdItem = downloadFinished(true, sourceUrl, sourceUrl, contentTypeHeader, pData, itemPos, QSize(itemSize.width(), itemSize.height()), false); |
|
|
|
UBItem *createdItem = downloadFinished(true, sourceUrl, srcFile, contentTypeHeader, pData, itemPos, QSize(itemSize.width(), itemSize.height()), false); |
|
|
|
if (createdItem) |
|
|
|
if (createdItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
createdItem->setSourceUrl(item->sourceUrl()); |
|
|
|
createdItem->setSourceUrl(item->sourceUrl()); |
|
|
|