Skip to content

Commit

Permalink
fix sorting order of location in caller callee view
Browse files Browse the repository at this point in the history
fixes: #466
  • Loading branch information
lievenhey committed Mar 1, 2023
1 parent 09a11b1 commit 9520607
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/models/callercalleemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class LocationCostModelImpl : public HashModel<Data::SourceLocationCostMap, Mode
{
if (role == SortRole) {
if (column == Location) {
return fileLine.toString();
return QVariant::fromValue(fileLine);
}
column -= NUM_BASE_COLUMNS;
if (column < m_totalCosts.numTypes()) {
Expand Down
17 changes: 12 additions & 5 deletions src/models/callercalleeproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@

#pragma once

#include "data.h"
#include <QSortFilterProxyModel>

namespace Data {
struct Symbol;
struct FileLine;
}

namespace CallerCalleeProxyDetail {
bool match(const QSortFilterProxyModel* proxy, const Data::Symbol& symbol);
bool match(const QSortFilterProxyModel* proxy, const Data::FileLine& fileLine);
Expand Down Expand Up @@ -44,5 +40,16 @@ class CallerCalleeProxy : public QSortFilterProxyModel
return CallerCalleeProxyDetail::match(this, key);
}

bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override
{
QVariant left = source_left.data(sortRole());
QVariant right = source_right.data(sortRole());
if (left.canConvert<Data::FileLine>()) {
return left.value<Data::FileLine>() < right.value<Data::FileLine>();
} else {
return QSortFilterProxyModel::lessThan(source_left, source_right);
}
}

private:
};

0 comments on commit 9520607

Please sign in to comment.