Multiple selection and deselection items implemented.

preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent efc8b7edff
commit 5e7cd52762
  1. 45
      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,16 +990,32 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
{ {
if ( QGraphicsSvgItem::Type != movingItem->type() if ( QGraphicsSvgItem::Type != movingItem->type()
&& UBGraphicsDelegateFrame::Type != movingItem->type()) && UBGraphicsDelegateFrame::Type != movingItem->type())
{
bReleaseIsNeed = false;
if (movingItem->isSelected() && mMultipleSelectionIsEnabled)
movingItem->setSelected(false);
else
{
if (movingItem->isSelected())
bReleaseIsNeed = true;
movingItem->setSelected(true); movingItem->setSelected(true);
} }
}
}
} }
if (mUBRubberBand && mUBRubberBand->isVisible()) { if (mUBRubberBand && mUBRubberBand->isVisible()) {
mUBRubberBand->hide(); mUBRubberBand->hide();
} }
if (bReleaseIsNeed)
{
qDebug() << "mre";
QGraphicsView::mouseReleaseEvent (event); QGraphicsView::mouseReleaseEvent (event);
} }
}
else if (currentTool == UBStylusTool::Play) else if (currentTool == UBStylusTool::Play)
{ {
if (mWidgetMoved) if (mWidgetMoved)

@ -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