multiple selection

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent 0a1799a514
commit d44cc5b68f
  1. 3
      src/api/api.pri
  2. 44
      src/board/UBBoardView.cpp
  3. 39
      src/domain/UBGraphicsItemDelegate.cpp
  4. 27
      src/domain/UBGraphicsScene.cpp
  5. 4
      src/domain/UBGraphicsScene.h
  6. 2
      src/gui/UBRubberBand.cpp

@ -8,7 +8,4 @@ SOURCES += src/api/UBWidgetUniboardAPI.cpp \
src/api/UBLibraryAPI.cpp \ src/api/UBLibraryAPI.cpp \
src/api/UBW3CWidgetAPI.cpp \ src/api/UBW3CWidgetAPI.cpp \
src/api/UBWidgetMessageAPI.cpp src/api/UBWidgetMessageAPI.cpp

@ -46,6 +46,9 @@
#include "domain/UBGraphicsPDFItem.h" #include "domain/UBGraphicsPDFItem.h"
#include "domain/UBGraphicsPolygonItem.h" #include "domain/UBGraphicsPolygonItem.h"
#include "domain/UBItem.h" #include "domain/UBItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsSvgItem.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
@ -517,6 +520,8 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
} }
} }
QSet<QGraphicsItem*> mJustSelectedItems;
void void
UBBoardView::mouseMoveEvent (QMouseEvent *event) UBBoardView::mouseMoveEvent (QMouseEvent *event)
{ {
@ -538,14 +543,39 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
event->accept (); event->accept ();
} }
else if (currentTool == UBStylusTool::Selector) else if (currentTool == UBStylusTool::Selector)
{ {
if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()) { if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()) {
return; return;
} }
if (mUBRubberBand && mUBRubberBand->isVisible()) { if (mUBRubberBand && mUBRubberBand->isVisible()) {
mUBRubberBand->setGeometry(QRect(mMouseDownPos, event->pos()).normalized()); QRect bandRect(mMouseDownPos, event->pos());
} bandRect = bandRect.normalized();
mUBRubberBand->setGeometry(bandRect);
QList<QGraphicsItem *> 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)) if (movingItem && (mMouseButtonIsPressed || mTabletStylusIsPressed))
{ {

@ -138,6 +138,21 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) 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 if ((change == QGraphicsItem::ItemSelectedHasChanged
|| change == QGraphicsItem::ItemPositionHasChanged || change == QGraphicsItem::ItemPositionHasChanged
|| change == QGraphicsItem::ItemTransformHasChanged) || change == QGraphicsItem::ItemTransformHasChanged)
@ -145,19 +160,6 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
{ {
mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom()); mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
if (mDelegated->isSelected())
{
QList<QGraphicsItem*> items = mDelegated->scene()->selectedItems();
foreach(QGraphicsItem* item, items)
{
if (item != mDelegated)
{
item->setSelected(false);
}
}
}
positionHandles(); positionHandles();
} }
@ -247,6 +249,17 @@ bool UBGraphicsItemDelegate::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
Q_UNUSED(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(); commitUndoStep();
return true; return true;

@ -306,17 +306,6 @@ void UBGraphicsScene::selectionChangedProcessing()
if (selectedItems().count()) if (selectedItems().count())
UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f') + "own z value is " UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f') + "own z value is "
+ QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f')); + QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f'));
QList<QGraphicsItem *> 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: - // MARK: -
@ -492,8 +481,6 @@ bool UBGraphicsScene::inputDeviceRelease()
bool accepted = false; bool accepted = false;
if (mPointer) if (mPointer)
{ {
mPointer->hide(); mPointer->hide();
@ -1921,17 +1908,13 @@ void UBGraphicsScene::setNominalSize(int pWidth, int pHeight)
setNominalSize(QSize(pWidth, pHeight)); setNominalSize(QSize(pWidth, pHeight));
} }
void UBGraphicsScene::setSelectedZLevel(QList<QGraphicsItem *> itemList) void UBGraphicsScene::setSelectedZLevel(QGraphicsItem * item)
{ {
foreach (QGraphicsItem *item, itemList) { item->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem));
item->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem));
}
} }
void UBGraphicsScene::setOwnZlevel(QList<QGraphicsItem *> 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) qreal UBGraphicsScene::changeZLevelTo(QGraphicsItem *item, UBZLayerController::moveDestination dest)

@ -285,8 +285,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
return mPreviousPoint; return mPreviousPoint;
} }
void setSelectedZLevel(QList<QGraphicsItem *> itemList); void setSelectedZLevel(QGraphicsItem *item);
void setOwnZlevel(QList<QGraphicsItem *> itemList); void setOwnZlevel(QGraphicsItem *item);
public slots: public slots:
void hideEraser(); void hideEraser();

@ -35,7 +35,7 @@ UBRubberBand::UBRubberBand(Shape s, QWidget * p)
#elif defined(Q_WS_MAC) #elif defined(Q_WS_MAC)
customStyle = new QMacStyle(); customStyle = new QMacStyle();
#elif defined(Q_WS_X11) #elif defined(Q_WS_X11)
customStyle = QStyleFactory::create("oxygen"); // customStyle = QStyleFactory::create("oxygen");
#endif #endif
if (customStyle) if (customStyle)

Loading…
Cancel
Save