/** ** ** @RDE_HEADER@ ** Event Dispatcher for Qt5 to handle mouse and keyboard event ** $Id$ ** $HeadURL$ ** $Author$ ** ** ----------------------------------------------------------------------------------------------- ** ** Hardware-Environment: Intel-PC ** Software-Environment: Windows 7, Qt 5.4. ArcGIS 10.2.5 ** ** Language ........: C++ 11 ** ** ----------------------------------------------------------------------------------------------- ** ** Author ...........: Jörg Turla, SPD G, Tel. 3132 ** ** ----------------------------------------------------------------------------------------------- ** ** Notes .........: ** ** 28.04.2003, JT : First edition for use with Qt4 in START Feature Editor fee ** 25.03.2015, JT : Refactoring for use with Qt5 ** ** ----------------------------------------------------------------------------------------------- */ #pragma once #include "abstract_event_dispatcher.h" class QGestureEvent; class QWheelEvent; namespace SituationMap { namespace RB { /** @class EventDispatcher event_dispatcher.h @brief Event filter that handles events when a rubberband it active. Implements class \c AbstractEventDispatcher to manage event handling for rubberbands. Following events are handled: | Input-Event | Interface Function | Description | | :--------------------------------------------- | : ----------------- | : ------------------------------------------------------------------------------------------------------ | | Mouse move without any modifier | moveAction | Move Cursor or preview | | Mouse move with pressed left button | movePickedAction | Move selected items. If movePickedAction == false redirect to \c EventMouseNavigator for panning of map. | | Mouse move with pressed middle button | | Redirect to \c EventMouseNavigator for panning of map | | Mouse wheel | | Redirect to \c EventMouseNavigator for zooming of map | | Left mouse button press | selectAction | Do selection of single item or panning of map. | | Left mouse button press with pressed SHIFT key | multiSelectAction | Do selection of multiple items. | | Left mouse button release | setCoordinateAction | Set final coordinate to selected items and deselects item. | | Double click left mouse button | completeStateAction | Finish input. | | Right mouse button release | contextMenuAction | Show context menu. | | Key release CTRL-Z | undoMenuAction | Undo last left mouse button click if possible. | | Key release Delete | deleteMenuAction | Delete selected item. | | Key release ESC | abortAction | Abort rubberband without saving data. The rubberband emits the abort signal. | | Key release RETURN | applyAndEndAction | Finish rubberband. The rubberband emits the apply signal. | | Key release UP | moveAction | Moves 1 pixel up. | | Key release DOWN | moveAction | Moves 1 pixel down. | | Key release LEFT | moveAction | Moves 1 pixel left. | | Key release RIGHT | moveAction | Moves 1 pixel right. | | Key release UP with SHIFT key pressed | moveAction | Moves 10 pixel up. | | Key release DOWN with SHIFT key pressed | moveAction | Moves 10 pixel down. | | Key release LEFT with SHIFT key pressed | moveAction | Moves 10 pixel left. | | Key release RIGHT with SHIFT key pressed | moveAction | Moves 10 pixel right. | @see AbstractEventDispatcher, EventDelegater, EventMouseNavigator, Rubberband, RubberbandPointFeature, RubberbandPointCluster, RubberbandMultiPointFeature, RubberbandCorridor, RubberbandRectangle, RubberbandEllipse, EventMouseNavigator */ class EventDispatcher final : public AbstractEventDispatcher { friend class RubberbandBase; Q_OBJECT public: /** @name Construction & Destruction @{ */ explicit EventDispatcher( QWidget * getEventsFrom ); explicit EventDispatcher( QWidget * getEventsFrom, EventActionInterface* ); ~EventDispatcher() = default; EventDispatcher(const EventDispatcher &) = delete; EventDispatcher & operator = (const EventDispatcher &) = delete; /** @} */ inline void setSnapEnabled(bool) {} inline bool SnapEnabled() { return _snapEnabled; } signals: /** Signal will be emitted if a mouse move is done (and if event is handled) */ void mouseMovedEvent(int windowPosX, int windowPosY); protected: bool eventFilter(QObject*, QEvent*) override; bool eventFilterKey( int key, Qt::KeyboardModifiers mod ); bool eventFilterGesture( QGestureEvent * gestureEvent ); bool eventFilterWheel( QWheelEvent * ); private: bool onMove (int x, int y, Qt::MouseButtons buttons, Qt::KeyboardModifiers mod); //!< Handle a mouse move event. bool onPress ( int x, int y, Qt::KeyboardModifiers mod); //!< Handle left mouse button press event. bool onClick ( int x, int y, Qt::KeyboardModifiers mod); //!< Handle left mouse button release event. bool onMenuPress ( int x, int y, Qt::KeyboardModifiers mod); //!< Handle right mouse button press event. bool onMenuClick ( int x, int y, Qt::KeyboardModifiers mod); //!< Handle right mouse button release event. bool onDoubleClick( int x, int y, Qt::KeyboardModifiers mod); //!< Handle left mouse button double click event. bool onDoDelete(); //!< Handle del key press event. bool onDoUndo(); //!< Handle ctrl-c key press event. bool onDoEscape(); //!< Handle esc key press event. bool onDoEnd(); //!< Handle enter key press event. bool _snapEnabled; uint _snapRatio; bool _drawRatio; bool _doubleClickHandled; bool _leftPressHandled; }; /* EventDispatcher */ } } /* namespace SituationMap::RB */