-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpqEventTranslator.h
131 lines (105 loc) · 4.91 KB
/
pqEventTranslator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
// SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
// SPDX-License-Identifier: BSD-3-Clause
#ifndef _pqEventTranslator_h
#define _pqEventTranslator_h
#include "QtTestingExport.h"
#include <QObject>
#include <QRect>
#include <QRegularExpression>
class pqEventComment;
class pqTestUtility;
class pqWidgetEventTranslator;
/**
Manages serialization of user interaction for test-cases, demos, tutorials, etc.
pqEventTranslator installs itself as a global Qt event "filter" that receives notification of every
Qt event. Each event is passed
through a collection of pqWidgetEventTranslator objects, until one of them "handles" the event. The
pqWidgetEventTranslator objects
convert low-level Qt events (mouse move, button down, key released, etc) into high-level ParaView
events (button clicked, row selected, etc)
that can be serialized as text. Once an event translator is found, the recordEvent() signal is
emitted with the name of the widget
that is receiving the event, plus the serialized event. Observers such as pqEventObserverXML
connect to the recordEvent() signal and
handle storage of the events.
\sa pqWidgetEventTranslator, pqEventObserverStdout, pqEventObserverXML, pqEventPlayer.
*/
class QTTESTING_EXPORT pqEventTranslator : public QObject
{
Q_OBJECT
public:
pqEventTranslator(QObject* p = 0);
~pqEventTranslator() override;
/** Adds the default set of widget translators to the working set.
Translators are executed in order, so you may call addWidgetEventTranslator()
with your own custom translators before calling this method,
to "override" the default translators. */
void addDefaultWidgetEventTranslators(pqTestUtility* util);
/** Adds a new translator to the current working set of widget translators.
pqEventTranslator assumes control of the lifetime of the supplied object.*/
void addWidgetEventTranslator(pqWidgetEventTranslator*);
/** Method to get a specific player */
bool removeWidgetEventTranslator(const QString& className);
/** Method to get a specific player */
pqWidgetEventTranslator* getWidgetEventTranslator(const QString& className);
/// Return a QList of all the Translators previously added.
QList<pqWidgetEventTranslator*> translators() const;
/// Add a new default eventComment in the scenario/recording to inform,
/// intract with the user during the play back.
void addDefaultEventManagers(pqTestUtility* util);
/// Return the pqEventComment, to be able to add any comment events
pqEventComment* eventComment() const;
/// Adds @a object to a list of objects that will be ignored when
/// translating events that have a command matching @a commandFilter
/// (useful to prevent recording UI events from being
/// captured as part of the recording)
///
/// You may also choose to ignore commands by setting the
/// "BlockRecordCommands" property of @a object to a QRegExp that will
/// match the commands to block. This is useful for temporarily blocking
/// a command when a programatically change will fire a signal that generates
/// a command.
void ignoreObject(QObject* object,
QRegularExpression commandFilter = QRegularExpression(
".*", QRegularExpression::CaseInsensitiveOption));
/// start listening to the GUI and translating events
void start();
/// stop listening to the GUI and translating events
void stop();
/// Record check event instead of events
void check(bool value);
/// Activate/Deactivate recording
void record(bool value);
bool isRecording();
/// Set the record interaction timings flag
void recordInteractionTimings(bool value);
/// Record a dashboard mode toggle event
void recordDashboardModeToggle(QObject* object, bool toggle);
Q_SIGNALS:
/// This signal will be emitted every time a translator generates a
/// high-level ParaView event. Observers should connect to this signal
/// to serialize high-level events.
void recordEvent(
const QString& Object, const QString& Command, const QString& Arguments, int eventType);
/// this signals when recording starts
void started();
/// this signals when recording stops
void stopped();
private Q_SLOTS:
// Slot called when recording an event
void onRecordEvent(
QObject* Object, const QString& Command, const QString& Arguments, int eventType);
// Legacy convenient slot for pqEventTypes::ACTION_EVENT events
void onRecordEvent(QObject* Object, const QString& Command, const QString& Arguments);
// Slots called when widget request a specific size for the check overlay
void setOverlayGeometry(const QRect& geometry, bool specific = true);
private:
pqEventTranslator(const pqEventTranslator&);
pqEventTranslator& operator=(const pqEventTranslator&);
bool eventFilter(QObject* Object, QEvent* Event) override;
int getWidgetEventTranslatorIndex(const QString& className);
struct pqImplementation;
pqImplementation* const Implementation;
};
#endif // !_pqEventTranslator_h