blob: dc08ba0ec2b390850b302c207582f9596e6d55a5 [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);
40 void setTimeSelection(int64_t start, int64_t end);
41
James Benton4c4896f2012-08-22 12:11:37 +010042 const trace::Profile::Call* getJumpCall(const QModelIndex & index) const;
James Bentonfc4f55a2012-08-08 17:09:07 +010043
44 virtual int rowCount(const QModelIndex & parent) const;
45 virtual int columnCount(const QModelIndex & parent) const;
46
47 virtual QVariant data(const QModelIndex &index, int role) const;
48 virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
49
50 virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
51
52private:
53 void updateModel();
54 ProfileTableRow* getRow(unsigned program);
55
56private:
57 QList<ProfileTableRow> m_rowData;
58 trace::Profile *m_profile;
59 int64_t m_timeMin;
60 int64_t m_timeMax;
61 int m_sortColumn;
62 Qt::SortOrder m_sortOrder;
63};
64
65#endif // PROFILEMODEL_H