Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
trinity/include/roomlistsortmodel.h

36 lines
985 B
C
Raw Permalink Normal View History

2021-07-21 16:08:15 -04:00
#pragma once
#include <QSortFilterProxyModel>
2022-08-15 21:53:56 -04:00
class RoomListSortModel : public QSortFilterProxyModel {
2021-07-21 16:08:15 -04:00
Q_OBJECT
public:
2022-08-15 21:53:56 -04:00
bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const;
2021-07-21 16:08:15 -04:00
Q_INVOKABLE unsigned int getOriginalIndex(const unsigned int i) const {
auto const proxyIndex = index(i, 0);
auto const sourceIndex = mapToSource(proxyIndex);
2022-08-15 21:53:56 -04:00
if (!sourceIndex.isValid())
2021-07-21 16:08:15 -04:00
return 0;
else
return sourceIndex.row();
}
};
2022-08-15 21:53:56 -04:00
class MemberListSortModel : public QSortFilterProxyModel {
Q_OBJECT
public:
2022-08-15 21:53:56 -04:00
bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const;
Q_INVOKABLE unsigned int getOriginalIndex(const unsigned int i) const {
auto const proxyIndex = index(i, 0);
auto const sourceIndex = mapToSource(proxyIndex);
2022-08-15 21:53:56 -04:00
if (!sourceIndex.isValid())
return 0;
else
return sourceIndex.row();
}
};