X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=gui%2Fprofiledialog.cpp;h=f33020386796def64e5d8f3c71e4eacd347c9568;hb=b70a86af10057c5b7fcf79b674cfe5abbeaadebb;hp=146e26a25d42bea544395089c3504a7fe56b9642;hpb=56ea30956b10d22fc78d120f5506f352cfecd3cd;p=apitrace diff --git a/gui/profiledialog.cpp b/gui/profiledialog.cpp index 146e26a..f330203 100644 --- a/gui/profiledialog.cpp +++ b/gui/profiledialog.cpp @@ -9,13 +9,8 @@ ProfileDialog::ProfileDialog(QWidget *parent) setupUi(this); connect(m_timeline, SIGNAL(jumpToCall(int)), SIGNAL(jumpToCall(int))); - connect(m_timeline, SIGNAL(selectionChanged(int64_t,int64_t)), SLOT(selectionChanged(int64_t,int64_t))); - connect(m_gpuGraph, SIGNAL(jumpToCall(int)), SIGNAL(jumpToCall(int))); connect(m_cpuGraph, SIGNAL(jumpToCall(int)), SIGNAL(jumpToCall(int))); - - connect(m_gpuGraph, SIGNAL(viewChanged(int,int)), m_cpuGraph, SLOT(changeView(int,int))); - connect(m_cpuGraph, SIGNAL(viewChanged(int,int)), m_gpuGraph, SLOT(changeView(int,int))); } @@ -32,36 +27,113 @@ void ProfileDialog::tableDoubleClicked(const QModelIndex& index) if (call) { emit jumpToCall(call->no); + } else { + unsigned program = model->getProgram(index); + m_timeline->selectProgram(program); + m_cpuGraph->selectProgram(program); + m_gpuGraph->selectProgram(program); } } void ProfileDialog::setProfile(trace::Profile* profile) { - if (m_profile) { - delete m_profile; + delete m_profile; + + if (profile->frames.size() == 0) { + m_profile = NULL; + } else { + m_profile = profile; + m_timeline->setProfile(m_profile); + m_gpuGraph->setProfile(m_profile, GraphGpu); + m_cpuGraph->setProfile(m_profile, GraphCpu); + + ProfileTableModel* model = new ProfileTableModel(m_table); + model->setProfile(m_profile); + + delete m_table->model(); + m_table->setModel(model); + m_table->update(QModelIndex()); + m_table->sortByColumn(1, Qt::DescendingOrder); + m_table->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); + m_table->resizeColumnsToContents(); + } +} + + +void ProfileDialog::selectNone() +{ + QObject* src = QObject::sender(); + + /* Update table model */ + ProfileTableModel* model = (ProfileTableModel*)m_table->model(); + model->selectNone(); + m_table->reset(); + + /* Update graphs */ + if (src != m_gpuGraph) { + m_gpuGraph->selectNone(); + } + + if (src != m_cpuGraph) { + m_cpuGraph->selectNone(); + } + + /* Update timeline */ + if (src != m_timeline) { + m_timeline->selectNone(); } +} + + +void ProfileDialog::selectProgram(unsigned program) +{ + QObject* src = QObject::sender(); - m_profile = profile; - m_timeline->setProfile(m_profile); - m_gpuGraph->setProfile(m_profile, GraphGpu); - m_cpuGraph->setProfile(m_profile, GraphCpu); + /* Update table model */ + ProfileTableModel* model = (ProfileTableModel*)m_table->model(); + model->selectNone(); + m_table->reset(); + m_table->selectRow(model->getRowIndex(program)); + + /* Update graphs */ + if (src != m_gpuGraph) { + m_gpuGraph->selectProgram(program); + } - ProfileTableModel* model = new ProfileTableModel(m_table); - model->setProfile(m_profile); + if (src != m_cpuGraph) { + m_cpuGraph->selectProgram(program); + } - delete m_table->model(); - m_table->setModel(model); - m_table->resizeColumnsToContents(); - m_table->sortByColumn(2, Qt::DescendingOrder); + /* Update timeline */ + if (src != m_timeline) { + m_timeline->selectProgram(program); + } } -void ProfileDialog::selectionChanged(int64_t start, int64_t end) +void ProfileDialog::selectTime(int64_t start, int64_t end) { + QObject* src = QObject::sender(); + + /* Update table model */ ProfileTableModel* model = (ProfileTableModel*)m_table->model(); - model->setTimeSelection(start, end); + model->selectTime(start, end); m_table->reset(); + + /* Update graphs */ + if (src != m_gpuGraph) { + m_gpuGraph->selectTime(start, end); + } + + if (src != m_cpuGraph) { + m_cpuGraph->selectTime(start, end); + } + + /* Update timeline */ + if (src != m_timeline) { + m_timeline->selectTime(start, end); + } }