Nomenclature : Add dialog when insert a new nomenclature table

This commit is contained in:
Claveau Joshua
2020-05-05 20:38:31 +02:00
parent 3905371da6
commit efac27b9b8
14 changed files with 1050 additions and 29 deletions

View File

@@ -0,0 +1,187 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "addtabledialog.h"
#include "ui_addtabledialog.h"
#include "elementquerywidget.h"
#include "marginseditdialog.h"
#include <QFontDialog>
/**
* @brief AddTableDialog::AddNomenclatureDialog
* @param parent
*/
AddTableDialog::AddTableDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddTableDialog)
{
ui->setupUi(this);
ui->m_header_font_pb->setText(m_header_font.family());
ui->m_table_font_pb->setText(m_table_font.family());
ui->m_tab->addTab(m_query_widget, tr("Contenu"));
ui->m_config_gb->setDisabled(true);
}
/**
* @brief AddTableDialog::~AddNomenclatureDialog
*/
AddTableDialog::~AddTableDialog() {
delete ui;
}
/**
* @brief AddTableDialog::setQueryWidget
* Not implemented yet
* @param widget
*/
void AddTableDialog::setQueryWidget(QWidget *widget) {
Q_UNUSED(widget)
}
/**
* @brief AddTableDialog::queryStr
* @return
*/
QString AddTableDialog::queryStr() {
return m_query_widget->queryStr();
}
/**
* @brief AddTableDialog::adjustTableToFolio
* @return
*/
bool AddTableDialog::adjustTableToFolio() const {
return ui->m_adjust_table_size_cb->isChecked();
}
/**
* @brief AddTableDialog::addNewTableToNewDiagram
* @return
*/
bool AddTableDialog::addNewTableToNewDiagram() const {
return ui->m_add_table_and_folio->isChecked();
}
/**
* @brief AddTableDialog::tableName
* @return
*/
QString AddTableDialog::tableName() const {
return ui->m_table_name_le->text();
}
/**
* @brief AddTableDialog::headerMargins
* @return
*/
QMargins AddTableDialog::headerMargins() const {
return m_header_margins;
}
/**
* @brief AddTableDialog::headerAlignment
* @return
*/
Qt::Alignment AddTableDialog::headerAlignment() const
{
switch (ui->m_header_alignment_cb->currentIndex()) {
case 0 :
return Qt::AlignLeft;
case 1:
return Qt::AlignCenter;
default:
return Qt::AlignRight;
}
}
/**
* @brief AddTableDialog::headerFont
* @return
*/
QFont AddTableDialog::headerFont() const {
return m_header_font;
}
/**
* @brief AddTableDialog::tableMargins
* @return
*/
QMargins AddTableDialog::tableMargins() const {
return m_table_margins;
}
/**
* @brief AddTableDialog::tableAlignment
* @return
*/
Qt::Alignment AddTableDialog::tableAlignment() const
{
switch (ui->m_table_alignment_cb->currentIndex()) {
case 0 :
return Qt::AlignLeft;
case 1:
return Qt::AlignCenter;
default:
return Qt::AlignRight;
}
}
/**
* @brief AddTableDialog::tableFont
* @return
*/
QFont AddTableDialog::tableFont() const {
return m_table_font;
}
void AddTableDialog::on_m_header_font_pb_clicked()
{
bool b;
auto font = QFontDialog::getFont(&b, m_header_font, this, tr("Sélectionné la police des en tête du tableau"));
if (b) {
m_header_font = font;
ui->m_header_font_pb->setText(font.family());
}
}
void AddTableDialog::on_m_table_font_pb_clicked()
{
bool b;
auto font = QFontDialog::getFont(&b, m_table_font, this, tr("Sélectionné la police des cellules du tableau"));
if (b) {
m_table_font = font;
ui->m_table_font_pb->setText(font.family());
}
}
void AddTableDialog::on_m_edit_header_margins_pb_clicked()
{
bool accept;
auto margins_ = MarginsEditDialog::getMargins(m_header_margins, &accept, this);
if (accept)
m_header_margins = margins_;
}
void AddTableDialog::on_m_table_margins_pb_clicked()
{
bool accept;
auto margins_ = MarginsEditDialog::getMargins(m_table_margins, &accept, this);
if (accept)
m_table_margins = margins_;
}

View File

@@ -0,0 +1,79 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ADDTABLEDIALOG_H
#define ADDTABLEDIALOG_H
#include <QDialog>
#include "elementquerywidget.h"
#include "qetapp.h"
namespace Ui {
class AddTableDialog;
}
/**
* @brief The AddTableDialog class
* Provide a dialog used to edit the properties of table befor adding to a diagram.
* The main difference betwen this dialog and the widget used to edit the properties of table
* is that the dialog have two extra check box.
* One for adjust the size of the table to diagram
* Second for add new tables on new folios if the table can't fit into diagram
*/
class AddTableDialog : public QDialog
{
Q_OBJECT
public:
explicit AddTableDialog(QWidget *parent = nullptr);
~AddTableDialog();
void setQueryWidget(QWidget *widget);
QString queryStr();
bool adjustTableToFolio() const;
bool addNewTableToNewDiagram() const;
QString tableName() const;
QMargins headerMargins() const;
Qt::Alignment headerAlignment() const;
QFont headerFont() const;
QMargins tableMargins() const;
Qt::Alignment tableAlignment() const;
QFont tableFont() const;
private slots:
void on_m_header_font_pb_clicked();
void on_m_table_font_pb_clicked();
void on_m_edit_header_margins_pb_clicked();
void on_m_table_margins_pb_clicked();
private:
Ui::AddTableDialog *ui;
ElementQueryWidget *m_query_widget = new ElementQueryWidget();
QMargins m_header_margins = QMargins(5,5,10,5),
m_table_margins = QMargins(5,5,10,5);
QFont m_header_font = QETApp::diagramTextsFont();
QFont m_table_font = QETApp::diagramTextsFont();
};
#endif // ADDTABLEDIALOG_H

View File

@@ -0,0 +1,272 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddTableDialog</class>
<widget class="QDialog" name="AddTableDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>692</width>
<height>623</height>
</rect>
</property>
<property name="windowTitle">
<string>Ajouter un tableau</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="m_tab">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="m_display_tab">
<attribute name="title">
<string>Affichage</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="m_adjust_table_size_cb">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Ajuster la taille du tableau au folio</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="m_add_table_and_folio">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Ajouter de nouveau folio et tableau si nécessaire.</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="m_table_name_le">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Nom du tableau</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Texte des en-têtes</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QComboBox" name="m_header_alignment_cb">
<item>
<property name="text">
<string>Gauche</string>
</property>
</item>
<item>
<property name="text">
<string>Centre</string>
</property>
</item>
<item>
<property name="text">
<string>Droite</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Police :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="m_edit_header_margins_pb">
<property name="text">
<string>Éditer</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="m_header_font_pb">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Marges :</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Alignement :</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Texte du tableau</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Marges :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="m_table_margins_pb">
<property name="text">
<string>Éditer</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Alignement :</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_table_alignment_cb">
<item>
<property name="text">
<string>Gauche</string>
</property>
</item>
<item>
<property name="text">
<string>Centre</string>
</property>
</item>
<item>
<property name="text">
<string>Droite</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Police :</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="m_table_font_pb">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="ConfigSaveLoaderWidget" name="m_config_gb">
<property name="title">
<string>Configuration</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="m_button_box">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ConfigSaveLoaderWidget</class>
<extends>QGroupBox</extends>
<header>configsaveloaderwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>m_button_box</sender>
<signal>accepted()</signal>
<receiver>AddTableDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>283</x>
<y>492</y>
</hint>
<hint type="destinationlabel">
<x>283</x>
<y>256</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_button_box</sender>
<signal>rejected()</signal>
<receiver>AddTableDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>283</x>
<y>492</y>
</hint>
<hint type="destinationlabel">
<x>283</x>
<y>256</y>
</hint>
</hints>
</connection>
</connections>
</ui>