Fix ClassesWidget sorting by vtable offset (#1686)

* Fix ClassesWidget sorting by vtable offset
* Force showing base above methods
This commit is contained in:
Adam Zambrzycki 2019-07-24 09:14:14 +02:00 committed by xarkes
parent d89063a203
commit a6e03d4195
2 changed files with 20 additions and 0 deletions

View File

@ -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();

View File

@ -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,