From 8cd9b3ba6e0643855f5a66077aacc33087555594 Mon Sep 17 00:00:00 2001 From: Claveau Joshua Date: Sat, 18 Apr 2020 18:11:56 +0200 Subject: [PATCH] Element info query : fix wrong behavior --- sources/dataBase/ui/elementquerywidget.cpp | 32 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/sources/dataBase/ui/elementquerywidget.cpp b/sources/dataBase/ui/elementquerywidget.cpp index 07ceff1f6..8766430dc 100644 --- a/sources/dataBase/ui/elementquerywidget.cpp +++ b/sources/dataBase/ui/elementquerywidget.cpp @@ -156,11 +156,33 @@ QString ElementQueryWidget::queryStr() const if (ui->m_all_cb->checkState() == Qt::PartiallyChecked) { - if (ui->m_terminal_cb->isChecked()) {where += " AND e.type = 'Terminale'";} - if (ui->m_simple_cb->isChecked()) {where += " AND e.type = 'Simple'";} - if (ui->m_button_cb->isChecked()) {where += " AND e.sub_type = 'commutator'";} - if (ui->m_coil_cb->isChecked()) {where += " AND e.sub_type = 'coil'";} - if (ui->m_protection_cb->isChecked()) {where += " AND e.sub_type = 'protection'";} + bool b = false; + where += " AND ("; + if (ui->m_terminal_cb->isChecked()) { + if (b) where +=" OR"; + where += " e.type = 'Terminale'"; + b = true; + } + if (ui->m_simple_cb->isChecked()) { + if (b) where +=" OR"; + where += " e.type = 'Simple'"; + b = true; + } + if (ui->m_button_cb->isChecked()) { + if (b) where +=" OR"; + where += " e.sub_type = 'commutator'"; + b = true; + } + if (ui->m_coil_cb->isChecked()) { + if (b) where +=" OR"; + where += " e.sub_type = 'coil'"; + b = true; + } + if (ui->m_protection_cb->isChecked()) { + if (b) where +=" OR"; + where += " e.sub_type = 'protection'"; + } + where += ")"; }