blob: da17550393ba83395b7a68539e25e1460b1c2c97 [file] [log] [blame]
James Bentonfc4f55a2012-08-08 17:09:07 +01001#ifndef PROFILETABLEMODEL_H
2#define PROFILETABLEMODEL_H
3
4#include <QAbstractTableModel>
5#include "trace_profiler.hpp"
6
7struct ProfileTableRow
8{
James Benton56ad11c2012-08-16 13:44:19 +01009 ProfileTableRow(unsigned no)
10 : program(no),
James Bentonfc4f55a2012-08-08 17:09:07 +010011 uses(0),
12 gpuTime(0),
13 cpuTime(0),
14 pixels(0),
15 longestGpu(0),
16 longestCpu(0),
17 longestPixel(0)
18 {
19 }
20
21 unsigned program;
22 qulonglong uses;
23 qulonglong gpuTime;
24 qulonglong cpuTime;
25 qulonglong pixels;
26
James Benton4c4896f2012-08-22 12:11:37 +010027 const trace::Profile::Call* longestGpu;
28 const trace::Profile::Call* longestCpu;
29 const trace::Profile::Call* longestPixel;
James Bentonfc4f55a2012-08-08 17:09:07 +010030};
31
32class ProfileTableModel : public QAbstractTableModel
33{
34 Q_OBJECT
35
36public:
37 ProfileTableModel(QObject *parent = NULL);
38
39 void setProfile(trace::Profile* profile);
James Bentonfc4f55a2012-08-08 17:09:07 +010040
James Bentonb70a86a2012-08-28 18:41:43 +010041 void selectNone();
42 void selectProgram(unsigned program);
43 void selectTime(int64_t start, int64_t end);
44
45 int getRowIndex(unsigned program) const;
46 unsigned getProgram(const QModelIndex & index) const;
James Benton4c4896f2012-08-22 12:11:37 +010047 const trace::Profile::Call* getJumpCall(const QModelIndex & index) const;
James Bentonfc4f55a2012-08-08 17:09:07 +010048
49 virtual int rowCount(const QModelIndex & parent) const;
50 virtual int columnCount(const QModelIndex & parent) const;
51
52 virtual QVariant data(const QModelIndex &index, int role) const;
53 virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
54
55 virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
56
57private:
58 void updateModel();
59 ProfileTableRow* getRow(unsigned program);
60
61private:
62 QList<ProfileTableRow> m_rowData;
63 trace::Profile *m_profile;
64 int64_t m_timeMin;
65 int64_t m_timeMax;
66 int m_sortColumn;
67 Qt::SortOrder m_sortOrder;
68};
69
70#endif // PROFILEMODEL_H