@@ -583,28 +583,32 @@ void NetworkEditor::mouseMoveEvent(QMouseEvent *event)
583583 if (event->button () != Qt::LeftButton)
584584 Q_EMIT networkEditorMouseButtonPressed ();
585585
586- if (ConnectionLine* cL = getSingleConnectionSelected ())
587- if (event->buttons () & Qt::LeftButton)
588- if (!(event->modifiers () & Qt::ControlModifier))
589- {
590- auto selectedPair = cL->getConnectedToModuleIds ();
586+ if (ConnectionLine* cL = getSingleConnectionSelected ())
587+ {
588+ if (event->buttons () & Qt::LeftButton)
589+ {
590+ if (!(event->modifiers () & Qt::ControlModifier))
591+ {
592+ auto selectedPair = cL->getConnectedToModuleIds ();
591593
592- findById (scene_->items (),selectedPair.first )->setSelected (true );
593- findById (scene_->items (),selectedPair.second )->setSelected (true );
594- modulesSelectedByCL_ = true ;
595- }
596- QGraphicsView::mouseMoveEvent (event);
594+ findById (scene_->items (), selectedPair.first )->setSelected (true );
595+ findById (scene_->items (), selectedPair.second )->setSelected (true );
596+ modulesSelectedByCL_ = true ;
597+ }
598+ }
599+ }
600+ QGraphicsView::mouseMoveEvent (event);
597601}
598602
599603void NetworkEditor::mouseReleaseEvent (QMouseEvent *event)
600604{
601- if (modulesSelectedByCL_)
602- {
603- unselectConnectionGroup ();
604- Q_EMIT modified ();
605- }
606- modulesSelectedByCL_ = false ;
607- QGraphicsView::mouseReleaseEvent (event);
605+ if (modulesSelectedByCL_)
606+ {
607+ unselectConnectionGroup ();
608+ Q_EMIT modified ();
609+ }
610+ modulesSelectedByCL_ = false ;
611+ QGraphicsView::mouseReleaseEvent (event);
608612}
609613
610614ConnectionLine* NetworkEditor::getSingleConnectionSelected ()
@@ -932,18 +936,23 @@ namespace
932936
933937void NetworkEditor::wheelEvent (QWheelEvent* event)
934938{
935- setTransformationAnchor (QGraphicsView::AnchorUnderMouse);
936-
937- if (event->delta () > 0 )
939+ if (event->modifiers () & Qt::ShiftModifier)
938940 {
939- zoomIn ();
941+ setTransformationAnchor (QGraphicsView::AnchorUnderMouse);
942+
943+ if (event->delta () > 0 )
944+ {
945+ zoomIn ();
946+ }
947+ else
948+ {
949+ zoomOut ();
950+ }
951+ // Don't call superclass handler here
952+ // as wheel is normally used for moving scrollbars
940953 }
941954 else
942- {
943- zoomOut ();
944- }
945- // Don't call superclass handler here
946- // as wheel is normally used for moving scrollbars
955+ QGraphicsView::wheelEvent (event);
947956}
948957
949958void NetworkEditor::zoomIn ()
@@ -979,6 +988,32 @@ int NetworkEditor::currentZoomPercentage() const
979988 return static_cast <int >(currentScale_ * 100 );
980989}
981990
991+ // static QGraphicsTextItem* zoomHelp = 0;
992+
993+ void NetworkEditor::keyPressEvent (QKeyEvent *event)
994+ {
995+ if (event->key () == Qt::Key_Shift)
996+ {
997+ // TODO
998+ // if (!zoomHelp)
999+ // zoomHelp = new QGraphicsTextItem("Network zoom enabled on scroll");
1000+ // scene()->addItem(zoomHelp);
1001+ // std::cout << "SHIFT IS ZOOM" << std::endl;
1002+ }
1003+ QGraphicsView::keyPressEvent (event);
1004+ }
1005+
1006+ void NetworkEditor::keyReleaseEvent (QKeyEvent *event)
1007+ {
1008+ if (event->key () == Qt::Key_Shift)
1009+ {
1010+ // TODO
1011+ // scene()->removeItem(zoomHelp);
1012+ // std::cout << "DONEZOOM" << std::endl;
1013+ }
1014+ QGraphicsView::keyPressEvent (event);
1015+ }
1016+
9821017bool NetworkEditor::containsViewScene () const
9831018{
9841019 return findFirstByName (scene_->items (), " ViewScene" ) != nullptr ;
0 commit comments