diff --git a/src/api/api.pri b/src/api/api.pri index f4de505e..3916901e 100644 --- a/src/api/api.pri +++ b/src/api/api.pri @@ -8,7 +8,4 @@ SOURCES += src/api/UBWidgetUniboardAPI.cpp \ src/api/UBLibraryAPI.cpp \ src/api/UBW3CWidgetAPI.cpp \ src/api/UBWidgetMessageAPI.cpp - - - diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 9bddf89e..c383588a 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -46,6 +46,9 @@ #include "domain/UBGraphicsPDFItem.h" #include "domain/UBGraphicsPolygonItem.h" #include "domain/UBItem.h" +#include "domain/UBGraphicsVideoItem.h" +#include "domain/UBGraphicsAudioItem.h" +#include "domain/UBGraphicsSvgItem.h" #include "document/UBDocumentProxy.h" @@ -517,6 +520,8 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) } } +QSet mJustSelectedItems; + void UBBoardView::mouseMoveEvent (QMouseEvent *event) { @@ -538,14 +543,39 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event) event->accept (); } else if (currentTool == UBStylusTool::Selector) - { - if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()) { - return; - } + { + if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()) { + return; + } - if (mUBRubberBand && mUBRubberBand->isVisible()) { - mUBRubberBand->setGeometry(QRect(mMouseDownPos, event->pos()).normalized()); - } + if (mUBRubberBand && mUBRubberBand->isVisible()) { + QRect bandRect(mMouseDownPos, event->pos()); + bandRect = bandRect.normalized(); + + mUBRubberBand->setGeometry(bandRect); + + QList rubberItems = items(bandRect); + foreach (QGraphicsItem *item, mJustSelectedItems) { + if (!rubberItems.contains(item)) { + item->setSelected(false); + mJustSelectedItems.remove(item); + } + } + foreach (QGraphicsItem *item, items(bandRect)) { + + if (item->type() == UBGraphicsW3CWidgetItem::Type + || item->type() == UBGraphicsPixmapItem::Type + || item->type() == UBGraphicsVideoItem::Type + || item->type() == UBGraphicsAudioItem::Type + || item->type() == UBGraphicsSvgItem::Type) { + + if (!mJustSelectedItems.contains(item)) { + item->setSelected(true); + mJustSelectedItems.insert(item); + } + } + } + } if (movingItem && (mMouseButtonIsPressed || mTabletStylusIsPressed)) { diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index 0c642de4..311ff93f 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -138,6 +138,21 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate() QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { + if (change == QGraphicsItem::ItemSelectedHasChanged) { + bool ok; + bool selected = value.toUInt(&ok); + if (ok) { + UBGraphicsScene *ubScene = castUBGraphicsScene(); + if (ubScene) { + if (selected) { + ubScene->setSelectedZLevel(delegated()); + } else { + ubScene->setOwnZlevel(delegated()); + } + } + } + } + if ((change == QGraphicsItem::ItemSelectedHasChanged || change == QGraphicsItem::ItemPositionHasChanged || change == QGraphicsItem::ItemTransformHasChanged) @@ -145,19 +160,6 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch { mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom()); - if (mDelegated->isSelected()) - { - QList items = mDelegated->scene()->selectedItems(); - - foreach(QGraphicsItem* item, items) - { - if (item != mDelegated) - { - item->setSelected(false); - } - } - } - positionHandles(); } @@ -247,6 +249,17 @@ bool UBGraphicsItemDelegate::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { Q_UNUSED(event); + //Deselect all the rest selected items if no ctrl key modifier + if (delegated()->scene() + && delegated()->scene()->selectedItems().count() + && event->modifiers() != Qt::ControlModifier) { + foreach (QGraphicsItem *item, delegated()->scene()->selectedItems()) { + if (item != delegated()) { + item->setSelected(false); + } + } + } + commitUndoStep(); return true; diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 1fbb2340..9cdbb279 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -306,17 +306,6 @@ void UBGraphicsScene::selectionChangedProcessing() if (selectedItems().count()) UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f') + "own z value is " + QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f')); - - QList allItemsList = items(); - for( int i = 0; i < allItemsList.size(); i++ ) { - QGraphicsItem *nextItem = allItemsList.at(i); - - if (nextItem->isSelected()) { - nextItem->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem)); - } else { - nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); - } - } } // MARK: - @@ -492,8 +481,6 @@ bool UBGraphicsScene::inputDeviceRelease() bool accepted = false; - - if (mPointer) { mPointer->hide(); @@ -1921,17 +1908,13 @@ void UBGraphicsScene::setNominalSize(int pWidth, int pHeight) setNominalSize(QSize(pWidth, pHeight)); } -void UBGraphicsScene::setSelectedZLevel(QList itemList) -{ - foreach (QGraphicsItem *item, itemList) { - item->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem)); - } +void UBGraphicsScene::setSelectedZLevel(QGraphicsItem * item) +{ + item->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem)); } -void UBGraphicsScene::setOwnZlevel(QList itemList) +void UBGraphicsScene::setOwnZlevel(QGraphicsItem *item) { - foreach (QGraphicsItem *item, itemList) { - item->setZValue(item->data(UBGraphicsItemData::ItemOwnZValue).toReal()); - } + item->setZValue(item->data(UBGraphicsItemData::ItemOwnZValue).toReal()); } qreal UBGraphicsScene::changeZLevelTo(QGraphicsItem *item, UBZLayerController::moveDestination dest) diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h index 829a3bb8..96794931 100644 --- a/src/domain/UBGraphicsScene.h +++ b/src/domain/UBGraphicsScene.h @@ -285,8 +285,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem return mPreviousPoint; } - void setSelectedZLevel(QList itemList); - void setOwnZlevel(QList itemList); + void setSelectedZLevel(QGraphicsItem *item); + void setOwnZlevel(QGraphicsItem *item); public slots: void hideEraser(); diff --git a/src/gui/UBRubberBand.cpp b/src/gui/UBRubberBand.cpp index 6417104e..04fcd26c 100644 --- a/src/gui/UBRubberBand.cpp +++ b/src/gui/UBRubberBand.cpp @@ -35,7 +35,7 @@ UBRubberBand::UBRubberBand(Shape s, QWidget * p) #elif defined(Q_WS_MAC) customStyle = new QMacStyle(); #elif defined(Q_WS_X11) - customStyle = QStyleFactory::create("oxygen"); +// customStyle = QStyleFactory::create("oxygen"); #endif if (customStyle)