Commit 6311ca2b authored by -f's avatar -f

copy/paste action the zlevel order is respected

parent 6e66f94c
......@@ -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<QGraphicsItem*>(s1)->data(UBGraphicsItemData::ItemOwnZValue).toReal();
qreal s2Zvalue = dynamic_cast<QGraphicsItem*>(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<UBItem*> items = mimeData->items();
qStableSort(items.begin(),items.end(),zLevelLessThan);
foreach(UBItem* item, items)
{
QGraphicsItem* pItem = dynamic_cast<QGraphicsItem*>(item);
if(NULL != pItem){
......
......@@ -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);
......
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