blob: c062982bc951dcc8b274aab43911a6dd0865a958 [file] [log] [blame]
Jose Fonseca9653f952015-05-19 16:32:43 +01001#pragma once
James Bentonfc4f55a2012-08-08 17:09:07 +01002
3#include <QAbstractTableModel>
4#include "trace_profiler.hpp"
5
6struct ProfileTableRow
7{
James Benton56ad11c2012-08-16 13:44:19 +01008 ProfileTableRow(unsigned no)
9 : program(no),
James Bentonfc4f55a2012-08-08 17:09:07 +010010 uses(0),
11 gpuTime(0),
12 cpuTime(0),
13 pixels(0),
14 longestGpu(0),
15 longestCpu(0),
16 longestPixel(0)
17 {
18 }
19
20 unsigned program;
21 qulonglong uses;
22 qulonglong gpuTime;
23 qulonglong cpuTime;
24 qulonglong pixels;
25
James Benton4c4896f2012-08-22 12:11:37 +010026 const trace::Profile::Call* longestGpu;
27 const trace::Profile::Call* longestCpu;
28 const trace::Profile::Call* longestPixel;
James Bentonfc4f55a2012-08-08 17:09:07 +010029};
30
31class ProfileTableModel : public QAbstractTableModel
32{
33 Q_OBJECT
34
35public:
36 ProfileTableModel(QObject *parent = NULL);
37
38 void setProfile(trace::Profile* profile);
James Bentonfc4f55a2012-08-08 17:09:07 +010039
James Bentonb70a86a2012-08-28 18:41:43 +010040 void selectNone();
41 void selectProgram(unsigned program);
42 void selectTime(int64_t start, int64_t end);
43
44 int getRowIndex(unsigned program) const;
45 unsigned getProgram(const QModelIndex & index) const;
James Benton4c4896f2012-08-22 12:11:37 +010046 const trace::Profile::Call* getJumpCall(const QModelIndex & index) const;
James Bentonfc4f55a2012-08-08 17:09:07 +010047
Jose Fonseca010f9962016-03-05 14:45:41 +000048 virtual int rowCount(const QModelIndex & parent) const override;
49 virtual int columnCount(const QModelIndex & parent) const override;
James Bentonfc4f55a2012-08-08 17:09:07 +010050
Jose Fonseca010f9962016-03-05 14:45:41 +000051 virtual QVariant data(const QModelIndex &index, int role) const override;
52 virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
James Bentonfc4f55a2012-08-08 17:09:07 +010053
Jose Fonseca010f9962016-03-05 14:45:41 +000054 virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
James Bentonfc4f55a2012-08-08 17:09:07 +010055
56private:
57 void updateModel();
58 ProfileTableRow* getRow(unsigned program);
59
60private:
61 QList<ProfileTableRow> m_rowData;
62 trace::Profile *m_profile;
63 int64_t m_timeMin;
64 int64_t m_timeMax;
65 int m_sortColumn;
66 Qt::SortOrder m_sortOrder;
67};
68