Fix sorting resources by index, vaddr and size (#2308)

* Fix sorting resources by index, vaddr and size
This commit is contained in:
Jan Deinhard 2020-07-25 10:32:44 +02:00 committed by GitHub
parent 00595da5ab
commit 73f99c696f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
#include "common/Helpers.h"
#include "ResourcesWidget.h"
#include "ui_ListDockWidget.h"
#include "core/MainWindow.h"
#include <QVBoxLayout>
@ -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