Fix ZLayerController addItem() bug

preferencesAboutTextFull
Ilia Ryabokon 11 years ago
parent f47733ee1a
commit 87ad5885ec
  1. 19
      src/domain/UBGraphicsScene.cpp
  2. 2
      src/domain/UBGraphicsScene.h
  3. 1
      src/domain/UBItem.cpp
  4. 11
      src/domain/UBSelectionFrame.cpp

@ -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*/)

Loading…
Cancel
Save