diff --git a/qelectrotech.pro b/qelectrotech.pro
index 1dee26cad..71d9336b8 100644
--- a/qelectrotech.pro
+++ b/qelectrotech.pro
@@ -105,7 +105,8 @@ INCLUDEPATH += sources \
sources/utils \
sources/pugixml \
sources/dataBase \
- sources/dataBase/ui
+ sources/dataBase/ui \
+ sources/factory/ui
# Fichiers sources
@@ -136,7 +137,8 @@ HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) \
$$files(sources/utils/*.h) \
$$files(sources/pugixml/*.hpp) \
$$files(sources/dataBase/*.h) \
- $$files(sources/dataBase/ui/*.h)
+ $$files(sources/dataBase/ui/*.h) \
+ $$files(sources/factory/ui/*.h)
SOURCES += $$files(sources/*.cpp) \
$$files(sources/editor/*.cpp) \
@@ -166,7 +168,8 @@ SOURCES += $$files(sources/*.cpp) \
$$files(sources/utils/*.cpp) \
$$files(sources/pugixml/*.cpp) \
$$files(sources/dataBase/*.cpp) \
- $$files(sources/dataBase/ui/*.cpp)
+ $$files(sources/dataBase/ui/*.cpp) \
+ $$files(sources/factory/ui/*.cpp)
# Liste des fichiers qui seront incorpores au binaire en tant que ressources Qt
RESOURCES += qelectrotech.qrc
@@ -190,7 +193,8 @@ FORMS += $$files(sources/richtext/*.ui) \
$$files(sources/SearchAndReplace/ui/*.ui) \
$$files(sources/NameList/ui/*.ui) \
$$files(sources/qetgraphicsitem/ViewItem/ui/*.ui) \
- $$files(sources/dataBase/ui/*.ui)
+ $$files(sources/dataBase/ui/*.ui) \
+ $$files(sources/factory/ui/*.ui)
UI_SOURCES_DIR = sources/ui/
UI_HEADERS_DIR = sources/ui/
diff --git a/sources/factory/qetgraphicstablefactory.cpp b/sources/factory/qetgraphicstablefactory.cpp
new file mode 100644
index 000000000..c22a9b4e9
--- /dev/null
+++ b/sources/factory/qetgraphicstablefactory.cpp
@@ -0,0 +1,61 @@
+/*
+ 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 .
+*/
+#include "qetgraphicstablefactory.h"
+#include "qetgraphicstableitem.h"
+#include "nomenclaturemodel.h"
+#include "elementquerywidget.h"
+#include "diagram.h"
+#include "qetgraphicsheaderitem.h"
+
+#include
+#include "addtabledialog.h"
+QetGraphicsTableFactory::QetGraphicsTableFactory()
+{
+
+}
+
+/**
+ * @brief QetGraphicsTableFactory::createAndAddNomenclature
+ * Create a nomenclature table, open a dialog for ask to user the config of the table,
+ * and add it to diagram @diagram;
+ * @param diagram
+ */
+void QetGraphicsTableFactory::createAndAddNomenclature(Diagram *diagram)
+{
+ QScopedPointer d(new AddTableDialog(diagram->views().first()));
+ d->setWindowTitle(QObject::tr("Ajouter une nomenclature"));
+
+ if (d->exec())
+ {
+ auto model = new NomenclatureModel(diagram->project(), diagram->project());
+ model->query(d->queryStr());
+ model->autoHeaders();
+ model->setData(model->index(0,0), int(d->tableAlignment()), Qt::TextAlignmentRole);
+ model->setData(model->index(0,0), d->tableFont(), Qt::FontRole);
+ model->setHeaderData(0, Qt::Horizontal, int(d->headerAlignment()), Qt::TextAlignmentRole);
+ model->setHeaderData(0, Qt::Horizontal, d->headerFont(), Qt::FontRole);
+
+ auto table = new QetGraphicsTableItem();
+ table->setTableName(d->tableName());
+ table->setMargins(d->tableMargins());
+ table->headerItem()->setMargins(d->headerMargins());
+ table->setModel(model);
+ diagram->addItem(table);
+ table->setPos(50,50);
+ }
+}
diff --git a/sources/factory/qetgraphicstablefactory.h b/sources/factory/qetgraphicstablefactory.h
new file mode 100644
index 000000000..b34284d3f
--- /dev/null
+++ b/sources/factory/qetgraphicstablefactory.h
@@ -0,0 +1,34 @@
+/*
+ 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 .
+*/
+#ifndef QETGRAPHICSTABLEFACTORY_H
+#define QETGRAPHICSTABLEFACTORY_H
+
+class Diagram;
+
+/**
+ * @brief The QetGraphicsTableFactory class
+ */
+class QetGraphicsTableFactory
+{
+ public:
+ QetGraphicsTableFactory();
+
+ static void createAndAddNomenclature(Diagram *diagram);
+};
+
+#endif // QETGRAPHICSTABLEFACTORY_H
diff --git a/sources/factory/ui/addtabledialog.cpp b/sources/factory/ui/addtabledialog.cpp
new file mode 100644
index 000000000..769877dac
--- /dev/null
+++ b/sources/factory/ui/addtabledialog.cpp
@@ -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 .
+*/
+#include "addtabledialog.h"
+#include "ui_addtabledialog.h"
+#include "elementquerywidget.h"
+#include "marginseditdialog.h"
+
+#include
+
+/**
+ * @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_;
+}
diff --git a/sources/factory/ui/addtabledialog.h b/sources/factory/ui/addtabledialog.h
new file mode 100644
index 000000000..9771eaafc
--- /dev/null
+++ b/sources/factory/ui/addtabledialog.h
@@ -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 .
+*/
+#ifndef ADDTABLEDIALOG_H
+#define ADDTABLEDIALOG_H
+
+#include
+
+#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
diff --git a/sources/factory/ui/addtabledialog.ui b/sources/factory/ui/addtabledialog.ui
new file mode 100644
index 000000000..3b8b3d6f8
--- /dev/null
+++ b/sources/factory/ui/addtabledialog.ui
@@ -0,0 +1,272 @@
+
+
+ AddTableDialog
+
+
+
+ 0
+ 0
+ 692
+ 623
+
+
+
+ Ajouter un tableau
+
+
+ -
+
+
+ 0
+
+
+
+ Affichage
+
+
+
-
+
+
+ false
+
+
+ Ajuster la taille du tableau au folio
+
+
+ true
+
+
+
+ -
+
+
+ false
+
+
+ Ajouter de nouveau folio et tableau si nécessaire.
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+
+
+
+ Nom du tableau
+
+
+
+ -
+
+
+ Texte des en-têtes
+
+
+
-
+
+
-
+
+ Gauche
+
+
+ -
+
+ Centre
+
+
+ -
+
+ Droite
+
+
+
+
+ -
+
+
+ Police :
+
+
+
+ -
+
+
+ Éditer
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Marges :
+
+
+
+ -
+
+
+ Alignement :
+
+
+
+
+
+
+ -
+
+
+ Texte du tableau
+
+
+
-
+
+
+ Marges :
+
+
+
+ -
+
+
+ Éditer
+
+
+
+ -
+
+
+ Alignement :
+
+
+
+ -
+
+
-
+
+ Gauche
+
+
+ -
+
+ Centre
+
+
+ -
+
+ Droite
+
+
+
+
+ -
+
+
+ Police :
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+ -
+
+
+ Configuration
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ -
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+
+
+ ConfigSaveLoaderWidget
+ QGroupBox
+
+ 1
+
+
+
+
+
+ m_button_box
+ accepted()
+ AddTableDialog
+ accept()
+
+
+ 283
+ 492
+
+
+ 283
+ 256
+
+
+
+
+ m_button_box
+ rejected()
+ AddTableDialog
+ reject()
+
+
+ 283
+ 492
+
+
+ 283
+ 256
+
+
+
+
+
diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp
index 7261f8612..5e441fd22 100644
--- a/sources/qetdiagrameditor.cpp
+++ b/sources/qetdiagrameditor.cpp
@@ -40,6 +40,7 @@
#include "bomexportdialog.h"
#include "nomenclaturemodel.h"
#include "QWidgetAnimation/qwidgetanimation.h"
+#include "qetgraphicstablefactory.h"
#include
@@ -395,30 +396,10 @@ void QETDiagramEditor::setUpActions()
});
//Add a nomenclature item
- m_add_nomenclature = new QAction(QET::Icons::TableOfContent, tr("Ajouter un tableau lambda (Fonctionnalité en cours de devellopement)"),this);
- connect(m_add_nomenclature, &QAction::triggered, [this]()
- {
- if(this->currentDiagramView())
- {
- auto table = new QetGraphicsTableItem();
-
- /*******ONLY FOR TEST DURING DEVEL*********/
- auto model = new NomenclatureModel(this->currentProject(), this->currentProject());
- QString query("SELECT ei.plant, ei.location, ei.label, ei.comment, ei.description, ei.manufacturer, e.pos, di.title, di.folio"
- " FROM element_info ei, element e, diagram_info di"
- " WHERE ei.element_uuid = e.uuid AND e.diagram_uuid = di.diagram_uuid"
- " ORDER BY ei.plant, ei.location, ei.label");
- model->query(query);
- model->autoHeaders();
- model->setData(model->index(0,0), Qt::AlignLeft, Qt::TextAlignmentRole);
- model->setData(model->index(0,0), QETApp::diagramTextsFont(), Qt::FontRole);
- model->setHeaderData(0, Qt::Horizontal, Qt::AlignHCenter, Qt::TextAlignmentRole);
- model->setHeaderData(0, Qt::Horizontal, QETApp::diagramTextsFont(), Qt::FontRole);
- table->setModel(model);
- /******************************************/
-
- this->currentDiagramView()->diagram()->addItem(table);
- table->setPos(50,50);
+ m_add_nomenclature = new QAction(QET::Icons::TableOfContent, tr("Ajouter une nomenclature"), this);
+ connect(m_add_nomenclature, &QAction::triggered, [this]() {
+ if(this->currentDiagramView()) {
+ QetGraphicsTableFactory::createAndAddNomenclature(this->currentDiagramView()->diagram());
}
});
diff --git a/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.cpp b/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.cpp
index e15e1cc3b..1c1e8eb74 100644
--- a/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.cpp
+++ b/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.cpp
@@ -195,7 +195,7 @@ void QetGraphicsTableItem::paint(QPainter *painter, const QStyleOptionGraphicsIt
static_cast(cell_height) - m_margin.top() - m_margin.bottom());
auto index_row = m_previous_table ? i + m_previous_table->displayNRowOffset() : i;
painter->drawText(QRectF(top_left, size),
- m_model->data(m_model->index(0,0), Qt::TextAlignmentRole).toInt(),
+ m_model->data(m_model->index(0,0), Qt::TextAlignmentRole).toInt() | Qt::AlignVCenter,
m_model->index(index_row, j).data().toString());
}
}
diff --git a/sources/ui/configsaveloaderwidget.cpp b/sources/ui/configsaveloaderwidget.cpp
new file mode 100644
index 000000000..5b9b859d8
--- /dev/null
+++ b/sources/ui/configsaveloaderwidget.cpp
@@ -0,0 +1,47 @@
+/*
+ Copyright 2006-2019 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 .
+*/
+#include "configsaveloaderwidget.h"
+#include "ui_configsaveloaderwidget.h"
+
+ConfigSaveLoaderWidget::ConfigSaveLoaderWidget(QWidget *parent) :
+ QGroupBox(parent),
+ ui(new Ui::ConfigSaveLoaderWidget)
+{
+ ui->setupUi(this);
+}
+
+ConfigSaveLoaderWidget::~ConfigSaveLoaderWidget()
+{
+ delete ui;
+}
+
+QString ConfigSaveLoaderWidget::selectedText() const {
+ return ui->m_combo_box->currentText();
+}
+
+QString ConfigSaveLoaderWidget::text() const {
+ return ui->m_line_edit->text();
+}
+
+void ConfigSaveLoaderWidget::on_m_load_pb_clicked() {
+ emit loadClicked();
+}
+
+void ConfigSaveLoaderWidget::on_m_save_pb_clicked() {
+ emit saveClicked();
+}
diff --git a/sources/ui/configsaveloaderwidget.h b/sources/ui/configsaveloaderwidget.h
new file mode 100644
index 000000000..a73bc23d9
--- /dev/null
+++ b/sources/ui/configsaveloaderwidget.h
@@ -0,0 +1,58 @@
+/*
+ Copyright 2006-2019 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 .
+*/
+#ifndef CONFIGSAVELOADERWIDGET_H
+#define CONFIGSAVELOADERWIDGET_H
+
+#include
+
+namespace Ui {
+class ConfigSaveLoaderWidget;
+}
+
+/**
+ * @brief The ConfigSaveLoaderWidget class
+ * This group box provide 4 widget:
+ * A combo box with the available config.
+ * A push button to load the selected config of combo box
+ * A line edit to edit the text of the config to save
+ * A push button to save the config
+ */
+class ConfigSaveLoaderWidget : public QGroupBox
+{
+ Q_OBJECT
+
+ public:
+ explicit ConfigSaveLoaderWidget(QWidget *parent = nullptr);
+ ~ConfigSaveLoaderWidget();
+
+ QString selectedText() const;
+ QString text()const;
+
+ signals:
+ void loadClicked();
+ void saveClicked();
+
+ private slots:
+ void on_m_load_pb_clicked();
+ void on_m_save_pb_clicked();
+
+ private:
+ Ui::ConfigSaveLoaderWidget *ui;
+};
+
+#endif // CONFIGSAVELOADERWIDGET_H
diff --git a/sources/ui/configsaveloaderwidget.ui b/sources/ui/configsaveloaderwidget.ui
new file mode 100644
index 000000000..152b4263c
--- /dev/null
+++ b/sources/ui/configsaveloaderwidget.ui
@@ -0,0 +1,52 @@
+
+
+ ConfigSaveLoaderWidget
+
+
+
+ 0
+ 0
+ 400
+ 300
+
+
+
+ GroupBox
+
+
+ Configuration
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+
+ :/ico/16x16/folder-open.png:/ico/16x16/folder-open.png
+
+
+
+ -
+
+
+
+
+
+
+ :/ico/16x16/document-save.png:/ico/16x16/document-save.png
+
+
+
+
+
+
+
+
diff --git a/sources/ui/marginseditdialog.cpp b/sources/ui/marginseditdialog.cpp
new file mode 100644
index 000000000..6819715eb
--- /dev/null
+++ b/sources/ui/marginseditdialog.cpp
@@ -0,0 +1,65 @@
+/*
+ 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 .
+*/
+#include "marginseditdialog.h"
+#include "ui_marginseditdialog.h"
+
+#include
+
+MarginsEditDialog::MarginsEditDialog(QMargins margins, QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::MarginsEditDialog)
+{
+ ui->setupUi(this);
+ ui->m_top_sb->setValue(margins.top());
+ ui->m_left_sb->setValue(margins.left());
+ ui->m_right_sb->setValue(margins.right());
+ ui->m_bottom_sb->setValue(margins.bottom());
+}
+
+MarginsEditDialog::~MarginsEditDialog()
+{
+ delete ui;
+}
+
+QMargins MarginsEditDialog::margins() const {
+ return QMargins(ui->m_left_sb->value(), ui->m_top_sb->value(), ui->m_right_sb->value(), ui->m_bottom_sb->value());
+}
+
+/**
+ * @brief MarginsEditDialog::getMargins
+ * @param margins : margins to set by default
+ * @param accepted : bool to know if dialog is accepted
+ * @param parent : parent widget.
+ * @return The a margins with the edited value if dialog is accepted or a default constructed QMargins() if dialog is rejected
+ */
+QMargins MarginsEditDialog::getMargins(QMargins margins, bool *accepted, QWidget *parent)
+{
+ QScopedPointer d(new MarginsEditDialog(margins, parent));
+ if (d->exec())
+ {
+ if (accepted) {
+ *accepted = true;
+ }
+ return d->margins();
+ }
+
+ if (accepted) {
+ *accepted = false;
+ }
+ return QMargins();
+}
diff --git a/sources/ui/marginseditdialog.h b/sources/ui/marginseditdialog.h
new file mode 100644
index 000000000..f47a63acb
--- /dev/null
+++ b/sources/ui/marginseditdialog.h
@@ -0,0 +1,48 @@
+/*
+ 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 .
+*/
+#ifndef MARGINSEDITDIALOG_H
+#define MARGINSEDITDIALOG_H
+
+#include
+#include
+
+namespace Ui {
+class MarginsEditDialog;
+}
+
+/**
+ * @brief The MarginsEditDialog class
+ * A simple dialog to edit QMargins
+ */
+class MarginsEditDialog : public QDialog
+{
+ Q_OBJECT
+
+ public:
+ explicit MarginsEditDialog(QMargins margins = QMargins(), QWidget *parent = nullptr);
+ ~MarginsEditDialog();
+
+ QMargins margins() const;
+
+ static QMargins getMargins(QMargins margins = QMargins(), bool *accepted = nullptr, QWidget *parent = nullptr);
+
+ private:
+ Ui::MarginsEditDialog *ui;
+};
+
+#endif // MARGINSEDITDIALOG_H
diff --git a/sources/ui/marginseditdialog.ui b/sources/ui/marginseditdialog.ui
new file mode 100644
index 000000000..253a755cf
--- /dev/null
+++ b/sources/ui/marginseditdialog.ui
@@ -0,0 +1,133 @@
+
+
+ MarginsEditDialog
+
+
+
+ 0
+ 0
+ 266
+ 172
+
+
+
+ Dialog
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ Haut :
+
+
+
+ -
+
+
+ Gauche :
+
+
+
+ -
+
+
+ Droit :
+
+
+
+ -
+
+
+ Bas :
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ MarginsEditDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ MarginsEditDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+