Enabled garbage cleaning.

Selected items can be moved by any frame of any item.
preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent 0210c41833
commit 4e691d5197
  1. 11
      src/board/UBBoardController.cpp
  2. 69
      src/domain/UBGraphicsDelegateFrame.cpp
  3. 6
      src/domain/UBGraphicsDelegateFrame.h

@ -1466,12 +1466,13 @@ void UBBoardController::ClearUndoStack()
while (itUniq.hasNext())
{
QGraphicsItem* item = itUniq.next();
UBGraphicsScene *scene = NULL;
if (item->scene()) {
UBGraphicsScene *scene = dynamic_cast<UBGraphicsScene*>(item->scene());
if(!scene)
{
mActiveScene->deleteItem(item);
}
scene = dynamic_cast<UBGraphicsScene*>(item->scene());
}
if(!scene)
{
mActiveScene->deleteItem(item);
}
}

@ -228,6 +228,9 @@ void UBGraphicsDelegateFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
mCurrentTool = toolFromPos(event->pos());
setCursorFromAngle(QString(""));
event->accept();
prepareFramesToMove(getLinkedFrames());
}
void UBGraphicsDelegateFrame::setCursorFromAngle(QString angle)
@ -469,6 +472,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
mTranslateX = move.dx();
mTranslateY = move.dy();
moveLinkedItems(move);
}
QTransform tr = buildTransform();
@ -534,6 +538,71 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event->accept();
}
QList<UBGraphicsDelegateFrame *> UBGraphicsDelegateFrame::getLinkedFrames()
{
QList<UBGraphicsDelegateFrame*> linkedFrames;
QList<QGraphicsItem*> sItems = mDelegate->delegated()->scene()->selectedItems();
if (sItems.count())
{
sItems.removeAll(delegated());
foreach(QGraphicsItem *item, sItems)
{
UBGraphicsItem *gitem = dynamic_cast<UBGraphicsItem*>(item);
if (gitem)
linkedFrames << gitem->Delegate()->frame();
}
}
return linkedFrames;
}
void UBGraphicsDelegateFrame::prepareFramesToMove(QList<UBGraphicsDelegateFrame *> framesToMove)
{
mLinkedFrames = framesToMove;
foreach (UBGraphicsDelegateFrame *frame, mLinkedFrames)
{
frame->prepareLinkedFrameToMove();
}
}
void UBGraphicsDelegateFrame::prepareLinkedFrameToMove()
{
mDelegate->startUndoStep();
mStartingPoint = QPointF(0,0);
initializeTransform();
mScaleX = 1;
mScaleY = 1;
mTranslateX = 0;
mTranslateY = 0;
mAngleOffset = 0;
mInitialTransform = buildTransform();
mCurrentTool = Move;
}
void UBGraphicsDelegateFrame::moveLinkedItems(QLineF movingVector, bool bLinked)
{
if (bLinked)
{
mCurrentTool = Move;
mTranslateX = movingVector.dx();
mTranslateY = movingVector.dy();
delegated()->setTransform(buildTransform(), false);
}
else
{
foreach(UBGraphicsDelegateFrame* frame, mLinkedFrames)
{
frame->moveLinkedItems(movingVector, true);
}
}
}
QTransform UBGraphicsDelegateFrame::buildTransform()
{

@ -48,6 +48,10 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
enum OperationMode {Scaling, Resizing, ResizingHorizontally};
void setOperationMode(OperationMode pMode) {mOperationMode = pMode;}
bool isResizing(){return mResizing;}
void moveLinkedItems(QLineF movingVector, bool bLinked = false);
void prepareFramesToMove(QList<UBGraphicsDelegateFrame *> framesToMove);
void prepareLinkedFrameToMove();
QList<UBGraphicsDelegateFrame *> getLinkedFrames();
private:
QRectF bottomRightResizeGripRect() const;
@ -120,5 +124,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
bool mResizing;
bool mMirroredXAtStart;
bool mMirroredYAtStart;
QList<UBGraphicsDelegateFrame *> mLinkedFrames;
};
#endif /* UBGRAPHICSDELEGATEFRAME_H_ */

Loading…
Cancel
Save