Attempt to fix devices issue

This commit is contained in:
Jonas Kvinge
2018-11-28 17:45:50 +01:00
parent 9fb3d06aac
commit 29a39b4e7f
5 changed files with 36 additions and 30 deletions

View File

@@ -30,11 +30,11 @@
DeviceStateFilterModel::DeviceStateFilterModel(QObject *parent, DeviceManager::State state)
: QSortFilterProxyModel(parent),
state_(state)
{
connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(ProxyRowCountChanged()));
connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(ProxyRowCountChanged()));
connect(this, SIGNAL(modelReset()), SLOT(ProxyRowCountChanged()));
state_(state) {
connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(ProxyRowCountChanged(QModelIndex, int, int)));
connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(ProxyRowCountChanged(QModelIndex, int, int)));
connect(this, SIGNAL(modelReset()), this, SLOT(ProxyRowCountChanged()));
}
bool DeviceStateFilterModel::filterAcceptsRow(int row, const QModelIndex&) const {
@@ -45,6 +45,10 @@ void DeviceStateFilterModel::ProxyRowCountChanged() {
emit IsEmptyChanged(rowCount() == 0);
}
void DeviceStateFilterModel::ProxyRowCountChanged(QModelIndex index, int first, int last) {
emit IsEmptyChanged(rowCount() == 0);
}
void DeviceStateFilterModel::setSourceModel(QAbstractItemModel *sourceModel) {
QSortFilterProxyModel::setSourceModel(sourceModel);
setDynamicSortFilter(true);