BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
CustomEventFilters.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Common/CustomEventFilters.h
6 //! @brief Defines classes releted to event filtering
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_VIEW_COMMON_CUSTOMEVENTFILTERS_H
16 #define BORNAGAIN_GUI_VIEW_COMMON_CUSTOMEVENTFILTERS_H
17 
18 #include <QObject>
19 
20 //! Filter out space bar key events, which is special case for dialog windows.
21 
22 class SpaceKeyEater : public QObject {
23  Q_OBJECT
24 public:
25  SpaceKeyEater(QObject* parent = nullptr);
26 
27 protected:
28  bool eventFilter(QObject* obj, QEvent* event) override;
29 };
30 
31 //! Event filter to install on combo boxes and spin boxes to not
32 //! to react on wheel events during scrolling of InstrumentComponentWidget.
33 
34 class WheelEventEater : public QObject {
35  Q_OBJECT
36 public:
37  static void install(QObject* obj);
38  WheelEventEater(QObject* parent = nullptr);
39 
40 protected:
41  bool eventFilter(QObject* obj, QEvent* event) override;
42 };
43 
44 //! Lisens for press-del-key events
45 
46 class DeleteEventFilter : public QObject {
47  Q_OBJECT
48 public:
49  DeleteEventFilter(QObject* parent = nullptr)
50  : QObject(parent)
51  {
52  }
53 
54 protected:
55  bool eventFilter(QObject* dist, QEvent* event) override;
56 
57 signals:
58  void removeItem();
59 };
60 
61 //! Event filter to prevent lost of focus by custom material editor.
62 
63 class LostFocusFilter : public QObject {
64  Q_OBJECT
65 public:
66  LostFocusFilter(QObject* parent = nullptr);
67 
68 protected:
69  bool eventFilter(QObject* obj, QEvent* event) override;
70 };
71 
72 //! Event filter for global tracking of shortcodes.
73 
74 class ShortcodeFilter : public QObject {
75  Q_OBJECT
76 public:
77  ShortcodeFilter(QString shortcode, QObject* parent = nullptr);
78 
79 signals:
80  void found();
81 
82 protected:
83  bool eventFilter(QObject* obj, QEvent* event) override;
84  QString m_shortcode;
85  int m_index;
86 };
87 
88 //! Filter out right mouse button events.
89 
90 class RightMouseButtonEater : public QObject {
91  Q_OBJECT
92 public:
93  RightMouseButtonEater(QObject* parent = nullptr);
94 
95 protected:
96  bool eventFilter(QObject* obj, QEvent* event) override;
97 };
98 
99 //! Propagate tab events from focusProxy to parent.
100 
101 class TabFromFocusProxy : public QObject {
102  Q_OBJECT
103 public:
104  TabFromFocusProxy(QWidget* parent = nullptr);
105 
106 protected:
107  bool eventFilter(QObject* obj, QEvent* event) override;
108  QWidget* m_parent;
109 };
110 
111 #endif // BORNAGAIN_GUI_VIEW_COMMON_CUSTOMEVENTFILTERS_H
Lisens for press-del-key events.
DeleteEventFilter(QObject *parent=nullptr)
bool eventFilter(QObject *dist, QEvent *event) override
Event filter to prevent lost of focus by custom material editor.
bool eventFilter(QObject *obj, QEvent *event) override
LostFocusFilter(QObject *parent=nullptr)
Filter out right mouse button events.
bool eventFilter(QObject *obj, QEvent *event) override
RightMouseButtonEater(QObject *parent=nullptr)
Event filter for global tracking of shortcodes.
ShortcodeFilter(QString shortcode, QObject *parent=nullptr)
bool eventFilter(QObject *obj, QEvent *event) override
Filter out space bar key events, which is special case for dialog windows.
SpaceKeyEater(QObject *parent=nullptr)
bool eventFilter(QObject *obj, QEvent *event) override
Propagate tab events from focusProxy to parent.
TabFromFocusProxy(QWidget *parent=nullptr)
Passing focus-related events from child widget (e.g. QSpinBox) to parent (e.g. IntEditor) to trigger ...
bool eventFilter(QObject *obj, QEvent *event) override
Event filter to install on combo boxes and spin boxes to not to react on wheel events during scrollin...
static void install(QObject *obj)
bool eventFilter(QObject *obj, QEvent *event) override
WheelEventEater(QObject *parent=nullptr)