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
|
// Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company,
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <QAbstractTableModel>
#include <QHash>
namespace CtfVisualizer::Internal {
class CtfStatisticsModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum Role {
SortRole = Qt::UserRole + 1,
};
enum Column {
Title = 0,
Count,
TotalDuration,
RelativeDuration,
MinDuration,
AvgDuration,
MaxDuration,
COUNT
};
struct EventData {
int count = 0;
qint64 totalDuration = 0.0;
qint64 minDuration = std::numeric_limits<qint64>::max();
qint64 maxDuration = 0.0;
};
explicit CtfStatisticsModel(QObject *parent);
~CtfStatisticsModel() override = default;
void beginLoading();
void addEvent(const QString &title, qint64 durationInNs);
void setMeasurementDuration(qint64 timeInNs);
void endLoading();
private:
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QHash<QString, EventData> m_data;
qint64 m_measurementDurationInNs = 0;
};
} // CtfVisualizer::Internal
|