diff --git a/sources/ui/bomexportdialog.cpp b/sources/ui/bomexportdialog.cpp index 70538c97a..95c3e3b64 100644 --- a/sources/ui/bomexportdialog.cpp +++ b/sources/ui/bomexportdialog.cpp @@ -1,4 +1,4 @@ - /* + /* Copyright 2006-2019 The QElectroTech Team This file is part of QElectroTech. @@ -50,6 +50,56 @@ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) : m_export_info.insert("folio_num", tr("Numéro de folio")); m_export_info.insert("designation_qty", tr("Quantité (Numéro d'article)")); + m_button_group.setExclusive(false); + m_button_group.addButton(ui->m_all_cb, 0); + m_button_group.addButton(ui->m_terminal_cb, 1); + m_button_group.addButton(ui->m_simple_cb, 2); + m_button_group.addButton(ui->m_button_cb, 3); + m_button_group.addButton(ui->m_coil_cb, 4); + m_button_group.addButton(ui->m_protection_cb, 5); + connect(&m_button_group, static_cast(&QButtonGroup::buttonClicked), [this](int id) + { + auto check_box = static_cast(m_button_group.button(0)); + if (id == 0) + { + switch (check_box->checkState()) { + case Qt::Checked : + for (auto button : m_button_group.buttons()) { + button->setChecked(true); + } + break; + case Qt::Unchecked : + for (auto button : m_button_group.buttons()) { + button->setChecked(false); + } + break; + default: break; + } + } + else + { + int checked = 0; + for (int i=1 ; i<5 ; ++i) { + if (m_button_group.button(i)->isChecked()) {++checked;} + } + + switch (checked) + { + case 0 : + check_box->setCheckState(Qt::Unchecked); + break; + case 5: + check_box->setCheckState(Qt::Checked); + break; + default: + check_box->setCheckState(Qt::PartiallyChecked); + break; + } + } + + updateQueryLine(); + }); + setUpItems(); createDataBase(); fillSavedQuery(); @@ -481,15 +531,28 @@ QString BOMExportDialog::queryStr() const QString from = " FROM bom"; QString count = ui->m_format_as_bom_rb->isChecked() ? QString(", COUNT(*) AS designation_qty ") : QString(); QString where; - if (ui->m_button_rb->isChecked()) { - where = " WHERE element_subtype = 'commutator'"; - } else if (ui->m_terminal_rb->isChecked()) { - where = " WHERE element_type = 'Terminale'"; - } else if (ui->m_coil_rb->isChecked()) { - where = " WHERE element_subtype = 'coil'"; - } else if (ui->m_protection_rb ->isChecked()) { - where = " WHERE element_subtype = 'protection'"; - } + if (ui->m_all_cb->checkState() == Qt::PartiallyChecked) + { + if (ui->m_terminal_cb->isChecked()) { + where = " WHERE element_type = 'Terminale'"; + } + if (ui->m_simple_cb->isChecked()) { + auto str = where.isEmpty() ? " WHERE element_type = 'Simple'" : " AND element_type = 'Simple'"; + where += str; + } + if (ui->m_button_cb->isChecked()) { + auto str = where.isEmpty() ? " WHERE element_subtype = 'commutator'" : " AND element_subtype = 'commutator'"; + where += str; + } + if (ui->m_coil_cb->isChecked()) { + auto str = where.isEmpty() ? " WHERE element_subtype = 'coil'" : " AND element_subtype = 'coil'"; + where += str; + } + if (ui->m_protection_cb->isChecked()) { + auto str = where.isEmpty() ? " WHERE element_subtype = 'protection'" : " AND element_subtype = 'protection'"; + where += str; + } + } QString where_bom; if(ui->m_format_as_bom_rb->isChecked()) { @@ -528,18 +591,6 @@ void BOMExportDialog::fillSavedQuery() } } -void BOMExportDialog::on_m_all_rb_clicked() { - updateQueryLine(); -} - -void BOMExportDialog::on_m_terminal_rb_clicked() { - updateQueryLine(); -} - -void BOMExportDialog::on_m_button_rb_clicked() { - updateQueryLine(); -} - void BOMExportDialog::on_m_format_as_nomenclature_rb_toggled(bool checked) { Q_UNUSED(checked) updateQueryLine(); diff --git a/sources/ui/bomexportdialog.h b/sources/ui/bomexportdialog.h index de375e7c0..14b46bf85 100644 --- a/sources/ui/bomexportdialog.h +++ b/sources/ui/bomexportdialog.h @@ -21,6 +21,7 @@ #include #include #include +#include class QListWidgetItem; class QETProject; @@ -48,15 +49,12 @@ class BOMExportDialog : public QDialog void on_m_up_pb_clicked(); void on_m_down_pb_clicked(); void on_m_save_name_le_textChanged(const QString &arg1); - void on_m_all_rb_clicked(); - void on_m_terminal_rb_clicked(); - void on_m_button_rb_clicked(); void on_m_format_as_nomenclature_rb_toggled(bool checked); void on_m_edit_sql_query_cb_clicked(); void on_m_save_current_conf_pb_clicked(); void on_m_load_pb_clicked(); - private: + private: void setUpItems(); QString getBom(); QString headers() const; @@ -75,6 +73,7 @@ class BOMExportDialog : public QDialog QSqlQuery m_insert_query; QString m_custom_query; QHash m_export_info; + QButtonGroup m_button_group; }; #endif // BOMExportDialog_H diff --git a/sources/ui/bomexportdialog.ui b/sources/ui/bomexportdialog.ui index 8b7c2c703..bad9ff5da 100644 --- a/sources/ui/bomexportdialog.ui +++ b/sources/ui/bomexportdialog.ui @@ -6,8 +6,8 @@ 0 0 - 685 - 630 + 576 + 715 @@ -189,9 +189,19 @@ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - + + + + + Simple + + + true + + + + + Tous @@ -200,78 +210,43 @@ - - - - Bornier - - - false - - - - - - - Bouton et commutateur - - - false - - - - - + + Contacteur et relais - - - - - - Organes de protection - - - - - - - - - - Mise en page - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - false - - - - - - Chaque élément portant la même référence sera listé - - - Formater en tant que nomenclature - true - - - - Une même référence utilisé par plusieurs éléments ne sera listé qu'une fois - + + - Formater en tant que liste de matériel + Bouton et commutateur + + + true + + + + + + + Bornier + + + true + + + + + + + Organes de protection + + + true @@ -288,6 +263,54 @@ + + + + Mise en page + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + false + + + + + + Chaque élément portant la même référence sera listé + + + Formater en tant que nomenclature + + + true + + + + + + + Une même référence utilisé par plusieurs éléments ne sera listé qu'une fois + + + Formater en tant que liste de matériel + + + + + + + + + + Qt::Horizontal + + +