actually sync the roles and only sort when we have an actual model already

This commit is contained in:
Aaron Seigo 2012-10-08 14:15:53 +02:00
parent cbd6bc5758
commit 4e78f327bb

View File

@ -78,6 +78,7 @@ void SortFilterModel::setModel(QAbstractItemModel* model)
connect(model, SIGNAL(modelReset()), this, SLOT(syncRoleNames()));
}
QSortFilterProxyModel::setSourceModel(model);
syncRoleNames();
sourceModelChanged(model);
}
@ -114,7 +115,7 @@ void SortFilterModel::setSortRole(const QString &role)
m_sortRole = role;
if (role.isEmpty()) {
sort(-1, Qt::AscendingOrder);
} else {
} else if (sourceModel()) {
QSortFilterProxyModel::setSortRole(roleNameToId(role));
sort(0, sortOrder());
}