#include "AdvancedFilterDialog.h" #include "ui_AdvancedFilterDialog.h" AdvancedFilterDialog::AdvancedFilterDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AdvancedFilterDialog) { ui->setupUi(this); makeConnections(); } AdvancedFilterDialog::~AdvancedFilterDialog() { delete ui; } /*************************************************************************************************/ void AdvancedFilterDialog::setActiveScopes(QMap options) { QMap::const_iterator i; for(i = options.constBegin(); i != options.constEnd(); i++) { auto item = new QListWidgetItem(i.key(), ui->listWidget); item->setCheckState(i.value() ? Qt::Checked : Qt::Unchecked); ui->listWidget->addItem(item); } } /*************************************************************************************************/ QMap AdvancedFilterDialog::getActiveScopes() const { QMap options; for(int i = 0; i < ui->listWidget->count(); ++i) { QListWidgetItem* item = ui->listWidget->item(i); options[item->text()] = item->checkState() == Qt::Checked; } return options; } /*************************************************************************************************/ void AdvancedFilterDialog::checkAll() { for(int i = 0; i < ui->listWidget->count(); ++i) { ui->listWidget->item(i)->setCheckState(Qt::Checked); } } /*************************************************************************************************/ void AdvancedFilterDialog::uncheckAll() { for(int i = 0; i < ui->listWidget->count(); ++i) { ui->listWidget->item(i)->setCheckState(Qt::Unchecked); } } /*************************************************************************************************/ void AdvancedFilterDialog::makeConnections() { connect(ui->checkAllButton, &QPushButton::clicked, this, &AdvancedFilterDialog::checkAll); connect(ui->uncheckAllButton, &QPushButton::clicked, this, &AdvancedFilterDialog::uncheckAll); }