Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qquickeventreplayclient.cpp
Go to the documentation of this file.
1
// Copyright (C) 2025 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant
4
5
#
include
"qquickeventreplayclient_p.h"
6
7
#
include
<
private
/
qpacket_p
.
h
>
8
#
include
<
private
/
qqmldebugconnection_p
.
h
>
9
#
include
<
private
/
qqmlprofilerdefinitions_p
.
h
>
10
11
#
include
<
QtCore
/
qxmlstream
.
h
>
12
13
QT_BEGIN_NAMESPACE
14
15
using
namespace
Qt::StringLiterals;
16
17
QQuickEventReplayClient
::QQuickEventReplayClient(
QQmlDebugConnection
*connection)
18
:
QQmlDebugClient
(QLatin1String(
"EventReplay"
), connection)
19
{
20
}
21
22
bool
QQuickEventReplayClient
::
loadEvents
(
23
const
QString &fileName,
24
qxp::function_ref<
void
(
const
QQmlProfilerEventType &, QQmlProfilerEvent &&)> &&handler)
25
{
26
QFile file(fileName);
27
if
(!file.open(QIODevice::ReadOnly)) {
28
qWarning() <<
"Cannot open file"
<< fileName <<
"for reading"
;
29
return
false
;
30
}
31
32
int
currentEventIndex = -1;
33
34
QHash<
int
, QQmlProfilerEventType> types;
35
36
QXmlStreamReader reader(&file);
37
while
(!reader.atEnd()) {
38
if
(reader.readNext() != QXmlStreamReader::StartElement)
39
continue
;
40
41
const
QStringView name = reader.name();
42
if
(name ==
"event"_L1
) {
43
currentEventIndex = reader.attributes().value(
"index"_L1
).toInt();
44
}
else
if
(name ==
"mouseEvent"_L1
|| name ==
"keyEvent"_L1
) {
45
types[currentEventIndex] = QQmlProfilerEventType(
46
Message::Event, RangeType::MaximumRangeType, reader.readElementText().toInt());
47
}
else
if
(name ==
"range"_L1
) {
48
const
QXmlStreamAttributes attributes = reader.attributes();
49
const
int
typeIndex = attributes.value(
"eventIndex"_L1
).toInt();
50
const
auto
type = types.constFind(typeIndex);
51
if
(type != types.constEnd()) {
52
handler(*type,
53
QQmlProfilerEvent(attributes.value(
"startTime"_L1
).toLongLong(), typeIndex,
54
{ attributes.value(
"type"_L1
).toInt(),
55
attributes.value(
"data1"_L1
).toInt(),
56
attributes.value(
"data2"_L1
).toInt() }));
57
}
58
}
59
}
60
61
return
true
;
62
}
63
64
void
QQuickEventReplayClient
::
sendEvent
(
65
const
QQmlProfilerEventType &type, QQmlProfilerEvent &&event)
66
{
67
QPacket stream(
connection
()->currentDataStreamVersion());
68
stream << event.timestamp() << QQmlProfilerDefinitions::Message::Event
69
<< type.detailType() << event.number<quint32>(0) << event.number<quint32>(1)
70
<< event.number<quint32>(2);
71
sendMessage(stream.data());
72
}
73
74
QT_END_NAMESPACE
QQmlDebugClient
Definition
qqmldebugclient_p.h:27
QQmlDebugClient::connection
QQmlDebugConnection * connection() const
Definition
qqmldebugclient.cpp:79
QQmlDebugConnection
Definition
qqmldebugconnection_p.h:28
QQuickEventReplayClient
Definition
qquickeventreplayclient_p.h:30
QQuickEventReplayClient::loadEvents
bool loadEvents(const QString &fileName, qxp::function_ref< void(const QQmlProfilerEventType &, QQmlProfilerEvent &&)> &&handler)
Definition
qquickeventreplayclient.cpp:22
QQuickEventReplayClient::sendEvent
void sendEvent(const QQmlProfilerEventType &type, QQmlProfilerEvent &&event)
Definition
qquickeventreplayclient.cpp:64
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
qmldebug
qquickeventreplayclient.cpp
Generated on
for Qt by
1.18.0