diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 3a186c71..fbfdab92 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -2255,13 +2255,22 @@ void UBBoardController::copy() void UBBoardController::paste() { QClipboard *clipboard = QApplication::clipboard(); - QPointF pos(0, 0); + qreal xPosition = ((qreal)qrand()/(qreal)RAND_MAX) * 400; + qreal yPosition = ((qreal)qrand()/(qreal)RAND_MAX) * 200; + QPointF pos(xPosition -200 , yPosition - 100); processMimeData(clipboard->mimeData(), pos); selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); } +bool zLevelLessThan( UBItem* s1, UBItem* s2) +{ + qreal s1Zvalue = dynamic_cast(s1)->data(UBGraphicsItemData::ItemOwnZValue).toReal(); + qreal s2Zvalue = dynamic_cast(s2)->data(UBGraphicsItemData::ItemOwnZValue).toReal(); + return s1Zvalue < s2Zvalue; +} + void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPointF& pPos) { if (pMimeData->hasFormat(UBApplication::mimeTypeUniboardPage)) @@ -2291,7 +2300,9 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint if (mimeData) { - foreach(UBItem* item, mimeData->items()) + QList items = mimeData->items(); + qStableSort(items.begin(),items.end(),zLevelLessThan); + foreach(UBItem* item, items) { QGraphicsItem* pItem = dynamic_cast(item); if(NULL != pItem){ diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index 2eb5bf02..9c45ce27 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -782,11 +782,13 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated) button->setParentItem(mFrame); button->setPos(topX + (i++ * 1.6 * mFrameWidth * mAntiScaleRatio), topY); button->setTransform(tr); - } else if (button->getSection() == Qt::BottomLeftSection) { + } + else if (button->getSection() == Qt::BottomLeftSection) { button->setParentItem(mFrame); button->setPos(bottomX + (++j * 1.6 * mFrameWidth * mAntiScaleRatio), bottomY); button->setTransform(tr); - } else if (button->getSection() == Qt::TitleBarArea){ + } + else if (button->getSection() == Qt::TitleBarArea){ button->setParentItem(mFrame); button->setPos(topXTitleBar + (k++ * (frameButtonHeight + 5)), topYTitleBar); button->setTransform(tr);