pqKeyEventFilter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 #ifndef pqKeyEventFilter_h
5 #define pqKeyEventFilter_h
6 
7 #include "pqCoreModule.h"
8 
9 #include <QObject>
10 
11 #include <QList>
12 #include <QMap>
13 #include <QSharedPointer>
14 
15 class QKeyEvent;
16 
26 class PQCORE_EXPORT pqKeyEventFilter : public QObject
27 {
28  Q_OBJECT;
29  typedef QObject Superclass;
30 
31 public:
32  pqKeyEventFilter(QObject* parent);
33  ~pqKeyEventFilter() override;
34 
39  {
44  Focus
45  };
46 
50  void filter(QObject* monitored);
51 
53 
57  void forwardTypes(QObject* monitored, QList<int> types);
58  void forwardType(QObject* monitored, int type);
60 
61 Q_SIGNALS:
72  void textChanged(int key);
73 
78  void accepted(bool modified);
79 
83  void rejected();
84 
90  void motion(int key);
91 
96  void focusChanged();
97 
98 protected:
102  bool eventFilter(QObject* obj, QEvent* event) override;
103 
104 private:
105  bool isAcceptType(int key);
106  bool isRejectType(int key);
107  bool isTextUpdateType(QChar key);
108  bool isMotionType(int key);
109  bool isFocusType(int key);
110 
111  bool shouldHandle(QObject* obj, int type);
112 
113  QMap<QObject*, QList<int>> ForwardTypes;
114  QList<QObject*> Monitored;
115 
116  QSharedPointer<QKeyEvent> LastEvent;
117 };
118 
119 #endif
#define PQCORE_EXPORT
Definition: pqCoreModule.h:15
: A class to handle QKeyEvent in an eventFilter and send high level signals.
KeyCategory
An enum for the key events categories.