Simplify code in DeviceSortProxyModel

This commit is contained in:
Nicolas Fella 2019-05-04 17:37:13 +02:00 committed by Nicolas Fella
parent 2545ba5926
commit db0360a994
2 changed files with 1 additions and 18 deletions

View file

@ -27,20 +27,7 @@ DevicesSortProxyModel::DevicesSortProxyModel(DevicesModel* devicesModel)
: QSortFilterProxyModel(devicesModel)
{
setSourceModel(devicesModel);
}
void DevicesSortProxyModel::setSourceModel(QAbstractItemModel* devicesModel)
{
QSortFilterProxyModel::setSourceModel(devicesModel);
if (devicesModel) {
setSortRole(DevicesModel::StatusModelRole);
connect(devicesModel, &QAbstractItemModel::dataChanged, this, &DevicesSortProxyModel::sourceDataChanged);
}
sort(0);
}
void DevicesSortProxyModel::sourceDataChanged()
{
setSortRole(DevicesModel::StatusModelRole);
sort(0);
}

View file

@ -33,10 +33,6 @@ public:
explicit DevicesSortProxyModel(DevicesModel* devicesModel = nullptr);
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
void setSourceModel(QAbstractItemModel* sourceModel) override;
public Q_SLOTS:
void sourceDataChanged();
};
#endif // DEVICESSORTPROXYMODEL_H