From 5fdf959077c3a93c0d2a5b233861adfaccc3ff1e Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 24 Aug 2017 14:41:06 +0100 Subject: [PATCH] Double clicking on the selected counter will reveal it in the tree --- .../Dialogs/PerformanceCounterSelection.cpp | 39 ++++++++++++++++++- .../Dialogs/PerformanceCounterSelection.h | 8 ++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.cpp b/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.cpp index f14ec96b2..81f1a94ab 100644 --- a/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.cpp +++ b/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.cpp @@ -87,6 +87,19 @@ QString ToString(CounterFamily family) const int PerformanceCounterSelection::CounterDescriptionRole = Qt::UserRole + 1; const int PerformanceCounterSelection::CounterIdRole = Qt::UserRole + 2; +void PerformanceCounterSelection::expandToNode(QTreeWidgetItem *node) +{ + QTreeWidgetItem *n = node; + while(node != NULL) + { + ui->counterTree->expandItem(node); + node = node->parent(); + } + + if(n) + ui->counterTree->scrollToItem(n); +} + PerformanceCounterSelection::PerformanceCounterSelection(ICaptureContext &ctx, const QList &selectedCounters, QWidget *parent) @@ -120,6 +133,7 @@ PerformanceCounterSelection::PerformanceCounterSelection(ICaptureContext &ctx, // Add QListWidgetItem *listItem = new QListWidgetItem(ui->enabledCounters); listItem->setText(item->text(0)); + listItem->setData(CounterIdRole, d); m_SelectedCounters.insert((GPUCounter)d.toUInt(), listItem); } else @@ -200,6 +214,8 @@ void PerformanceCounterSelection::SetCounters(const QVector counterItem->setData(0, CounterDescriptionRole, desc.description); counterItem->setData(0, CounterIdRole, (uint32_t)desc.counterID); counterItem->setCheckState(0, Qt::Unchecked); + + m_CounterToTreeItem[desc.counterID] = counterItem; } } @@ -310,4 +326,25 @@ void PerformanceCounterSelection::Load() RDDialog::critical(this, tr("Error loading config"), tr("Couldn't open path %1 for reading.").arg(filename)); } -} \ No newline at end of file +} + +void PerformanceCounterSelection::on_enabledCounters_activated(const QModelIndex &index) +{ + QListWidgetItem *item = ui->enabledCounters->item(index.row()); + + if(!item) + return; + + QVariant counterID = item->data(CounterIdRole); + + // locate the item in the description tree + auto it = m_CounterToTreeItem.find((GPUCounter)counterID.toUInt()); + + if(it != m_CounterToTreeItem.end()) + { + ui->counterTree->setCurrentItem(it.value()); + it.value()->setSelected(true); + + expandToNode(it.value()); + } +} diff --git a/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.h b/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.h index 85733d5bf..4a9f3f703 100644 --- a/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.h +++ b/qrenderdoc/Windows/Dialogs/PerformanceCounterSelection.h @@ -33,6 +33,7 @@ class PerformanceCounterSelection; struct ICaptureContext; class QListWidgetItem; +class QTreeWidgetItem; class PerformanceCounterSelection : public QDialog { @@ -48,11 +49,17 @@ public: QList GetSelectedCounters() const; public slots: + // manual slots void Save(); void Load(); +private slots: + // automatic slots + void on_enabledCounters_activated(const QModelIndex &index); + private: void SetCounters(const QVector &descriptions); + void expandToNode(QTreeWidgetItem *node); Ui::PerformanceCounterSelection *ui; @@ -60,6 +67,7 @@ private: QMap m_SelectedCounters; QMap m_CounterToUuid; QMap m_UuidToCounter; + QMap m_CounterToTreeItem; static const int CounterDescriptionRole; static const int CounterIdRole;