1 #pragma once
2 
3 #include <QObject>
4 #include <QEvent>
5 
6 #include "control/controlobject.h"
7 #include "widget/controlwidgetconnection.h"
8 
9 struct ControlInfo {
ControlInfoControlInfo10     ControlInfo()
11             : clickControl(NULL),
12               emitOption(ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE),
13               leftClickControl(NULL),
14               leftEmitOption(ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE),
15               rightClickControl(NULL),
16               rightEmitOption(ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE) {
17     }
18 
19     ControlObject* clickControl;
20     ControlParameterWidgetConnection::EmitOption emitOption;
21     ControlObject* leftClickControl;
22     ControlParameterWidgetConnection::EmitOption leftEmitOption;
23     ControlObject* rightClickControl;
24     ControlParameterWidgetConnection::EmitOption rightEmitOption;
25 };
26 
27 class ControllerLearningEventFilter : public QObject {
28     Q_OBJECT
29   public:
30     ControllerLearningEventFilter(QObject* pParent = NULL);
31     virtual ~ControllerLearningEventFilter();
32 
33     virtual bool eventFilter(QObject* pObject, QEvent* pEvent);
34 
35     void addWidgetClickInfo(QWidget* pWidget, Qt::MouseButton buttonState,
36                             ControlObject* pControl,
37                             ControlParameterWidgetConnection::EmitOption emitOption);
38 
39   public slots:
40     void startListening();
41     void stopListening();
42 
43   signals:
44     void controlClicked(ControlObject* pControl);
45 
46   private:
47     QHash<QWidget*, ControlInfo> m_widgetControlInfo;
48     bool m_bListening;
49 };
50