indexsorter.cpp
1 #include "indexsorter.h" 2 #include <QtQml> 3 4 int IndexSorter::compare(const QModelIndex &sourceLeft, const QModelIndex &sourceRight, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) const 5 { 6 Q_UNUSED(proxyModel) 7 return sourceLeft.row() - sourceRight.row(); 8 } 9 10 int ReverseIndexSorter::compare(const QModelIndex &sourceLeft, const QModelIndex &sourceRight, const qqsfpm::QQmlSortFilterProxyModel& proxyModel) const 11 { 12 Q_UNUSED(proxyModel) 13 return sourceRight.row() - sourceLeft.row(); 14 } 15 16 void registerIndexSorterTypes() { 17 qmlRegisterType<IndexSorter>("SortFilterProxyModel.Test", 0, 2, "IndexSorter"); 18 qmlRegisterType<ReverseIndexSorter>("SortFilterProxyModel.Test", 0, 2, "ReverseIndexSorter"); 19 } 20 21 Q_COREAPP_STARTUP_FUNCTION(registerIndexSorterTypes)