Implemented group duplication

preferencesAboutTextFull
shibakaneki 13 years ago
parent 83e6a26327
commit 4f7e1d743d
  1. 33
      src/board/UBBoardController.cpp
  2. 1
      src/core/UB.h
  3. 1
      src/domain/UBGraphicsGroupContainerItemDelegate.cpp
  4. 3
      src/frameworks/UBFileSystemUtils.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<UBGraphicsGroupContainerItem*>(commonItem)){
itemMimeType = UBMimeType::Group;
}else{
itemMimeType = UBFileSystemUtils::mimeTypeFromString(contentTypeHeader);
}
switch(static_cast<int>(itemMimeType))
{
@ -598,6 +602,29 @@ void UBBoardController::duplicateItem(UBItem *item)
pixitem->pixmap().save(&buffer, format.toLatin1());
}
}break;
case UBMimeType::Group:
{
UBGraphicsGroupContainerItem* groupItem = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
if(groupItem){
QList<QGraphicsItem*> children = groupItem->childItems();
foreach(QGraphicsItem* pIt, children){
UBItem* pItem = dynamic_cast<UBItem*>(pIt);
if(NULL != pItem){
duplicateItem(pItem); // The duplication already copies the item parameters
QGraphicsItem* pDuplicatedItem = dynamic_cast<QGraphicsItem*>((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<QGraphicsItem*>(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
{

@ -33,6 +33,7 @@ struct UBMimeType
Flash,
PDF,
UniboardTool,
Group,
UNKNOWN
};
};

@ -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()

@ -588,6 +588,9 @@ UBMimeType::Enum UBFileSystemUtils::mimeTypeFromString(const QString& typeString
{
type = UBMimeType::UniboardTool;
}
else if (typeString.startsWith("group")){
type = UBMimeType::Group;
}
return type;
}

Loading…
Cancel
Save