mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-18 18:38:51 +00:00
Fix ClassesWidget sorting by vtable offset (#1686)
* Fix ClassesWidget sorting by vtable offset * Force showing base above methods
This commit is contained in:
parent
d89063a203
commit
a6e03d4195
@ -440,6 +440,8 @@ QVariant AnalClassesModel::data(const QModelIndex &index, int role) const
|
||||
return QIcon(new SvgIconEngine(QString(":/img/icons/home.svg"), QPalette::WindowText));
|
||||
}
|
||||
return QVariant();
|
||||
case VTableRole:
|
||||
return -1;
|
||||
case NameRole:
|
||||
return base.className;
|
||||
case TypeRole:
|
||||
@ -470,6 +472,8 @@ QVariant AnalClassesModel::data(const QModelIndex &index, int role) const
|
||||
return QIcon(new SvgIconEngine(QString(":/img/icons/fork.svg"), QPalette::WindowText));
|
||||
}
|
||||
return QVariant();
|
||||
case VTableRole:
|
||||
return QVariant::fromValue(meth.vtableOffset);
|
||||
case OffsetRole:
|
||||
return QVariant::fromValue(meth.addr);
|
||||
case NameRole:
|
||||
@ -547,6 +551,14 @@ bool ClassesSortFilterProxyModel::lessThan(const QModelIndex &left, const QModel
|
||||
}
|
||||
}
|
||||
// fallthrough
|
||||
case ClassesModel::VTABLE: {
|
||||
auto left_vtable = left.data(ClassesModel::VTableRole).toLongLong();
|
||||
auto right_vtable = right.data(ClassesModel::VTableRole).toLongLong();
|
||||
if (left_vtable != right_vtable) {
|
||||
return left_vtable < right_vtable;
|
||||
}
|
||||
}
|
||||
// fallthrough
|
||||
case ClassesModel::NAME:
|
||||
default:
|
||||
QString left_name = left.data(ClassesModel::NameRole).toString();
|
||||
|
@ -53,6 +53,14 @@ public:
|
||||
*/
|
||||
static const int TypeRole = Qt::UserRole + 2;
|
||||
|
||||
/**
|
||||
* @brief VTable role of data for QModelIndex
|
||||
*
|
||||
* will contain values of type long long for sorting
|
||||
* by vtable offset
|
||||
*/
|
||||
static const int VTableRole = Qt::UserRole + 3;
|
||||
|
||||
explicit ClassesModel(QObject *parent = nullptr) : QAbstractItemModel(parent) {}
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
|
Loading…
Reference in New Issue
Block a user