Enable/Disable devices checkbox now takes filter into account. Fix #1587

This commit is contained in:
morg 2021-07-05 10:11:38 +02:00 committed by Adam Honse
parent cbee33706f
commit ec5e71424c
3 changed files with 8 additions and 4 deletions

View file

@ -146,10 +146,13 @@ void DetectorTableModel::applySettings()
ResourceManager::get()->GetSettingsManager()->SaveSettings();
}
void DetectorTableModel::toggleAll(const bool state)
void DetectorTableModel::toggleAll(const bool state, QSortFilterProxyModel* detectorSortModel)
{
for(unsigned int detector_idx = 0; detector_idx < detectors.size(); detector_idx++)
{
setData(index(detector_idx,1), state, Qt::CheckStateRole);
if(detectorSortModel->mapFromSource(index(detector_idx, 0)).isValid())
{
setData(index(detector_idx,1), state, Qt::CheckStateRole);
}
}
}

View file

@ -1,6 +1,7 @@
#ifndef DETECTORTABLEMODEL_H
#define DETECTORTABLEMODEL_H
#include <QSortFilterProxyModel>
#include <QAbstractTableModel>
#include "ResourceManager.h"
@ -28,7 +29,7 @@ public:
public slots:
void applySettings();
void toggleAll(const bool state);
void toggleAll(const bool state, QSortFilterProxyModel* detectorSortModel);
};
#endif // DETECTORTABLEMODEL_H

View file

@ -64,5 +64,5 @@ void OpenRGBSupportedDevicesPage::on_Filter_textChanged(const QString &arg1)
void OpenRGBSupportedDevicesPage::on_ToggleAllCheckbox_toggled(const bool checked)
{
detectorTableModel->toggleAll(checked);
detectorTableModel->toggleAll(checked, detectorSortModel);
}