@@ -3158,48 +3158,51 @@ void GraphicsView::mousePressEvent(QMouseEvent *event)
31583158 if (event->button () == Qt::RightButton) {
31593159 return ;
31603160 }
3161- /* Ticket:4379 Select multiple objects with [Shift] key (not with [Control] key)
3162- * To provide multi select we switch the shift key with control.
3163- */
3164- if (event->modifiers () & Qt::ShiftModifier) {
3165- event->setModifiers ((event->modifiers () & ~Qt::ShiftModifier) | Qt::ControlModifier);
3166- }
3167- QGraphicsView::mousePressEvent (event);
31683161 // if user is starting panning.
31693162 if (QApplication::keyboardModifiers () == Qt::ControlModifier) {
31703163 setIsPanning (true );
31713164 mLastMouseEventPos = event->pos ();
3165+ QGraphicsView::mousePressEvent (event);
31723166 return ;
31733167 }
31743168 MainWindow *pMainWindow = MainWindow::instance ();
31753169 QPointF snappedPoint = snapPointToGrid (mapToScene (event->pos ()));
3170+ bool eventConsumed = false ;
31763171 // if left button presses and we are creating a connector
31773172 if (isCreatingConnection ()) {
31783173 if (mpModelWidget->getLibraryTreeItem ()->getLibraryType () == LibraryTreeItem::OMS) {
31793174 mpConnectionLineAnnotation->addPoint (roundPoint (mapToScene (event->pos ())));
31803175 } else {
31813176 mpConnectionLineAnnotation->addPoint (snappedPoint);
31823177 }
3178+ eventConsumed = true ;
31833179 } else if (isCreatingTransition ()) {
31843180 mpTransitionLineAnnotation->addPoint (snappedPoint);
3181+ eventConsumed = true ;
31853182 } else if (pMainWindow->getLineShapeAction ()->isChecked ()) {
31863183 /* if line shape tool button is checked then create a line */
31873184 createLineShape (snappedPoint);
3185+ eventConsumed = true ;
31883186 } else if (pMainWindow->getPolygonShapeAction ()->isChecked ()) {
31893187 /* if polygon shape tool button is checked then create a polygon */
31903188 createPolygonShape (snappedPoint);
3189+ eventConsumed = true ;
31913190 } else if (pMainWindow->getRectangleShapeAction ()->isChecked ()) {
31923191 /* if rectangle shape tool button is checked then create a rectangle */
31933192 createRectangleShape (snappedPoint);
3193+ eventConsumed = true ;
31943194 } else if (pMainWindow->getEllipseShapeAction ()->isChecked ()) {
31953195 /* if ellipse shape tool button is checked then create an ellipse */
31963196 createEllipseShape (snappedPoint);
3197+ eventConsumed = true ;
31973198 } else if (pMainWindow->getTextShapeAction ()->isChecked ()) {
31983199 /* if text shape tool button is checked then create a text */
31993200 createTextShape (snappedPoint);
3201+ eventConsumed = true ;
32003202 } else if (pMainWindow->getBitmapShapeAction ()->isChecked ()) {
32013203 /* if bitmap shape tool button is checked then create a bitmap */
32023204 createBitmapShape (snappedPoint);
3205+ eventConsumed = true ;
32033206 } else if (dynamic_cast <ResizerItem*>(itemAt (event->pos ()))) {
32043207 // do nothing if resizer item is clicked. It will be handled in its class mousePressEvent();
32053208 } else if (dynamic_cast <CornerItem*>(itemAt (event->pos ()))) {
@@ -3235,22 +3238,25 @@ void GraphicsView::mousePressEvent(QMouseEvent *event)
32353238 mpClickedComponent = pComponent;
32363239 } else if (isCreatingConnection ()) {
32373240 addConnection (pComponent); // end the connection
3238- /* we set this flag here instead of the constructor
3239- * to avoid the unnecessary itemChange calls while creating the connection.
3240- */
3241- mpConnectionLineAnnotation->setFlag (QGraphicsItem::ItemIsSelectable);
3241+ eventConsumed = true ; // consume the event so that connection line or end component will not become selected
32423242 }
32433243 } else if (Component *pComponent = stateComponentAtPosition (event->pos ())) {
32443244 if (!isCreatingTransition ()) {
32453245 mpClickedState = pComponent;
32463246 } else if (isCreatingTransition ()) {
32473247 addTransition (pComponent); // end the transition
3248- /* we set this flag here instead of the constructor
3249- * to avoid the unnecessary itemChange calls while creating the transition.
3250- */
3251- mpTransitionLineAnnotation->setFlag (QGraphicsItem::ItemIsSelectable);
3248+ eventConsumed = true ; // consume the event so that transition line or end component will not become selected
32523249 }
32533250 }
3251+ if (!eventConsumed) {
3252+ /* Ticket:4379 Select multiple objects with [Shift] key (not with [Control] key)
3253+ * To provide multi select we switch the shift key with control.
3254+ */
3255+ if (event->modifiers () & Qt::ShiftModifier) {
3256+ event->setModifiers ((event->modifiers () & ~Qt::ShiftModifier) | Qt::ControlModifier);
3257+ }
3258+ QGraphicsView::mousePressEvent (event);
3259+ }
32543260 setFocus (Qt::ActiveWindowFocusReason);
32553261}
32563262
@@ -3261,7 +3267,6 @@ void GraphicsView::mousePressEvent(QMouseEvent *event)
32613267 */
32623268void GraphicsView::mouseMoveEvent (QMouseEvent *event)
32633269{
3264- QGraphicsView::mouseMoveEvent (event);
32653270 // if we are in panning mode
32663271 if (isPanning ()) {
32673272 QScrollBar *pHorizontalScrollBar = horizontalScrollBar ();
@@ -3330,30 +3335,18 @@ void GraphicsView::mouseMoveEvent(QMouseEvent *event)
33303335 mpClickedState->setSelected (false );
33313336 }
33323337 }
3338+ QGraphicsView::mouseMoveEvent (event);
33333339}
33343340
33353341void GraphicsView::mouseReleaseEvent (QMouseEvent *event)
33363342{
33373343 if (event->button () == Qt::RightButton) {
33383344 return ;
33393345 }
3340-
33413346 setIsPanning (false );
33423347 mpClickedComponent = 0 ;
33433348 mpClickedState = 0 ;
33443349
3345- if (isCreatingShape () || isCreatingConnection () || isCreatingTransition ()) {
3346- return ;
3347- }
3348- /* Ticket:4379 Select multiple objects with [Shift] key (not with [Control] key)
3349- * To provide multi select we switch the shift key with control.
3350- * Yes we need to do this in both mousePressEvent and mouseReleaseEvent.
3351- */
3352- if (event->modifiers () & Qt::ShiftModifier) {
3353- event->setModifiers ((event->modifiers () & ~Qt::ShiftModifier) | Qt::ControlModifier);
3354- }
3355- QGraphicsView::mouseReleaseEvent (event);
3356-
33573350 if (isMovingComponentsAndShapes ()) {
33583351 setIsMovingComponentsAndShapes (false );
33593352 bool hasComponentMoved = false ;
@@ -3396,6 +3389,14 @@ void GraphicsView::mouseReleaseEvent(QMouseEvent *event)
33963389 mpModelWidget->endMacro ();
33973390 }
33983391 }
3392+ /* Ticket:4379 Select multiple objects with [Shift] key (not with [Control] key)
3393+ * To provide multi select we switch the shift key with control.
3394+ * Yes we need to do this in both mousePressEvent and mouseReleaseEvent.
3395+ */
3396+ if (event->modifiers () & Qt::ShiftModifier) {
3397+ event->setModifiers ((event->modifiers () & ~Qt::ShiftModifier) | Qt::ControlModifier);
3398+ }
3399+ QGraphicsView::mouseReleaseEvent (event);
33993400}
34003401
34013402bool GraphicsView::handleDoubleClickOnComponent (QMouseEvent *event)
0 commit comments