diff --git a/qqmlsortfilterproxymodel.cpp b/qqmlsortfilterproxymodel.cpp index 4745d4e..61cde40 100644 --- a/qqmlsortfilterproxymodel.cpp +++ b/qqmlsortfilterproxymodel.cpp @@ -9,9 +9,18 @@ QQmlSortFilterProxyModel::QQmlSortFilterProxyModel(QObject *parent) : { connect(this, &QAbstractProxyModel::sourceModelChanged, this, &QQmlSortFilterProxyModel::updateRoles); connect(this, &QAbstractItemModel::modelReset, this, &QQmlSortFilterProxyModel::updateRoles); + connect(this, &QAbstractItemModel::rowsInserted, this, &QQmlSortFilterProxyModel::countChanged); + connect(this, &QAbstractItemModel::rowsRemoved, this, &QQmlSortFilterProxyModel::countChanged); + connect(this, &QAbstractItemModel::modelReset, this, &QQmlSortFilterProxyModel::countChanged); + connect(this, &QAbstractItemModel::layoutChanged, this, &QQmlSortFilterProxyModel::countChanged); setDynamicSortFilter(true); } +int QQmlSortFilterProxyModel::count() const +{ + return rowCount(); +} + QString QQmlSortFilterProxyModel::filterRoleName() const { return m_filterRoleName; diff --git a/qqmlsortfilterproxymodel.h b/qqmlsortfilterproxymodel.h index 916f113..206092b 100644 --- a/qqmlsortfilterproxymodel.h +++ b/qqmlsortfilterproxymodel.h @@ -7,6 +7,7 @@ class QQmlSortFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT + Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QString filterRoleName READ filterRoleName WRITE setFilterRoleName NOTIFY filterRoleNameChanged) Q_PROPERTY(QString filterPattern READ filterPattern WRITE setFilterPattern NOTIFY filterPatternChanged) Q_PROPERTY(PatternSyntax filterPatternSyntax READ filterPatternSyntax WRITE setFilterPatternSyntax NOTIFY filterPatternSyntaxChanged) @@ -29,6 +30,8 @@ public: QQmlSortFilterProxyModel(QObject* parent = 0); + int count() const; + QString filterRoleName() const; void setFilterRoleName(QString filterRoleName); @@ -53,6 +56,8 @@ public: void setSortExpression(QQmlScriptString compareScriptString); signals: + void countChanged(); + void filterRoleNameChanged(); void filterPatternSyntaxChanged(); void filterPatternChanged();