rolesorter.h
1 #ifndef ROLESORTER_H 2 #define ROLESORTER_H 3 4 #include "sorter.h" 5 6 namespace qqsfpm { 7 8 class RoleSorter : public Sorter 9 { 10 Q_OBJECT 11 Q_PROPERTY(QString roleName READ roleName WRITE setRoleName NOTIFY roleNameChanged) 12 13 public: 14 using Sorter::Sorter; 15 16 const QString& roleName() const; 17 void setRoleName(const QString& roleName); 18 19 Q_SIGNALS: 20 void roleNameChanged(); 21 22 protected: 23 QPair<QVariant, QVariant> sourceData(const QModelIndex &sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel& proxyModel) const; 24 int compare(const QModelIndex& sourceLeft, const QModelIndex& sourceRight, const QQmlSortFilterProxyModel& proxyModel) const override; 25 26 private: 27 QString m_roleName; 28 }; 29 30 } 31 32 #endif // ROLESORTER_H