diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index cdaea1e2..660a2f5a 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -29,6 +29,7 @@ #include "domain/UBGraphicsTextItem.h" #include "domain/UBAbstractWidget.h" #include "domain/UBGraphicsStroke.h" +#include "domain/UBItem.h" #include "tools/UBGraphicsRuler.h" #include "tools/UBGraphicsCompass.h" @@ -1337,11 +1338,13 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol if (!ubZValue.isNull()) { - polygonItem->setZValue(ubZValue.toString().toFloat()); +// polygonItem->setZValue (ubZValue.toString().toFloat()); + UBGraphicsItem::assignZValue(polygonItem, ubZValue.toString().toFloat()); } else { - polygonItem->setZValue(mGroupZIndex); +// polygonItem->setZValue(mGroupZIndex); + UBGraphicsItem::assignZValue(polygonItem, mGroupZIndex); } QStringRef ubFillOnDarkBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-dark-background"); @@ -1444,11 +1447,13 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromLin if (!ubZValue.isNull()) { - polygonItem->setZValue(ubZValue.toString().toFloat()); +// polygonItem->setZValue(ubZValue.toString().toFloat()); + UBGraphicsItem::assignZValue(polygonItem, ubZValue.toString().toFloat()); } else { - polygonItem->setZValue(mGroupZIndex); +// polygonItem->setZValue(mGroupZIndex); + UBGraphicsItem::assignZValue(polygonItem, mGroupZIndex); } @@ -1587,7 +1592,8 @@ QList UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItem { UBGraphicsPolygonItem* polygonItem = new UBGraphicsPolygonItem(QLineF(points.at(i), points.at(i + 1)), lineWidth); polygonItem->setColor(brushColor); - polygonItem->setZValue(zValue); +// polygonItem->setZValue(zValue); + UBGraphicsItem::assignZValue(polygonItem, zValue); polygonItem->setColorOnDarkBackground(colorOnDarkBackground); polygonItem->setColorOnLightBackground(colorOnLightBackground); @@ -1931,7 +1937,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* g if (!ubZValue.isNull()) { - gItem->setZValue(ubZValue.toString().toFloat()); +// gItem->setZValue(ubZValue.toString().toFloat()); + UBGraphicsItem::assignZValue(gItem, ubZValue.toString().toFloat()); } UBItem* ubItem = dynamic_cast(gItem); @@ -2484,7 +2491,8 @@ UBGraphicsRuler* UBSvgSubsetAdaptor::UBSvgSubsetReader::rulerFromSvg() graphicsItemFromSvg(ruler); - ruler->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetRuler); +// ruler->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetRuler); + UBGraphicsItem::assignZValue(ruler, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetRuler); ruler->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); QStringRef svgWidth = mXmlReader.attributes().value("width"); @@ -2542,7 +2550,8 @@ UBGraphicsCompass* UBSvgSubsetAdaptor::UBSvgSubsetReader::compassFromSvg() graphicsItemFromSvg(compass); - compass->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCompass); + //compass->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCompass); + UBGraphicsItem::assignZValue(compass, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCompass); compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); QStringRef svgX = mXmlReader.attributes().value("x"); @@ -2606,7 +2615,8 @@ UBGraphicsProtractor* UBSvgSubsetAdaptor::UBSvgSubsetReader::protractorFromSvg() { UBGraphicsProtractor* protractor = new UBGraphicsProtractor(); - protractor->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetProtractor); +// protractor->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetProtractor); + UBGraphicsItem::assignZValue(protractor, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetProtractor); protractor->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); graphicsItemFromSvg(protractor); @@ -2676,7 +2686,8 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg() { UBGraphicsTriangle* triangle = new UBGraphicsTriangle(); - triangle->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetTriangle); +// triangle->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetTriangle); + UBGraphicsItem::assignZValue(triangle, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetTriangle); triangle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); graphicsItemFromSvg(triangle); @@ -2695,7 +2706,6 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg() triangle->setRect(svgX.toString().toFloat(), svgY.toString().toFloat(), svgWidth.toString().toFloat(), svgHeight.toString().toFloat(), orientation); } - triangle->setVisible(true); return triangle; } @@ -2703,7 +2713,8 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg() UBGraphicsCache* UBSvgSubsetAdaptor::UBSvgSubsetReader::cacheFromSvg() { UBGraphicsCache* pCache = new UBGraphicsCache(); - //pCache->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCache); + pCache->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCache); +// UBGraphicsItem::assignZValue(pCache, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCache); pCache->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); graphicsItemFromSvg(pCache); diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 829c07ef..5c63fec8 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -1842,7 +1842,8 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint if (gi) { - gi->setZValue(mActiveScene->getNextObjectZIndex()); +// gi->setZValue(mActiveScene->getNextObjectZIndex()); + UBGraphicsItem::assignZValue(gi, mActiveScene->getNextObjectZIndex()); mActiveScene->addItem(gi); gi->setPos(gi->pos() + QPointF(50, 50)); } diff --git a/src/core/UB.h b/src/core/UB.h index fbe7dd77..83a4b456 100644 --- a/src/core/UB.h +++ b/src/core/UB.h @@ -78,6 +78,7 @@ struct UBGraphicsItemData ItemLayerType , ItemLocked , ItemEditable//for text only + , ItemOwnZValue }; }; diff --git a/src/domain/UBGraphicsAudioItem.cpp b/src/domain/UBGraphicsAudioItem.cpp index 12a2eae6..d38e27b7 100644 --- a/src/domain/UBGraphicsAudioItem.cpp +++ b/src/domain/UBGraphicsAudioItem.cpp @@ -95,7 +95,8 @@ UBItem* UBGraphicsAudioItem::deepCopy() const UBGraphicsAudioItem *copy = new UBGraphicsAudioItem(audioUrl, parentItem()); copy->setPos(this->pos()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, true); diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index 7cc8fa96..de335a3a 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -72,7 +72,8 @@ void UBGraphicsItemDelegate::init() { mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio); mFrame->hide(); - mFrame->setZValue(UBGraphicsScene::toolLayerStart + 1); +// mFrame->setZValue(UBGraphicsScene::toolLayerStart + 1); + UBGraphicsItem::assignZValue(mFrame, UBGraphicsScene::toolLayerStart + 1); mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true); mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame); @@ -92,7 +93,8 @@ void UBGraphicsItemDelegate::init() foreach(DelegateButton* button, mButtons) { button->hide(); - button->setZValue(UBGraphicsScene::toolLayerStart + 2); +// button->setZValue(UBGraphicsScene::toolLayerStart + 2); + UBGraphicsItem::assignZValue(button, UBGraphicsScene::toolLayerStart + 2); button->setFlag(QGraphicsItem::ItemIsSelectable, true); } } diff --git a/src/domain/UBGraphicsItemTransformUndoCommand.cpp b/src/domain/UBGraphicsItemTransformUndoCommand.cpp index 0d799f0a..e56027ea 100644 --- a/src/domain/UBGraphicsItemTransformUndoCommand.cpp +++ b/src/domain/UBGraphicsItemTransformUndoCommand.cpp @@ -15,6 +15,7 @@ #include "UBGraphicsItemTransformUndoCommand.h" #include "UBResizableGraphicsItem.h" +#include "domain/UBItem.h" #include "core/memcheck.h" @@ -48,7 +49,8 @@ void UBGraphicsItemTransformUndoCommand::undo() { mItem->setPos(mPreviousPosition); mItem->setTransform(mPreviousTransform); - mItem->setZValue(mPreviousZValue); +// mItem->setZValue(mPreviousZValue); + UBGraphicsItem::assignZValue(mItem, mPreviousZValue); UBResizableGraphicsItem* resizableItem = dynamic_cast(mItem); @@ -60,7 +62,8 @@ void UBGraphicsItemTransformUndoCommand::redo() { mItem->setPos(mCurrentPosition); mItem->setTransform(mCurrentTransform); - mItem->setZValue(mCurrentZValue); +// mItem->setZValue(mCurrentZValue); + UBGraphicsItem::assignZValue(mItem, mCurrentZValue); UBResizableGraphicsItem* resizableItem = dynamic_cast(mItem); diff --git a/src/domain/UBGraphicsPDFItem.cpp b/src/domain/UBGraphicsPDFItem.cpp index 7838358f..704ba676 100644 --- a/src/domain/UBGraphicsPDFItem.cpp +++ b/src/domain/UBGraphicsPDFItem.cpp @@ -84,7 +84,8 @@ UBItem* UBGraphicsPDFItem::deepCopy() const UBGraphicsPDFItem *copy = new UBGraphicsPDFItem(mRenderer, mPageNumber, parentItem()); copy->setPos(this->pos()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, true); @@ -134,7 +135,8 @@ UBGraphicsPixmapItem* UBGraphicsPDFItem::toPixmapItem() const pixmapItem->setPixmap(pixmap); pixmapItem->setPos(this->pos()); - pixmapItem->setZValue(this->zValue()); +// pixmapItem->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(pixmapItem, this->zValue()); pixmapItem->setTransform(this->transform()); pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true); pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true); diff --git a/src/domain/UBGraphicsPixmapItem.cpp b/src/domain/UBGraphicsPixmapItem.cpp index edffb90d..ceb4fd28 100644 --- a/src/domain/UBGraphicsPixmapItem.cpp +++ b/src/domain/UBGraphicsPixmapItem.cpp @@ -98,7 +98,8 @@ UBItem* UBGraphicsPixmapItem::deepCopy() const copy->setPixmap(this->pixmap()); copy->setPos(this->pos()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, true); diff --git a/src/domain/UBGraphicsPolygonItem.cpp b/src/domain/UBGraphicsPolygonItem.cpp index c8153ca4..d2e96e25 100644 --- a/src/domain/UBGraphicsPolygonItem.cpp +++ b/src/domain/UBGraphicsPolygonItem.cpp @@ -153,7 +153,9 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con copy->setPen(this->pen()); copy->mHasAlpha = this->mHasAlpha; - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); + copy->setColorOnDarkBackground(this->colorOnDarkBackground()); copy->setColorOnLightBackground(this->colorOnLightBackground()); diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 476dd289..d4a7f8d8 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -75,6 +75,8 @@ qreal UBGraphicsScene::toolOffsetEraser = 200; qreal UBGraphicsScene::toolOffsetCurtain = 1000; qreal UBGraphicsScene::toolOffsetPointer = 1100; +qreal UBGraphicsScene::toolOffsetCache = 1000;//Didier please define offset you want + UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) : UBCoreGraphicsScene(parent) , mEraser(0) @@ -824,8 +826,8 @@ void UBGraphicsScene::initPolygonItem(UBGraphicsPolygonItem* polygonItem) polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); - polygonItem->setZValue(getNextDrawingZIndex()); - +// polygonItem->setZValue(getNextDrawingZIndex()); + UBGraphicsItem::assignZValue(polygonItem, getNextDrawingZIndex()); } @@ -1035,7 +1037,8 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const Q pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true); pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true); - pixmapItem->setZValue(getNextObjectZIndex()); +// pixmapItem->setZValue(getNextObjectZIndex()); + UBGraphicsItem::assignZValue(pixmapItem, getNextObjectZIndex()); pixmapItem->setPixmap(pPixmap); @@ -1083,7 +1086,8 @@ UBGraphicsVideoItem* UBGraphicsScene::addVideo(const QUrl& pVideoFileUrl, bool s videoItem->setFlag(QGraphicsItem::ItemIsMovable, true); videoItem->setFlag(QGraphicsItem::ItemIsSelectable, true); - videoItem->setZValue(getNextObjectZIndex()); +// videoItem->setZValue(getNextObjectZIndex()); + UBGraphicsItem::assignZValue(videoItem, getNextObjectZIndex()); addItem(videoItem); @@ -1113,7 +1117,8 @@ UBGraphicsAudioItem* UBGraphicsScene::addAudio(const QUrl& pAudioFileUrl, bool s audioItem->setFlag(QGraphicsItem::ItemIsMovable, true); audioItem->setFlag(QGraphicsItem::ItemIsSelectable, true); - audioItem->setZValue(getNextObjectZIndex()); +// audioItem->setZValue(getNextObjectZIndex()); + UBGraphicsItem::assignZValue(audioItem, getNextObjectZIndex()); addItem(audioItem); @@ -1178,7 +1183,8 @@ UBGraphicsW3CWidgetItem* UBGraphicsScene::addW3CWidget(const QUrl& pWidgetUrl, c void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, const QPointF& pPos) { graphicsWidget->setFlag(QGraphicsItem::ItemIsSelectable, true); - graphicsWidget->setZValue(getNextObjectZIndex()); +// graphicsWidget->setZValue(getNextObjectZIndex()); + UBGraphicsItem::assignZValue(graphicsWidget, getNextObjectZIndex()); addItem(graphicsWidget); @@ -1238,7 +1244,8 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint svgItem->setFlag(QGraphicsItem::ItemIsMovable, true); svgItem->setFlag(QGraphicsItem::ItemIsSelectable, true); - svgItem->setZValue(getNextObjectZIndex()); +// svgItem->setZValue(getNextObjectZIndex()); + UBGraphicsItem::assignZValue(svgItem, getNextObjectZIndex()); qreal sscale = 1 / UBApplication::boardController->systemScaleFactor(); svgItem->scale(sscale, sscale); @@ -1271,7 +1278,8 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con { UBGraphicsTextItem *textItem = new UBGraphicsTextItem(); textItem->setPlainText(pString); - textItem->setZValue(getNextObjectZIndex()); +// textItem->setZValue(getNextObjectZIndex()); + UBGraphicsItem::assignZValue(textItem, getNextObjectZIndex()); QFont font = textItem->font(); @@ -1326,7 +1334,8 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q UBGraphicsTextItem *textItem = new UBGraphicsTextItem(); textItem->setPlainText(""); textItem->setHtml(pString); - textItem->setZValue(getNextObjectZIndex()); +// textItem->setZValue(getNextObjectZIndex()); + UBGraphicsItem::assignZValue(textItem, getNextObjectZIndex()); addItem(textItem); textItem->show(); @@ -1337,7 +1346,6 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q connect(textItem, SIGNAL(textUndoCommandAdded(UBGraphicsTextItem *)), this, SLOT(textUndoCommandAdded(UBGraphicsTextItem *))); -// textItem->setSelected(true); textItem->setFocus(); setDocumentUpdated(); @@ -1425,7 +1433,8 @@ QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool item->setAcceptedMouseButtons(Qt::NoButton); item->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::FixedBackground); - item->setZValue(backgroundLayerStart); +// item->setZValue(backgroundLayerStart); + UBGraphicsItem::assignZValue(item, backgroundLayerStart); if (pAdaptTransformation) { @@ -1529,7 +1538,9 @@ void UBGraphicsScene::addRuler(QPointF center) QRectF rect = ruler->rect(); ruler->setRect(center.x() - rect.width()/2, center.y() - rect.height()/2, rect.width(), rect.height()); - ruler->setZValue(toolLayerStart + toolOffsetRuler); +// ruler->setZValue(toolLayerStart + toolOffsetRuler); + UBGraphicsItem::assignZValue(ruler, toolLayerStart + toolOffsetRuler); + ruler->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); addItem(ruler); @@ -1546,7 +1557,9 @@ void UBGraphicsScene::addProtractor(QPointF center) UBGraphicsProtractor* protractor = new UBGraphicsProtractor(); // mem : owned and destroyed by the scene mTools << protractor; - protractor->setZValue(toolLayerStart + toolOffsetProtractor); +// protractor->setZValue(toolLayerStart + toolOffsetProtractor); + UBGraphicsItem::assignZValue(protractor, toolLayerStart + toolOffsetProtractor); + protractor->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); addItem(protractor); @@ -1565,7 +1578,9 @@ void UBGraphicsScene::addTriangle(QPointF center) UBGraphicsTriangle* triangle = new UBGraphicsTriangle(); // mem : owned and destroyed by the scene mTools << triangle; - triangle->setZValue(toolLayerStart + toolOffsetProtractor); +// triangle->setZValue(toolLayerStart + toolOffsetProtractor); + UBGraphicsItem::assignZValue(triangle, toolLayerStart + toolOffsetTriangle); + triangle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); addItem(triangle); @@ -1700,7 +1715,9 @@ void UBGraphicsScene::addCompass(QPointF center) QRectF rect = compass->rect(); compass->setRect(center.x() - rect.width() / 2, center.y() - rect.height() / 2, rect.width(), rect.height()); - compass->setZValue(toolLayerStart + toolOffsetCompass); +// compass->setZValue(toolLayerStart + toolOffsetCompass); + UBGraphicsItem::assignZValue(compass, toolLayerStart + toolOffsetCompass); + compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); compass->setVisible(true); @@ -1740,7 +1757,10 @@ void UBGraphicsScene::addMask() view = (QGraphicsView*)UBApplication::boardController->controlView(); QPolygonF polygon = view->mapToScene(view->rect()); - curtain->setZValue(toolLayerStart + toolOffsetCurtain); + +// curtain->setZValue(toolLayerStart + toolOffsetCurtain); + UBGraphicsItem::assignZValue(curtain, toolLayerStart + toolOffsetCurtain); + QRectF rect = polygon.boundingRect(); qreal xScale = view->matrix().m11(); qreal yScale = view->matrix().m22(); diff --git a/src/domain/UBGraphicsSvgItem.cpp b/src/domain/UBGraphicsSvgItem.cpp index cfd3509a..9d8798ec 100644 --- a/src/domain/UBGraphicsSvgItem.cpp +++ b/src/domain/UBGraphicsSvgItem.cpp @@ -132,7 +132,8 @@ UBItem* UBGraphicsSvgItem::deepCopy() const UBGraphicsSvgItem* copy = new UBGraphicsSvgItem(this->fileData()); copy->setPos(this->pos()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, true); @@ -186,7 +187,8 @@ UBGraphicsPixmapItem* UBGraphicsSvgItem::toPixmapItem() const pixmapItem->setPixmap(QPixmap::fromImage(image)); pixmapItem->setPos(this->pos()); - pixmapItem->setZValue(this->zValue()); +// pixmapItem->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(pixmapItem, this->zValue()); pixmapItem->setTransform(this->transform()); pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true); pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true); diff --git a/src/domain/UBGraphicsTextItem.cpp b/src/domain/UBGraphicsTextItem.cpp index 8770a435..0d01527a 100644 --- a/src/domain/UBGraphicsTextItem.cpp +++ b/src/domain/UBGraphicsTextItem.cpp @@ -205,7 +205,8 @@ UBItem* UBGraphicsTextItem::deepCopy() const copy->setHtml(toHtml()); copy->setPos(this->pos()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, true); diff --git a/src/domain/UBGraphicsVideoItem.cpp b/src/domain/UBGraphicsVideoItem.cpp index 841667cf..c1e57e4d 100644 --- a/src/domain/UBGraphicsVideoItem.cpp +++ b/src/domain/UBGraphicsVideoItem.cpp @@ -68,7 +68,8 @@ UBItem* UBGraphicsVideoItem::deepCopy() const UBGraphicsVideoItem *copy = new UBGraphicsVideoItem(videoUrl, parentItem()); copy->setPos(this->pos()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, true); diff --git a/src/domain/UBGraphicsVideoItemDelegate.cpp b/src/domain/UBGraphicsVideoItemDelegate.cpp index 429194b0..99ba687b 100644 --- a/src/domain/UBGraphicsVideoItemDelegate.cpp +++ b/src/domain/UBGraphicsVideoItemDelegate.cpp @@ -52,7 +52,8 @@ void UBGraphicsVideoItemDelegate::buildButtons() mMuteButton->hide(); mVideoControl = new DelegateVideoControl(delegated(), mFrame); - mVideoControl->setZValue(UBGraphicsScene::toolLayerStart + 2); +// mVideoControl->setZValue(UBGraphicsScene::toolLayerStart + 2); + UBGraphicsItem::assignZValue(mVideoControl, UBGraphicsScene::toolLayerStart + 2); mVideoControl->setFlag(QGraphicsItem::ItemIsSelectable, true); connect(mPlayPauseButton, SIGNAL(clicked(bool)), this, SLOT(togglePlayPause())); diff --git a/src/domain/UBGraphicsWidgetItem.cpp b/src/domain/UBGraphicsWidgetItem.cpp index b1246f2a..a786e55a 100644 --- a/src/domain/UBGraphicsWidgetItem.cpp +++ b/src/domain/UBGraphicsWidgetItem.cpp @@ -366,7 +366,8 @@ UBItem* UBGraphicsW3CWidgetItem::deepCopy() const UBGraphicsW3CWidgetItem *copy = new UBGraphicsW3CWidgetItem(mWebKitWidget->widgetUrl(), parentItem()); copy->setPos(this->pos()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, true); diff --git a/src/domain/UBItem.cpp b/src/domain/UBItem.cpp index 4a3e1643..3e6f68cf 100644 --- a/src/domain/UBItem.cpp +++ b/src/domain/UBItem.cpp @@ -28,3 +28,9 @@ UBItem::~UBItem() { // NOOP } + +void UBGraphicsItem::assignZValue(QGraphicsItem *item, int value) +{ + item->setZValue(value); + item->setData(UBGraphicsItemData::ItemOwnZValue, value); +} diff --git a/src/domain/UBItem.h b/src/domain/UBItem.h index 328a3c37..7ae29988 100644 --- a/src/domain/UBItem.h +++ b/src/domain/UBItem.h @@ -100,6 +100,7 @@ protected: public: + static void assignZValue(QGraphicsItem*, int value); virtual UBGraphicsItemDelegate *Delegate() const = 0; virtual void remove() = 0; diff --git a/src/gui/UBLibraryWidget.cpp b/src/gui/UBLibraryWidget.cpp index 22c27adc..963bd4e2 100644 --- a/src/gui/UBLibraryWidget.cpp +++ b/src/gui/UBLibraryWidget.cpp @@ -39,9 +39,9 @@ */ UBLibraryWidget::UBLibraryWidget(QWidget *parent, const char *name):UBThumbnailWidget(parent) , chainedElements(NULL) + , mLibraryController(NULL) , mpCrntDir(NULL) , mpCrntElem(NULL) - , mLibraryController(NULL) , mpTmpElem(NULL) { setObjectName(name); diff --git a/src/gui/UBThumbnailWidget.h b/src/gui/UBThumbnailWidget.h index c4fa103f..5f0543f8 100644 --- a/src/gui/UBThumbnailWidget.h +++ b/src/gui/UBThumbnailWidget.h @@ -23,6 +23,7 @@ #include "frameworks/UBCoreGraphicsScene.h" #include "core/UBSettings.h" +#include "domain/UBItem.h" #define STARTDRAGTIME 1000000 #define BUTTONSIZE 48 @@ -147,7 +148,8 @@ class UBThumbnail if (!mSelectionItem->scene()) { item->scene()->addItem(mSelectionItem); - mSelectionItem->setZValue(item->zValue() - 1); +// mSelectionItem->setZValue(item->zValue() - 1); + UBGraphicsItem::assignZValue(mSelectionItem, item->zValue() - 1); mAddedToScene = true; } diff --git a/src/pdf-merger/Object.h b/src/pdf-merger/Object.h index d2bc75ba..982d3734 100644 --- a/src/pdf-merger/Object.h +++ b/src/pdf-merger/Object.h @@ -48,7 +48,7 @@ namespace merge_lib std::string fileName = "", std::pair streamBounds = std::make_pair ((unsigned int)0,(unsigned int)0), bool hasStream = false ): _number(objectNumber), _generationNumber(generationNumber), _oldNumber(objectNumber), _content(objectContent),_parents(),_children(),_isPassed(false), - _fileName(fileName), _streamBounds(streamBounds), _hasStream(hasStream), _hasStreamInContent(false) + _streamBounds(streamBounds), _fileName(fileName), _hasStream(hasStream), _hasStreamInContent(false) { } virtual ~Object(); diff --git a/src/tools/UBGraphicsCache.cpp b/src/tools/UBGraphicsCache.cpp index 231399c3..a7e97895 100644 --- a/src/tools/UBGraphicsCache.cpp +++ b/src/tools/UBGraphicsCache.cpp @@ -33,7 +33,8 @@ UBGraphicsCache::UBGraphicsCache():QGraphicsRectItem() // Get the board size and pass it to the shape QRect boardRect = UBApplication::boardController->displayView()->rect(); setRect(-15*boardRect.width(), -15*boardRect.height(), 30*boardRect.width(), 30*boardRect.height()); - setZValue(CACHE_ZVALUE); +// setZValue(CACHE_ZVALUE); + UBGraphicsItem::assignZValue(this, CACHE_ZVALUE); setData(Qt::UserRole, QVariant("Cache")); } @@ -48,7 +49,8 @@ UBItem* UBGraphicsCache::deepCopy() const copy->setPos(this->pos()); copy->setRect(this->rect()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); // TODO UB 4.7 ... complete all members ? @@ -90,7 +92,8 @@ void UBGraphicsCache::paint(QPainter *painter, const QStyleOptionGraphicsItem *o //Q_UNUSED(option); Q_UNUSED(widget); - setZValue(CACHE_ZVALUE); +// setZValue(CACHE_ZVALUE); + UBGraphicsItem::assignZValue(this, CACHE_ZVALUE); painter->setBrush(mMaskColor); painter->setPen(mMaskColor); diff --git a/src/tools/UBGraphicsCompass.cpp b/src/tools/UBGraphicsCompass.cpp index d0374c11..6e13b125 100644 --- a/src/tools/UBGraphicsCompass.cpp +++ b/src/tools/UBGraphicsCompass.cpp @@ -85,7 +85,8 @@ UBItem* UBGraphicsCompass::deepCopy() const copy->setPos(this->pos()); copy->setRect(this->rect()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); // TODO UB 4.7 ... complete all members ? diff --git a/src/tools/UBGraphicsCurtainItem.cpp b/src/tools/UBGraphicsCurtainItem.cpp index 118b92f2..3dfb21b6 100644 --- a/src/tools/UBGraphicsCurtainItem.cpp +++ b/src/tools/UBGraphicsCurtainItem.cpp @@ -57,8 +57,8 @@ UBGraphicsCurtainItem::~UBGraphicsCurtainItem() QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVariant &value) { - if (change == QGraphicsItem::ItemSelectedHasChanged && QGraphicsRectItem::scene() && isSelected()) - setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCurtain); +// if (change == QGraphicsItem::ItemSelectedHasChanged && QGraphicsRectItem::scene() && isSelected()) +// setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCurtain); QVariant newValue = value; @@ -130,7 +130,8 @@ UBItem* UBGraphicsCurtainItem::deepCopy() const copy->setPos(this->pos()); copy->setBrush(this->brush()); copy->setPen(this->pen()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, true); diff --git a/src/tools/UBGraphicsCurtainItemDelegate.cpp b/src/tools/UBGraphicsCurtainItemDelegate.cpp index 31eb0da7..a16685b6 100644 --- a/src/tools/UBGraphicsCurtainItemDelegate.cpp +++ b/src/tools/UBGraphicsCurtainItemDelegate.cpp @@ -52,7 +52,7 @@ bool UBGraphicsCurtainItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *ev if (!mDelegated->isSelected()) { mDelegated->setSelected(true); - mDelegated->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCurtain); +// mDelegated->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCurtain); positionHandles(); return true; @@ -69,13 +69,13 @@ QVariant UBGraphicsCurtainItemDelegate::itemChange(QGraphicsItem::GraphicsItemCh { if (change == QGraphicsItem::ItemZValueHasChanged) { - mFrame->setZValue(mDelegated->zValue() + 1); +// mFrame->setZValue(mDelegated->zValue() + 1); - foreach(DelegateButton* button, mButtons) - { - button->setZValue(mDelegated->zValue() + 2); - button->setZValue(mDelegated->zValue() + 2); - } +// foreach(DelegateButton* button, mButtons) +// { +// button->setZValue(mDelegated->zValue() + 2); +// button->setZValue(mDelegated->zValue() + 2); +// } } if (change == QGraphicsItem::ItemVisibleHasChanged) diff --git a/src/tools/UBGraphicsProtractor.cpp b/src/tools/UBGraphicsProtractor.cpp index 43a84af1..bafb5689 100644 --- a/src/tools/UBGraphicsProtractor.cpp +++ b/src/tools/UBGraphicsProtractor.cpp @@ -580,7 +580,8 @@ UBItem* UBGraphicsProtractor::deepCopy() const copy->setPos(this->pos()); copy->setRect(this->rect()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); copy->mCurrentAngle = this->mCurrentAngle; diff --git a/src/tools/UBGraphicsRuler.cpp b/src/tools/UBGraphicsRuler.cpp index cd15de78..2bf27719 100644 --- a/src/tools/UBGraphicsRuler.cpp +++ b/src/tools/UBGraphicsRuler.cpp @@ -74,7 +74,8 @@ UBItem* UBGraphicsRuler::deepCopy() const copy->setPos(this->pos()); copy->setRect(this->rect()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); // TODO UB 4.7 ... complete all members ? diff --git a/src/tools/UBGraphicsTriangle.cpp b/src/tools/UBGraphicsTriangle.cpp index f6459f97..e5c7fdeb 100644 --- a/src/tools/UBGraphicsTriangle.cpp +++ b/src/tools/UBGraphicsTriangle.cpp @@ -93,7 +93,8 @@ UBItem* UBGraphicsTriangle::deepCopy(void) const copy->setPos(this->pos()); copy->setPolygon(this->polygon()); - copy->setZValue(this->zValue()); +// copy->setZValue(this->zValue()); + UBGraphicsItem::assignZValue(copy, this->zValue()); copy->setTransform(this->transform()); // TODO UB 4.7 ... complete all members ?