-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcustom_event_analyzer.hpp
40 lines (34 loc) · 1.2 KB
/
custom_event_analyzer.hpp
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
#pragma once
#include <QtCore/QString>
#include <functional>
class QWidget;
class QEvent;
class QObject;
namespace qt_monkey_agent
{
/**
* Type of function which custom event analyzer
* may save and reuse later for async code generation
*/
using GenerateCommand = std::function<void(QString)>;
class Agent;
//! Event info for CustomEventAnalyzer
struct EventInfo final {
Agent &agent;
QObject *obj; //!< the same as in QObject::eventFilter
QEvent *event; //!< the same as in QObject::eventFilter
QWidget *widget; //!< widget to which related this event, may be null
QString widgetName; //!< may contains cached value of name of obj
const GenerateCommand
&codeGenerator; //!< may be used by analyzer for async code generation
};
/**
* return not empty string [QString] with javascript code if can handle this
* event
* it is possible to return javascript comments to prevent javascript code
* generation and wait another event, for example on key press return comment
* and on key release return real code
* @tparam const EventInfo & information about event
*/
using CustomEventAnalyzer = std::function<QString(const EventInfo &)>;
} // namespace qt_monkey_agent