sortOrder/setSortOrder property

svn path=/trunk/KDE/kdebase/runtime/; revision=1190489
This commit is contained in:
Marco Martin 2010-10-27 21:19:03 +00:00
parent 540606d0ed
commit a84b230ddc
2 changed files with 10 additions and 0 deletions

View File

@ -83,6 +83,7 @@ void DataModel::setSortRole(const QString &role)
{
QSortFilterProxyModel::setSortRole(m_internalDataModel->roleNameToId(role));
m_sortRole = role;
sort(0, sortOrder());
}
QString DataModel::sortRole() const
@ -90,6 +91,12 @@ QString DataModel::sortRole() const
return m_sortRole;
}
void DataModel::setSortOrder(const Qt::SortOrder order)
{
sort(0, order);
}
InternalDataModel::InternalDataModel(DataModel* parent)

View File

@ -41,6 +41,7 @@ class DataModel : public QSortFilterProxyModel
Q_PROPERTY(QString filterRegExp READ filterRegExp WRITE setFilterRegExp)
Q_PROPERTY(QString filterRole READ filterRole WRITE setFilterRole)
Q_PROPERTY(QString sortRole READ sortRole WRITE setSortRole)
Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder)
friend class InternalDataModel;
@ -63,6 +64,8 @@ public:
void setSortRole(const QString &role);
QString sortRole() const;
void setSortOrder(const Qt::SortOrder order);
private:
InternalDataModel *m_internalDataModel;
QString m_filterRole;