Export SortFilterModel sort column to QML
Test Plan: Used in model Reviewers: #plasma, broulik Reviewed By: #plasma, broulik Subscribers: broulik, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D21419
This commit is contained in:
parent
e99f653113
commit
39d1db6e49
@ -179,7 +179,7 @@ void SortFilterModel::setSortRole(const QString &role)
|
||||
sort(-1, Qt::AscendingOrder);
|
||||
} else if (sourceModel()) {
|
||||
QSortFilterProxyModel::setSortRole(roleNameToId(role));
|
||||
sort(0, sortOrder());
|
||||
sort(sortColumn(), sortOrder());
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,7 +190,19 @@ QString SortFilterModel::sortRole() const
|
||||
|
||||
void SortFilterModel::setSortOrder(const Qt::SortOrder order)
|
||||
{
|
||||
sort(0, order);
|
||||
if (order == sortOrder()) {
|
||||
return;
|
||||
}
|
||||
sort(sortColumn(), order);
|
||||
}
|
||||
|
||||
void SortFilterModel::setSortColumn(int column)
|
||||
{
|
||||
if (column == sortColumn()) {
|
||||
return;
|
||||
}
|
||||
sort(column, sortOrder());
|
||||
emit sortColumnChanged();
|
||||
}
|
||||
|
||||
QVariantMap SortFilterModel::get(int row) const
|
||||
|
@ -82,6 +82,11 @@ class SortFilterModel : public QSortFilterProxyModel
|
||||
*/
|
||||
Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder)
|
||||
|
||||
/**
|
||||
* Specify which column shoud be used for sorting
|
||||
*/
|
||||
Q_PROPERTY(int sortColumn READ sortColumn WRITE setSortColumn NOTIFY sortColumnChanged)
|
||||
|
||||
/**
|
||||
* How many items are in this model
|
||||
*/
|
||||
@ -112,6 +117,8 @@ public:
|
||||
|
||||
void setSortOrder(const Qt::SortOrder order);
|
||||
|
||||
void setSortColumn(int column);
|
||||
|
||||
int count() const
|
||||
{
|
||||
return QSortFilterProxyModel::rowCount();
|
||||
@ -132,6 +139,7 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void countChanged();
|
||||
void sortColumnChanged();
|
||||
void sourceModelChanged(QObject *);
|
||||
void filterRegExpChanged(const QString &);
|
||||
Q_REVISION(1) void filterStringChanged(const QString &);
|
||||
|
Loading…
Reference in New Issue
Block a user