QSortFilterProxyModel: Add change signals for properties
Makes it more easily consumable from QML. This patch only adds them for properties where no behavior change (i.e. no "if (m_foo == foo) return" changes) is necessary. The other ones will be done in a follow-up patch. Change-Id: If9f35cf9ac382e6f626db138a88eb14cebda1d52 Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
5142fe2c54
commit
935681eaca
@ -2682,6 +2682,7 @@ void QSortFilterProxyModel::setFilterCaseSensitivity(Qt::CaseSensitivity cs)
|
||||
d->filter_about_to_be_changed();
|
||||
d->filter_data.setCaseSensitivity(cs);
|
||||
d->filter_changed();
|
||||
emit filterCaseSensitivityChanged(cs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2707,6 +2708,7 @@ void QSortFilterProxyModel::setSortCaseSensitivity(Qt::CaseSensitivity cs)
|
||||
|
||||
d->sort_casesensitivity = cs;
|
||||
d->sort();
|
||||
emit sortCaseSensitivityChanged(cs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2732,6 +2734,7 @@ void QSortFilterProxyModel::setSortLocaleAware(bool on)
|
||||
|
||||
d->sort_localeaware = on;
|
||||
d->sort();
|
||||
emit sortLocaleAwareChanged(on);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2856,6 +2859,7 @@ void QSortFilterProxyModel::setSortRole(int role)
|
||||
return;
|
||||
d->sort_role = role;
|
||||
d->sort();
|
||||
emit sortRoleChanged(role);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2881,6 +2885,7 @@ void QSortFilterProxyModel::setFilterRole(int role)
|
||||
d->filter_about_to_be_changed();
|
||||
d->filter_role = role;
|
||||
d->filter_changed();
|
||||
emit filterRoleChanged(role);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2907,6 +2912,7 @@ void QSortFilterProxyModel::setRecursiveFilteringEnabled(bool recursive)
|
||||
d->filter_about_to_be_changed();
|
||||
d->filter_recursive = recursive;
|
||||
d->filter_changed();
|
||||
emit recursiveFilteringEnabledChanged(recursive);
|
||||
}
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 11)
|
||||
|
@ -68,12 +68,12 @@ class Q_CORE_EXPORT QSortFilterProxyModel : public QAbstractProxyModel
|
||||
#endif
|
||||
Q_PROPERTY(int filterKeyColumn READ filterKeyColumn WRITE setFilterKeyColumn)
|
||||
Q_PROPERTY(bool dynamicSortFilter READ dynamicSortFilter WRITE setDynamicSortFilter)
|
||||
Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity)
|
||||
Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity)
|
||||
Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware)
|
||||
Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole)
|
||||
Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole)
|
||||
Q_PROPERTY(bool recursiveFilteringEnabled READ isRecursiveFilteringEnabled WRITE setRecursiveFilteringEnabled)
|
||||
Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity NOTIFY filterCaseSensitivityChanged)
|
||||
Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity NOTIFY sortCaseSensitivityChanged)
|
||||
Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware NOTIFY sortLocaleAwareChanged)
|
||||
Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole NOTIFY sortRoleChanged)
|
||||
Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole NOTIFY filterRoleChanged)
|
||||
Q_PROPERTY(bool recursiveFilteringEnabled READ isRecursiveFilteringEnabled WRITE setRecursiveFilteringEnabled NOTIFY recursiveFilteringEnabledChanged)
|
||||
|
||||
public:
|
||||
explicit QSortFilterProxyModel(QObject *parent = nullptr);
|
||||
@ -185,6 +185,16 @@ public:
|
||||
|
||||
QStringList mimeTypes() const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void dynamicSortFilterChanged(bool dynamicSortFilter);
|
||||
void filterCaseSensitivityChanged(Qt::CaseSensitivity filterCaseSensitivity);
|
||||
void sortCaseSensitivityChanged(Qt::CaseSensitivity sortCaseSensitivity);
|
||||
void sortLocaleAwareChanged(bool sortLocaleAware);
|
||||
void sortRoleChanged(int sortRole);
|
||||
void filterRoleChanged(int filterRole);
|
||||
void recursiveFilteringEnabledChanged(bool recursiveFilteringEnabled);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QSortFilterProxyModel)
|
||||
Q_DISABLE_COPY(QSortFilterProxyModel)
|
||||
|
Loading…
Reference in New Issue
Block a user