Merge branch 'develop' of github.com:Sankore/Sankore-3.1 into develop

preferencesAboutTextFull
bmagnin 12 years ago
commit 7addaddc72
  1. 26
      src/board/UBBoardController.cpp
  2. 1
      src/domain/UBGraphicsPolygonItem.cpp
  3. 34
      src/domain/UBGraphicsStrokesGroup.cpp

@ -611,18 +611,28 @@ void UBBoardController::duplicateItem(UBItem *item)
{ {
UBGraphicsGroupContainerItem* groupItem = dynamic_cast<UBGraphicsGroupContainerItem*>(item); UBGraphicsGroupContainerItem* groupItem = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
if(groupItem){ if(groupItem){
QTransform groupTransform = groupItem->transform();
groupItem->resetTransform();
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(NULL != pItem){
duplicateItem(pItem); // The duplication already copies the item parameters duplicateItem(pItem);
if(NULL != mLastCreatedItem){
mLastCreatedItem->setSelected(true);
}
} }
} }
groupItem->setTransform(groupTransform);
groupItem->setSelected(false); groupItem->setSelected(false);
UBApplication::mainWindow->actionGroupItems->trigger(); 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
UBGraphicsGroupContainerItem* duplicatedGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(selItems.at(0));
if(NULL != duplicatedGroup){
duplicatedGroup->setTransform(groupTransform);
}
}
} }
return; return;
break; break;
@ -635,7 +645,7 @@ void UBBoardController::duplicateItem(UBItem *item)
{ {
mActiveScene->addItem(gitem); mActiveScene->addItem(gitem);
gitem->setPos(itemPos); gitem->setPos(itemPos);
mLastCreatedItem = gitem; mLastCreatedItem = gitem;
gitem->setSelected(true); gitem->setSelected(true);
} }
return; return;
@ -652,6 +662,7 @@ void UBBoardController::duplicateItem(UBItem *item)
if (createdGitem) if (createdGitem)
createdGitem->setPos(itemPos); createdGitem->setPos(itemPos);
mLastCreatedItem = dynamic_cast<QGraphicsItem*>(createdItem); mLastCreatedItem = dynamic_cast<QGraphicsItem*>(createdItem);
mLastCreatedItem->setSelected(true);
} }
} }
@ -2176,7 +2187,10 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
{ {
foreach(UBItem* item, mimeData->items()) foreach(UBItem* item, mimeData->items())
{ {
duplicateItem(item); QGraphicsItem* pItem = dynamic_cast<QGraphicsItem*>(item);
if(NULL != pItem){
duplicateItem(item);
}
} }
return; return;

@ -171,6 +171,7 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
cp->setColorOnDarkBackground(this->colorOnDarkBackground()); cp->setColorOnDarkBackground(this->colorOnDarkBackground());
cp->setColorOnLightBackground(this->colorOnLightBackground()); cp->setColorOnLightBackground(this->colorOnLightBackground());
//cp->setTransform(transform());
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
} }

@ -113,27 +113,33 @@ void UBGraphicsStrokesGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
UBItem* UBGraphicsStrokesGroup::deepCopy() const UBItem* UBGraphicsStrokesGroup::deepCopy() const
{ {
UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
QList<QGraphicsItem*> chl = childItems(); QTransform groupTransform = transform();
const_cast<UBGraphicsStrokesGroup*>(this)->resetTransform();
foreach(QGraphicsItem *child, chl) QList<QGraphicsItem*> chl = childItems();
{
UBGraphicsPolygonItem *polygon = dynamic_cast<UBGraphicsPolygonItem*>(child); foreach(QGraphicsItem *child, chl)
if (polygon) {
{ UBGraphicsPolygonItem *polygon = dynamic_cast<UBGraphicsPolygonItem*>(child);
copy->addToGroup(dynamic_cast<QGraphicsItem*>(polygon->deepCopy()));
polygon->setStrokesGroup(copy); if (polygon){
} QGraphicsItem* pItem = dynamic_cast<QGraphicsItem*>(polygon->deepCopy());
} copy->addToGroup(pItem);
copyItemParameters(copy); }
}
const_cast<UBGraphicsStrokesGroup*>(this)->setTransform(groupTransform);
copyItemParameters(copy);
return copy; return copy;
} }
void UBGraphicsStrokesGroup::copyItemParameters(UBItem *copy) const void UBGraphicsStrokesGroup::copyItemParameters(UBItem *copy) const
{ {
UBGraphicsStrokesGroup *cp = dynamic_cast<UBGraphicsStrokesGroup*>(copy); QGraphicsItem *cp = dynamic_cast<QGraphicsItem*>(copy);
if(NULL != cp)
{ {
cp->setTransform(transform()); cp->setTransform(transform());

Loading…
Cancel
Save