Commit 87ad5885 authored by Ilia Ryabokon's avatar Ilia Ryabokon

Fix ZLayerController addItem() bug

parent f47733ee
......@@ -276,6 +276,18 @@ void UBZLayerController::setLayerType(QGraphicsItem *pItem, itemLayerType::Enum
pItem->setData(UBGraphicsItemData::itemLayerType, QVariant(pNewType));
}
void UBZLayerController::shiftStoredZValue(QGraphicsItem *item, qreal zValue)
{
itemLayerType::Enum type = typeForData(item);
if (validLayerType(type)) {
ItemLayerTypeData typeData = scopeMap.value(type);
if (typeData.curValue < zValue) {
scopeMap[type].curValue = zValue;
}
}
}
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoStack)
: UBCoreGraphicsScene(parent)
, mEraser(0)
......@@ -1051,6 +1063,11 @@ UBBoardView *UBGraphicsScene::controlView()
return result;
}
void UBGraphicsScene::notifyZChanged(QGraphicsItem *item, qreal zValue)
{
mZLayerController->shiftStoredZValue(item, zValue);
}
void UBGraphicsScene::updateSelectionFrame()
{
qDebug() << "selected item count" << selectedItems().count();
......@@ -1647,6 +1664,8 @@ void UBGraphicsScene::addItem(QGraphicsItem* item)
if(item->zValue() == DEFAULT_Z_VALUE || item->zValue() == UBZLayerController::errorNum()){
qreal zvalue = mZLayerController->generateZLevel(item);
UBGraphicsItem::assignZValue(item, zvalue);
} else {
notifyZChanged(item, item->zValue());
}
if (!mTools.contains(item))
......
......@@ -96,6 +96,7 @@ public:
qreal changeZLevelTo(QGraphicsItem *item, moveDestination dest);
itemLayerType::Enum typeForData(QGraphicsItem *item) const;
void setLayerType(QGraphicsItem *pItem, itemLayerType::Enum pNewType);
void shiftStoredZValue(QGraphicsItem *item, qreal zValue);
private:
ScopeMap scopeMap;
......@@ -311,6 +312,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsPolygonItem* polygonToPolygonItem(const QPolygonF pPolygon);
void clearSelectionFrame();
UBBoardView *controlView();
void notifyZChanged(QGraphicsItem *item, qreal zValue);
public slots:
......
......@@ -32,6 +32,7 @@
#include "domain/UBGraphicsStrokesGroup.h"
#include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsScene.h"
#include "tools/UBGraphicsCurtainItem.h"
#include "domain/UBGraphicsItemDelegate.h"
......
......@@ -191,7 +191,7 @@ void UBSelectionFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
item->update();
item->setTransform(ownTransform, false);
int resultAngle = (int)mRotationAngle % 360;
// int resultAngle = (int)mRotationAngle % 360;
// setCursorFromAngle(QString::number(resultAngle));
qDebug() << "curAngle" << mRotationAngle;
......@@ -284,9 +284,14 @@ void UBSelectionFrame::increaseZlevelDown()
void UBSelectionFrame::increaseZlevelBottom()
{
foreach (QGraphicsItem *item, sortedByZ(scene()->selectedItems())) {
ubscene()->changeZLevelTo(item, UBZLayerController::bottom);
QListIterator<QGraphicsItem*> iter(sortedByZ(scene()->selectedItems()));
iter.toBack();
while (iter.hasPrevious()) {
ubscene()->changeZLevelTo(iter.previous(), UBZLayerController::bottom);
}
// foreach (QGraphicsItem *item, sortedByZ(scene()->selectedItems())) {
// ubscene()->changeZLevelTo(item, UBZLayerController::bottom);
// }
}
void UBSelectionFrame::translateItem(QGraphicsItem */*item*/, const QPointF &/*translatePoint*/)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment