mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-20 19:19:58 +01:00
CSV export : improve selection type.
This commit is contained in:
@@ -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<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), [this](int id)
|
||||
{
|
||||
auto check_box = static_cast<QCheckBox *>(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();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <QDialog>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
#include <QButtonGroup>
|
||||
|
||||
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 <QString, QString> m_export_info;
|
||||
QButtonGroup m_button_group;
|
||||
};
|
||||
|
||||
#endif // BOMExportDialog_H
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>685</width>
|
||||
<height>630</height>
|
||||
<width>576</width>
|
||||
<height>715</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -189,9 +189,19 @@
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_all_rb">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="m_simple_cb">
|
||||
<property name="text">
|
||||
<string>Simple</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_all_cb">
|
||||
<property name="text">
|
||||
<string>Tous</string>
|
||||
</property>
|
||||
@@ -200,78 +210,43 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_terminal_rb">
|
||||
<property name="text">
|
||||
<string>Bornier</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_button_rb">
|
||||
<property name="text">
|
||||
<string>Bouton et commutateur</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_coil_rb">
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="m_coil_cb">
|
||||
<property name="text">
|
||||
<string>Contacteur et relais</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_protection_rb">
|
||||
<property name="text">
|
||||
<string>Organes de protection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Mise en page</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_format_as_nomenclature_rb">
|
||||
<property name="toolTip">
|
||||
<string>Chaque élément portant la même référence sera listé</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Formater en tant que nomenclature</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_format_as_bom_rb">
|
||||
<property name="toolTip">
|
||||
<string>Une même référence utilisé par plusieurs éléments ne sera listé qu'une fois</string>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="m_button_cb">
|
||||
<property name="text">
|
||||
<string>Formater en tant que liste de matériel</string>
|
||||
<string>Bouton et commutateur</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="m_terminal_cb">
|
||||
<property name="text">
|
||||
<string>Bornier</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="m_protection_cb">
|
||||
<property name="text">
|
||||
<string>Organes de protection</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -288,6 +263,54 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Mise en page</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_format_as_nomenclature_rb">
|
||||
<property name="toolTip">
|
||||
<string>Chaque élément portant la même référence sera listé</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Formater en tant que nomenclature</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_format_as_bom_rb">
|
||||
<property name="toolTip">
|
||||
<string>Une même référence utilisé par plusieurs éléments ne sera listé qu'une fois</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Formater en tant que liste de matériel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
|
||||
Reference in New Issue
Block a user