diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 2ef4cedf..5015e90a 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()); 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/domain/domain.pri b/src/domain/domain.pri index e8b46b4d..1111106f 100644 --- a/src/domain/domain.pri +++ b/src/domain/domain.pri @@ -1,63 +1,58 @@ - -HEADERS += src/domain/UBGraphicsScene.h \ - src/domain/UBGraphicsItemUndoCommand.h \ - src/domain/UBGraphicsTextItemUndoCommand.h \ - src/domain/UBGraphicsItemTransformUndoCommand.h \ - src/domain/UBGraphicsPixmapItem.h \ - src/domain/UBDocumentUndoCommand.h \ - src/domain/UBPageSizeUndoCommand.h \ - src/domain/UBGraphicsProxyWidget.h \ - src/domain/UBGraphicsWebView.h \ - src/domain/UBGraphicsSvgItem.h \ - src/domain/UBGraphicsPolygonItem.h \ - src/domain/UBItem.h \ - src/domain/UBGraphicsWidgetItem.h \ - src/domain/UBGraphicsPDFItem.h \ - src/domain/UBGraphicsTextItem.h \ - src/domain/UBResizableGraphicsItem.h \ - src/domain/UBGraphicsStroke.h \ - src/domain/UBGraphicsMediaItem.h \ - src/domain/UBAbstractUndoCommand.h\ - src/domain/UBGraphicsGroupContainerItem.h \ - src/domain/UBGraphicsGroupContainerItemDelegate.h \ - src/domain/UBGraphicsStrokesGroup.h \ - src/domain/UBGraphicsItemGroupUndoCommand.h - -HEADERS += src/domain/UBGraphicsItemDelegate.h \ - src/domain/UBGraphicsTextItemDelegate.h \ - src/domain/UBGraphicsDelegateFrame.h \ - src/domain/UBGraphicsWidgetItemDelegate.h \ - src/domain/UBGraphicsMediaItemDelegate.h - - -SOURCES += src/domain/UBGraphicsScene.cpp \ - src/domain/UBGraphicsItemUndoCommand.cpp \ - src/domain/UBGraphicsTextItemUndoCommand.cpp \ - src/domain/UBGraphicsItemTransformUndoCommand.cpp \ - src/domain/UBGraphicsPixmapItem.cpp \ - src/domain/UBDocumentUndoCommand.cpp \ - src/domain/UBPageSizeUndoCommand.cpp \ - src/domain/UBGraphicsProxyWidget.cpp \ - src/domain/UBGraphicsWebView.cpp \ - src/domain/UBGraphicsSvgItem.cpp \ - src/domain/UBGraphicsPolygonItem.cpp \ - src/domain/UBItem.cpp \ - src/domain/UBGraphicsVideoItem.cpp \ - src/domain/UBGraphicsWidgetItem.cpp \ - src/domain/UBGraphicsPDFItem.cpp \ - src/domain/UBGraphicsTextItem.cpp \ - src/domain/UBResizableGraphicsItem.cpp \ - src/domain/UBGraphicsStroke.cpp \ - src/domain/UBGraphicsMediaItem.cpp \ - src/domain/UBAbstractUndoCommand.cpp \ - src/domain/ubgraphicsgroupcontaineritem.cpp \ - src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \ - src/domain/UBGraphicsStrokesGroup.cpp \ - src/domain/UBGraphicsItemGroupUndoCommand.cpp - -SOURCES += src/domain/UBGraphicsItemDelegate.cpp \ - src/domain/UBGraphicsTextItemDelegate.cpp \ - src/domain/UBGraphicsMediaItemDelegate.cpp \ - src/domain/UBGraphicsDelegateFrame.cpp \ - src/domain/UBGraphicsWidgetItemDelegate.cpp \ - +HEADERS += src/domain/UBGraphicsScene.h \ + src/domain/UBGraphicsItemUndoCommand.h \ + src/domain/UBGraphicsTextItemUndoCommand.h \ + src/domain/UBGraphicsItemTransformUndoCommand.h \ + src/domain/UBGraphicsPixmapItem.h \ + src/domain/UBDocumentUndoCommand.h \ + src/domain/UBPageSizeUndoCommand.h \ + src/domain/UBGraphicsProxyWidget.h \ + src/domain/UBGraphicsWebView.h \ + src/domain/UBGraphicsSvgItem.h \ + src/domain/UBGraphicsPolygonItem.h \ + src/domain/UBItem.h \ + src/domain/UBGraphicsWidgetItem.h \ + src/domain/UBGraphicsPDFItem.h \ + src/domain/UBGraphicsTextItem.h \ + src/domain/UBResizableGraphicsItem.h \ + src/domain/UBGraphicsStroke.h \ + src/domain/UBGraphicsMediaItem.h \ + src/domain/UBAbstractUndoCommand.h \ + src/domain/UBGraphicsGroupContainerItem.h \ + src/domain/UBGraphicsGroupContainerItemDelegate.h \ + src/domain/UBGraphicsStrokesGroup.h \ + src/domain/UBGraphicsItemGroupUndoCommand.h \ + src/domain/UBGraphicsItemDelegate.h \ + src/domain/UBGraphicsTextItemDelegate.h \ + src/domain/UBGraphicsDelegateFrame.h \ + src/domain/UBGraphicsWidgetItemDelegate.h \ + src/domain/UBGraphicsMediaItemDelegate.h + +SOURCES += src/domain/UBGraphicsScene.cpp \ + src/domain/UBGraphicsItemUndoCommand.cpp \ + src/domain/UBGraphicsTextItemUndoCommand.cpp \ + src/domain/UBGraphicsItemTransformUndoCommand.cpp \ + src/domain/UBGraphicsPixmapItem.cpp \ + src/domain/UBDocumentUndoCommand.cpp \ + src/domain/UBPageSizeUndoCommand.cpp \ + src/domain/UBGraphicsProxyWidget.cpp \ + src/domain/UBGraphicsWebView.cpp \ + src/domain/UBGraphicsSvgItem.cpp \ + src/domain/UBGraphicsPolygonItem.cpp \ + src/domain/UBItem.cpp \ + src/domain/UBGraphicsVideoItem.cpp \ + src/domain/UBGraphicsWidgetItem.cpp \ + src/domain/UBGraphicsPDFItem.cpp \ + src/domain/UBGraphicsTextItem.cpp \ + src/domain/UBResizableGraphicsItem.cpp \ + src/domain/UBGraphicsStroke.cpp \ + src/domain/UBGraphicsMediaItem.cpp \ + src/domain/UBAbstractUndoCommand.cpp \ + src/domain/ubgraphicsgroupcontaineritem.cpp \ + src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \ + src/domain/UBGraphicsStrokesGroup.cpp \ + src/domain/UBGraphicsItemGroupUndoCommand.cpp \ + src/domain/UBGraphicsItemDelegate.cpp \ + src/domain/UBGraphicsTextItemDelegate.cpp \ + src/domain/UBGraphicsMediaItemDelegate.cpp \ + src/domain/UBGraphicsDelegateFrame.cpp \ + src/domain/UBGraphicsWidgetItemDelegate.cpp