James Benton | fc4f55a | 2012-08-08 17:09:07 +0100 | [diff] [blame] | 1 | #include "profiledialog.h" |
| 2 | #include "profiletablemodel.h" |
| 3 | #include <QSortFilterProxyModel> |
| 4 | |
| 5 | ProfileDialog::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 | |
| 16 | ProfileDialog::~ProfileDialog() |
| 17 | { |
| 18 | delete m_profile; |
| 19 | } |
| 20 | |
| 21 | |
| 22 | void ProfileDialog::tableDoubleClicked(const QModelIndex& index) |
| 23 | { |
| 24 | ProfileTableModel* model = (ProfileTableModel*)m_table->model(); |
James Benton | 4c4896f | 2012-08-22 12:11:37 +0100 | [diff] [blame^] | 25 | const trace::Profile::Call* call = model->getJumpCall(index); |
James Benton | fc4f55a | 2012-08-08 17:09:07 +0100 | [diff] [blame] | 26 | |
| 27 | if (call) { |
| 28 | emit jumpToCall(call->no); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | |
| 33 | void 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 | |
| 52 | void 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 | |
| 60 | void 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 | |
| 72 | void 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" |