Allow model to be set to 0
This commit is contained in:
parent
91313b5eb5
commit
bfcc27e01d
@ -67,13 +67,21 @@ int SortFilterModel::roleNameToId(const QString &name)
|
||||
|
||||
void SortFilterModel::setModel(QObject *source)
|
||||
{
|
||||
QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(source);
|
||||
QAbstractItemModel *model = 0;
|
||||
if (source) {
|
||||
model = qobject_cast<QAbstractItemModel *>(source);
|
||||
if (!model) {
|
||||
kWarning() << "Error: QAbstractItemModel type expected";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceModel()) {
|
||||
disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(syncRoleNames()));
|
||||
}
|
||||
if (model) {
|
||||
connect(model, SIGNAL(modelReset()), this, SLOT(syncRoleNames()));
|
||||
}
|
||||
QSortFilterProxyModel::setSourceModel(model);
|
||||
sourceModelChanged(model);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user