Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion ui/gpu_timing_tab_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ GpuTimingTabView::GpuTimingTabView(GpuTimingModel &gpu_timing_mode
&QAbstractItemModel::modelReset,
this,
&GpuTimingTabView::OnModelReset);

QObject::connect(m_table_view->selectionModel(),
&QItemSelectionModel::currentChanged,
this,
&GpuTimingTabView::OnSelectionChanged);
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -136,6 +141,8 @@ int GpuTimingTabView::EventIndexToRow(const QModelIndex &model_index)
//--------------------------------------------------------------------------------------------------
void GpuTimingTabView::OnEventSelectionChanged(const QModelIndex &model_index)
{
QItemSelectionModel *selection_model = m_table_view->selectionModel();
QSignalBlocker blocker(selection_model);
// Verify that the number of rows in the model is consistent with the rows of
// m_timed_event_indices
if (m_model.rowCount() != static_cast<int>(m_timed_event_indices.size()))
Expand All @@ -149,8 +156,38 @@ void GpuTimingTabView::OnEventSelectionChanged(const QModelIndex &model_index)
int row = EventIndexToRow(model_index);
if (row < 0)
{
m_table_view->clearSelection();
ClearSelection();
return;
}
m_table_view->selectRow(row);
m_table_view->update();
m_table_view->viewport()->update();
}

//--------------------------------------------------------------------------------------------------
void GpuTimingTabView::OnSelectionChanged(const QModelIndex &index)
{
// Resize columns to fit the content
ResizeColumns();
int selected_row = index.row();
if (static_cast<size_t>(selected_row) < m_timed_event_indices.size() && selected_row >= 0)
{
emit GpuTimingDataSelected(m_timed_event_indices.at(selected_row));
}
else
{
qDebug() << "GpuTimingTabView::OnSelectionChanged() ERROR: selected row (" << selected_row
<< ") is out of range of collected indices of timed Vulkan events: "
<< m_timed_event_indices.size() << ". Non-gpu timed event selected.";
}
}

//--------------------------------------------------------------------------------------------------
void GpuTimingTabView::ClearSelection()
{
QItemSelectionModel *selection_model = m_table_view->selectionModel();
if (selection_model)
{
selection_model->clear();
}
}
6 changes: 6 additions & 0 deletions ui/gpu_timing_tab_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ class GpuTimingTabView : public QWidget
void CollectIndicesFromModel(const QAbstractItemModel &command_hierarchy_model,
const QModelIndex &parent_index);

void ClearSelection();

public slots:
void OnModelReset();
void OnEventSelectionChanged(const QModelIndex &model_index);
void OnSelectionChanged(const QModelIndex &index);

signals:
void GpuTimingDataSelected(uint64_t);

private:
void ResizeColumns();
Expand Down
Loading