summaryrefslogtreecommitdiff
path: root/gui/apitracemodel.h
blob: 36aaae7032bb5248e992f0fdfb5a3e8a9bbe930a (plain)
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
#pragma once


#include <QAbstractItemModel>
#include <QModelIndex>
#include <QSet>
#include <QVariant>

class ApiTrace;
class ApiTraceCall;
class ApiTraceEvent;
class ApiTraceFrame;

class ApiTraceModel : public QAbstractItemModel
{
    Q_OBJECT
public:
    enum Roles {
        EventRole = Qt::UserRole + 1
    };
public:
    ApiTraceModel(QObject *parent = 0);
    ~ApiTraceModel();

    void setApiTrace(ApiTrace *trace);
    const ApiTrace *apiTrace() const;
    void stateSetOnEvent(ApiTraceEvent *event);

    QModelIndex indexForCall(ApiTraceCall *call) const;

public:
    /* QAbstractItemModel { */
    QVariant data(const QModelIndex &index, int role) const override;
    Qt::ItemFlags flags(const QModelIndex &index) const override;
    QVariant headerData(int section, Qt::Orientation orientation,
                        int role = Qt::DisplayRole) const override;
    QModelIndex index(int row, int column,
                      const QModelIndex &parent = QModelIndex()) const override;
    bool hasChildren(const QModelIndex &parent) const override;
    QModelIndex parent(const QModelIndex &index) const override;
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;

    bool insertRows(int position, int rows,
                    const QModelIndex &parent = QModelIndex()) override;
    bool removeRows(int position, int rows,
                    const QModelIndex &parent = QModelIndex()) override;
    virtual bool canFetchMore(const QModelIndex & parent) const override;
    virtual void fetchMore(const QModelIndex &parent) override;
    /* } QAbstractItemModel; */

private slots:
    void invalidateFrames();
    void beginAddingFrames(int oldCount, int numAdded);
    void endAddingFrames();
    void changed(ApiTraceEvent *event);
    void callChanged(ApiTraceCall *call);
    void frameChanged(ApiTraceFrame *frame);
    void beginLoadingFrame(ApiTraceFrame *frame, int numAdded);
    void endLoadingFrame(ApiTraceFrame *frame);

private:
    ApiTraceEvent *item(const QModelIndex &index) const;

private:
    ApiTrace *m_trace;
    QSet<ApiTraceFrame*> m_loadingFrames;
};