KDWinUtils
Helper library for MFC to Qt migration
|
The KSortFilterProxyModel is a QSortFilterProxyModel that allows custom sorting. More...
#include <ksortfilterproxymodel.h>
Public Types | |
using | SortFunction = std::function<bool(const QModelIndex &, const QModelIndex &)> |
Public Member Functions | |
KSortFilterProxyModel (QObject *parent=nullptr) | |
void | setSortFunction (SortFunction fn) |
Protected Member Functions | |
bool | lessThan (const QModelIndex &left, const QModelIndex &right) const override |
The KSortFilterProxyModel is a QSortFilterProxyModel that allows custom sorting.
This class allows to set a custom sorting function that will be used to sort the items in the model. The default implementation of lessThan() will call the custom sorting function if it is set, otherwise it will call the base class implementation.
This class is used internally by KListModel but can also be used as is in new code.
using KSortFilterProxyModel::SortFunction = std::function<bool(const QModelIndex &, const QModelIndex &)> |
KSortFilterProxyModel::KSortFilterProxyModel | ( | QObject * | parent = nullptr | ) |
|
overrideprotected |
Calls the custom sort function if it is set, otherwise calls the base class implementation.
void KSortFilterProxyModel::setSortFunction | ( | SortFunction | fn | ) |
Sets the sort function.