From 73f99c696f0154fab565c6c190a5fbd663f91b8f Mon Sep 17 00:00:00 2001 From: Jan Deinhard Date: Sat, 25 Jul 2020 10:32:44 +0200 Subject: [PATCH] Fix sorting resources by index, vaddr and size (#2308) * Fix sorting resources by index, vaddr and size --- src/widgets/ResourcesWidget.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/widgets/ResourcesWidget.cpp b/src/widgets/ResourcesWidget.cpp index 00340d5d..6ca7ddff 100644 --- a/src/widgets/ResourcesWidget.cpp +++ b/src/widgets/ResourcesWidget.cpp @@ -1,5 +1,6 @@ #include "common/Helpers.h" #include "ResourcesWidget.h" +#include "ui_ListDockWidget.h" #include "core/MainWindow.h" #include @@ -41,6 +42,23 @@ QVariant ResourcesModel::data(const QModelIndex &index, int role) const default: return QVariant(); } + case Qt::EditRole: + switch (index.column()) { + case NAME: + return res.name; + case VADDR: + return res.vaddr; + case INDEX: + return res.index; + case TYPE: + return res.type; + case SIZE: + return res.size; + case LANG: + return res.lang; + default: + return QVariant(); + } case Qt::UserRole: return QVariant::fromValue(res); default: @@ -86,8 +104,11 @@ ResourcesWidget::ResourcesWidget(MainWindow *main) : model = new ResourcesModel(&resources, this); filterModel = new AddressableFilterProxyModel(model, this); + filterModel->setSortRole(Qt::EditRole); setModels(filterModel); + ui->treeView->sortByColumn(0, Qt::AscendingOrder); + showCount(false); // Configure widget