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)));
16 ProfileDialog::~ProfileDialog()
22 void ProfileDialog::tableDoubleClicked(const QModelIndex& index)
24 ProfileTableModel* model = (ProfileTableModel*)m_table->model();
25 const trace::Profile::Call* call = model->getJumpCall(index);
28 emit jumpToCall(call->no);
33 void ProfileDialog::setProfile(trace::Profile* profile)
40 m_timeline->setProfile(m_profile);
42 ProfileTableModel* model = new ProfileTableModel(m_table);
43 model->setProfile(m_profile);
45 delete m_table->model();
46 m_table->setModel(model);
47 m_table->resizeColumnsToContents();
48 m_table->sortByColumn(2, Qt::DescendingOrder);
52 void ProfileDialog::selectionChanged(int64_t start, int64_t end)
54 ProfileTableModel* model = (ProfileTableModel*)m_table->model();
55 model->setTimeSelection(start, end);
60 void ProfileDialog::setVerticalScrollMax(int max)
63 m_verticalScrollBar->hide();
65 m_verticalScrollBar->show();
66 m_verticalScrollBar->setMinimum(0);
67 m_verticalScrollBar->setMaximum(max);
72 void ProfileDialog::setHorizontalScrollMax(int max)
75 m_horizontalScrollBar->hide();
77 m_horizontalScrollBar->show();
78 m_horizontalScrollBar->setMinimum(0);
79 m_horizontalScrollBar->setMaximum(max);
85 * Convert a CPU / GPU time to a textual representation.
86 * This includes automatic unit selection.
88 QString getTimeString(int64_t time, int64_t unitTime)
98 if (unitTime >= 60e9) {
99 int64_t mins = time / 60e9;
100 text += QString("%1 m ").arg(mins);
105 } else if (unitTime >= 1e9) {
108 } else if (unitTime >= 1e6) {
111 } else if (unitTime >= 1e3) {
116 /* 3 decimal places */
117 text += QString("%1").arg(time / unitScale, 0, 'f', 3);
119 /* Remove trailing 0 */
120 while(text.endsWith('0'))
121 text.truncate(text.length() - 1);
123 /* Remove trailing decimal point */
124 if (text.endsWith(QLocale::system().decimalPoint()))
125 text.truncate(text.length() - 1);
131 #include "profiledialog.moc"