actually sync the roles and only sort when we have an actual model already
This commit is contained in:
parent
cbd6bc5758
commit
4e78f327bb
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user