Skip to content

Commit

Permalink
sortproxymodel: check if source model is a proxy model
Browse files Browse the repository at this point in the history
if the source model is a proxy model, the source model's source
model might be changed and our sortproxymodel won't get notified.
This might happen when we try to pass a QML-based proxy model as
source model, like KItemModel.KSortFilterProxyModel for example.
  • Loading branch information
BLumia committed Jul 24, 2024
1 parent e3fd152 commit 5e88dde
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions qt/model_view/sortProxyModel/sortproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ void SortProxyModel::setSourceModel(QAbstractItemModel *model)
connect(model, &QAbstractItemModel::dataChanged, this, &SortProxyModel::handleDataChanged);
connect(model, &QAbstractItemModel::rowsInserted, this, &SortProxyModel::handleRowsInserted);
connect(model, &QAbstractItemModel::rowsRemoved, this, &SortProxyModel::handleRowsRemoved);
QAbstractProxyModel * proxyModel = qobject_cast<QAbstractProxyModel*>(model);
if (proxyModel)
{
connect(proxyModel, &QAbstractProxyModel::sourceModelChanged, this, &SortProxyModel::resetInternalData);
}
}
endResetModel();
}
Expand Down

0 comments on commit 5e88dde

Please sign in to comment.