Simplify code in DeviceSortProxyModel
This commit is contained in:
parent
2545ba5926
commit
db0360a994
2 changed files with 1 additions and 18 deletions
|
@ -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()
|
||||
{
|
||||
sort(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue