From 605fd4dcc56b194fa2d3c39cd9995aaa696089f8 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 21 Apr 2017 18:38:47 +0100 Subject: [PATCH] Use single QVariant tagging on RDTreeWidgetItem instead of setData * It saves on allocating a vector of vectors and in most cases is all we need. --- qrenderdoc/Windows/APIInspector.cpp | 4 +- .../Windows/Dialogs/EnvironmentEditor.cpp | 6 +- qrenderdoc/Windows/Dialogs/RemoteManager.cpp | 8 +- qrenderdoc/Windows/EventBrowser.cpp | 110 ++++++++++-------- qrenderdoc/Windows/EventBrowser.h | 3 +- .../D3D11PipelineStateViewer.cpp | 22 ++-- .../D3D12PipelineStateViewer.cpp | 22 ++-- .../PipelineState/GLPipelineStateViewer.cpp | 24 ++-- .../VulkanPipelineStateViewer.cpp | 6 +- qrenderdoc/Windows/ShaderViewer.cpp | 10 +- 10 files changed, 114 insertions(+), 101 deletions(-) diff --git a/qrenderdoc/Windows/APIInspector.cpp b/qrenderdoc/Windows/APIInspector.cpp index a9dbfe172..38e1322c0 100644 --- a/qrenderdoc/Windows/APIInspector.cpp +++ b/qrenderdoc/Windows/APIInspector.cpp @@ -94,7 +94,7 @@ void APIInspector::on_apiEvents_itemSelectionChanged() if(!node) return; - APIEvent ev = ui->apiEvents->selectedItems()[0]->data(0, Qt::UserRole).value(); + APIEvent ev = node->tag().value(); if(ev.callstack.count > 0) { @@ -152,7 +152,7 @@ void APIInspector::fillAPIView() if(ev.eventID == draw->eventID) root->setBold(true); - root->setData(0, Qt::UserRole, QVariant::fromValue(ev)); + root->setTag(QVariant::fromValue(ev)); ui->apiEvents->addTopLevelItem(root); diff --git a/qrenderdoc/Windows/Dialogs/EnvironmentEditor.cpp b/qrenderdoc/Windows/Dialogs/EnvironmentEditor.cpp index c8efc847e..5041ba5ed 100644 --- a/qrenderdoc/Windows/Dialogs/EnvironmentEditor.cpp +++ b/qrenderdoc/Windows/Dialogs/EnvironmentEditor.cpp @@ -127,7 +127,7 @@ void EnvironmentEditor::on_variables_currentItemChanged(RDTreeWidgetItem *curren if(!sel) return; - EnvironmentModification mod = sel[0]->data(0, Qt::UserRole).value(); + EnvironmentModification mod = sel->tag().value(); if(!mod.value.empty()) { @@ -214,7 +214,7 @@ void EnvironmentEditor::addModification(EnvironmentModification mod, bool silent node->setText(2, ToQStr(mod.value)); } - node->setData(0, Qt::UserRole, QVariant::fromValue(mod)); + node->setTag(QVariant::fromValue(mod)); ui->variables->setSelectedItem(node); @@ -236,7 +236,7 @@ QList EnvironmentEditor::modifications() for(int i = 0; i < ui->variables->topLevelItemCount(); i++) { EnvironmentModification mod = - ui->variables->topLevelItem(i)->data(0, Qt::UserRole).value(); + ui->variables->topLevelItem(i)->tag().value(); if(!mod.name.empty()) ret.push_back(mod); diff --git a/qrenderdoc/Windows/Dialogs/RemoteManager.cpp b/qrenderdoc/Windows/Dialogs/RemoteManager.cpp index 8378c4fae..46fc59e82 100644 --- a/qrenderdoc/Windows/Dialogs/RemoteManager.cpp +++ b/qrenderdoc/Windows/Dialogs/RemoteManager.cpp @@ -46,7 +46,7 @@ static void setRemoteConnect(RDTreeWidgetItem *item, const RemoteConnect &connec if(!item) return; - item->setData(0, Qt::UserRole, QVariant::fromValue(connect)); + item->setTag(QVariant::fromValue(connect)); } static RemoteConnect getRemoteConnect(RDTreeWidgetItem *item) @@ -54,7 +54,7 @@ static RemoteConnect getRemoteConnect(RDTreeWidgetItem *item) if(!item) return RemoteConnect(); - return item->data(0, Qt::UserRole).value(); + return item->tag().value(); } static void setRemoteHost(RDTreeWidgetItem *item, RemoteHost *host) @@ -62,7 +62,7 @@ static void setRemoteHost(RDTreeWidgetItem *item, RemoteHost *host) if(!item) return; - item->setData(0, Qt::UserRole + 1, QVariant::fromValue((uintptr_t)host)); + item->setTag(QVariant::fromValue((uintptr_t)host)); } static RemoteHost *getRemoteHost(RDTreeWidgetItem *item) @@ -70,7 +70,7 @@ static RemoteHost *getRemoteHost(RDTreeWidgetItem *item) if(!item) return NULL; - return (RemoteHost *)item->data(0, Qt::UserRole + 1).value(); + return (RemoteHost *)item->tag().value(); } RemoteManager::RemoteManager(ICaptureContext &ctx, MainWindow *main) diff --git a/qrenderdoc/Windows/EventBrowser.cpp b/qrenderdoc/Windows/EventBrowser.cpp index 221aec03f..c92ad2858 100644 --- a/qrenderdoc/Windows/EventBrowser.cpp +++ b/qrenderdoc/Windows/EventBrowser.cpp @@ -31,16 +31,26 @@ #include "Code/QRDUtils.h" #include "ui_EventBrowser.h" +struct EventItemTag +{ + EventItemTag() = default; + EventItemTag(uint32_t eventID) : EID(eventID), lastEID(eventID) {} + EventItemTag(uint32_t eventID, uint32_t lastEventID) : EID(eventID), lastEID(lastEventID) {} + uint32_t EID = 0; + uint32_t lastEID = 0; + double duration = -1.0; + bool current = false; + bool find = false; + bool bookmark = false; +}; + +Q_DECLARE_METATYPE(EventItemTag); + enum { COL_NAME = 0, COL_EID = 1, COL_DURATION = 2, - - COL_CURRENT, - COL_FIND, - COL_BOOKMARK, - COL_LAST_EID, }; EventBrowser::EventBrowser(ICaptureContext &ctx, QWidget *parent) @@ -135,17 +145,12 @@ void EventBrowser::OnLogfileLoaded() clearBookmarks(); RDTreeWidgetItem *framestart = new RDTreeWidgetItem({"Frame Start", "0", ""}); - framestart->setData(COL_EID, Qt::UserRole, QVariant(0)); - framestart->setData(COL_CURRENT, Qt::UserRole, QVariant(false)); - framestart->setData(COL_FIND, Qt::UserRole, QVariant(false)); - framestart->setData(COL_BOOKMARK, Qt::UserRole, QVariant(false)); - framestart->setData(COL_LAST_EID, Qt::UserRole, QVariant(0)); + framestart->setTag(QVariant::fromValue(EventItemTag())); frame->addChild(framestart); uint lastEID = AddDrawcalls(frame, m_Ctx.CurDrawcalls()); - frame->setData(COL_EID, Qt::UserRole, QVariant(0)); - frame->setData(COL_LAST_EID, Qt::UserRole, QVariant(lastEID)); + frame->setTag(QVariant::fromValue(EventItemTag(0, lastEID))); ui->events->addTopLevelItem(frame); @@ -206,11 +211,7 @@ uint EventBrowser::AddDrawcalls(RDTreeWidgetItem *parent, lastEID = draws[i + 1].eventID; } - child->setData(COL_EID, Qt::UserRole, QVariant(draws[i].eventID)); - child->setData(COL_CURRENT, Qt::UserRole, QVariant(false)); - child->setData(COL_FIND, Qt::UserRole, QVariant(false)); - child->setData(COL_BOOKMARK, Qt::UserRole, QVariant(false)); - child->setData(COL_LAST_EID, Qt::UserRole, QVariant(lastEID)); + child->setTag(QVariant::fromValue(EventItemTag(draws[i].eventID, lastEID))); parent->addChild(child); } @@ -230,7 +231,7 @@ void EventBrowser::SetDrawcallTimes(RDTreeWidgetItem *node, // look up leaf nodes in the dictionary if(node->childCount() == 0) { - uint eid = node->data(COL_EID, Qt::UserRole).toUInt(); + uint32_t eid = node->tag().value().EID; duration = -1.0; @@ -250,7 +251,9 @@ void EventBrowser::SetDrawcallTimes(RDTreeWidgetItem *node, secs *= 1000000000.0; node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(secs)); - node->setData(COL_DURATION, Qt::UserRole, QVariant(duration)); + EventItemTag tag = node->tag().value(); + tag.duration = duration; + node->setTag(QVariant::fromValue(tag)); return; } @@ -259,7 +262,7 @@ void EventBrowser::SetDrawcallTimes(RDTreeWidgetItem *node, { SetDrawcallTimes(node->child(i), results); - double nd = node->child(i)->data(COL_DURATION, Qt::UserRole).toDouble(); + double nd = node->tag().value().duration; if(nd > 0.0) duration += nd; @@ -275,7 +278,9 @@ void EventBrowser::SetDrawcallTimes(RDTreeWidgetItem *node, secs *= 1000000000.0; node->setText(COL_DURATION, duration < 0.0f ? "" : QString::number(secs)); - node->setData(COL_DURATION, Qt::UserRole, QVariant(duration)); + EventItemTag tag = node->tag().value(); + tag.duration = duration; + node->setTag(QVariant::fromValue(tag)); } void EventBrowser::on_find_clicked() @@ -297,7 +302,7 @@ void EventBrowser::on_bookmark_clicked() RDTreeWidgetItem *n = ui->events->currentItem(); if(n) - toggleBookmark(n->data(COL_LAST_EID, Qt::UserRole).toUInt()); + toggleBookmark(n->tag().value().lastEID); } void EventBrowser::on_timeDraws_clicked() @@ -314,20 +319,21 @@ void EventBrowser::on_events_currentItemChanged(RDTreeWidgetItem *current, RDTre { if(previous) { - previous->setData(COL_CURRENT, Qt::UserRole, QVariant(false)); - RefreshIcon(previous); + EventItemTag tag = previous->tag().value(); + tag.current = false; + previous->setTag(QVariant::fromValue(tag)); + RefreshIcon(previous, tag); } if(!current) return; - current->setData(COL_CURRENT, Qt::UserRole, QVariant(true)); - RefreshIcon(current); + EventItemTag tag = current->tag().value(); + tag.current = true; + current->setTag(QVariant::fromValue(tag)); + RefreshIcon(current, tag); - uint EID = current->data(COL_EID, Qt::UserRole).toUInt(); - uint lastEID = current->data(COL_LAST_EID, Qt::UserRole).toUInt(); - - m_Ctx.SetEventID({this}, EID, lastEID); + m_Ctx.SetEventID({this}, tag.EID, tag.lastEID); highlightBookmarks(); } @@ -664,8 +670,10 @@ void EventBrowser::toggleBookmark(uint32_t EID) if(found) { - found->setData(COL_BOOKMARK, Qt::UserRole, QVariant(false)); - RefreshIcon(found); + EventItemTag tag = found->tag().value(); + tag.bookmark = false; + found->setTag(QVariant::fromValue(tag)); + RefreshIcon(found, tag); } } else @@ -689,8 +697,10 @@ void EventBrowser::toggleBookmark(uint32_t EID) if(found) { - found->setData(COL_BOOKMARK, Qt::UserRole, QVariant(true)); - RefreshIcon(found); + EventItemTag tag = found->tag().value(); + tag.bookmark = true; + found->setTag(QVariant::fromValue(tag)); + RefreshIcon(found, tag); } m_BookmarkStripLayout->removeItem(m_BookmarkSpacer); @@ -724,7 +734,7 @@ void EventBrowser::highlightBookmarks() bool EventBrowser::hasBookmark(RDTreeWidgetItem *node) { if(node) - return hasBookmark(node->data(COL_EID, Qt::UserRole).toUInt()); + return hasBookmark(node->tag().value().EID); return false; } @@ -734,13 +744,13 @@ bool EventBrowser::hasBookmark(uint32_t EID) return m_Bookmarks.contains(EID); } -void EventBrowser::RefreshIcon(RDTreeWidgetItem *item) +void EventBrowser::RefreshIcon(RDTreeWidgetItem *item, EventItemTag tag) { - if(item->data(COL_CURRENT, Qt::UserRole).toBool()) + if(tag.current) item->setIcon(COL_NAME, m_CurrentIcon); - else if(item->data(COL_BOOKMARK, Qt::UserRole).toBool()) + else if(tag.bookmark) item->setIcon(COL_NAME, m_BookmarkIcon); - else if(item->data(COL_FIND, Qt::UserRole).toBool()) + else if(tag.find) item->setIcon(COL_NAME, m_FindIcon); else item->setIcon(COL_NAME, QIcon()); @@ -754,8 +764,8 @@ bool EventBrowser::FindEventNode(RDTreeWidgetItem *&found, RDTreeWidgetItem *par { RDTreeWidgetItem *n = parent->child(i); - uint nEID = n->data(COL_LAST_EID, Qt::UserRole).toUInt(); - uint fEID = found ? found->data(COL_LAST_EID, Qt::UserRole).toUInt() : 0; + uint nEID = n->tag().value().lastEID; + uint fEID = found ? found->tag().value().lastEID : 0; if(nEID >= eventID && (found == NULL || nEID <= fEID)) found = n; @@ -812,8 +822,10 @@ void EventBrowser::ClearFindIcons(RDTreeWidgetItem *parent) { RDTreeWidgetItem *n = parent->child(i); - n->setData(COL_FIND, Qt::UserRole, QVariant(false)); - RefreshIcon(n); + EventItemTag tag = n->tag().value(); + tag.find = false; + n->setTag(QVariant::fromValue(tag)); + RefreshIcon(n, tag); if(n->childCount() > 0) ClearFindIcons(n); @@ -836,8 +848,10 @@ int EventBrowser::SetFindIcons(RDTreeWidgetItem *parent, QString filter) if(n->text(COL_NAME).contains(filter, Qt::CaseInsensitive)) { - n->setData(COL_FIND, Qt::UserRole, QVariant(true)); - RefreshIcon(n); + EventItemTag tag = n->tag().value(); + tag.find = true; + n->setTag(QVariant::fromValue(tag)); + RefreshIcon(n, tag); results++; } @@ -864,7 +878,7 @@ RDTreeWidgetItem *EventBrowser::FindNode(RDTreeWidgetItem *parent, QString filte { RDTreeWidgetItem *n = parent->child(i); - uint eid = n->data(COL_LAST_EID, Qt::UserRole).toUInt(); + uint eid = n->tag().value().lastEID; if(eid > after && n->text(COL_NAME).contains(filter, Qt::CaseInsensitive)) return n; @@ -891,7 +905,7 @@ int EventBrowser::FindEvent(RDTreeWidgetItem *parent, QString filter, uint32_t a { auto n = parent->child(i); - uint eid = n->data(COL_LAST_EID, Qt::UserRole).toUInt(); + uint eid = n->tag().value().lastEID; bool matchesAfter = (forward && eid > after) || (!forward && eid < after); @@ -931,7 +945,7 @@ void EventBrowser::Find(bool forward) RDTreeWidgetItem *node = ui->events->selectedItem(); if(node) - curEID = node->data(COL_LAST_EID, Qt::UserRole).toUInt(); + curEID = node->tag().value().lastEID; int eid = FindEvent(ui->findEvent->text(), curEID, forward); if(eid >= 0) diff --git a/qrenderdoc/Windows/EventBrowser.h b/qrenderdoc/Windows/EventBrowser.h index 0c8cea250..ce3138e1b 100644 --- a/qrenderdoc/Windows/EventBrowser.h +++ b/qrenderdoc/Windows/EventBrowser.h @@ -40,6 +40,7 @@ class QTimer; class QTextStream; class FlowLayout; class SizeDelegate; +struct EventItemTag; class EventBrowser : public QFrame, public IEventBrowser, public ILogViewer { @@ -133,7 +134,7 @@ private: QList m_Bookmarks; QList m_BookmarkButtons; - void RefreshIcon(RDTreeWidgetItem *item); + void RefreshIcon(RDTreeWidgetItem *item, EventItemTag tag); Ui::EventBrowser *ui; ICaptureContext &m_Ctx; diff --git a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp index 77c42e020..fcd04bde7 100644 --- a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp @@ -642,7 +642,7 @@ void D3D11PipelineStateViewer::addResourceRow(const ViewTag &view, const ShaderR RDTreeWidgetItem *node = new RDTreeWidgetItem({slotname, name, typeName, w, h, d, a, format, ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(view)); + node->setTag(QVariant::fromValue(view)); if(viewDetails) { @@ -1002,7 +1002,7 @@ void D3D11PipelineStateViewer::setShaderState(const D3D11Pipe::Shader &stage, QL RDTreeWidgetItem *node = new RDTreeWidgetItem({slotname, name, vecrange, sizestr, ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(i)); + node->setTag(QVariant::fromValue(i)); if(!filledSlot) setEmptyRow(node); @@ -1273,8 +1273,8 @@ void D3D11PipelineStateViewer::setState() new RDTreeWidgetItem({"Index", name, draw ? draw->indexByteWidth : 0, state.m_IA.ibuffer.Offset, (qulonglong)length, ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(VBIBTag(state.m_IA.ibuffer.Buffer, - draw ? draw->indexOffset : 0))); + node->setTag( + QVariant::fromValue(VBIBTag(state.m_IA.ibuffer.Buffer, draw ? draw->indexOffset : 0))); if(!ibufferUsed) setInactiveRow(node); @@ -1292,8 +1292,8 @@ void D3D11PipelineStateViewer::setState() RDTreeWidgetItem *node = new RDTreeWidgetItem({"Index", tr("No Buffer Set"), "-", "-", "-", ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(VBIBTag(state.m_IA.ibuffer.Buffer, - draw ? draw->indexOffset : 0))); + node->setTag( + QVariant::fromValue(VBIBTag(state.m_IA.ibuffer.Buffer, draw ? draw->indexOffset : 0))); setEmptyRow(node); @@ -1338,7 +1338,7 @@ void D3D11PipelineStateViewer::setState() else node = new RDTreeWidgetItem({i, "No Buffer Set", "-", "-", "-", ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(VBIBTag(v.Buffer, v.Offset))); + node->setTag(QVariant::fromValue(VBIBTag(v.Buffer, v.Offset))); if(!filledSlot) setEmptyRow(node); @@ -1425,7 +1425,7 @@ void D3D11PipelineStateViewer::setState() RDTreeWidgetItem *node = new RDTreeWidgetItem({i, name, length, s.Offset, ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(s.Buffer)); + node->setTag(QVariant::fromValue(s.Buffer)); if(!filledSlot) setEmptyRow(node); @@ -1707,7 +1707,7 @@ void D3D11PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in if(stage == NULL) return; - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); TextureDescription *tex = NULL; BufferDescription *buf = NULL; @@ -1945,7 +1945,7 @@ void D3D11PipelineStateViewer::cbuffer_itemActivated(RDTreeWidgetItem *item, int if(stage == NULL) return; - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); if(!tag.canConvert()) return; @@ -1964,7 +1964,7 @@ void D3D11PipelineStateViewer::on_iaLayouts_itemActivated(RDTreeWidgetItem *item void D3D11PipelineStateViewer::on_iaBuffers_itemActivated(RDTreeWidgetItem *item, int column) { - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); if(tag.canConvert()) { diff --git a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp index 484db2117..f48c83ed9 100644 --- a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp @@ -734,10 +734,10 @@ void D3D12PipelineStateViewer::addResourceRow(const ViewTag &view, const D3D12Pi viewDetails = true; } - node->setData(0, Qt::UserRole, QVariant::fromValue(view)); RDTreeWidgetItem *node = new RDTreeWidgetItem({rootel, view.space, regname, name, typeName, w, h, d, a, format, ""}); + node->setTag(QVariant::fromValue(view)); if(viewDetails) { @@ -1154,7 +1154,7 @@ void D3D12PipelineStateViewer::setShaderState(const D3D12Pipe::Shader &stage, QL RDTreeWidgetItem *node = new RDTreeWidgetItem( {rootel, (qulonglong)space, regname, name, (qulonglong)offset, sizestr, ""}); - node->setData(0, Qt::UserRole, tag); + node->setTag(tag); if(!filledSlot) setEmptyRow(node); @@ -1312,8 +1312,8 @@ void D3D12PipelineStateViewer::setState() new RDTreeWidgetItem({"Index", name, draw ? draw->indexByteWidth : 0, (qulonglong)state.m_IA.ibuffer.Offset, (qulonglong)length, ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(VBIBTag(state.m_IA.ibuffer.Buffer, - draw ? draw->indexOffset : 0))); + node->setTag( + QVariant::fromValue(VBIBTag(state.m_IA.ibuffer.Buffer, draw ? draw->indexOffset : 0))); if(!ibufferUsed) setInactiveRow(node); @@ -1331,8 +1331,8 @@ void D3D12PipelineStateViewer::setState() RDTreeWidgetItem *node = new RDTreeWidgetItem({"Index", tr("No Buffer Set"), "-", "-", "-", ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(VBIBTag(state.m_IA.ibuffer.Buffer, - draw ? draw->indexOffset : 0))); + node->setTag( + QVariant::fromValue(VBIBTag(state.m_IA.ibuffer.Buffer, draw ? draw->indexOffset : 0))); setEmptyRow(node); @@ -1377,7 +1377,7 @@ void D3D12PipelineStateViewer::setState() else node = new RDTreeWidgetItem({i, "No Buffer Set", "-", "-", "-", ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(VBIBTag(v.Buffer, v.Offset))); + node->setTag(QVariant::fromValue(VBIBTag(v.Buffer, v.Offset))); if(!filledSlot) setEmptyRow(node); @@ -1439,7 +1439,7 @@ void D3D12PipelineStateViewer::setState() RDTreeWidgetItem *node = new RDTreeWidgetItem({i, name, length, (qulonglong)s.Offset, ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(s.Buffer)); + node->setTag(QVariant::fromValue(s.Buffer)); if(!filledSlot) setEmptyRow(node); @@ -1678,7 +1678,7 @@ void D3D12PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in if(stage == NULL) return; - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); TextureDescription *tex = NULL; BufferDescription *buf = NULL; @@ -1888,7 +1888,7 @@ void D3D12PipelineStateViewer::cbuffer_itemActivated(RDTreeWidgetItem *item, int if(stage == NULL) return; - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); if(!tag.canConvert()) return; @@ -1919,7 +1919,7 @@ void D3D12PipelineStateViewer::on_iaLayouts_itemActivated(RDTreeWidgetItem *item void D3D12PipelineStateViewer::on_iaBuffers_itemActivated(RDTreeWidgetItem *item, int column) { - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); if(tag.canConvert()) { diff --git a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp index 8e5bbb19f..ec464a370 100644 --- a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp @@ -828,7 +828,7 @@ void GLPipelineStateViewer::setShaderState(const GLPipe::Shader &stage, QLabel * RDTreeWidgetItem *node = new RDTreeWidgetItem({slotname, name, byterange, sizestr, ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(i)); + node->setTag(QVariant::fromValue(i)); if(!filledSlot) setEmptyRow(node); @@ -975,7 +975,7 @@ void GLPipelineStateViewer::setShaderState(const GLPipe::Shader &stage, QLabel * RDTreeWidgetItem *node = new RDTreeWidgetItem({binding, slotname, name, dimensions, format, access, ""}); - node->setData(0, Qt::UserRole, tag); + node->setTag(tag); if(!filledSlot) setEmptyRow(node); @@ -1206,8 +1206,7 @@ void GLPipelineStateViewer::setState() RDTreeWidgetItem *node = new RDTreeWidgetItem( {"Element", name, 0, 0, draw ? draw->indexByteWidth : 0, (qulonglong)length, ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(VBIBTag(state.m_VtxIn.ibuffer, - draw ? draw->indexOffset : 0))); + node->setTag(QVariant::fromValue(VBIBTag(state.m_VtxIn.ibuffer, draw ? draw->indexOffset : 0))); if(!ibufferUsed) setInactiveRow(node); @@ -1225,8 +1224,7 @@ void GLPipelineStateViewer::setState() RDTreeWidgetItem *node = new RDTreeWidgetItem({"Element", tr("No Buffer Set"), "-", "-", "-", "-", ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(VBIBTag(state.m_VtxIn.ibuffer, - draw ? draw->indexOffset : 0))); + node->setTag(QVariant::fromValue(VBIBTag(state.m_VtxIn.ibuffer, draw ? draw->indexOffset : 0))); setEmptyRow(node); @@ -1268,7 +1266,7 @@ void GLPipelineStateViewer::setState() RDTreeWidgetItem *node = new RDTreeWidgetItem( {i, name, v.Stride, (qulonglong)offset, v.Divisor, (qulonglong)length, ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(VBIBTag(v.Buffer, v.Offset))); + node->setTag(QVariant::fromValue(VBIBTag(v.Buffer, v.Offset))); if(!filledSlot) setEmptyRow(node); @@ -1331,7 +1329,7 @@ void GLPipelineStateViewer::setState() RDTreeWidgetItem *node = new RDTreeWidgetItem({i, name, length, (qulonglong)state.m_Feedback.Offset[i], ""}); - node->setData(0, Qt::UserRole, QVariant::fromValue(state.m_Feedback.BufferBinding[i])); + node->setTag(QVariant::fromValue(state.m_Feedback.BufferBinding[i])); if(!filledSlot) setEmptyRow(node); @@ -1675,7 +1673,7 @@ void GLPipelineStateViewer::setState() RDTreeWidgetItem *node = new RDTreeWidgetItem({i, name, typeName, w, h, d, a, format, ""}); if(tex) - node->setData(0, Qt::UserRole, QVariant::fromValue(p)); + node->setTag(QVariant::fromValue(p)); if(p == ResourceId()) { @@ -1747,7 +1745,7 @@ void GLPipelineStateViewer::setState() new RDTreeWidgetItem({slot, name, typeName, w, h, d, a, format, ""}); if(tex) - node->setData(0, Qt::UserRole, QVariant::fromValue(ds)); + node->setTag(QVariant::fromValue(ds)); if(ds == ResourceId()) setEmptyRow(node); @@ -1945,7 +1943,7 @@ void GLPipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, int c if(stage == NULL) return; - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); if(tag.canConvert()) { @@ -2029,7 +2027,7 @@ void GLPipelineStateViewer::ubo_itemActivated(RDTreeWidgetItem *item, int column if(stage == NULL) return; - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); if(!tag.canConvert()) return; @@ -2048,7 +2046,7 @@ void GLPipelineStateViewer::on_viAttrs_itemActivated(RDTreeWidgetItem *item, int void GLPipelineStateViewer::on_viBuffers_itemActivated(RDTreeWidgetItem *item, int column) { - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); if(tag.canConvert()) { diff --git a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp index a99567503..84da4ba8b 100644 --- a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp @@ -1976,7 +1976,7 @@ void VulkanPipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, i if(stage == NULL) return; - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); if(tag.canConvert()) { @@ -2062,7 +2062,7 @@ void VulkanPipelineStateViewer::ubo_itemActivated(RDTreeWidgetItem *item, int co if(stage == NULL) return; - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); if(!tag.canConvert()) return; @@ -2081,7 +2081,7 @@ void VulkanPipelineStateViewer::on_viAttrs_itemActivated(RDTreeWidgetItem *item, void VulkanPipelineStateViewer::on_viBuffers_itemActivated(RDTreeWidgetItem *item, int column) { - QVariant tag = item->data(0, Qt::UserRole); + QVariant tag = item->tag(); if(tag.canConvert()) { diff --git a/qrenderdoc/Windows/ShaderViewer.cpp b/qrenderdoc/Windows/ShaderViewer.cpp index eea141386..a49731f97 100644 --- a/qrenderdoc/Windows/ShaderViewer.cpp +++ b/qrenderdoc/Windows/ShaderViewer.cpp @@ -853,10 +853,10 @@ void ShaderViewer::updateDebugging() { if(m_Trace->cbuffers[i][j].rows > 0 || m_Trace->cbuffers[i][j].columns > 0) { - node->setData(0, Qt::UserRole, QVariant::fromValue(CBufferTag(i, j))); RDTreeWidgetItem *node = new RDTreeWidgetItem({ToQStr(m_Trace->cbuffers[i][j].name), "cbuffer", stringRep(m_Trace->cbuffers[i][j], false)}); + node->setTag(QVariant::fromValue(CBufferTag(i, j))); ui->constants->addTopLevelItem(node); } @@ -869,9 +869,9 @@ void ShaderViewer::updateDebugging() if(input.rows > 0 || input.columns > 0) { - node->setData(0, Qt::UserRole, QVariant::fromValue(ResourceTag(i))); RDTreeWidgetItem *node = new RDTreeWidgetItem( {ToQStr(input.name), ToQStr(input.type) + " input", stringRep(input, true)}); + node->setTag(QVariant::fromValue(ResourceTag(i))); ui->constants->addTopLevelItem(node); } @@ -982,7 +982,7 @@ void ShaderViewer::updateDebugging() RDTreeWidgetItem *node = ui->variables->topLevelItem(v++); node->setText(2, stringRep(state.registers[i], false)); - node->setData(0, Qt::UserRole, QVariant::fromValue(state.registers[i])); + node->setTag(QVariant::fromValue(state.registers[i])); } for(int i = 0; i < state.indexableTemps.count; i++) @@ -994,7 +994,7 @@ void ShaderViewer::updateDebugging() RDTreeWidgetItem *child = node->child(t); child->setText(2, stringRep(state.indexableTemps[i][t], false)); - child->setData(0, Qt::UserRole, QVariant::fromValue(state.indexableTemps[i][t])); + child->setTag(QVariant::fromValue(state.indexableTemps[i][t])); } } @@ -1003,7 +1003,7 @@ void ShaderViewer::updateDebugging() RDTreeWidgetItem *node = ui->variables->topLevelItem(v++); node->setText(2, stringRep(state.outputs[i], false)); - node->setData(0, Qt::UserRole, QVariant::fromValue(state.outputs[i])); + node->setTag(QVariant::fromValue(state.outputs[i])); } ui->variables->setUpdatesEnabled(true);