-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnapshotModel.h
104 lines (53 loc) · 1.72 KB
/
SnapshotModel.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
// SnapshotModel.cpp
// Implements the SnapshotModel class representing the model for displaying project's snapshots
#ifndef SNAPSHOTMODEL_H
#define SNAPSHOTMODEL_H
#include <memory>
#include <QStandardItemModel>
// fwd:
class Project;
typedef std::shared_ptr<Project> ProjectPtr;
class Snapshot;
typedef std::shared_ptr<Snapshot> SnapshotPtr;
class SnapshotModel:
public QStandardItemModel
{
typedef QStandardItemModel Super;
Q_OBJECT
public:
/** Column indices. */
enum
{
colTimestamp = 0,
colHeapSize = 1,
colHeapExtraSize = 2,
colMaxPlusOne,
colMax = colMaxPlusOne - 1,
};
enum
{
/** Data role used for sorting (rather than sorting on the DisplayRole) */
SortRole = Qt::UserRole + 1,
/** Data role used to store snapshot's timestamp in the QModelIndex. */
SnapshotTimestampRole = Qt::UserRole + 2,
};
/** Creates a new model for the specified project. */
explicit SnapshotModel(ProjectPtr a_Project);
/** Returns the snapshot represented by the specified item. */
SnapshotPtr getItemSnapshot(const QModelIndex & a_Index) const;
virtual Qt::ItemFlags flags(const QModelIndex & a_Index) const override;
signals:
protected slots:
/** Called from m_Project after a new snapshot has been added to the project. */
void onProjectAddedSnapshot(SnapshotPtr a_Snapshot);
protected:
/** The project whose snapshots are modelled. */
ProjectPtr m_Project;
/** Icon displayed in the tree view if the snapshot has detailed allocations attached to it. */
QIcon m_IcoAllocations;
/** Sets the model's columns. Called from the constructor. */
void initColumns();
/** Adds the specified snapshot to the model. */
void addSnapshot(SnapshotPtr a_Snapshot);
};
#endif // SNAPSHOTMODEL_H