mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Nomenclature : Add dialog when insert a new nomenclature table
This commit is contained in:
parent
3905371da6
commit
efac27b9b8
@ -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/
|
||||
|
61
sources/factory/qetgraphicstablefactory.cpp
Normal file
61
sources/factory/qetgraphicstablefactory.cpp
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "qetgraphicstablefactory.h"
|
||||
#include "qetgraphicstableitem.h"
|
||||
#include "nomenclaturemodel.h"
|
||||
#include "elementquerywidget.h"
|
||||
#include "diagram.h"
|
||||
#include "qetgraphicsheaderitem.h"
|
||||
|
||||
#include <QDialog>
|
||||
#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<AddTableDialog> 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);
|
||||
}
|
||||
}
|
34
sources/factory/qetgraphicstablefactory.h
Normal file
34
sources/factory/qetgraphicstablefactory.h
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef QETGRAPHICSTABLEFACTORY_H
|
||||
#define QETGRAPHICSTABLEFACTORY_H
|
||||
|
||||
class Diagram;
|
||||
|
||||
/**
|
||||
* @brief The QetGraphicsTableFactory class
|
||||
*/
|
||||
class QetGraphicsTableFactory
|
||||
{
|
||||
public:
|
||||
QetGraphicsTableFactory();
|
||||
|
||||
static void createAndAddNomenclature(Diagram *diagram);
|
||||
};
|
||||
|
||||
#endif // QETGRAPHICSTABLEFACTORY_H
|
187
sources/factory/ui/addtabledialog.cpp
Normal file
187
sources/factory/ui/addtabledialog.cpp
Normal 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_;
|
||||
}
|
79
sources/factory/ui/addtabledialog.h
Normal file
79
sources/factory/ui/addtabledialog.h
Normal 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
|
272
sources/factory/ui/addtabledialog.ui
Normal file
272
sources/factory/ui/addtabledialog.ui
Normal 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>
|
@ -40,6 +40,7 @@
|
||||
#include "bomexportdialog.h"
|
||||
#include "nomenclaturemodel.h"
|
||||
#include "QWidgetAnimation/qwidgetanimation.h"
|
||||
#include "qetgraphicstablefactory.h"
|
||||
|
||||
#include <KAutoSaveFile>
|
||||
|
||||
@ -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());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -195,7 +195,7 @@ void QetGraphicsTableItem::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
||||
static_cast<int>(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());
|
||||
}
|
||||
}
|
||||
|
47
sources/ui/configsaveloaderwidget.cpp
Normal file
47
sources/ui/configsaveloaderwidget.cpp
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#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();
|
||||
}
|
58
sources/ui/configsaveloaderwidget.h
Normal file
58
sources/ui/configsaveloaderwidget.h
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef CONFIGSAVELOADERWIDGET_H
|
||||
#define CONFIGSAVELOADERWIDGET_H
|
||||
|
||||
#include <QGroupBox>
|
||||
|
||||
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
|
52
sources/ui/configsaveloaderwidget.ui
Normal file
52
sources/ui/configsaveloaderwidget.ui
Normal file
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigSaveLoaderWidget</class>
|
||||
<widget class="QGroupBox" name="ConfigSaveLoaderWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>GroupBox</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Configuration</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="m_line_edit"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="m_combo_box"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="m_load_pb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/ico/16x16/folder-open.png</normaloff>:/ico/16x16/folder-open.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="m_save_pb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/ico/16x16/document-save.png</normaloff>:/ico/16x16/document-save.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
65
sources/ui/marginseditdialog.cpp
Normal file
65
sources/ui/marginseditdialog.cpp
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "marginseditdialog.h"
|
||||
#include "ui_marginseditdialog.h"
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
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<MarginsEditDialog> d(new MarginsEditDialog(margins, parent));
|
||||
if (d->exec())
|
||||
{
|
||||
if (accepted) {
|
||||
*accepted = true;
|
||||
}
|
||||
return d->margins();
|
||||
}
|
||||
|
||||
if (accepted) {
|
||||
*accepted = false;
|
||||
}
|
||||
return QMargins();
|
||||
}
|
48
sources/ui/marginseditdialog.h
Normal file
48
sources/ui/marginseditdialog.h
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef MARGINSEDITDIALOG_H
|
||||
#define MARGINSEDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMargins>
|
||||
|
||||
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
|
133
sources/ui/marginseditdialog.ui
Normal file
133
sources/ui/marginseditdialog.ui
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MarginsEditDialog</class>
|
||||
<widget class="QDialog" name="MarginsEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>266</width>
|
||||
<height>172</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="m_bottom_sb">
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="m_left_sb">
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="m_top_sb">
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="m_right_sb">
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<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>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Haut :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Gauche :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Droit :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Bas :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>MarginsEditDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>MarginsEditDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user