copy/paste action the zlevel order is respected

preferencesAboutTextFull
-f 11 years ago
parent 6e66f94c06
commit 6311ca2b46
  1. 15
      src/board/UBBoardController.cpp
  2. 6
      src/domain/UBGraphicsItemDelegate.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<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);

Loading…
Cancel
Save