blob: 5568b54120a905518f97dc50af6e8658722adf47 [file] [log] [blame]
James Bentonfc4f55a2012-08-08 17:09:07 +01001#include "profiledialog.h"
2#include "profiletablemodel.h"
3#include <QSortFilterProxyModel>
4
5ProfileDialog::ProfileDialog(QWidget *parent)
6 : QDialog(parent),
7 m_profile(0)
8{
9 setupUi(this);
10
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)));
13}
14
15
16ProfileDialog::~ProfileDialog()
17{
18 delete m_profile;
19}
20
21
22void ProfileDialog::tableDoubleClicked(const QModelIndex& index)
23{
24 ProfileTableModel* model = (ProfileTableModel*)m_table->model();
James Benton4c4896f2012-08-22 12:11:37 +010025 const trace::Profile::Call* call = model->getJumpCall(index);
James Bentonfc4f55a2012-08-08 17:09:07 +010026
27 if (call) {
28 emit jumpToCall(call->no);
29 }
30}
31
32
33void ProfileDialog::setProfile(trace::Profile* profile)
34{
35 if (m_profile) {
36 delete m_profile;
37 }
38
39 m_profile = profile;
40 m_timeline->setProfile(m_profile);
41
42 ProfileTableModel* model = new ProfileTableModel(m_table);
43 model->setProfile(m_profile);
44
45 delete m_table->model();
46 m_table->setModel(model);
47 m_table->resizeColumnsToContents();
48 m_table->sortByColumn(2, Qt::DescendingOrder);
49}
50
51
52void ProfileDialog::selectionChanged(int64_t start, int64_t end)
53{
54 ProfileTableModel* model = (ProfileTableModel*)m_table->model();
55 model->setTimeSelection(start, end);
56 m_table->reset();
57}
58
59
60void ProfileDialog::setVerticalScrollMax(int max)
61{
62 if (max <= 0) {
63 m_verticalScrollBar->hide();
64 } else {
65 m_verticalScrollBar->show();
66 m_verticalScrollBar->setMinimum(0);
67 m_verticalScrollBar->setMaximum(max);
68 }
69}
70
71
72void ProfileDialog::setHorizontalScrollMax(int max)
73{
74 if (max <= 0) {
75 m_horizontalScrollBar->hide();
76 } else {
77 m_horizontalScrollBar->show();
78 m_horizontalScrollBar->setMinimum(0);
79 m_horizontalScrollBar->setMaximum(max);
80 }
81}
82
83#include "profiledialog.moc"