1 #include "profiledialog.h"
2 #include "profiletablemodel.h"
3 #include <QSortFilterProxyModel>
5 ProfileDialog::ProfileDialog(QWidget *parent)
11 connect(m_timeline, SIGNAL(jumpToCall(int)), SIGNAL(jumpToCall(int)));
12 connect(m_timeline, SIGNAL(selectionChanged(int64_t,int64_t)), SLOT(selectionChanged(int64_t,int64_t)));
14 connect(m_gpuGraph, SIGNAL(jumpToCall(int)), SIGNAL(jumpToCall(int)));
15 connect(m_cpuGraph, SIGNAL(jumpToCall(int)), SIGNAL(jumpToCall(int)));
17 connect(m_gpuGraph, SIGNAL(viewChanged(int,int)), m_cpuGraph, SLOT(changeView(int,int)));
18 connect(m_cpuGraph, SIGNAL(viewChanged(int,int)), m_gpuGraph, SLOT(changeView(int,int)));
22 ProfileDialog::~ProfileDialog()
28 void ProfileDialog::tableDoubleClicked(const QModelIndex& index)
30 ProfileTableModel* model = (ProfileTableModel*)m_table->model();
31 const trace::Profile::Call* call = model->getJumpCall(index);
34 emit jumpToCall(call->no);
39 void ProfileDialog::setProfile(trace::Profile* profile)
46 m_timeline->setProfile(m_profile);
47 m_gpuGraph->setProfile(m_profile, GraphGpu);
48 m_cpuGraph->setProfile(m_profile, GraphCpu);
50 ProfileTableModel* model = new ProfileTableModel(m_table);
51 model->setProfile(m_profile);
53 delete m_table->model();
54 m_table->setModel(model);
55 m_table->resizeColumnsToContents();
56 m_table->sortByColumn(2, Qt::DescendingOrder);
60 void ProfileDialog::selectionChanged(int64_t start, int64_t end)
62 ProfileTableModel* model = (ProfileTableModel*)m_table->model();
63 model->setTimeSelection(start, end);
68 void ProfileDialog::setVerticalScrollMax(int max)
71 m_verticalScrollBar->hide();
73 m_verticalScrollBar->show();
74 m_verticalScrollBar->setMinimum(0);
75 m_verticalScrollBar->setMaximum(max);
80 void ProfileDialog::setHorizontalScrollMax(int max)
83 m_horizontalScrollBar->hide();
85 m_horizontalScrollBar->show();
86 m_horizontalScrollBar->setMinimum(0);
87 m_horizontalScrollBar->setMaximum(max);
93 * Convert a CPU / GPU time to a textual representation.
94 * This includes automatic unit selection.
96 QString getTimeString(int64_t time, int64_t unitTime)
100 double unitScale = 1;
106 if (unitTime >= 60e9) {
107 int64_t mins = time / 60e9;
108 text += QString("%1 m ").arg(mins);
113 } else if (unitTime >= 1e9) {
116 } else if (unitTime >= 1e6) {
119 } else if (unitTime >= 1e3) {
124 /* 3 decimal places */
125 text += QString("%1").arg(time / unitScale, 0, 'f', 3);
127 /* Remove trailing 0 */
128 while(text.endsWith('0'))
129 text.truncate(text.length() - 1);
131 /* Remove trailing decimal point */
132 if (text.endsWith(QLocale::system().decimalPoint()))
133 text.truncate(text.length() - 1);
139 #include "profiledialog.moc"