-
- // Rebuild groups or they get corrupted (because of translate / move issues)
- AbstractGroupItem *group = static_cast <AbstractGroupItem *>(children.at(i));
- //kDebug()<<"// GRP POS:"<<group->scenePos()<<", SELECT:"<<selectionPos;
- if (group->scenePos() != selectionPos)
- group->translate(selectionPos.x(), selectionPos.y());
- //group->setPos(-selectionPos.x(), -selectionPos.y());
- QList<QGraphicsItem *> selection = group->childItems();
- m_document->clipManager()->removeGroup(group);
- scene()->destroyItemGroup(group);
- if (!selection.isEmpty()) {
- QPointF top = selection.at(0)->sceneBoundingRect().topLeft();
-
- // Find top left position of selection
- for (int j = 1; j < selection.count(); j++) {
- if (selection.at(j)->type() == AVWIDGET || selection.at(j)->type() == TRANSITIONWIDGET) {
- selection.at(j)->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
- QPointF currenttop = selection.at(j)->sceneBoundingRect().topLeft();
- //kDebug()<<"// GRP ITEM POS:"<<currenttop;
- if (currenttop.x() < top.x()) top.setX(currenttop.x());
- if (currenttop.y() < top.y()) top.setY(currenttop.y());
- }
- }
-
- AbstractGroupItem *newGroup = m_document->clipManager()->createGroup();
- newGroup->translate(-top.x(), -top.y() + 1);
- newGroup->setPos(top.x(), top.y() - 1);
- scene()->addItem(newGroup);
-
- for (int j = 0; j < selection.count(); j++) {
- if (selection.at(j)->type() == AVWIDGET || selection.at(j)->type() == TRANSITIONWIDGET) {
- newGroup->addToGroup(selection.at(j));
- //kDebug()<<"// ADDING ITEM:"<<selection.at(j)->sceneBoundingRect();
- selection.at(j)->setFlags(QGraphicsItem::ItemIsSelectable);
- }
- }
- }