Multiple selection and deselection items implemented.

preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent efc8b7edff
commit 5e7cd52762
  1. 49
      src/board/UBBoardView.cpp
  2. 2
      src/board/UBBoardView.h

@ -71,6 +71,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent)
, suspendedMousePressEvent(NULL) , suspendedMousePressEvent(NULL)
, mLongPressInterval(1000) , mLongPressInterval(1000)
, mIsDragInProgress(false) , mIsDragInProgress(false)
, mMultipleSelectionIsEnabled(false)
{ {
init (); init ();
@ -86,6 +87,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int p
, suspendedMousePressEvent(NULL) , suspendedMousePressEvent(NULL)
, mLongPressInterval(1000) , mLongPressInterval(1000)
, mIsDragInProgress(false) , mIsDragInProgress(false)
, mMultipleSelectionIsEnabled(false)
{ {
init (); init ();
@ -206,6 +208,11 @@ UBBoardView::keyPressEvent (QKeyEvent *event)
mController->addScene (); mController->addScene ();
break; break;
} }
case Qt::Key_Control:
case Qt::Key_Shift:
{
mMultipleSelectionIsEnabled = true;
}break;
} }
@ -266,6 +273,21 @@ UBBoardView::keyPressEvent (QKeyEvent *event)
} }
} }
void UBBoardView::keyReleaseEvent(QKeyEvent *event)
{
// if (!event->isAccepted ())
{
if (Qt::Key_Shift == event->key()
||Qt::Key_Control == event->key())
{
mMultipleSelectionIsEnabled = false;
}
}
QGraphicsView::keyReleaseEvent(event);
}
bool bool
UBBoardView::event (QEvent * e) UBBoardView::event (QEvent * e)
{ {
@ -576,7 +598,8 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
if (movingItem && QGraphicsSvgItem::Type != movingItem->type() if (movingItem && QGraphicsSvgItem::Type != movingItem->type()
&& UBGraphicsDelegateFrame::Type != movingItem->type()) && UBGraphicsDelegateFrame::Type != movingItem->type()
&& !mMultipleSelectionIsEnabled)
{ {
foreach(QGraphicsItem *item, scene()->selectedItems()) foreach(QGraphicsItem *item, scene()->selectedItems())
{ {
@ -587,6 +610,9 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
} }
} }
if (mMultipleSelectionIsEnabled)
return;
if (itemShouldReceiveMousePressEvent(movingItem)) if (itemShouldReceiveMousePressEvent(movingItem))
QGraphicsView::mousePressEvent (event); QGraphicsView::mousePressEvent (event);
else else
@ -944,6 +970,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
if (currentTool == UBStylusTool::Selector) if (currentTool == UBStylusTool::Selector)
{ {
bool bReleaseIsNeed = true;
if (mWidgetMoved) if (mWidgetMoved)
{ {
mWidgetMoved = false; mWidgetMoved = false;
@ -963,7 +990,19 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
{ {
if ( QGraphicsSvgItem::Type != movingItem->type() if ( QGraphicsSvgItem::Type != movingItem->type()
&& UBGraphicsDelegateFrame::Type != movingItem->type()) && UBGraphicsDelegateFrame::Type != movingItem->type())
movingItem->setSelected(true); {
bReleaseIsNeed = false;
if (movingItem->isSelected() && mMultipleSelectionIsEnabled)
movingItem->setSelected(false);
else
{
if (movingItem->isSelected())
bReleaseIsNeed = true;
movingItem->setSelected(true);
}
}
} }
} }
@ -971,7 +1010,11 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
mUBRubberBand->hide(); mUBRubberBand->hide();
} }
QGraphicsView::mouseReleaseEvent (event); if (bReleaseIsNeed)
{
qDebug() << "mre";
QGraphicsView::mouseReleaseEvent (event);
}
} }
else if (currentTool == UBStylusTool::Play) else if (currentTool == UBStylusTool::Play)
{ {

@ -65,6 +65,7 @@ class UBBoardView : public QGraphicsView
virtual bool event (QEvent * e); virtual bool event (QEvent * e);
virtual void keyPressEvent(QKeyEvent *event); virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
virtual void tabletEvent(QTabletEvent * event); virtual void tabletEvent(QTabletEvent * event);
virtual void mouseDoubleClickEvent(QMouseEvent *event); virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event);
@ -145,6 +146,7 @@ class UBBoardView : public QGraphicsView
QTimer mLongPressTimer; QTimer mLongPressTimer;
bool mIsDragInProgress; bool mIsDragInProgress;
bool mMultipleSelectionIsEnabled;
private slots: private slots:

Loading…
Cancel
Save