diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index d5a383df..5d1d8add 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -551,9 +551,13 @@ void UBBoardController::duplicateItem(UBItem *item) itemSize = commonItem->boundingRect().size(); } + UBMimeType::Enum itemMimeType; QString contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(item->sourceUrl().toLocalFile()); - - UBMimeType::Enum itemMimeType = UBFileSystemUtils::mimeTypeFromString(contentTypeHeader); + if(NULL != qgraphicsitem_cast(commonItem)){ + itemMimeType = UBMimeType::Group; + }else{ + itemMimeType = UBFileSystemUtils::mimeTypeFromString(contentTypeHeader); + } switch(static_cast(itemMimeType)) { @@ -598,6 +602,29 @@ void UBBoardController::duplicateItem(UBItem *item) pixitem->pixmap().save(&buffer, format.toLatin1()); } }break; + + case UBMimeType::Group: + { + UBGraphicsGroupContainerItem* groupItem = dynamic_cast(item); + if(groupItem){ + QList children = groupItem->childItems(); + foreach(QGraphicsItem* pIt, children){ + UBItem* pItem = dynamic_cast(pIt); + if(NULL != pItem){ + duplicateItem(pItem); // The duplication already copies the item parameters + QGraphicsItem* pDuplicatedItem = dynamic_cast((mActiveScene->children().last())); + if(NULL != pDuplicatedItem){ + pDuplicatedItem->setSelected(true); + } + } + } + groupItem->setSelected(false); + UBApplication::mainWindow->actionGroupItems->trigger(); + } + return; + break; + } + case UBMimeType::UNKNOWN: { QGraphicsItem *gitem = dynamic_cast(item->deepCopy()); @@ -1330,6 +1357,8 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri } } } + }else if("group" == sourceUrl.toString()){ + qDebug() << "accepting url " << sourceUrl.toString() << "as group content"; } else { diff --git a/src/core/UB.h b/src/core/UB.h index afc0f91e..02e2ba18 100644 --- a/src/core/UB.h +++ b/src/core/UB.h @@ -33,6 +33,7 @@ struct UBMimeType Flash, PDF, UniboardTool, + Group, UNKNOWN }; }; diff --git a/src/domain/UBGraphicsGroupContainerItemDelegate.cpp b/src/domain/UBGraphicsGroupContainerItemDelegate.cpp index 6d753cd8..8a24f8f0 100644 --- a/src/domain/UBGraphicsGroupContainerItemDelegate.cpp +++ b/src/domain/UBGraphicsGroupContainerItemDelegate.cpp @@ -19,6 +19,7 @@ UBGraphicsGroupContainerItemDelegate::UBGraphicsGroupContainerItemDelegate(QGrap //Wrapper function. Use it to set correct data() to QGraphicsItem as well setFlippable(false); setRotatable(false); + setCanDuplicate(true); } UBGraphicsGroupContainerItem *UBGraphicsGroupContainerItemDelegate::delegated() diff --git a/src/frameworks/UBFileSystemUtils.cpp b/src/frameworks/UBFileSystemUtils.cpp index 1cd529cd..32f47414 100644 --- a/src/frameworks/UBFileSystemUtils.cpp +++ b/src/frameworks/UBFileSystemUtils.cpp @@ -588,6 +588,9 @@ UBMimeType::Enum UBFileSystemUtils::mimeTypeFromString(const QString& typeString { type = UBMimeType::UniboardTool; } + else if (typeString.startsWith("group")){ + type = UBMimeType::Group; + } return type; }