Corrected a few minor duplication / zValue issues:

- zValue is correctly initialized when duplicating an object
- Duplicated objects are translated correctly
preferencesAboutTextFull
Craig Watson 9 years ago
parent c956cb0427
commit 41b538c733
  1. 5
      src/board/UBBoardController.cpp
  2. 25
      src/domain/UBGraphicsScene.cpp
  3. 2
      src/domain/UBGraphicsScene.h

@ -690,7 +690,10 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item)
if (gitem)
{
mActiveScene->addItem(gitem);
gitem->setPos(itemPos);
// Translate the new object a bit
gitem->setPos(20, 20);
mLastCreatedItem = gitem;
gitem->setSelected(true);
}

@ -297,6 +297,19 @@ void UBZLayerController::shiftStoredZValue(QGraphicsItem *item, qreal zValue)
}
}
/**
* @brief Returns true if the zLevel is not used by any item on the scene, or false if so.
*/
bool UBZLayerController::zLevelAvailable(qreal z)
{
foreach(QGraphicsItem* it, mScene->items()) {
if (it->zValue() == z)
return false;
}
return true;
}
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoStack)
: UBCoreGraphicsScene(parent)
, mEraser(0)
@ -322,7 +335,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
, mSelectionFrame(0)
{
UBCoreGraphicsScene::setObjectName("BoardScene");
//setItemIndexMethod(NoIndex);
setItemIndexMethod(BspTreeIndex);
setUuid(QUuid::createUuid());
setDocument(parent);
@ -1688,13 +1701,17 @@ void UBGraphicsScene::addItem(QGraphicsItem* item)
UBCoreGraphicsScene::addItem(item);
// the default z value is already set. This is the case when a svg file is read
if(item->zValue() == DEFAULT_Z_VALUE || item->zValue() == UBZLayerController::errorNum()){
if(item->zValue() == DEFAULT_Z_VALUE
|| item->zValue() == UBZLayerController::errorNum()
|| !mZLayerController->zLevelAvailable(item->zValue()))
{
qreal zvalue = mZLayerController->generateZLevel(item);
UBGraphicsItem::assignZValue(item, zvalue);
} else {
notifyZChanged(item, item->zValue());
}
else
notifyZChanged(item, item->zValue());
if (!mTools.contains(item))
++mItemCount;

@ -102,6 +102,8 @@ public:
void setLayerType(QGraphicsItem *pItem, itemLayerType::Enum pNewType);
void shiftStoredZValue(QGraphicsItem *item, qreal zValue);
bool zLevelAvailable(qreal z);
private:
ScopeMap scopeMap;
static qreal errorNumber;

Loading…
Cancel
Save