auto bottomUpProxy = new TreeProxy(m_bottomUpModel);
bottomUpProxy->setSourceModel(m_bottomUpModel);
+ bottomUpProxy->setSortRole(TreeModel::SortRole);
m_ui->bottomUpResults->setModel(bottomUpProxy);
m_ui->bottomUpResults->hideColumn(TreeModel::FunctionColumn);
m_ui->bottomUpResults->hideColumn(TreeModel::FileColumn);
auto topDownProxy = new TreeProxy(m_topDownModel);
topDownProxy->setSourceModel(m_topDownModel);
+ topDownProxy->setSortRole(TreeModel::SortRole);
m_ui->topDownResults->setModel(topDownProxy);
m_ui->topDownResults->hideColumn(TreeModel::FunctionColumn);
m_ui->topDownResults->hideColumn(TreeModel::FileColumn);
case ModuleColumn:
return i18n("Module");
case AllocationsColumn:
- return i18n("Allocations [-]");
+ return i18n("Allocations");
case TemporaryColumn:
- return i18n("Temporary Allocations [-]");
+ return i18n("Temporary");
case PeakColumn:
- return i18n("Peak [B]");
+ return i18n("Peak");
case LeakedColumn:
- return i18n("Leaked [B]");
+ return i18n("Leaked");
case AllocatedColumn:
- return i18n("Allocated [B]");
+ return i18n("Allocated");
case LocationColumn:
return i18n("Location");
case NUM_COLUMNS:
return {};
}
const auto row = toRow(index);
- if (role == Qt::DisplayRole) {
+ if (role == Qt::DisplayRole || role == SortRole) {
+ KFormat format;
switch (static_cast<Columns>(index.column())) {
case AllocatedColumn:
- return row->allocated;
+ if (role == SortRole) {
+ return row->allocated;
+ } else {
+ return format.formatByteSize(row->allocated);
+ }
case AllocationsColumn:
return row->allocations;
case TemporaryColumn:
return row->temporary;
case PeakColumn:
- return row->peak;
+ if (role == SortRole) {
+ return row->peak;
+ } else {
+ return format.formatByteSize(row->peak);
+ }
case LeakedColumn:
- return row->leaked;
+ if (role == SortRole) {
+ return row->leaked;
+ } else {
+ return format.formatByteSize(row->leaked);
+ }
case FunctionColumn:
return row->location->function;
case ModuleColumn:
NUM_COLUMNS
};
+ enum Roles {
+ SortRole = Qt::UserRole
+ };
+
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;