Compare commits

..

2 Commits

Author SHA1 Message Date
Martin Marmsoler
f6bef3a365 WIP2 2020-10-11 15:43:51 +02:00
Martin Marmsoler
b69dea1747 WIP 2020-10-11 13:19:20 +02:00
55 changed files with 936 additions and 1840 deletions

5
.gitignore vendored
View File

@@ -1,7 +1,2 @@
*.snap *.snap
.flatpak-builder .flatpak-builder
# Qt build output
*.user
# doxygen Doxyfile output
doc/
QElectroTech.tag

View File

@@ -27,7 +27,6 @@
#include <QtCore/QSharedMemory> #include <QtCore/QSharedMemory>
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) // ### Qt 6: remove
#else #else
#pragma message("@TODO remove code for QT 5.10 or later")
#include <QRandomGenerator> #include <QRandomGenerator>
#endif #endif
#include "singleapplication.h" #include "singleapplication.h"
@@ -107,7 +106,6 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda
qsrand( QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max() ); qsrand( QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max() );
QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( qrand() ) / RAND_MAX * 10 ) ); QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( qrand() ) / RAND_MAX * 10 ) );
#else #else
#pragma message("@TODO remove code for QT 5.10 or later")
quint32 value = QRandomGenerator::global()->generate(); quint32 value = QRandomGenerator::global()->generate();
QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( value ) / RAND_MAX * 10 ) ); QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( value ) / RAND_MAX * 10 ) );
#endif #endif

View File

@@ -3,7 +3,5 @@
<name lang="fr">11- Schémas et plans d'installation, architecturaux et topographiques</name> <name lang="fr">11- Schémas et plans d'installation, architecturaux et topographiques</name>
<name lang="es">11- Dibujos y planos arquitectónicos y topográficos</name> <name lang="es">11- Dibujos y planos arquitectónicos y topográficos</name>
<name lang="da">11- Bygningsmæssige og topografiske installationstegninger og -skemaer</name> <name lang="da">11- Bygningsmæssige og topografiske installationstegninger og -skemaer</name>
<name lang="en">11- Installation, architectural and topographical diagrams and plans</name>
<name lang="be">11- Installatie, bouwkundig en topografische schema's en plannen</name>
</names> </names>
</qet-directory> </qet-directory>

View File

@@ -641,7 +641,6 @@ void ElementsCollectionWidget::search()
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList text_list = text.split("+", QString::SkipEmptyParts); QStringList text_list = text.split("+", QString::SkipEmptyParts);
#else #else
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList text_list = text.split("+", Qt::SkipEmptyParts); QStringList text_list = text.split("+", Qt::SkipEmptyParts);
#endif #endif
QModelIndexList match_index; QModelIndexList match_index;

View File

@@ -754,7 +754,6 @@ QDebug operator<< (QDebug debug, const ElementsLocation &location)
QDebugStateSaver saver(debug); QDebugStateSaver saver(debug);
#if QT_VERSION >= 0x050400 #if QT_VERSION >= 0x050400
#pragma message("@TODO remove code for QT 5.04 or later")
debug.noquote(); debug.noquote();
#else #else
debug.nospace(); debug.nospace();

View File

@@ -27,7 +27,7 @@
- 17 columns of 60.0 px wide by 20.0px high - 17 columns of 60.0 px wide by 20.0px high
- 8 lines of 80.0 px high by 20.0px wide - 8 lines of 80.0 px high by 20.0px wide
\~French Initialise un objet BorderProperties avec les proprietes par Initialise un objet BorderProperties avec les proprietes par
defaut suivantes : defaut suivantes :
- 17 colonnes affichees de 60.0 px de large pour 20.0px de haut - 17 colonnes affichees de 60.0 px de large pour 20.0px de haut
- 8 lignes affichees de 80.0 px de haut pour 20.0px de large - 8 lignes affichees de 80.0 px de haut pour 20.0px de large
@@ -53,11 +53,12 @@ BorderProperties::~BorderProperties() {
/** /**
@brief BorderProperties::operator == @brief BorderProperties::operator ==
@param bp :
\~ @param bp : Other BorderProperties container/class. - other BorderProperties container/class
\~French Autre conteneur BorderProperties - autre conteneur BorderProperties
\~ @return True if it and this container are identical, false otherwise. @return
\~French True si ip et ce conteneur sont identiques, false sinon - true if it and this container are identical, false otherwise
- true si ip et ce conteneur sont identiques, false sinon
*/ */
bool BorderProperties::operator==(const BorderProperties &bp) { bool BorderProperties::operator==(const BorderProperties &bp) {
return( return(
@@ -74,13 +75,12 @@ bool BorderProperties::operator==(const BorderProperties &bp) {
/** /**
@brief BorderProperties::operator != @brief BorderProperties::operator !=
@param bp :
\~ @param bp : - other BorderProperties container/class
Other BorderProperties container/class. - autre conteneur BorderProperties
\~French Autre conteneur BorderProperties @return
\~ @return - false if it and this container are identical, true otherwise
False if it and this container are identical, true otherwise. - false si bp et ce conteneur sont identiques, true sinon
\~French False si bp et ce conteneur sont identiques, true sinon
*/ */
bool BorderProperties::operator!=(const BorderProperties &bp) { bool BorderProperties::operator!=(const BorderProperties &bp) {
return(!(*this == bp)); return(!(*this == bp));
@@ -88,12 +88,11 @@ bool BorderProperties::operator!=(const BorderProperties &bp) {
/** /**
@brief BorderProperties::toXml @brief BorderProperties::toXml
Exports dimensions as XML attributes added to element e. - Exports dimensions as XML attributes added to element e.
\~French Exporte les dimensions sous formes d'attributs XML ajoutes a l'element e. - Exporte les dimensions sous formes d'attributs XML ajoutes a l'element e.
@param e :
\~ @param e : - XML element to which attributes will be added
XML element to which attributes will be added - Element XML auquel seront ajoutes des attributs
\~French Element XML auquel seront ajoutes des attributs
*/ */
void BorderProperties::toXml(QDomElement &e) const { void BorderProperties::toXml(QDomElement &e) const {
e.setAttribute("cols", columns_count); e.setAttribute("cols", columns_count);
@@ -106,12 +105,11 @@ void BorderProperties::toXml(QDomElement &e) const {
/** /**
@brief BorderProperties::fromXml @brief BorderProperties::fromXml
Import dimensions from XML attributes of element e - Import dimensions from XML attributes of element e
\~French Importe les dimensions a partir des attributs XML de l'element e - Importe les dimensions a partir des attributs XML de l'element e
@param e :
\~ @param e : - XML element whose attributes will be read
XML element whose attributes will be read - Element XML dont les attributs seront lus
\~French Element XML dont les attributs seront lus
*/ */
void BorderProperties::fromXml(QDomElement &e) { void BorderProperties::fromXml(QDomElement &e) {
if (e.hasAttribute("cols")) columns_count = e.attribute("cols").toInt(); if (e.hasAttribute("cols")) columns_count = e.attribute("cols").toInt();
@@ -124,15 +122,14 @@ void BorderProperties::fromXml(QDomElement &e) {
/** /**
@brief BorderProperties::toSettings @brief BorderProperties::toSettings
Export dimensions in a QSettings object. - Export dimensions in a QSettings object.
\~French Exporte les dimensions dans une configuration. - Exporte les dimensions dans une configuration.
@param settings :
\~ @param settings : - QSettings object to write
QSettings object to write - Parametres a ecrire
\~French Parametres a ecrire @param prefix :
\~ @param prefix : - prefix to be added before the names of the parameters
prefix to be added before the names of the parameters - prefixe a ajouter devant les noms des parametres
\~French prefixe a ajouter devant les noms des parametres
*/ */
void BorderProperties::toSettings(QSettings &settings, const QString &prefix) const { void BorderProperties::toSettings(QSettings &settings, const QString &prefix) const {
settings.setValue(prefix + "cols", columns_count); settings.setValue(prefix + "cols", columns_count);
@@ -145,12 +142,14 @@ void BorderProperties::toSettings(QSettings &settings, const QString &prefix) co
/** /**
@brief BorderProperties::fromSettings @brief BorderProperties::fromSettings
Import dimensions from a QSettings object. - Import dimensions from a QSettings object.
\~French Importe les dimensions depuis une configuration. - Importe les dimensions depuis une configuration.
\~ @param settings : QSettings object to read @param settings :
\~French Parametres a lire - QSettings object to read
\~ @param prefix : prefix to be added before the names of the parameters - Parametres a lire
\~French prefixe a ajouter devant les noms des parametres @param prefix :
- prefix to be added before the names of the parameters
- prefixe a ajouter devant les noms des parametres
*/ */
void BorderProperties::fromSettings(QSettings &settings, const QString &prefix) { void BorderProperties::fromSettings(QSettings &settings, const QString &prefix) {
columns_count = settings.value(prefix + "cols", columns_count).toInt(); columns_count = settings.value(prefix + "cols", columns_count).toInt();

View File

@@ -32,16 +32,9 @@
#define MIN_ROW_HEIGHT 5.0 #define MIN_ROW_HEIGHT 5.0
/** /**
@brief BorderTitleBlock::BorderTitleBlock Constructeur simple : construit une bordure en recuperant les dimensions
Simple constructor:
build a border by recovering the dimensions
in the application configuration.
\~French Constructeur simple :
construit une bordure en recuperant les dimensions
dans la configuration de l'application. dans la configuration de l'application.
\~ @param parent : @param parent QObject parent de ce BorderTitleBlock
\~French QObject parent de ce BorderTitleBlock
*/ */
BorderTitleBlock::BorderTitleBlock(QObject *parent) : BorderTitleBlock::BorderTitleBlock(QObject *parent) :
QObject(parent) QObject(parent)
@@ -68,119 +61,95 @@ BorderTitleBlock::BorderTitleBlock(QObject *parent) :
} }
/** /**
@brief BorderTitleBlock::~BorderTitleBlock Destructeur - ne fait rien
\~French Destructeur - ne fait rien
*/ */
BorderTitleBlock::~BorderTitleBlock() { BorderTitleBlock::~BorderTitleBlock() {
} }
/** /**
@brief BorderTitleBlock::titleBlockRect * @brief BorderTitleBlock::titleBlockRect
@return the rectangle of the titleblock in scene coordinate. * @return the rectangle of the titleblock in scene coordinate.
*/ */
QRectF BorderTitleBlock::titleBlockRect() const QRectF BorderTitleBlock::titleBlockRect() const
{ {
if (m_edge == Qt::BottomEdge) if (m_edge == Qt::BottomEdge)
return QRectF(diagram_rect_.bottomLeft(), return QRectF(diagram_rect_.bottomLeft(), QSize(diagram_rect_.width(), m_titleblock_template_renderer -> height()));
QSize(diagram_rect_.width(),
m_titleblock_template_renderer -> height()
));
else else
return QRectF(diagram_rect_.topRight(), return QRectF(diagram_rect_.topRight(), QSize(m_titleblock_template_renderer -> height(), diagram_rect_.height()));
QSize(m_titleblock_template_renderer -> height(),
diagram_rect_.height()
));
} }
/**
@brief BorderTitleBlock::titleblockInformation
@return
*/
DiagramContext BorderTitleBlock::titleblockInformation() const { DiagramContext BorderTitleBlock::titleblockInformation() const {
return m_titleblock_template_renderer->context(); return m_titleblock_template_renderer->context();
} }
/** /**
@brief BorderTitleBlock::titleBlockRectForQPainter * @brief BorderTitleBlock::titleBlockRectForQPainter
@return The title block rect to use with the QPainter in the method draw. * @return The title block rect to use with the QPainter in the method draw.
The returned rect is alway horizontal * The returned rect is alway horizontal (like displayed at the bottom of rect) only the top left change of pos
(like displayed at the bottom of rect) only the top left change of pos * according to the edge where the title block need to be displayed.
according to the edge where the title block need to be displayed. * Rect according to edge:
Rect according to edge: * Bottom : top left is at the bottom left edge of the diagram rect.
Bottom : top left is at the bottom left edge of the diagram rect. * Right : top left is at the bottom right of diagram rect. Befor use this rect you need to rotate the QPainter by -90°
Right : top left is at the bottom right of diagram rect. * for snap the rect at the right edge of diagram.
Befor use this rect you need to rotate the QPainter by -90°
for snap the rect at the right edge of diagram.
*/ */
QRectF BorderTitleBlock::titleBlockRectForQPainter() const QRectF BorderTitleBlock::titleBlockRectForQPainter() const
{ {
//Rect at bottom have same position and dimension of displayed rect if (m_edge == Qt::BottomEdge) //Rect at bottom have same position and dimension of displayed rect
if (m_edge == Qt::BottomEdge)
return titleBlockRect(); return titleBlockRect();
else else
return QRectF (diagram_rect_.bottomRight(), return QRectF (diagram_rect_.bottomRight(), QSize(diagram_rect_.height(), m_titleblock_template_renderer -> height()));
QSize(diagram_rect_.height(),
m_titleblock_template_renderer -> height()
));
} }
/** /**
@brief BorderTitleBlock::borderAndTitleBlockRect * @brief BorderTitleBlock::borderAndTitleBlockRect
@return the bounding rectangle of diagram and titleblock. * @return the bounding rectangle of diagram and titleblock.
It's like unite outsideBorderRect and titleBlockRect. * It's like unite outsideBorderRect and titleBlockRect.
The rect is in scene coordinate * The rect is in scene coordinate
*/ */
QRectF BorderTitleBlock::borderAndTitleBlockRect() const { QRectF BorderTitleBlock::borderAndTitleBlockRect() const {
return diagram_rect_ | titleBlockRect(); return diagram_rect_ | titleBlockRect();
} }
/** /**
@brief BorderTitleBlock::columnsRect * @brief BorderTitleBlock::columnsRect
@return The columns rect in scene coordinate. * @return The columns rect in scene coordinate.
If column is not displayed, return a null QRectF * If column is not displayed, return a null QRectF
*/ */
QRectF BorderTitleBlock::columnsRect() const QRectF BorderTitleBlock::columnsRect() const
{ {
if (!display_columns_) return QRectF(); if (!display_columns_) return QRectF();
return QRectF (Diagram::margin, return QRectF (Diagram::margin, Diagram::margin, (columns_count_*columns_width_) + rows_header_width_, columns_header_height_);
Diagram::margin,
(columns_count_*columns_width_) + rows_header_width_,
columns_header_height_);
} }
/** /**
@brief BorderTitleBlock::rowsRect * @brief BorderTitleBlock::rowsRect
@return The rows rect in scene coordinate. * @return The rows rect in scene coordinate.
If row is not displayed, return a null QRectF * If row is not displayed, return a null QRectF
*/ */
QRectF BorderTitleBlock::rowsRect() const QRectF BorderTitleBlock::rowsRect() const
{ {
if (!display_rows_) return QRectF(); if (!display_rows_) return QRectF();
return QRectF (Diagram::margin, return QRectF (Diagram::margin, Diagram::margin, rows_header_width_, (rows_count_*rows_height_) + columns_header_height_);
Diagram::margin,
rows_header_width_,
(rows_count_*rows_height_) + columns_header_height_);
} }
/** /**
@brief BorderTitleBlock::outsideBorderRect * @brief BorderTitleBlock::outsideBorderRect
@return The rect of outside border (diagram with columns and rows) * @return The rect of outside border (diagram with columns and rows)
The rect is in scene coordinate * The rect is in scene coordinate
*/ */
QRectF BorderTitleBlock::outsideBorderRect() const QRectF BorderTitleBlock::outsideBorderRect() const
{ {
return QRectF (Diagram::margin, return QRectF (Diagram::margin, Diagram::margin,
Diagram::margin,
(columns_width_*columns_count_) + rows_header_width_, (columns_width_*columns_count_) + rows_header_width_,
(rows_height_*rows_count_) + columns_header_height_); (rows_height_*rows_count_) + columns_header_height_);
} }
/** /**
@brief BorderTitleBlock::insideBorderRect * @brief BorderTitleBlock::insideBorderRect
@return The rect of the inside border, in other word, the drawing area. * @return The rect of the inside border, in other word, the drawing area.
This method take care about if rows or columns are displayed or not. * This method take care about if rows or columns are displayed or not.
The rect is in scene coordinate * The rect is in scene coordinate
*/ */
QRectF BorderTitleBlock::insideBorderRect() const QRectF BorderTitleBlock::insideBorderRect() const
{ {
@@ -196,7 +165,6 @@ QRectF BorderTitleBlock::insideBorderRect() const
} }
/** /**
@brief BorderTitleBlock::titleBlockToXml
Exports the title block current values to XML. Exports the title block current values to XML.
@param xml_elmt the XML element attributes will be added to @param xml_elmt the XML element attributes will be added to
*/ */
@@ -205,7 +173,6 @@ void BorderTitleBlock::titleBlockToXml(QDomElement &xml_elmt) {
} }
/** /**
@brief BorderTitleBlock::titleBlockFromXml
Reads the title block values from XML. Reads the title block values from XML.
@param xml_elmt the XML element values will be read from @param xml_elmt the XML element values will be read from
*/ */
@@ -216,7 +183,6 @@ void BorderTitleBlock::titleBlockFromXml(const QDomElement &xml_elmt) {
} }
/** /**
@brief BorderTitleBlock::borderToXml
Exports the border current settings to XML. Exports the border current settings to XML.
@param xml_elmt the XML element attributes will be added to @param xml_elmt the XML element attributes will be added to
*/ */
@@ -234,7 +200,6 @@ void BorderTitleBlock::borderToXml(QDomElement &xml_elmt) {
} }
/** /**
@brief BorderTitleBlock::borderFromXml
Reads the border settings from XML. Reads the border settings from XML.
@param xml_elmt the XML element values will be read from @param xml_elmt the XML element values will be read from
*/ */
@@ -248,8 +213,7 @@ void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
double cols_width = xml_elmt.attribute("colsize").toDouble(&ok); double cols_width = xml_elmt.attribute("colsize").toDouble(&ok);
if (ok) setColumnsWidth(cols_width); if (ok) setColumnsWidth(cols_width);
// backward compatibility: // backward compatibility: diagrams saved with 0.1 version have a "height" attribute
// diagrams saved with 0.1 version have a "height" attribute
if (xml_elmt.hasAttribute("rows") && xml_elmt.hasAttribute("rowsize")) { if (xml_elmt.hasAttribute("rows") && xml_elmt.hasAttribute("rowsize")) {
// rows counts // rows counts
int rows_count = xml_elmt.attribute("rows").toInt(&ok); int rows_count = xml_elmt.attribute("rows").toInt(&ok);
@@ -272,9 +236,7 @@ void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
} }
/** /**
@brief BorderTitleBlock::exportTitleBlock @return les proprietes du cartouches
@return the properties of the titleblock
\~French les proprietes du cartouches
*/ */
TitleBlockProperties BorderTitleBlock::exportTitleBlock() { TitleBlockProperties BorderTitleBlock::exportTitleBlock() {
TitleBlockProperties ip; TitleBlockProperties ip;
@@ -298,8 +260,8 @@ TitleBlockProperties BorderTitleBlock::exportTitleBlock() {
} }
/** /**
@brief BorderTitleBlock::importTitleBlock * @brief BorderTitleBlock::importTitleBlock
@param ip the new properties of titleblock * @param ip the new properties of titleblock
*/ */
void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) { void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) {
setAuthor(ip.author); setAuthor(ip.author);
@@ -320,15 +282,12 @@ void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) {
additional_fields_ = ip.context; additional_fields_ = ip.context;
emit(needFolioData()); // Note: we expect additional data to be provided emit(needFolioData()); // Note: we expect additional data to be provided
// through setFolioData(), // through setFolioData(), which in turn calls updateDiagramContextForTitleBlock().
// which in turn calls updateDiagramContextForTitleBlock().
emit(needTitleBlockTemplate(ip.template_name)); emit(needTitleBlockTemplate(ip.template_name));
} }
/** /**
@brief BorderTitleBlock::exportBorder @return les proprietes de la bordure
@return border properties
\~French les proprietes de la bordure
*/ */
BorderProperties BorderTitleBlock::exportBorder() { BorderProperties BorderTitleBlock::exportBorder() {
BorderProperties bp; BorderProperties bp;
@@ -344,9 +303,7 @@ BorderProperties BorderTitleBlock::exportBorder() {
} }
/** /**
@brief BorderTitleBlock::importBorder @param bp les nouvelles proprietes de la bordure
@param bp : the new properties of the border
\~French les nouvelles proprietes de la bordure
*/ */
void BorderTitleBlock::importBorder(const BorderProperties &bp) { void BorderTitleBlock::importBorder(const BorderProperties &bp) {
setColumnsHeaderHeight(bp.columns_header_height); setColumnsHeaderHeight(bp.columns_header_height);
@@ -360,7 +317,6 @@ void BorderTitleBlock::importBorder(const BorderProperties &bp) {
} }
/** /**
@brief BorderTitleBlock::titleBlockTemplate
@return the titleblock template used to render the titleblock @return the titleblock template used to render the titleblock
@see TitleBlockTemplateRenderer::titleBlockTemplate() @see TitleBlockTemplateRenderer::titleBlockTemplate()
*/ */
@@ -369,19 +325,14 @@ const TitleBlockTemplate *BorderTitleBlock::titleBlockTemplate() {
} }
/** /**
@brief BorderTitleBlock::setTitleBlockTemplate @param titleblock_template The new titleblock template to use to render the titleblock
@param titleblock_template:
The new titleblock template to use to render the titleblock
@see TitleBlockTemplateRenderer::setTitleBlockTemplate() @see TitleBlockTemplateRenderer::setTitleBlockTemplate()
*/ */
void BorderTitleBlock::setTitleBlockTemplate( void BorderTitleBlock::setTitleBlockTemplate(const TitleBlockTemplate *titleblock_template) {
const TitleBlockTemplate *titleblock_template) { m_titleblock_template_renderer -> setTitleBlockTemplate(titleblock_template);
m_titleblock_template_renderer -> setTitleBlockTemplate(
titleblock_template);
} }
/** /**
@brief BorderTitleBlock::titleBlockTemplateName
@return The name of the template used to render the titleblock. @return The name of the template used to render the titleblock.
*/ */
QString BorderTitleBlock::titleBlockTemplateName() const { QString BorderTitleBlock::titleBlockTemplateName() const {
@@ -390,11 +341,10 @@ QString BorderTitleBlock::titleBlockTemplateName() const {
} }
/** /**
@brief BorderTitleBlock::titleBlockTemplateChanged
This slot may be used to inform this class that the given title block This slot may be used to inform this class that the given title block
template has changed. template has changed. The title block-dedicated rendering cache will thus be
The title block-dedicated rendering cache will thus be flushed. flushed.
@param template_name : Name of the title block template that has changed @param template_name Name of the title block template that has changed
*/ */
void BorderTitleBlock::titleBlockTemplateChanged(const QString &template_name) { void BorderTitleBlock::titleBlockTemplateChanged(const QString &template_name) {
if (titleBlockTemplateName() != template_name) return; if (titleBlockTemplateName() != template_name) return;
@@ -402,18 +352,14 @@ void BorderTitleBlock::titleBlockTemplateChanged(const QString &template_name) {
} }
/** /**
@brief BorderTitleBlock::titleBlockTemplateRemoved
This slot has to be used to inform this class that the given title block This slot has to be used to inform this class that the given title block
template is about to be removed and is no longer accessible. This class template is about to be removed and is no longer accessible. This class
will either use the provided optional TitleBlockTemplate or the default will either use the provided optional TitleBlockTemplate or the default
title block provided by QETApp::defaultTitleBlockTemplate() title block provided by QETApp::defaultTitleBlockTemplate()
@param removed_template_name : @param template_name Name of the title block template that has changed
Name of the title block template that has changed
@param new_template (Optional) title block template to use instead @param new_template (Optional) title block template to use instead
*/ */
void BorderTitleBlock::titleBlockTemplateRemoved( void BorderTitleBlock::titleBlockTemplateRemoved(const QString &removed_template_name, const TitleBlockTemplate *new_template) {
const QString &removed_template_name,
const TitleBlockTemplate *new_template) {
if (titleBlockTemplateName() != removed_template_name) return; if (titleBlockTemplateName() != removed_template_name) return;
if (new_template) { if (new_template) {
@@ -424,9 +370,7 @@ void BorderTitleBlock::titleBlockTemplateRemoved(
} }
/** /**
@brief BorderTitleBlock::displayTitleBlock @param di true pour afficher le cartouche, false sinon
@param di : true to display the title block, false otherwise
\~French true pour afficher le cartouche, false sinon
*/ */
void BorderTitleBlock::displayTitleBlock(bool di) { void BorderTitleBlock::displayTitleBlock(bool di) {
bool change = (di != display_titleblock_); bool change = (di != display_titleblock_);
@@ -435,9 +379,7 @@ void BorderTitleBlock::displayTitleBlock(bool di) {
} }
/** /**
@brief BorderTitleBlock::displayColumns @param dc true pour afficher les entetes des colonnes, false sinon
@param dc : true to display the column headers, false otherwise
\~French true pour afficher les entetes des colonnes, false sinon
*/ */
void BorderTitleBlock::displayColumns(bool dc) { void BorderTitleBlock::displayColumns(bool dc) {
bool change = (dc != display_columns_); bool change = (dc != display_columns_);
@@ -446,9 +388,7 @@ void BorderTitleBlock::displayColumns(bool dc) {
} }
/** /**
@brief BorderTitleBlock::displayRows @param dr true pour afficher les entetes des lignes, false sinon
@param dr : true to display line headers, false otherwise
\~French true pour afficher les entetes des lignes, false sinon
*/ */
void BorderTitleBlock::displayRows(bool dr) { void BorderTitleBlock::displayRows(bool dr) {
bool change = (dr != display_rows_); bool change = (dr != display_rows_);
@@ -457,13 +397,9 @@ void BorderTitleBlock::displayRows(bool dr) {
} }
/** /**
@brief BorderTitleBlock::displayBorder @param db true pour afficher la bordure du schema, false sinon
@param db : true to display the border of the diagram, false otherwise Note : si l'affichage de la bordure est ainsi desactivee, les lignes et
\~French true pour afficher la bordure du schema, false sinon colonnes ne seront pas dessinees.
\~ @note : if the border display is deactivated,
the rows and columns will not be drawn.
\~French si l'affichage de la bordure est ainsi desactivee,
les lignes et colonnes ne seront pas dessinees.
*/ */
void BorderTitleBlock::displayBorder(bool db) { void BorderTitleBlock::displayBorder(bool db) {
bool change = (db != display_border_); bool change = (db != display_border_);
@@ -472,34 +408,29 @@ void BorderTitleBlock::displayBorder(bool db) {
} }
/** /**
@brief BorderTitleBlock::slot_setAutoPageNum * @brief BorderTitleBlock::slot_setAutoPageNum
@param pageAutoNum : * @param pageAutoNum
Set Page (Folio) Auto Num * Set Page (Folio) Auto Num
*/ */
void BorderTitleBlock::slot_setAutoPageNum(QString pageAutoNum) { void BorderTitleBlock::slot_setAutoPageNum(QString pageAutoNum) {
btb_auto_page_num_=std::move(pageAutoNum); btb_auto_page_num_=std::move(pageAutoNum);
} }
/** /**
@brief BorderTitleBlock::updateRectangles * @brief BorderTitleBlock::updateRectangles
This method update the diagram rect according * This method update the diagram rect according to the value of rows and columns (number and size)
to the value of rows and columns (number and size)
*/ */
void BorderTitleBlock::updateRectangles() void BorderTitleBlock::updateRectangles()
{ {
QRectF previous_diagram = diagram_rect_; QRectF previous_diagram = diagram_rect_;
diagram_rect_ = QRectF(Diagram::margin, diagram_rect_ = QRectF(Diagram::margin, Diagram::margin, diagramWidth(), diagramHeight());
Diagram::margin, if (diagram_rect_ != previous_diagram) emit(borderChanged(previous_diagram, diagram_rect_));
diagramWidth(),
diagramHeight());
if (diagram_rect_ != previous_diagram)
emit(borderChanged(previous_diagram, diagram_rect_));
} }
/** /**
@brief BorderTitleBlock::draw * @brief BorderTitleBlock::draw
Draw the border and the titleblock. * Draw the border and the titleblock.
@param painter, QPainter to use for draw this. * @param painter, QPainter to use for draw this.
*/ */
void BorderTitleBlock::draw(QPainter *painter) void BorderTitleBlock::draw(QPainter *painter)
{ {
@@ -533,24 +464,16 @@ void BorderTitleBlock::draw(QPainter *painter)
if (display_border_ && display_columns_) { if (display_border_ && display_columns_) {
for (int i = 1 ; i <= columns_count_ ; ++ i) { for (int i = 1 ; i <= columns_count_ ; ++ i) {
QRectF numbered_rectangle = QRectF( QRectF numbered_rectangle = QRectF(
diagram_rect_.topLeft().x() diagram_rect_.topLeft().x() + (rows_header_width_ + ((i - 1) * columns_width_)),
+ (rows_header_width_
+ ((i - 1) * columns_width_)),
diagram_rect_.topLeft().y(), diagram_rect_.topLeft().y(),
columns_width_, columns_width_,
columns_header_height_ columns_header_height_
); );
painter -> drawRect(numbered_rectangle); painter -> drawRect(numbered_rectangle);
if (settings.value("border-columns_0", true).toBool()){ if (settings.value("border-columns_0", true).toBool()){
painter -> drawText(numbered_rectangle, painter -> drawText(numbered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, QString("%1").arg(i - 1));
Qt::AlignVCenter
| Qt::AlignCenter,
QString("%1").arg(i - 1));
}else{ }else{
painter -> drawText(numbered_rectangle, painter -> drawText(numbered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, QString("%1").arg(i));
Qt::AlignVCenter
| Qt::AlignCenter,
QString("%1").arg(i));
} }
} }
} }
@@ -561,19 +484,12 @@ void BorderTitleBlock::draw(QPainter *painter)
for (int i = 1 ; i <= rows_count_ ; ++ i) { for (int i = 1 ; i <= rows_count_ ; ++ i) {
QRectF lettered_rectangle = QRectF( QRectF lettered_rectangle = QRectF(
diagram_rect_.topLeft().x(), diagram_rect_.topLeft().x(),
diagram_rect_.topLeft().y() diagram_rect_.topLeft().y() + (columns_header_height_ + ((i - 1) * rows_height_)),
+ (
columns_header_height_
+ ((i - 1)* rows_height_)
),
rows_header_width_, rows_header_width_,
rows_height_ rows_height_
); );
painter -> drawRect(lettered_rectangle); painter -> drawRect(lettered_rectangle);
painter -> drawText(lettered_rectangle, painter -> drawText(lettered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, row_string);
Qt::AlignVCenter
| Qt::AlignCenter,
row_string);
row_string = incrementLetters(row_string); row_string = incrementLetters(row_string);
} }
} }
@@ -584,18 +500,14 @@ void BorderTitleBlock::draw(QPainter *painter)
if (m_edge == Qt::BottomEdge) if (m_edge == Qt::BottomEdge)
{ {
painter -> translate(tbt_rect.topLeft()); painter -> translate(tbt_rect.topLeft());
m_titleblock_template_renderer -> render( m_titleblock_template_renderer -> render(painter, tbt_rect.width());
painter,
tbt_rect.width());
painter -> translate(-tbt_rect.topLeft()); painter -> translate(-tbt_rect.topLeft());
} }
else else
{ {
painter->translate(tbt_rect.topLeft()); painter->translate(tbt_rect.topLeft());
painter->rotate(-90); painter->rotate(-90);
m_titleblock_template_renderer -> render( m_titleblock_template_renderer -> render(painter, tbt_rect.width());
painter,
tbt_rect.width());
painter->rotate(90); painter->rotate(90);
painter -> translate(-tbt_rect.topLeft()); painter -> translate(-tbt_rect.topLeft());
} }
@@ -604,20 +516,7 @@ void BorderTitleBlock::draw(QPainter *painter)
painter -> restore(); painter -> restore();
} }
/** void BorderTitleBlock::drawDxf(int width, int height, bool keep_aspect_ratio, QString &file_path, int color) {
* @brief BorderTitleBlock::drawDxf
* @param width
* @param height
* @param keep_aspect_ratio
* @param file_path
* @param color
*/
void BorderTitleBlock::drawDxf(
int width,
int height,
bool keep_aspect_ratio,
QString &file_path,
int color) {
Q_UNUSED (width); Q_UNUSED (height); Q_UNUSED (keep_aspect_ratio); Q_UNUSED (width); Q_UNUSED (height); Q_UNUSED (keep_aspect_ratio);
// Transform to DXF scale. // Transform to DXF scale.
@@ -626,7 +525,6 @@ void BorderTitleBlock::drawDxf(
rows_header_width_ *= Createdxf::xScale; rows_header_width_ *= Createdxf::xScale;
columns_width_ *= Createdxf::xScale; columns_width_ *= Createdxf::xScale;
// draw the empty box that appears as soon as there is a header
// dessine la case vide qui apparait des qu'il y a un entete // dessine la case vide qui apparait des qu'il y a un entete
if (display_border_ && if (display_border_ &&
(display_columns_ || (display_columns_ ||
@@ -635,10 +533,7 @@ void BorderTitleBlock::drawDxf(
Createdxf::drawRectangle( Createdxf::drawRectangle(
file_path, file_path,
double(diagram_rect_.topLeft().x()) * Createdxf::xScale, double(diagram_rect_.topLeft().x()) * Createdxf::xScale,
Createdxf::sheetHeight Createdxf::sheetHeight - double(diagram_rect_.topLeft().y()) * Createdxf::yScale - columns_header_height_,
- double(diagram_rect_.topLeft().y())
* Createdxf::yScale
- columns_header_height_,
rows_header_width_, rows_header_width_,
columns_header_height_, columns_header_height_,
color color
@@ -647,7 +542,6 @@ void BorderTitleBlock::drawDxf(
QSettings settings; QSettings settings;
// draw the numbering of the columns
// dessine la numerotation des colonnes // dessine la numerotation des colonnes
if (display_border_ && if (display_border_ &&
display_columns_) { display_columns_) {
@@ -655,74 +549,34 @@ void BorderTitleBlock::drawDxf(
double xCoord = diagram_rect_.topLeft().x() + double xCoord = diagram_rect_.topLeft().x() +
(rows_header_width_ + ((i - 1) * (rows_header_width_ + ((i - 1) *
columns_width_)); columns_width_));
double yCoord = Createdxf::sheetHeight double yCoord = Createdxf::sheetHeight - diagram_rect_.topLeft().y() - columns_header_height_;
- diagram_rect_.topLeft().y()
- columns_header_height_;
double recWidth = columns_width_; double recWidth = columns_width_;
double recHeight = columns_header_height_; double recHeight = columns_header_height_;
Createdxf::drawRectangle(file_path, xCoord, yCoord, Createdxf::drawRectangle(file_path, xCoord, yCoord, recWidth, recHeight, color);
recWidth, recHeight, color);
if (settings.value("border-columns_0", true).toBool()){ if (settings.value("border-columns_0", true).toBool()){
Createdxf::drawTextAligned(file_path, Createdxf::drawTextAligned(file_path, QString::number(i - 1), xCoord,
QString::number(i - 1), yCoord + recHeight*0.5, recHeight*0.7, 0, 0, 1, 2, xCoord+recWidth/2, color, 0);
xCoord,
yCoord + recHeight*0.5,
recHeight*0.7,
0,
0,
1,
2,
xCoord+recWidth/2,
color,
0);
}else{ }else{
Createdxf::drawTextAligned(file_path, Createdxf::drawTextAligned(file_path, QString::number(i), xCoord,
QString::number(i), yCoord + recHeight*0.5, recHeight*0.7, 0, 0, 1, 2, xCoord+recWidth/2, color, 0);
xCoord,
yCoord + recHeight*0.5,
recHeight*0.7,
0,
0,
1,
2,
xCoord+recWidth/2,
color,
0);
} }
} }
} }
// draw line numbering
// dessine la numerotation des lignes // dessine la numerotation des lignes
if (display_border_ && display_rows_) { if (display_border_ && display_rows_) {
QString row_string("A"); QString row_string("A");
for (int i = 1 ; i <= rows_count_ ; ++ i) { for (int i = 1 ; i <= rows_count_ ; ++ i) {
double xCoord = diagram_rect_.topLeft().x() double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale;
* Createdxf::xScale; double yCoord = Createdxf::sheetHeight - diagram_rect_.topLeft().y()*Createdxf::yScale
double yCoord = Createdxf::sheetHeight - (columns_header_height_ + ((i - 1) * rows_height_))
- diagram_rect_.topLeft().y()
*Createdxf::yScale
- (
columns_header_height_
+ ((i - 1)
* rows_height_) )
- rows_height_; - rows_height_;
double recWidth = rows_header_width_; double recWidth = rows_header_width_;
double recHeight = rows_height_; double recHeight = rows_height_;
Createdxf::drawRectangle(file_path, xCoord, yCoord, Createdxf::drawRectangle(file_path, xCoord, yCoord, recWidth, recHeight, color);
recWidth, recHeight, color); Createdxf::drawTextAligned(file_path, row_string, xCoord,
Createdxf::drawTextAligned(file_path, yCoord + recHeight*0.5, recWidth*0.7, 0, 0, 1, 2, xCoord+recWidth/2, color, 0);
row_string,
xCoord,
yCoord + recHeight*0.5,
recWidth*0.7,
0,
0,
1,
2,
xCoord+recWidth/2,
color,
0);
row_string = incrementLetters(row_string); row_string = incrementLetters(row_string);
} }
} }
@@ -731,10 +585,7 @@ void BorderTitleBlock::drawDxf(
if (display_titleblock_) { if (display_titleblock_) {
//qp -> translate(titleblock_rect_.topLeft()); //qp -> translate(titleblock_rect_.topLeft());
QRectF rect = titleBlockRect(); QRectF rect = titleBlockRect();
m_titleblock_template_renderer -> renderDxf(rect, m_titleblock_template_renderer -> renderDxf(rect, rect.width(), file_path, color);
rect.width(),
file_path,
color);
//qp -> translate(-titleblock_rect_.topLeft()); //qp -> translate(-titleblock_rect_.topLeft());
} }
@@ -747,17 +598,11 @@ void BorderTitleBlock::drawDxf(
} }
/** /**
@brief BorderTitleBlock::setColumnsCount Permet de changer le nombre de colonnes.
Allows you to change the number of columns. Si ce nombre de colonnes est inferieur au minimum requis, c'est ce minimum
If this number of columns is less than the minimum required, qui est utilise.
it is this minimum which is used. @param nb_c nouveau nombre de colonnes
@see minNbColumns()
\~French Permet de changer le nombre de colonnes.
Si ce nombre de colonnes est inferieur au minimum requis,
c'est ce minimum qui est utilise.
\~ @param nb_c : new number of columns
\~French nouveau nombre de colonnes
\~ @see minNbColumns()
*/ */
void BorderTitleBlock::setColumnsCount(int nb_c) { void BorderTitleBlock::setColumnsCount(int nb_c) {
if (nb_c == columnsCount()) return; if (nb_c == columnsCount()) return;
@@ -766,17 +611,11 @@ void BorderTitleBlock::setColumnsCount(int nb_c) {
} }
/** /**
@brief BorderTitleBlock::setColumnsWidth Change la largeur des colonnes.
Change the width of the columns. Si la largeur indiquee est inferieure au minimum requis, c'est ce minimum
If the width indicated is less than the minimum required, qui est utilise.
it is this minimum which is used. @param new_cw nouvelle largeur des colonnes
@see minColumnsWidth()
\~French Change la largeur des colonnes.
Si la largeur indiquee est inferieure au minimum requis,
c'est ce minimum qui est utilise.
\~ @param new_cw : new column width
\~French nouvelle largeur des colonnes
\~ @see minColumnsWidth()
*/ */
void BorderTitleBlock::setColumnsWidth(const qreal &new_cw) { void BorderTitleBlock::setColumnsWidth(const qreal &new_cw) {
if (new_cw == columnsWidth()) return; if (new_cw == columnsWidth()) return;
@@ -785,14 +624,9 @@ void BorderTitleBlock::setColumnsWidth(const qreal &new_cw) {
} }
/** /**
@brief BorderTitleBlock::setColumnsHeaderHeight Change la hauteur des en-tetes contenant les numeros de colonnes. Celle-ci
Change the height of the headers containing the column numbers. doit rester comprise entre 5 et 50 px.
This must remain between 5 and 50 px. @param new_chh nouvelle hauteur des en-tetes de colonnes
\~French Change la hauteur des en-tetes contenant les numeros de colonnes.
Celle-ci doit rester comprise entre 5 et 50 px.
\~ @param new_chh : new height of column headers
\~French nouvelle hauteur des en-tetes de colonnes
*/ */
void BorderTitleBlock::setColumnsHeaderHeight(const qreal &new_chh) { void BorderTitleBlock::setColumnsHeaderHeight(const qreal &new_chh) {
columns_header_height_ = qBound(qreal(5.0), new_chh, qreal(50.0)); columns_header_height_ = qBound(qreal(5.0), new_chh, qreal(50.0));
@@ -800,17 +634,11 @@ void BorderTitleBlock::setColumnsHeaderHeight(const qreal &new_chh) {
} }
/** /**
@brief BorderTitleBlock::setRowsCount Permet de changer le nombre de lignes.
Allows you to change the number of lines. Si ce nombre de lignes est inferieur au minimum requis, cette fonction ne
If this number of lines is lower than the minimum required, fait rien
this function does nothing @param nb_r nouveau nombre de lignes
@see minNbRows()
\~French Permet de changer le nombre de lignes.
Si ce nombre de lignes est inferieur au minimum requis,
cette fonction ne fait rien
\~ @param nb_r : new number of lines
\~French nouveau nombre de lignes
\~ @see minNbRows()
*/ */
void BorderTitleBlock::setRowsCount(int nb_r) { void BorderTitleBlock::setRowsCount(int nb_r) {
if (nb_r == rowsCount()) return; if (nb_r == rowsCount()) return;
@@ -819,17 +647,11 @@ void BorderTitleBlock::setRowsCount(int nb_r) {
} }
/** /**
@brief BorderTitleBlock::setRowsHeight Change la hauteur des lignes.
Change the height of the lines. Si la hauteur indiquee est inferieure au minimum requis, c'est ce minimum
If the indicated height is lower than the minimum required, qui est utilise.
it is this minimum which is used. @param new_rh nouvelle hauteur des lignes
@see minRowsHeight()
\~French Change la hauteur des lignes.
Si la hauteur indiquee est inferieure au minimum requis,
c'est ce minimum qui est utilise.
\~ @param new_rh : new row height
\~French nouvelle hauteur des lignes
\~ @see minRowsHeight()
*/ */
void BorderTitleBlock::setRowsHeight(const qreal &new_rh) { void BorderTitleBlock::setRowsHeight(const qreal &new_rh) {
if (new_rh == rowsHeight()) return; if (new_rh == rowsHeight()) return;
@@ -838,14 +660,9 @@ void BorderTitleBlock::setRowsHeight(const qreal &new_rh) {
} }
/** /**
@brief BorderTitleBlock::setRowsHeaderWidth Change la largeur des en-tetes contenant les numeros de lignes. Celle-ci
Change the width of the headers containing the line numbers. doit rester comprise entre 5 et 50 px.
This must remain between 5 and 50 px. @param new_rhw nouvelle largeur des en-tetes des lignes
\~French Change la largeur des en-tetes contenant les numeros de lignes.
Celle-ci doit rester comprise entre 5 et 50 px.
\~ @param new_rhw : new width of line headers
\~French nouvelle largeur des en-tetes des lignes
*/ */
void BorderTitleBlock::setRowsHeaderWidth(const qreal &new_rhw) { void BorderTitleBlock::setRowsHeaderWidth(const qreal &new_rhw) {
rows_header_width_ = qBound(qreal(5.0), new_rhw, qreal(50.0)); rows_header_width_ = qBound(qreal(5.0), new_rhw, qreal(50.0));
@@ -853,26 +670,19 @@ void BorderTitleBlock::setRowsHeaderWidth(const qreal &new_rhw) {
} }
/** /**
@brief BorderTitleBlock::setDiagramHeight Cette methode essaye de se rapprocher le plus possible de la hauteur donnee
This method tries to get as close as possible to the given height en parametre en modifiant le nombre de lignes en cours.
as a parameter by modifying the number of rows in progress.
\~French Cette methode essaye de se rapprocher le plus possible de la
hauteur donnee en parametre en modifiant le nombre de lignes en cours.
\~ @param height :
*/ */
void BorderTitleBlock::setDiagramHeight(const qreal &height) { void BorderTitleBlock::setDiagramHeight(const qreal &height) {
// size of rows to use = rows_height
// taille des lignes a utiliser = rows_height // taille des lignes a utiliser = rows_height
setRowsCount(qRound(ceil(height / rows_height_))); setRowsCount(qRound(ceil(height / rows_height_)));
} }
/** /**
@brief BorderTitleBlock::convertPosition * @brief BorderTitleBlock::convertPosition
Convert a Point in cartesian coordinate (x : 12.5, 56.9) * Convert a Point in cartesian coordinate (x : 12.5, 56.9) to a point in grid coordinate (ex : B2)
to a point in grid coordinate (ex : B2) * @param pos : position to convert
@param pos : position to convert * @return the converted point in grid coordinate.
@return the converted point in grid coordinate.
*/ */
DiagramPosition BorderTitleBlock::convertPosition(const QPointF &pos) DiagramPosition BorderTitleBlock::convertPosition(const QPointF &pos)
{ {
@@ -891,24 +701,24 @@ DiagramPosition BorderTitleBlock::convertPosition(const QPointF &pos)
} }
/** /**
@brief BorderTitleBlock::setAuthor * @brief BorderTitleBlock::setAuthor
@param author the new value of the "Author" field * @param author the new value of the "Author" field
*/ */
void BorderTitleBlock::setAuthor(const QString &author) { void BorderTitleBlock::setAuthor(const QString &author) {
btb_author_ = author; btb_author_ = author;
} }
/** /**
@brief BorderTitleBlock::setDate * @brief BorderTitleBlock::setDate
@param date the new value of the "Date" field * @param date the new value of the "Date" field
*/ */
void BorderTitleBlock::setDate(const QDate &date) { void BorderTitleBlock::setDate(const QDate &date) {
btb_date_ = date; btb_date_ = date;
} }
/** /**
@brief BorderTitleBlock::setTitle * @brief BorderTitleBlock::setTitle
@param title the new value of the "Title" field * @param title the new value of the "Title" field
*/ */
void BorderTitleBlock::setTitle(const QString &title) void BorderTitleBlock::setTitle(const QString &title)
{ {
@@ -920,8 +730,8 @@ void BorderTitleBlock::setTitle(const QString &title)
} }
/** /**
@brief BorderTitleBlock::setFolio * @brief BorderTitleBlock::setFolio
@param folio the new value of the "Folio" field * @param folio the new value of the "Folio" field
*/ */
void BorderTitleBlock::setFolio(const QString &folio) void BorderTitleBlock::setFolio(const QString &folio)
{ {
@@ -930,14 +740,12 @@ void BorderTitleBlock::setFolio(const QString &folio)
} }
/** /**
@brief BorderTitleBlock::updateDiagramContextForTitleBlock Update the informations given to the titleblock template by regenerating a
Update the informations given to the titleblock template DiagramContext object.
by regenerating a DiagramContext object. @param initial_context Base diagram context that will be overridden by
@param initial_context : diagram-wide values
Base diagram context that will be overridden by diagram-wide values
*/ */
void BorderTitleBlock::updateDiagramContextForTitleBlock( void BorderTitleBlock::updateDiagramContextForTitleBlock(const DiagramContext &initial_context) {
const DiagramContext &initial_context) {
// Our final DiagramContext is the initial one (which is supposed to bring // Our final DiagramContext is the initial one (which is supposed to bring
// project-wide properties), overridden by the "additional fields" one... // project-wide properties), overridden by the "additional fields" one...
DiagramContext context = initial_context; DiagramContext context = initial_context;
@@ -947,8 +755,7 @@ void BorderTitleBlock::updateDiagramContextForTitleBlock(
// ... overridden by the historical and/or dynamically generated fields // ... overridden by the historical and/or dynamically generated fields
context.addValue("author", btb_author_); context.addValue("author", btb_author_);
context.addValue("date", btb_date_.toString( context.addValue("date", btb_date_.toString(Qt::SystemLocaleShortDate));
Qt::SystemLocaleShortDate));
context.addValue("title", btb_title_); context.addValue("title", btb_title_);
context.addValue("filename", btb_filename_); context.addValue("filename", btb_filename_);
context.addValue("plant", btb_plant_); context.addValue("plant", btb_plant_);
@@ -965,25 +772,14 @@ void BorderTitleBlock::updateDiagramContextForTitleBlock(
m_titleblock_template_renderer -> setContext(context); m_titleblock_template_renderer -> setContext(context);
} }
/**
@brief BorderTitleBlock::incrementLetters
increments string with Letters A to Z
@param string
@return string ++Letters
eg:
- A-> B
- Z -> AA
*/
QString BorderTitleBlock::incrementLetters(const QString &string) { QString BorderTitleBlock::incrementLetters(const QString &string) {
if (string.isEmpty()) { if (string.isEmpty()) {
return("A"); return("A");
} else { } else {
// separate previous digits from last digit
// separe les digits precedents du dernier digit // separe les digits precedents du dernier digit
QString first_digits(string.left(string.count() - 1)); QString first_digits(string.left(string.count() - 1));
QChar last_digit(string.at(string.count() - 1)); QChar last_digit(string.at(string.count() - 1));
if (last_digit != 'Z') { if (last_digit != 'Z') {
// increments the last digit
// incremente le dernier digit // incremente le dernier digit
last_digit = last_digit.toLatin1() + 1; last_digit = last_digit.toLatin1() + 1;
return(first_digits + QString(last_digit)); return(first_digits + QString(last_digit));
@@ -994,32 +790,17 @@ QString BorderTitleBlock::incrementLetters(const QString &string) {
} }
/** /**
@brief BorderTitleBlock::setFolioData @param index numero du schema (de 1 a total)
@param total nombre total de schemas dans le projet
\~ @param index : schema number (from 1 to total) @param project_properties Project-wide properties, to be merged with diagram-wide ones.
\~French numero du schema (de 1 a total)
\~ @param total : total number of diagrams in the project
\~French nombre total de schemas dans le projet
\~ @param autonum :
\~ @param project_properties : Project-wide properties,
to be merged with diagram-wide ones.
*/ */
void BorderTitleBlock::setFolioData( void BorderTitleBlock::setFolioData(int index, int total, const QString& autonum, const DiagramContext &project_properties) {
int index,
int total,
const QString& autonum,
const DiagramContext &project_properties) {
if (index < 1 || total < 1 || index > total) return; if (index < 1 || total < 1 || index > total) return;
// memorize information
// memorise les informations // memorise les informations
folio_index_ = index; folio_index_ = index;
folio_total_ = total; folio_total_ = total;
// regenerate the content of the folio field
// regenere le contenu du champ folio // regenere le contenu du champ folio
btb_final_folio_ = btb_folio_; btb_final_folio_ = btb_folio_;
@@ -1030,60 +811,61 @@ void BorderTitleBlock::setFolioData(
btb_final_folio_.replace("%id", QString::number(folio_index_)); btb_final_folio_.replace("%id", QString::number(folio_index_));
btb_final_folio_.replace("%total", QString::number(folio_total_)); btb_final_folio_.replace("%total", QString::number(folio_total_));
updateDiagramContextForTitleBlock(project_properties); updateDiagramContextForTitleBlock(project_properties);
} }
/** /**
@brief BorderTitleBlock::setPlant * @brief BorderTitleBlock::setPlant
@param plant the new value of the "plant" field * @param plant the new value of the "plant" field
*/ */
void BorderTitleBlock::setPlant(const QString &plant) { void BorderTitleBlock::setPlant(const QString &plant) {
btb_plant_ = plant; btb_plant_ = plant;
} }
/** /**
@brief BorderTitleBlock::setLocMach * @brief BorderTitleBlock::setLocMach
@param locmach the new value of the "locmach" field * @param locmach the new value of the "locmach" field
*/ */
void BorderTitleBlock::setLocMach(const QString &locmach) { void BorderTitleBlock::setLocMach(const QString &locmach) {
btb_locmach_ = locmach; btb_locmach_ = locmach;
} }
/** /**
@brief BorderTitleBlock::setIndicerev * @brief BorderTitleBlock::setIndicerev
@param indexrev the new value of the "indexrev" field * @param indexrev the new value of the "indexrev" field
*/ */
void BorderTitleBlock::setIndicerev(const QString &indexrev) { void BorderTitleBlock::setIndicerev(const QString &indexrev) {
btb_indexrev_ = indexrev; btb_indexrev_ = indexrev;
} }
/** /**
@brief BorderTitleBlock::setFileName * @brief BorderTitleBlock::setFileName
@param filename the new value of the "filename" field * @param filename the new value of the "filename" field
*/ */
void BorderTitleBlock::setFileName(const QString &filename) { void BorderTitleBlock::setFileName(const QString &filename) {
btb_filename_ = filename; btb_filename_ = filename;
} }
/** /**
@brief BorderTitleBlock::setVersion * @brief BorderTitleBlock::setVersion
@param version the new value of the "version" field * @param version the new value of the "version" field
*/ */
void BorderTitleBlock::setVersion(const QString &version) { void BorderTitleBlock::setVersion(const QString &version) {
btb_version_ = version; btb_version_ = version;
} }
/** /**
@brief BorderTitleBlock::setAutoPageNum * @brief BorderTitleBlock::setAutoPageNum
@param auto_page_num the new value of the "auto_page_num" field * @param auto_page_num the new value of the "auto_page_num" field
*/ */
void BorderTitleBlock::setAutoPageNum(const QString &auto_page_num) { void BorderTitleBlock::setAutoPageNum(const QString &auto_page_num) {
btb_auto_page_num_ = auto_page_num; btb_auto_page_num_ = auto_page_num;
} }
/** /**
@brief BorderTitleBlock::setPreviousFolioNum * @brief BorderTitleBlock::setPreviousFolioNum
@param previous the new value of the "previous-folio-num" field * @param previous the new value of the "previous-folio-num" field
*/ */
void BorderTitleBlock::setPreviousFolioNum(const QString &previous) void BorderTitleBlock::setPreviousFolioNum(const QString &previous)
{ {
@@ -1094,8 +876,8 @@ void BorderTitleBlock::setPreviousFolioNum(const QString &previous)
} }
/** /**
@brief BorderTitleBlock::setNextFolioNum * @brief BorderTitleBlock::setNextFolioNum
@param next the new value of the "next-folio-num" field * @param next the new value of the "next-folio-num" field
*/ */
void BorderTitleBlock::setNextFolioNum(const QString &next) void BorderTitleBlock::setNextFolioNum(const QString &next)
{ {

View File

@@ -29,7 +29,6 @@ class DiagramPosition;
class TitleBlockTemplate; class TitleBlockTemplate;
class TitleBlockTemplateRenderer; class TitleBlockTemplateRenderer;
/** /**
@brief The BorderTitleBlock class
This class represents the border and the titleblock which frame a This class represents the border and the titleblock which frame a
particular electric diagram. particular electric diagram.
*/ */
@@ -56,11 +55,9 @@ class BorderTitleBlock : public QObject
/// @return the columns width, in pixels /// @return the columns width, in pixels
qreal columnsWidth() const { return(columns_width_); } qreal columnsWidth() const { return(columns_width_); }
/// @return the total width of all columns, headers excluded /// @return the total width of all columns, headers excluded
qreal columnsTotalWidth() const { qreal columnsTotalWidth() const { return(columns_count_ * columns_width_); }
return(columns_count_ * columns_width_); }
/// @return the column headers height, in pixels /// @return the column headers height, in pixels
qreal columnsHeaderHeight() const { qreal columnsHeaderHeight() const { return(columns_header_height_); }
return(columns_header_height_); }
//ROWS //ROWS
/// @return the number of rows /// @return the number of rows
@@ -68,26 +65,15 @@ class BorderTitleBlock : public QObject
/// @return the rows height, in pixels /// @return the rows height, in pixels
qreal rowsHeight() const { return(rows_height_); } qreal rowsHeight() const { return(rows_height_); }
/// @return the total height of all rows, headers excluded /// @return the total height of all rows, headers excluded
qreal rowsTotalHeight() const { qreal rowsTotalHeight() const { return(rows_count_ * rows_height_); }
return(rows_count_ * rows_height_); }
/// @return la rows header width, in pixels /// @return la rows header width, in pixels
qreal rowsHeaderWidth() const { return(rows_header_width_); } qreal rowsHeaderWidth() const { return(rows_header_width_); }
// border - title block = diagram // border - title block = diagram
/** /// @return the diagram width, i.e. the width of the border without title block
@brief diagramWidth qreal diagramWidth() const { return(columnsTotalWidth() + rowsHeaderWidth()); }
@return the diagram width, /// @return the diagram height, i.e. the height of the border without title block
i.e. the width of the border without title block qreal diagramHeight() const { return(rowsTotalHeight() + columnsHeaderHeight()); }
*/
qreal diagramWidth() const {
return(columnsTotalWidth() + rowsHeaderWidth()); }
/**
@brief diagramHeight
@return the diagram height,
i.e. the height of the border without title block
*/
qreal diagramHeight() const {
return(rowsTotalHeight() + columnsHeaderHeight()); }
QRectF titleBlockRect () const; QRectF titleBlockRect () const;
@@ -124,8 +110,7 @@ class BorderTitleBlock : public QObject
/// @return the value of the title block Additional Fields /// @return the value of the title block Additional Fields
QString version() const { return(btb_version_); } QString version() const { return(btb_version_); }
/// @return the value of the title block Additional Fields /// @return the value of the title block Additional Fields
DiagramContext additionalFields() const { DiagramContext additionalFields() const { return (additional_fields_); }
return (additional_fields_); }
/// @return the value of the title block /// @return the value of the title block
QString autoPageNum() const { return(btb_auto_page_num_); } QString autoPageNum() const { return(btb_auto_page_num_); }
/// @return the value of the total number of folios /// @return the value of the total number of folios
@@ -133,13 +118,10 @@ class BorderTitleBlock : public QObject
// methods to get display options // methods to get display options
/// @return true si le cartouche est affiche, false sinon /// @return true si le cartouche est affiche, false sinon
bool titleBlockIsDisplayed() const { bool titleBlockIsDisplayed() const { return(display_titleblock_); }
return(display_titleblock_); } /// @return true si les entetes des colonnes sont affiches, false sinon
/// @return true si les entetes des colonnes sont affiches,
/// false sinon
bool columnsAreDisplayed() const { return(display_columns_); } bool columnsAreDisplayed() const { return(display_columns_); }
/// @return true si les entetes des lignes sont affiches, /// @return true si les entetes des lignes sont affiches, false sinon
/// false sinon
bool rowsAreDisplayed() const { return(display_rows_); } bool rowsAreDisplayed() const { return(display_rows_); }
/// @return true si la bordure est affichee, false sinon /// @return true si la bordure est affichee, false sinon
bool borderIsDisplayed() const { return(display_border_); } bool borderIsDisplayed() const { return(display_border_); }
@@ -160,8 +142,7 @@ class BorderTitleBlock : public QObject
void setDate(const QDate &date); void setDate(const QDate &date);
void setTitle(const QString &title); void setTitle(const QString &title);
void setFolio(const QString &folio); void setFolio(const QString &folio);
void setFolioData(int, int, const QString& = nullptr, void setFolioData(int, int, const QString& = nullptr, const DiagramContext & = DiagramContext());
const DiagramContext & = DiagramContext());
void setPlant(const QString &plant); void setPlant(const QString &plant);
void setLocMach(const QString &locmach); void setLocMach(const QString &locmach);
void setIndicerev(const QString &indexrev); void setIndicerev(const QString &indexrev);
@@ -187,9 +168,7 @@ class BorderTitleBlock : public QObject
public slots: public slots:
void titleBlockTemplateChanged(const QString &); void titleBlockTemplateChanged(const QString &);
void titleBlockTemplateRemoved( void titleBlockTemplateRemoved(const QString &, const TitleBlockTemplate * = nullptr);
const QString &,
const TitleBlockTemplate * = nullptr);
// methods to set display options // methods to set display options
void displayTitleBlock(bool); void displayTitleBlock(bool);
@@ -200,25 +179,21 @@ class BorderTitleBlock : public QObject
private: private:
void updateRectangles(); void updateRectangles();
void updateDiagramContextForTitleBlock( void updateDiagramContextForTitleBlock(const DiagramContext & = DiagramContext());
const DiagramContext & = DiagramContext());
QString incrementLetters(const QString &); QString incrementLetters(const QString &);
signals: signals:
/** /**
@brief borderChanged
Signal emitted after the border has changed Signal emitted after the border has changed
@param old_border Former border @param old_border Former border
@param new_border New border @param new_border New border
*/ */
void borderChanged(QRectF old_border, QRectF new_border); void borderChanged(QRectF old_border, QRectF new_border);
/** /**
@brief displayChanged
Signal emitted after display options have changed Signal emitted after display options have changed
*/ */
void displayChanged(); void displayChanged();
/** /**
@brief diagramTitleChanged
Signal emitted after the title has changed Signal emitted after the title has changed
*/ */
void diagramTitleChanged(const QString &); void diagramTitleChanged(const QString &);
@@ -228,53 +203,48 @@ class BorderTitleBlock : public QObject
*/ */
void titleBlockFolioChanged(const QString &); void titleBlockFolioChanged(const QString &);
/** /**
@brief needFolioData Signal emitted when the title block requires its data to be updated in order
Signal emitted when the title block to generate the folio field.
requires its data to be updated
in order to generate the folio field.
*/ */
void needFolioData(); void needFolioData();
/** /**
@brief needTitleBlockTemplate Signal emitted when this object needs to set a specific title block
Signal emitted when this object needs to template. This object cannot handle the job since it does not know of
set a specific title block template. its parent project.
This object cannot handle the job
since it does not know of its parent project.
*/ */
void needTitleBlockTemplate(const QString &); void needTitleBlockTemplate(const QString &);
// attributes // attributes
private: private:
// titleblock basic data // titleblock basic data
QString btb_author_; ///< titleblock author QString btb_author_;
QDate btb_date_; ///< titleblock date QDate btb_date_;
QString btb_title_; ///< titleblock title QString btb_title_;
QString btb_folio_; ///< titleblock folio QString btb_folio_;
QString btb_plant_; ///< titleblock plant QString btb_plant_;
QString btb_locmach_; ///< titleblock locmach QString btb_locmach_;
QString btb_indexrev_; ///< titleblock index rev QString btb_indexrev_;
QString btb_final_folio_; ///< titleblock final folio QString btb_final_folio_;
QString btb_auto_page_num_; ///< titleblock auto page num QString btb_auto_page_num_;
int folio_index_; ///< titleblock index int folio_index_;
int folio_total_; ///< titleblock total int folio_total_;
QString btb_filename_; ///< titleblock filename QString btb_filename_;
QString btb_version_; ///< titleblock version QString btb_version_;
/// titleblock additional fields
DiagramContext additional_fields_; DiagramContext additional_fields_;
Qt::Edge m_edge; ///< titleblock edge Qt::Edge m_edge;
QString m_next_folio_num; ///< titleblock next folio num QString m_next_folio_num,
QString m_previous_folio_num; ///< titleblock previous folio num m_previous_folio_num;
// border dimensions (rows and columns) // border dimensions (rows and columns)
// columns: number and dimensions // columns: number and dimensions
int columns_count_; ///< columns count int columns_count_;
qreal columns_width_; ///< columns width qreal columns_width_;
qreal columns_header_height_; ///< columns header height qreal columns_header_height_;
// rows: number and dimensions // rows: number and dimensions
int rows_count_; ///< rows count int rows_count_;
qreal rows_height_; ///< rows height qreal rows_height_;
qreal rows_header_width_; ///< rows header width qreal rows_header_width_;
// title block dimensions // title block dimensions
qreal titleblock_height_; qreal titleblock_height_;

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2020 The QElectroTech team Copyright 2006-2014 The QElectroTech team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -26,23 +26,16 @@
#include "assignvariables.h" #include "assignvariables.h"
/** /**
@brief ConductorAutoNumerotation::ConductorAutoNumerotation * @brief ConductorAutoNumerotation::ConductorAutoNumerotation
Constructor of autonum, after create a class, * Constructor of autonum, after create a class, call numerate to apply the autonum.
call numerate to apply the autonum. * When autonum is applyed, they do with an undo command added to the stack of diagram.
When autonum is applyed, * If you give a parent_undo at constructor, the undo command create in this class have parent_undo for parent,
they do with an undo command added to the stack of diagram. * and wasn't added to the stack of diagram (it's the responsabillty of the parent_undo)
If you give a parent_undo at constructor, * @param conductor : the conductor to apply automatic numerotation
the undo command create in this class have parent_undo for parent, * @param diagram : the diagram of conductor
and wasn't added to the stack of diagram * @param parent_undo : parent undo command
(it's the responsabillty of the parent_undo)
@param conductor : the conductor to apply automatic numerotation
@param diagram : the diagram of conductor
@param parent_undo : parent undo command
*/ */
ConductorAutoNumerotation::ConductorAutoNumerotation( ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *conductor, Diagram *diagram, QUndoCommand *parent_undo) :
Conductor *conductor,
Diagram *diagram,
QUndoCommand *parent_undo) :
m_diagram (diagram), m_diagram (diagram),
m_conductor (conductor), m_conductor (conductor),
conductor_list (conductor -> relatedPotentialConductors().values()), conductor_list (conductor -> relatedPotentialConductors().values()),
@@ -50,21 +43,18 @@ ConductorAutoNumerotation::ConductorAutoNumerotation(
{} {}
/** /**
@brief ConductorAutoNumerotation::numerate * @brief ConductorAutoNumerotation::numerate
execute the automatic numerotation * execute the automatic numerotation
*/ */
void ConductorAutoNumerotation::numerate() { void ConductorAutoNumerotation::numerate() {
if (!m_conductor) return; if (!m_conductor) return;
if (conductor_list.size() >= 1 ) numeratePotential(); if (conductor_list.size() >= 1 ) numeratePotential();
else if (m_conductor -> properties().type == ConductorProperties::Multi) else if (m_conductor -> properties().type == ConductorProperties::Multi) numerateNewConductor();
numerateNewConductor();
} }
/** /**
@brief ConductorAutoNumerotation::applyText * @brief ConductorAutoNumerotation::applyText
apply the text @t to @conductor_ * apply the text @t to @conductor_ and all conductors at the same potential
and all conductors at the same potential
@param t : Conductor text
*/ */
void ConductorAutoNumerotation::applyText(const QString& t) void ConductorAutoNumerotation::applyText(const QString& t)
{ {
@@ -80,36 +70,20 @@ void ConductorAutoNumerotation::applyText(const QString& t)
if (m_parent_undo) if (m_parent_undo)
{ {
new QPropertyUndoCommand( new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, m_parent_undo);
m_conductor,
"properties",
old_value,
new_value,
m_parent_undo);
undo = m_parent_undo; undo = m_parent_undo;
} }
else else
{ {
undo = new QUndoCommand(); undo = new QUndoCommand();
new QPropertyUndoCommand( new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, undo);
m_conductor, undo->setText(QObject::tr("Modifier les propriétés d'un conducteur", "undo caption"));
"properties",
old_value,
new_value,
undo);
undo->setText(
QObject::tr(
"Modifier les propriétés d'un conducteur",
"undo caption"));
} }
if (!conductor_list.isEmpty()) if (!conductor_list.isEmpty())
{ {
if (!m_parent_undo) if (!m_parent_undo)
undo->setText( undo->setText(QObject::tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
QObject::tr(
"Modifier les propriétés de plusieurs conducteurs",
"undo caption"));
foreach (Conductor *cond, conductor_list) foreach (Conductor *cond, conductor_list)
{ {
@@ -117,12 +91,7 @@ void ConductorAutoNumerotation::applyText(const QString& t)
old_value.setValue(cp2); old_value.setValue(cp2);
cp2.text = t; cp2.text = t;
new_value.setValue(cp2); new_value.setValue(cp2);
new QPropertyUndoCommand( new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
cond,
"properties",
old_value,
new_value,
undo);
} }
} }
@@ -131,19 +100,15 @@ void ConductorAutoNumerotation::applyText(const QString& t)
} }
/** /**
@brief ConductorAutoNumerotation::newProperties * @brief ConductorAutoNumerotation::newProperties
Create a new properties according to the current autonum rule of diagram * Create a new properties according to the current autonum rule of diagram
@param diagram : Diagram class * @param d
@param cp : ConductorProperties * @param cp
@param seq : sequentialNumbers * @param seq
*/ */
void ConductorAutoNumerotation::newProperties( void ConductorAutoNumerotation::newProperties(Diagram *diagram, ConductorProperties &cp, autonum::sequentialNumbers &seq)
Diagram *diagram,
ConductorProperties &cp,
autonum::sequentialNumbers &seq)
{ {
NumerotationContext context = diagram->project()->conductorAutoNum( NumerotationContext context = diagram->project()->conductorAutoNum(diagram->conductorsAutonumName());
diagram->conductorsAutonumName());
if (context.isEmpty()) { if (context.isEmpty()) {
return; return;
} }
@@ -159,8 +124,8 @@ void ConductorAutoNumerotation::newProperties(
} }
/** /**
@brief ConductorAutoNumerotation::numeratePotential * @brief ConductorAutoNumerotation::numeratePotential
Numerate a conductor on an existing potential * Numerate a conductor on an existing potential
*/ */
void ConductorAutoNumerotation::numeratePotential() void ConductorAutoNumerotation::numeratePotential()
{ {
@@ -171,8 +136,7 @@ void ConductorAutoNumerotation::numeratePotential()
if (conductor->properties() != cp) if (conductor->properties() != cp)
properties_equal = false; properties_equal = false;
} }
// Every properties of the potential is equal, //Every properties of the potential is equal, so we apply it to m_conductor
// so we apply it to m_conductor
if (properties_equal) if (properties_equal)
{ {
m_conductor->setProperties(cp); m_conductor->setProperties(cp);
@@ -205,25 +169,21 @@ void ConductorAutoNumerotation::numeratePotential()
//the texts isn't identicals //the texts isn't identicals
else else
{ {
PotentialSelectorDialog psd( PotentialSelectorDialog psd(m_conductor, m_parent_undo, m_conductor->diagramEditor());
m_conductor,
m_parent_undo,
m_conductor->diagramEditor());
psd.exec(); psd.exec();
} }
} }
/** /**
@brief ConductorAutoNumerotation::numerateNewConductor * @brief ConductorAutoNumerotation::numerateNewConductor
create and apply a new numerotation to @m_conductor * create and apply a new numerotation to @m_conductor
*/ */
void ConductorAutoNumerotation::numerateNewConductor() void ConductorAutoNumerotation::numerateNewConductor()
{ {
if (!m_conductor || m_diagram->conductorsAutonumName().isEmpty()) if (!m_conductor || m_diagram->conductorsAutonumName().isEmpty())
return; return;
NumerotationContext context = m_diagram->project()->conductorAutoNum( NumerotationContext context = m_diagram->project()->conductorAutoNum(m_diagram -> conductorsAutonumName());
m_diagram -> conductorsAutonumName());
if (context.isEmpty()) if (context.isEmpty())
return; return;
@@ -234,17 +194,10 @@ void ConductorAutoNumerotation::numerateNewConductor()
cp.m_formula = formula; cp.m_formula = formula;
m_conductor->setProperties(cp); m_conductor->setProperties(cp);
autonum::setSequential(formula, autonum::setSequential(formula, m_conductor->rSequenceNum(), context, m_diagram, autoNum_name);
m_conductor->rSequenceNum(),
context,
m_diagram,
autoNum_name);
NumerotationContextCommands ncc (context, m_diagram); NumerotationContextCommands ncc (context, m_diagram);
m_diagram->project()->addConductorAutoNum(autoNum_name, ncc.next()); m_diagram->project()->addConductorAutoNum(autoNum_name, ncc.next());
applyText(autonum::AssignVariables::formulaToLabel( applyText(autonum::AssignVariables::formulaToLabel(formula, m_conductor->rSequenceNum(), m_diagram));
formula,
m_conductor->rSequenceNum(),
m_diagram));
} }

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2020 The QElectroTech team Copyright 2006-2014 The QElectroTech team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -26,23 +26,16 @@ class Conductor;
class QUndoCommand; class QUndoCommand;
class ConductorProperties; class ConductorProperties;
/**
@brief The ConductorAutoNumerotation class
*/
class ConductorAutoNumerotation class ConductorAutoNumerotation
{ {
public: public:
//constructors & destructor //constructors & destructor
ConductorAutoNumerotation (Conductor *conductor, ConductorAutoNumerotation (Conductor *conductor, Diagram *diagram, QUndoCommand *undo_parent = nullptr);
Diagram *diagram,
QUndoCommand *undo_parent = nullptr);
//methods //methods
void numerate (); void numerate ();
void applyText (const QString&); void applyText (const QString&);
static void newProperties(Diagram *diagram, static void newProperties(Diagram *diagram, ConductorProperties &cp, autonum::sequentialNumbers &seq);
ConductorProperties &cp,
autonum::sequentialNumbers &seq);
private: private:
//methods //methods

View File

@@ -70,7 +70,6 @@ bool ConductorNumExport::toCsv()
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
stream << wiresNum() << endl; stream << wiresNum() << endl;
#else #else
#pragma message("@TODO remove code for QT 5.15 or later")
stream << wiresNum() << &Qt::endl(stream); stream << wiresNum() << &Qt::endl(stream);
#endif #endif
} }

View File

@@ -331,23 +331,12 @@ void ConductorProperties::fromXml(QDomElement &e)
horiz_rotate_text = e.attribute("horizrotatetext").toDouble(); horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>(); QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
m_horizontal_alignment = Qt::Alignment( m_horizontal_alignment = Qt::Alignment(me.keyToValue(e.attribute("horizontal-alignment", "AlignBottom").toStdString().data()));
me.keyToValue( m_vertical_alignment = Qt::Alignment(me.keyToValue(e.attribute("vertical-alignment", "AlignRight").toStdString().data()));
e.attribute(
"horizontal-alignment",
"AlignBottom"
).toStdString().data()));
m_vertical_alignment = Qt::Alignment(
me.keyToValue(
e.attribute(
"vertical-alignment",
"AlignRight"
).toStdString().data()));
//Keep retrocompatible with version older than 0,4 //Keep retrocompatible with version older than 0,4
//If the propertie @type is simple (removed since QET 0,4), we set text no visible. //If the propertie @type is simple (removed since QET 0,4), we set text no visible.
//@TODO remove this code for qet 0.6 or later //@TODO remove this code for qet 0.6 or later
#pragma message("@TODO remove this code for qet 0.6 or later")
if (e.attribute("type") == "simple") m_show_text = false; if (e.attribute("type") == "simple") m_show_text = false;
} }
@@ -765,7 +754,6 @@ void ConductorProperties::readStyle(const QString &style_string) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList styles = style_string.split(";", QString::SkipEmptyParts); QStringList styles = style_string.split(";", QString::SkipEmptyParts);
#else #else
#pragma message("@TODO remove code QString::SkipEmptyParts for QT 5.14 or later")
QStringList styles = style_string.split(";", Qt::SkipEmptyParts); QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
#endif #endif

View File

@@ -25,7 +25,6 @@
class QPainter; class QPainter;
/** /**
@brief The SingleLineProperties class
This class represents the properties of a singleline conductor. This class represents the properties of a singleline conductor.
*/ */
class SingleLineProperties { class SingleLineProperties {
@@ -60,7 +59,6 @@ class SingleLineProperties {
}; };
/** /**
@brief The ConductorProperties class
This class represents the functional properties of a particular conductor, This class represents the functional properties of a particular conductor,
i.e. properties other than path and terminals. i.e. properties other than path and terminals.
*/ */
@@ -71,10 +69,9 @@ class ConductorProperties
virtual ~ConductorProperties(); virtual ~ConductorProperties();
/** /**
@brief The ConductorType enum Represents * @brief The ConductorType enum Represents the kind of a particular conductor:
the kind of a particular conductor: * Single: singleline symbols, no text input
Single: singleline symbols, no text input * Multi: text input, no symbol
Multi: text input, no symbol
*/ */
enum ConductorType { Single, Multi }; enum ConductorType { Single, Multi };

View File

@@ -15,32 +15,19 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QScrollArea>
#include "configdialog.h" #include "configdialog.h"
#include "configpages.h" #include "configpages.h"
#include "qetapp.h" #include "qetapp.h"
#include "machine_info.h"
/** /**
Constructeur Constructeur
@param parent QWidget parent @param parent QWidget parent
*/ */
ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) { ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
Machine_info *mymachineinfo= new Machine_info(this);
//ScrollArea for low screens
QScrollArea *scroll = new QScrollArea(this);
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
// liste des pages // liste des pages
pages_list = new QListWidget(); pages_list = new QListWidget();
pages_list -> setViewMode(QListView::IconMode); pages_list -> setViewMode(QListView::IconMode);
if(mymachineinfo->get_max_screen_height()<1000){
pages_list -> setIconSize(QSize(64, 64));
} else {
pages_list -> setIconSize(QSize(128, 128)); pages_list -> setIconSize(QSize(128, 128));
}
pages_list -> setMovement(QListView::Static); pages_list -> setMovement(QListView::Static);
pages_list -> setMinimumWidth(168); pages_list -> setMinimumWidth(168);
pages_list -> setMaximumWidth(168); pages_list -> setMaximumWidth(168);
@@ -49,39 +36,24 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
// pages // pages
pages_widget = new QStackedWidget(); pages_widget = new QStackedWidget();
// boutons // boutons
buttons = new QDialogButtonBox( buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
QDialogButtonBox::Ok
|QDialogButtonBox::Cancel);
QWidget *viewport = new QWidget(this);
scroll->setWidget(viewport);
scroll->setWidgetResizable(true);
// layouts // layouts
QHBoxLayout *hlayout1 = new QHBoxLayout(viewport); QHBoxLayout *hlayout1 = new QHBoxLayout();
// add needed widgets to layout "hlayout1"
hlayout1 -> addWidget(pages_list); hlayout1 -> addWidget(pages_list);
hlayout1 -> addWidget(pages_widget); hlayout1 -> addWidget(pages_widget);
//add hlayout1 to widget QVBoxLayout *vlayout1 = new QVBoxLayout();
viewport->setLayout(hlayout1); vlayout1 -> addLayout(hlayout1);
vlayout1 -> addWidget(buttons);
// Add a layout for QDialog setLayout(vlayout1);
QVBoxLayout *dialog_layout = new QVBoxLayout(this);
dialog_layout->addWidget(scroll); // add scroll to the QDialog's layout
dialog_layout -> addWidget(buttons);
setLayout(dialog_layout);
// connexion signaux / slots // connexion signaux / slots
connect(buttons, SIGNAL(accepted()), this, SLOT(applyConf())); connect(buttons, SIGNAL(accepted()), this, SLOT(applyConf()));
connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
connect(pages_list, SIGNAL(currentRowChanged(int)), connect(pages_list, SIGNAL(currentRowChanged(int)), pages_widget, SLOT(setCurrentIndex(int)));
pages_widget, SLOT(setCurrentIndex(int)));
resize(mymachineinfo->get_max_screen_width(),
mymachineinfo->get_max_screen_height());
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
if (parent) { if (parent) {

View File

@@ -46,7 +46,6 @@ ElementQueryWidget::ElementQueryWidget(QWidget *parent) :
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), [this](int id) connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), [this](int id)
#else #else
#pragma message("@TODO remove code for QT 5.15 or later")
connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idClicked), [this](int id) connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idClicked), [this](int id)
#endif #endif
{ {

View File

@@ -928,6 +928,8 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
// The first element must be a diagram // The first element must be a diagram
if (root.tagName() != "diagram") return(false); if (root.tagName() != "diagram") return(false);
qDebug() << "Diagram: " << root.attribute("title");
// Read attributes of this diagram // Read attributes of this diagram
if (consider_informations) { if (consider_informations) {
// Version of diagram // Version of diagram
@@ -1023,6 +1025,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
} }
int state = 0; int state = 0;
qDebug() << "Element from collection: " << element_location;
Element *nvel_elmt = ElementFactory::Instance() -> createElement(element_location, nullptr, &state); Element *nvel_elmt = ElementFactory::Instance() -> createElement(element_location, nullptr, &state);
if (state) if (state)
{ {
@@ -1141,7 +1144,6 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
content_ptr -> m_images = added_images.toSet(); content_ptr -> m_images = added_images.toSet();
content_ptr -> m_shapes = added_shapes.toSet(); content_ptr -> m_shapes = added_shapes.toSet();
#else #else
#pragma message("@TODO remove code for QT 5.14 or later")
content_ptr -> m_text_fields = QSet<IndependentTextItem *>( content_ptr -> m_text_fields = QSet<IndependentTextItem *>(
added_texts.begin(), added_texts.begin(),
added_texts.end()); added_texts.end());

View File

@@ -118,7 +118,7 @@ int DiagramContext::count() {
/** /**
* @brief DiagramContext::keyMustShow * @brief DiagramContext::keyMustShow
* @return the value pairs with key, if key no found, return false * @return the value pairs with key, if key not found, return false
*/ */
bool DiagramContext::keyMustShow(const QString &key) const { bool DiagramContext::keyMustShow(const QString &key) const {
if (m_content_show.contains(key)) if (m_content_show.contains(key))

View File

@@ -416,7 +416,6 @@ void ChangeZValueCommand::applyRaise(const QList<QGraphicsItem *> &items_list) {
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) // ### Qt 6: remove
my_items_list.swap(i, i + 1); my_items_list.swap(i, i + 1);
#else #else
#pragma message("@TODO remove code for QT 5.13 or later")
my_items_list.swapItemsAt(i, i + 1); my_items_list.swapItemsAt(i, i + 1);
#endif #endif
} }
@@ -439,7 +438,6 @@ void ChangeZValueCommand::applyLower(const QList<QGraphicsItem *> &items_list) {
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) // ### Qt 6: remove
my_items_list.swap(i, i - 1); my_items_list.swap(i, i - 1);
#else #else
#pragma message("@TODO remove code for QT 5.13 or later")
my_items_list.swapItemsAt(i, i - 1); my_items_list.swapItemsAt(i, i - 1);
#endif #endif
} }

View File

@@ -498,7 +498,6 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts); QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
#else #else
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts); QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts);
#endif #endif

View File

@@ -53,7 +53,6 @@ ElementsCollectionCache::ElementsCollectionCache(const QString &database_path, Q
//TODO This code remove old table with mtime for create table with uuid, created at version 0,5 //TODO This code remove old table with mtime for create table with uuid, created at version 0,5
//see to remove this code at version 0,6 or 0,7 when all users will table with uuid. //see to remove this code at version 0,6 or 0,7 when all users will table with uuid.
#pragma message("@TODO remove this code for qet 0.6 or later")
QSqlQuery table_name(cache_db_); QSqlQuery table_name(cache_db_);
if (table_name.exec("PRAGMA table_info(names)")) if (table_name.exec("PRAGMA table_info(names)"))
{ {

View File

@@ -559,7 +559,6 @@ void ElementPictureFactory::setPainterStyle(const QDomElement &dom, QPainter &pa
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
const QStringList styles = dom.attribute("style").split(";", QString::SkipEmptyParts); const QStringList styles = dom.attribute("style").split(";", QString::SkipEmptyParts);
#else #else
#pragma message("@TODO remove code for QT 5.14 or later")
const QStringList styles = dom.attribute("style").split(";", Qt::SkipEmptyParts); const QStringList styles = dom.attribute("style").split(";", Qt::SkipEmptyParts);
#endif #endif
QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$"); QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");

View File

@@ -1,85 +0,0 @@
/*
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 "machine_info.h"
#include <QScreen>
#include <QApplication>
/**
@brief Machine_info::Machine_info
@param parent
*/
Machine_info::Machine_info(QObject *parent) : QObject(parent)
{
init_get_Screen_info();
}
/**
@brief Machine_info::init_get_Screen_info
Finds the largest screen and saves the values
*/
void Machine_info::init_get_Screen_info()
{
const auto screens = qApp->screens();
for (int ii = 0; ii < screens.count(); ++ii)
{
if(
Max_screen_width
<
screens[ii]->geometry().width()
*
screens[ii]->devicePixelRatio()
)
{
Max_screen_width =
screens[ii]->geometry().width()
*
screens[ii]->devicePixelRatio();
}
if(
Max_screen_height
<
screens[ii]->geometry().height()
*
screens[ii]->devicePixelRatio()
)
{
Max_screen_height =
screens[ii]->geometry().height()
*
screens[ii]->devicePixelRatio();
}
}
}
/**
@brief Machine_info::get_max_screen_width
@return max screen width
*/
int32_t Machine_info::get_max_screen_width()
{
return Max_screen_width;
}
/**
@brief Machine_info::get_max_screen_height
@return max screen height
*/
int32_t Machine_info::get_max_screen_height()
{
return Max_screen_height;
}

View File

@@ -1,45 +0,0 @@
/*
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 MACHINE_INFO_H
#define MACHINE_INFO_H
#include <QObject>
/**
@brief The Machine_info class
This class hold information from your PC.
*/
class Machine_info : public QObject
{
Q_OBJECT
public:
explicit Machine_info(QObject *parent = nullptr);
int32_t get_max_screen_width();
int32_t get_max_screen_height();
signals:
private:
void init_get_Screen_info();
int32_t Max_screen_width;
int32_t Max_screen_height;
};
#endif // MACHINE_INFO_H

View File

@@ -22,13 +22,11 @@
#include <QStyleFactory> #include <QStyleFactory>
/** /**
@brief main * @brief main
Main function of QElectroTech * Main function of QElectroTech
@param argc : number of parameters * @param argc : number of paramètres
\~French number of paramètres * @param argv : paramètres
\~ @param argv : parameters * @return
\~French paramètres
\~ @return exit code
*/ */
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
@@ -39,7 +37,6 @@ int main(int argc, char **argv)
//Creation and execution of the application //Creation and execution of the application
//HighDPI //HighDPI
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
#pragma message("@TODO remove code for QT 5.6 or later")
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#else #else
qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("auto")); qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("auto"));
@@ -59,16 +56,14 @@ int main(int argc, char **argv)
//Remove the first argument, it's the binary file //Remove the first argument, it's the binary file
arg_list.takeFirst(); arg_list.takeFirst();
QETArguments qetarg(arg_list); QETArguments qetarg(arg_list);
QString message = "launched-with-args: " + QET::joinWithSpaces( QString message = "launched-with-args: " + QET::joinWithSpaces(QStringList(qetarg.arguments()));
QStringList(qetarg.arguments()));
app.sendMessage(message.toUtf8()); app.sendMessage(message.toUtf8());
return 0; return 0;
} }
QETApp qetapp; QETApp qetapp;
QETApp::instance()->installEventFilter(&qetapp); QETApp::instance()->installEventFilter(&qetapp);
QObject::connect(&app, &SingleApplication::receivedMessage, QObject::connect(&app, &SingleApplication::receivedMessage, &qetapp, &QETApp::receiveMessage);
&qetapp, &QETApp::receiveMessage);
return app.exec(); return app.exec();
} }

View File

@@ -69,7 +69,6 @@ bool nomenclature::saveToCSVFile()
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
stream << getNomenclature() << endl; stream << getNomenclature() << endl;
#else #else
#pragma message("@TODO remove code for QT 5.15 or later")
stream << getNomenclature() << &Qt::endl(stream); stream << getNomenclature() << &Qt::endl(stream);
#endif #endif
} }

View File

@@ -17,16 +17,6 @@
*/ */
#include "propertiesinterface.h" #include "propertiesinterface.h"
/**
@brief PropertiesInterface::PropertiesInterface
*/
PropertiesInterface::PropertiesInterface() PropertiesInterface::PropertiesInterface()
{ {
} }
/**
@brief PropertiesInterface::~PropertiesInterface
*/
PropertiesInterface::~PropertiesInterface()
{
}

View File

@@ -23,44 +23,18 @@
#include <QDomElement> #include <QDomElement>
/** /**
@brief The PropertiesInterface class * @brief The PropertiesInterface class
This class is an interface for have common way * This class is an interface for have common way to use properties in QElectroTech
to use properties in QElectroTech
*/ */
class PropertiesInterface class PropertiesInterface
{ {
public: public:
PropertiesInterface(); PropertiesInterface();
virtual ~PropertiesInterface(); // Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre
/** virtual void toSettings (QSettings &settings, const QString = QString()) const =0;
@brief toSettings virtual void fromSettings (const QSettings &settings, const QString = QString()) =0;
Save properties to setting file. // Save/load properties to xml element
@param settings : is use for prefix a word
befor the name of each paramètre
*/
virtual void toSettings (QSettings &settings,
const QString = QString()) const =0;
/**
@brief fromSettings
load properties to setting file.
@param settings : is use for prefix a word
befor the name of each paramètre
*/
virtual void fromSettings (const QSettings &settings,
const QString = QString()) =0;
/**
@brief toXml
Save properties to xml element
@param xml_document
@return QDomElement
*/
virtual QDomElement toXml (QDomDocument &xml_document) const =0; virtual QDomElement toXml (QDomDocument &xml_document) const =0;
/**
@brief fromXml
load properties to xml element
@param xml_element
@return true / false
*/
virtual bool fromXml (const QDomElement &xml_element) =0; virtual bool fromXml (const QDomElement &xml_element) =0;
}; };

View File

@@ -20,9 +20,6 @@
#include <QString> #include <QString>
/**
@brief The ReportProperties class
*/
class ReportProperties class ReportProperties
{ {
public: public:

View File

@@ -23,89 +23,44 @@ TerminalData::~TerminalData()
} }
/**
@brief TerminalData::setParent
@param parent
*/
void TerminalData::setParent(QGraphicsObject* parent) void TerminalData::setParent(QGraphicsObject* parent)
{ {
q = parent; q = parent;
} }
/**
@brief TerminalData::toSettings
Save properties to setting file.
QString is use for prefix a word befor the name of each paramètre
@param settings UNUSED
*/
void TerminalData::toSettings(QSettings &settings, const QString) const void TerminalData::toSettings(QSettings &settings, const QString) const
{ {
Q_UNUSED(settings); Q_UNUSED(settings);
} }
/**
@brief TerminalData::fromSettings
load properties to setting file.
QString is use for prefix a word befor the name of each paramètre
@param settings UNUSED
*/
void TerminalData::fromSettings(const QSettings &settings, const QString) void TerminalData::fromSettings(const QSettings &settings, const QString)
{ {
Q_UNUSED(settings); Q_UNUSED(settings);
} }
/**
@brief TerminalData::toXml
Save properties to xml element
write the name, number, position and orientation of the terminal
to xml_element
@note This method is only called from the PartTerminal
and should never called from the Terminal class
@param xml_document
@return xml_element : DomElement with
the name, number, position and orientation of the terminal
*/
QDomElement TerminalData::toXml(QDomDocument &xml_document) const QDomElement TerminalData::toXml(QDomDocument &xml_document) const
{ {
QDomElement xml_element = xml_document.createElement("terminal"); QDomElement xml_element = xml_document.createElement("terminal");
// write the position of the terminal
// ecrit la position de la borne // ecrit la position de la borne
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x())); xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y())); xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
// Write name and number to XML
xml_element.setAttribute("uuid", m_uuid.toString()); xml_element.setAttribute("uuid", m_uuid.toString());
xml_element.setAttribute("name", m_name); xml_element.setAttribute("name", m_name);
// write the orientation of the terminal
// ecrit l'orientation de la borne // ecrit l'orientation de la borne
xml_element.setAttribute("orientation", xml_element.setAttribute("orientation", Qet::orientationToString(m_orientation));
Qet::orientationToString(m_orientation)); // Write name and number to XML
return(xml_element); return(xml_element);
} }
/**
@brief TerminalData::fromXml
load properties to xml element
@note This method is only called from the PartTerminal
and should never called from the Terminal class
@param xml_element
@return true if succeeded / false if the attribute is not real
*/
bool TerminalData::fromXml (const QDomElement &xml_element) bool TerminalData::fromXml (const QDomElement &xml_element)
{ {
qreal term_x = 0.0;
qreal term_y = 0.0;
// reads the position of the terminal
// lit la position de la borne // lit la position de la borne
qreal term_x = 0.0, term_y = 0.0;
if (!QET::attributeIsAReal(xml_element, "x", &term_x)) if (!QET::attributeIsAReal(xml_element, "x", &term_x))
return false; return false;
@@ -117,20 +72,16 @@ bool TerminalData::fromXml (const QDomElement &xml_element)
//emit posFromXML(QPointF(term_x, term_y)); //emit posFromXML(QPointF(term_x, term_y));
QString uuid = xml_element.attribute("uuid"); QString uuid = xml_element.attribute("uuid");
// update part and add uuid, which is used in the new version // update part and add uuid, which is used in the new version to connect terminals together
// to connect terminals together // if the attribute not exists, means, the element is created with an older version of qet. So use the legacy approach
// if the attribute not exists, means, the element is created with an
// older version of qet. So use the legacy approach
// to identify terminals // to identify terminals
if (!uuid.isEmpty()) if (!uuid.isEmpty())
m_uuid = QUuid(uuid); m_uuid = QUuid(uuid);
m_name = xml_element.attribute("name"); m_name = xml_element.attribute("name");
// read the orientation of the terminal
// lit l'orientation de la borne // lit l'orientation de la borne
m_orientation = Qet::orientationFromString( m_orientation = Qet::orientationFromString(xml_element.attribute("orientation"));
xml_element.attribute("orientation"));
return true; return true;
} }

View File

@@ -26,58 +26,50 @@ class TerminalData : public PropertiesInterface
void init(); void init();
void setParent(QGraphicsObject* parent); void setParent(QGraphicsObject* parent);
void toSettings(QSettings &settings,
const QString = QString()) const override; // Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre
void fromSettings(const QSettings &settings, void toSettings(QSettings &settings, const QString = QString()) const override;
const QString = QString()) override; void fromSettings(const QSettings &settings, const QString = QString()) override;
// Save/load properties to xml element
// This method is only called from the PartTerminal and should never called from the Terminal class
QDomElement toXml(QDomDocument &xml_element) const override; QDomElement toXml(QDomDocument &xml_element) const override;
bool fromXml(const QDomElement &xml_element) override; bool fromXml(const QDomElement &xml_element) override;
// must be public, because this class is a private member // must be public, because this class is a private member of PartTerminal/Terminal and they must
// of PartTerminal/Terminal and they must access this data // access this data
public: public:
/** /*!
@brief m_orientation * \brief m_orientation
Orientation of the terminal * Orientation of the terminal
*/ */
Qet::Orientation m_orientation; Qet::Orientation m_orientation;
/** /*!
@brief second_point * \brief second_point
Position of the second point of the terminal * Position of the second point of the terminal in scene coordinates
in scene coordinates
*/ */
QPointF second_point; QPointF second_point;
/** /*!
@brief m_uuid * \brief m_uuid
Uuid of the terminal. * Uuid of the terminal.
*
In elementscene.cpp an element gets a new uuid when * In elementscene.cpp an element gets a new uuid when saving the element. In the current state
saving the element. In the current state * each connection is made by using the local position of the terminal and a dynamic id. In the new
each connection is made by using the local position * case, each terminal should have it's own uuid to identify it uniquely. When changing each time this
of the terminal and a dynamic id. In the new * uuid, the conductor after updating the part is anymore valid. So if in the loaded document a uuid exists,
case, each terminal should have it's own uuid to * use this one and don't create a new one.
identify it uniquely. When changing each time this
uuid, the conductor after updating the part is anymore
valid. So if in the loaded document a uuid exists,
use this one and don't create a new one.
*/ */
QUuid m_uuid; QUuid m_uuid;
/** /*!
@brief m_name * \brief m_name
Name of the element. * Name of the element. It can be used to create wiring harness tables
It can be used to create wiring harness tables
*/ */
QString m_name; QString m_name;
/** /*!
@brief m_pos * \brief m_pos
Position of the terminal. The second point is calculated * Position of the terminal. The second point is calculated from this position and the orientation
from this position and the orientation * Important: this variable is only updated during read from xml and not during mouse move!
@note * It is used to store the initial position so that PartTerminal and Terminal have access to it.
Important: this variable is only updated during read
from xml and not during mouse move!
It is used to store the initial position so that
PartTerminal and Terminal have access to it.
*/ */
QPointF m_pos; QPointF m_pos;
private: private:

View File

@@ -176,7 +176,6 @@ bool QET::orthogonalProjection(const QPointF &point, const QLineF &line, QPointF
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectType it = line.intersect(perpendicular_line, &intersection_point); // ### Qt 6: remove QLineF::IntersectType it = line.intersect(perpendicular_line, &intersection_point); // ### Qt 6: remove
#else #else
#pragma message("@TODO remove code for QT 5.14 or later")
QLineF::IntersectType it = line.intersects(perpendicular_line, &intersection_point); QLineF::IntersectType it = line.intersects(perpendicular_line, &intersection_point);
#endif #endif
@@ -451,7 +450,6 @@ QStringList QET::splitWithSpaces(const QString &string) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList escaped_strings = string.split(QRegExp("[^\\]?(?:\\\\)* "), QString::SkipEmptyParts); QStringList escaped_strings = string.split(QRegExp("[^\\]?(?:\\\\)* "), QString::SkipEmptyParts);
#else #else
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList escaped_strings = string.split(QRegExp("[^\\]?(?:\\\\)* "), Qt::SkipEmptyParts); QStringList escaped_strings = string.split(QRegExp("[^\\]?(?:\\\\)* "), Qt::SkipEmptyParts);
#endif #endif

View File

@@ -2220,19 +2220,19 @@ void QETDiagramEditor::generateTerminalBlock()
success = process->startDetached("qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())}); success = process->startDetached("qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
} }
else { else {
success = process->startDetached("qet_tb_generator", {("")}); success = process->startDetached("qet_tb_generator");
} }
if (openedProjects().count()){ if (openedProjects().count()){
success = process->startDetached(QDir::homePath() + "/Application Data/qet/qet_tb_generator.exe", {(QETDiagramEditor::currentProjectView()->project()->filePath())}); success = process->startDetached(QDir::homePath() + "/Application Data/qet/qet_tb_generator.exe", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
} }
else { else {
success = process->startDetached(QDir::homePath() + "/Application Data/qet/qet_tb_generator.exe", {("")}); success = process->startDetached(QDir::homePath() + "/Application Data/qet/qet_tb_generator.exe");
} }
if (openedProjects().count()){ if (openedProjects().count()){
success = process->startDetached(QDir::homePath() + "/qet_tb_generator.exe", {(QETDiagramEditor::currentProjectView()->project()->filePath())}); success = process->startDetached(QDir::homePath() + "/qet_tb_generator.exe", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
} }
else { else {
success = process->startDetached(QDir::homePath() + "/qet_tb_generator.exe", {("")}); success = process->startDetached(QDir::homePath() + "/qet_tb_generator.exe");
} }
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
@@ -2240,13 +2240,13 @@ void QETDiagramEditor::generateTerminalBlock()
success = process->startDetached("/Library/Frameworks/Python.framework/Versions/3.8/bin/qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())}); success = process->startDetached("/Library/Frameworks/Python.framework/Versions/3.8/bin/qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
} }
else { else {
success = process->startDetached("/Library/Frameworks/Python.framework/Versions/3.8/bin/qet_tb_generator", {("")}); success = process->startDetached("/Library/Frameworks/Python.framework/Versions/3.8/bin/qet_tb_generator");
} }
if (openedProjects().count()){ if (openedProjects().count()){
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator.app", {(QETDiagramEditor::currentProjectView()->project()->filePath())}); success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator.app", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
} }
else { else {
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator.app", {("")}); success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator.app");
} }
#else #else
@@ -2254,13 +2254,13 @@ void QETDiagramEditor::generateTerminalBlock()
success = process->startDetached("qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())}); success = process->startDetached("qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
} }
else { else {
success = process->startDetached("qet_tb_generator", {("")}); success = process->startDetached("qet_tb_generator");
} }
if (openedProjects().count()){ if (openedProjects().count()){
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())}); success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
} }
else { else {
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator", {("")}); success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator");
} }
#endif #endif

View File

@@ -309,6 +309,8 @@ void ProjectDBModel::dataBaseUpdated()
auto new_record = m_record; auto new_record = m_record;
m_record = original_record; m_record = original_record;
//This a very special case, if this nomenclature model is added
//befor any element, column count return 0, so in this case we emit column inserted
if (new_record.size() != m_record.size()) if (new_record.size() != m_record.size())
{ {
emit beginResetModel(); emit beginResetModel();

View File

@@ -61,56 +61,6 @@ void QetGraphicsTableItem::adjustTableToFolio(QetGraphicsTableItem *table, QMarg
table->setDisplayNRow(int(floor(available_height/min_row_height))); //Convert a double to int, but max_row_to_display is already rounded an integer so we assume everything is ok table->setDisplayNRow(int(floor(available_height/min_row_height))); //Convert a double to int, but max_row_to_display is already rounded an integer so we assume everything is ok
} }
/**
* @brief QetGraphicsTableItem::checkInsufficientRowsCount
* Check if the number of rows of @table + linked table is enough to display all
* content of the model, if not open a dialog to advise user what to do.
* @param table
*/
void QetGraphicsTableItem::checkInsufficientRowsCount(QetGraphicsTableItem *table)
{
if (!table->diagram() || !table->model()) {
return;
}
auto first_table = table;
while (first_table->previousTable())
first_table = first_table->previousTable();
if (first_table->displayNRow() <= 0) //displayed rows is unlimited
return;
int count_ = first_table->displayNRow();
bool several_table = false;
while (first_table->nextTable())
{
several_table = true;
first_table = first_table->nextTable();
if (first_table->displayNRow() <= 0) { //displayed rows is unlimited
return;
} else {
count_ += first_table->displayNRow();
first_table->displayNRowOffset();
}
}
if (count_ < first_table->model()->rowCount())
{
QWidget *parent = first_table->diagram()->views().first() ? first_table->diagram()->views().first() : nullptr;
QString text;
if (several_table) {
text = tr("Les information à afficher sont supérieurs à la quantité maximal pouvant être affiché par les tableaux.\n"
"Veuillez ajouter un nouveau tableau ou regler les tableaux existant afin d'afficher l'integralité des informations.");
} else {
text = tr("Les information à afficher sont supérieurs à la quantité maximal pouvant être affiché par le tableau.\n"
"Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'afficher l'integralité des informations.");
}
QMessageBox::information(parent, tr("Limitation de tableau"), text);
}
}
/** /**
* @brief QetGraphicsTableItem::QetGraphicsTableItem * @brief QetGraphicsTableItem::QetGraphicsTableItem
* Default constructor * Default constructor
@@ -651,10 +601,6 @@ QVariant QetGraphicsTableItem::itemChange(QGraphicsItem::GraphicsItemChange chan
void QetGraphicsTableItem::modelReseted() { void QetGraphicsTableItem::modelReseted() {
dataChanged(m_model->index(0,0), m_model->index(0,0), QVector<int>()); dataChanged(m_model->index(0,0), m_model->index(0,0), QVector<int>());
setToMinimumHeight(); setToMinimumHeight();
if (!previousTable()) { //this is the head table
checkInsufficientRowsCount(this);
}
} }
/** /**

View File

@@ -48,7 +48,6 @@ class QetGraphicsTableItem : public QetGraphicsItem
public : public :
static void adjustTableToFolio(QetGraphicsTableItem *table, QMargins margins = QMargins(20,20,20,0)); static void adjustTableToFolio(QetGraphicsTableItem *table, QMargins margins = QMargins(20,20,20,0));
static void checkInsufficientRowsCount(QetGraphicsTableItem *first_table);
public: public:
QetGraphicsTableItem(QGraphicsItem *parent= nullptr); QetGraphicsTableItem(QGraphicsItem *parent= nullptr);

View File

@@ -52,8 +52,6 @@ GraphicsTablePropertiesEditor::GraphicsTablePropertiesEditor(QetGraphicsTableIte
if (table) { if (table) {
setTable(table); setTable(table);
} }
ui->m_info_label->setStyleSheet("QLabel {color : red; }");
} }
/** /**
@@ -283,8 +281,6 @@ void GraphicsTablePropertiesEditor::updateUi()
} }
} }
updateInfoLabel();
auto margin = QETUtils::marginsFromString(m_table_item->model()->headerData(0, Qt::Horizontal, Qt::UserRole+1).toString()); auto margin = QETUtils::marginsFromString(m_table_item->model()->headerData(0, Qt::Horizontal, Qt::UserRole+1).toString());
ui->m_header_top_margin ->setValue(margin.top()); ui->m_header_top_margin ->setValue(margin.top());
ui->m_header_left_margin ->setValue(margin.left()); ui->m_header_left_margin ->setValue(margin.left());
@@ -310,38 +306,6 @@ void GraphicsTablePropertiesEditor::updateUi()
setUpEditConnection(); setUpEditConnection();
} }
void GraphicsTablePropertiesEditor::updateInfoLabel()
{
auto table_ = m_table_item;
while (table_->previousTable()) { table_ = table_->previousTable();}
int count_ = 0;
bool infinite = false;
if (table_->displayNRow() <= 0) {
infinite = true;
} else {
count_ = table_->displayNRow();
}
while (table_->nextTable())
{
table_ = table_->nextTable();
if (table_->displayNRow() <= 0) {
infinite = true;
} else {
count_ += table_->displayNRow();
}
}
auto value = m_table_item->model()->rowCount() - count_;
if (value > 0 && !infinite) {
ui->m_info_label->setText(tr("<center>ATTENTION :</center>\n il manque %1 lignes afin d'afficher l'intégralité des informations").arg(value));
ui->m_info_label->show();
} else {
ui->m_info_label->hide();
}
}
/** /**
* @brief GraphicsTablePropertiesEditor::setUpEditConnection * @brief GraphicsTablePropertiesEditor::setUpEditConnection
*/ */
@@ -369,12 +333,10 @@ void GraphicsTablePropertiesEditor::setUpEditConnection()
m_edit_connection << connect(m_table_button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &GraphicsTablePropertiesEditor::apply); m_edit_connection << connect(m_table_button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &GraphicsTablePropertiesEditor::apply);
m_edit_connection << connect(m_header_button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &GraphicsTablePropertiesEditor::apply); m_edit_connection << connect(m_header_button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &GraphicsTablePropertiesEditor::apply);
#else #else
#pragma message("@TODO remove code for QT 5.15 or later")
m_edit_connection << connect(m_table_button_group, QOverload<int>::of(&QButtonGroup::idClicked), this, &GraphicsTablePropertiesEditor::apply); m_edit_connection << connect(m_table_button_group, QOverload<int>::of(&QButtonGroup::idClicked), this, &GraphicsTablePropertiesEditor::apply);
m_edit_connection << connect(m_header_button_group, QOverload<int>::of(&QButtonGroup::idClicked), this, &GraphicsTablePropertiesEditor::apply); m_edit_connection << connect(m_header_button_group, QOverload<int>::of(&QButtonGroup::idClicked), this, &GraphicsTablePropertiesEditor::apply);
#endif #endif
m_edit_connection << connect(ui->m_display_n_row_sb, QOverload<int>::of(&QSpinBox::valueChanged), this, &GraphicsTablePropertiesEditor::apply); m_edit_connection << connect(ui->m_display_n_row_sb, QOverload<int>::of(&QSpinBox::valueChanged), this, &GraphicsTablePropertiesEditor::apply);
m_edit_connection << connect(ui->m_display_n_row_sb, QOverload<int>::of(&QSpinBox::valueChanged), this, &GraphicsTablePropertiesEditor::updateInfoLabel);
} }
} }

View File

@@ -52,7 +52,6 @@ class GraphicsTablePropertiesEditor : public PropertiesEditorWidget
void on_m_header_font_pb_clicked(); void on_m_header_font_pb_clicked();
void on_m_table_font_pb_clicked(); void on_m_table_font_pb_clicked();
virtual void updateUi() override; virtual void updateUi() override;
void updateInfoLabel();
void on_m_table_name_le_textEdited(const QString &arg1); void on_m_table_name_le_textEdited(const QString &arg1);
void on_m_previous_table_cb_activated(int index); void on_m_previous_table_cb_activated(int index);
void on_m_previous_pb_clicked(); void on_m_previous_pb_clicked();

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>524</width>
<height>623</height> <height>600</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -40,17 +40,40 @@
<string>Géometrie et lignes</string> <string>Géometrie et lignes</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0,0,0,0,0,0"> <layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0,0,0,0,0,0">
<item row="1" column="4"> <item row="0" column="6">
<widget class="QSpinBox" name="m_display_n_row_sb"> <widget class="QPushButton" name="m_apply_geometry_to_linked_table_pb">
<property name="specialValueText"> <property name="toolTip">
<string>Toutes</string> <string>Appliquer la géometrie à tous les tableaux liée à celui-ci</string>
</property> </property>
<property name="maximum"> <property name="text">
<number>999</number> <string/>
</property>
<property name="icon">
<iconset resource="../../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/all_pages.png</normaloff>:/ico/22x22/all_pages.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="6"> <item row="1" column="2">
<widget class="QSpinBox" name="m_y_pos">
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QComboBox" name="m_previous_table_cb">
<property name="insertPolicy">
<enum>QComboBox::InsertAtBottom</enum>
</property>
<item>
<property name="text">
<string>Aucun</string>
</property>
</item>
</widget>
</item>
<item row="1" column="6">
<widget class="QPushButton" name="m_next_pb"> <widget class="QPushButton" name="m_next_pb">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@@ -70,19 +93,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="4"> <item row="0" column="2">
<widget class="QComboBox" name="m_previous_table_cb"> <widget class="QSpinBox" name="m_x_pos">
<property name="insertPolicy"> <property name="maximum">
<enum>QComboBox::InsertAtBottom</enum> <number>10000</number>
</property> </property>
<item>
<property name="text">
<string>Aucun</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="0" column="0">
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@@ -95,7 +113,20 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="5"> <item row="1" column="7">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="m_auto_geometry_pb"> <widget class="QPushButton" name="m_auto_geometry_pb">
<property name="toolTip"> <property name="toolTip">
<string>Ajuster le tableau au folio</string> <string>Ajuster le tableau au folio</string>
@@ -109,47 +140,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="7"> <item row="2" column="1" colspan="6">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Y :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_8">
<property name="text">
<string>X :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="m_x_pos">
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="4" column="1" colspan="6">
<widget class="QWidget" name="widget_3" native="true"> <widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin"> <property name="leftMargin">
@@ -167,7 +158,47 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="5"> <item row="0" column="3">
<widget class="QLabel" name="label">
<property name="text">
<string>Lignes à afficher :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_8">
<property name="text">
<string>X :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QSpinBox" name="m_display_n_row_sb">
<property name="specialValueText">
<string>Toutes</string>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Tableau précédent :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QPushButton" name="m_previous_pb"> <widget class="QPushButton" name="m_previous_pb">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@@ -187,60 +218,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="1" column="1">
<widget class="QSpinBox" name="m_y_pos"> <widget class="QLabel" name="label_7">
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QPushButton" name="m_apply_geometry_to_linked_table_pb">
<property name="toolTip">
<string>Appliquer la géometrie à tous les tableaux liée à celui-ci</string>
</property>
<property name="text"> <property name="text">
<string/> <string>Y :</string>
</property>
<property name="icon">
<iconset resource="../../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/all_pages.png</normaloff>:/ico/22x22/all_pages.png</iconset>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Tableau précédent :</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3">
<widget class="QLabel" name="label">
<property name="text">
<string>Lignes à afficher :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1" colspan="6">
<widget class="QLabel" name="m_info_label">
<property name="text">
<string>TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@@ -1675,7 +1675,6 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram,
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
other_conductors += other_conductors_list_t.toSet(); other_conductors += other_conductors_list_t.toSet();
#else #else
#pragma message("@TODO remove code for QT 5.14 or later")
other_conductors += QSet<Conductor*>(other_conductors_list_t.begin(),other_conductors_list_t.end()); other_conductors += QSet<Conductor*>(other_conductors_list_t.begin(),other_conductors_list_t.end());
#endif #endif
} }

View File

@@ -418,6 +418,7 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
{ {
//Minor workaround to find if there is a "input" tagg as label. //Minor workaround to find if there is a "input" tagg as label.
//If not, we set the tagg "label" to the first "input. //If not, we set the tagg "label" to the first "input.
// TODO: Remove in later version begin
QList <QDomElement> input_field; QList <QDomElement> input_field;
bool have_label = false; bool have_label = false;
for (QDomElement input_node = node.firstChildElement("input") ; !input_node.isNull() ; input_node = input_node.nextSiblingElement("input")) for (QDomElement input_node = node.firstChildElement("input") ; !input_node.isNull() ; input_node = input_node.nextSiblingElement("input"))
@@ -429,8 +430,11 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
have_label = true; have_label = true;
} }
} }
if(!have_label && !input_field.isEmpty()) if(!have_label && !input_field.isEmpty()) {
qDebug() << input_field.first().attribute("text");
input_field.first().setAttribute("tagg", "label"); input_field.first().setAttribute("tagg", "label");
}
// TODO: Remove in later version end
//Parse the definition //Parse the definition
for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling()) for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling())
@@ -717,15 +721,20 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
setRotation(90*read_ori); setRotation(90*read_ori);
} }
//Befor load the dynamic text field, // TODO: elementInformations are not read from the diagram section or? Yes see below
//#######################################################################################################################
//#### START #######################################################################################################
//#######################################################################################################################
//Before load the dynamic text field,
//we remove the dynamic text field created from the description of this element, to avoid doublons. //we remove the dynamic text field created from the description of this element, to avoid doublons.
for(DynamicElementTextItem *deti : m_dynamic_text_list) for(DynamicElementTextItem *deti : m_dynamic_text_list)
delete deti; delete deti;
m_dynamic_text_list.clear(); m_dynamic_text_list.clear();
//************************// //************************//
//***Dynamic texts item***// //***Dynamic texts item***//
//************************// //************************//
// Texts in diagram section
for (const QDomElement& qde : QET::findInDomElement(e, "dynamic_texts", DynamicElementTextItem::xmlTagName())) for (const QDomElement& qde : QET::findInDomElement(e, "dynamic_texts", DynamicElementTextItem::xmlTagName()))
{ {
DynamicElementTextItem *deti = new DynamicElementTextItem(this); DynamicElementTextItem *deti = new DynamicElementTextItem(this);
@@ -733,20 +742,24 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
deti->fromXml(qde); deti->fromXml(qde);
} }
// TODO: remove in later version begin
//************************// //************************//
//***Element texts item***// //***Element texts item***//
//************************// //************************//
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input"); // Inputs in diagram section
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input"); // Inputs in diagram section
//First case, we check for the text item converted to dynamic text item //First case, we check for the text item converted to dynamic text item
const QList <DynamicElementTextItem *> conv_deti_list = m_converted_text_from_xml_description.keys(); const QList <DynamicElementTextItem *> conv_deti_list = m_converted_text_from_xml_description.keys(); // Texts in element definition (elements collection)
QList <DynamicElementTextItem *> successfully_converted; QList <DynamicElementTextItem *> successfully_converted;
const QList <QDomElement> dom_inputs = inputs; const QList <QDomElement> dom_inputs = inputs;
for (DynamicElementTextItem *deti : conv_deti_list)
for (DynamicElementTextItem *deti : conv_deti_list) // Texts from element definition (elements collection)
{ {
for(const QDomElement& dom_input : dom_inputs) for(const QDomElement& dom_input : dom_inputs) // Inputs in diagram section
{ {
//we use the same method used in ElementTextItem::fromXml to compar and know if the input dom element is for one of the text stored. //we use the same method used in ElementTextItem::fromXml to compar and know if the input dom element is for one of the text stored.
//The comparaison is made from the text position : if the position of the text is the same as the position stored in 'input' dom element //The comparaison is made from the text position : if the position of the text is the same as the position stored in 'input' dom element
@@ -817,7 +830,7 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
group->fromXml(qde); group->fromXml(qde);
} }
//load informations //load elementInformations from diagram section
DiagramContext dc; DiagramContext dc;
dc.fromXml(e.firstChildElement("elementInformations"), "elementInformation"); dc.fromXml(e.firstChildElement("elementInformations"), "elementInformation");
/** /**
@@ -826,7 +839,6 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
* this mean the label was made before commit 4791 (0.51 dev). So we swap the value stored in "label" to "formula" as expected. * this mean the label was made before commit 4791 (0.51 dev). So we swap the value stored in "label" to "formula" as expected.
* @TODO remove this code at version 0.7 or more (probably useless). * @TODO remove this code at version 0.7 or more (probably useless).
*/ */
#pragma message("@TODO remove this code for qet 0.7 or later")
if (dc["label"].toString().contains("%") && dc["formula"].toString().isNull()) if (dc["label"].toString().contains("%") && dc["formula"].toString().isNull())
{ {
dc.addValue("formula", dc["label"]); dc.addValue("formula", dc["label"]);
@@ -992,6 +1004,12 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
} }
} }
} }
// TODO: remove in later version end
//#######################################################################################################################
//#### END #######################################################################################################
//#######################################################################################################################
m_state = QET::GIOK; m_state = QET::GIOK;
return(true); return(true);
} }

View File

@@ -23,12 +23,11 @@
#include <QFont> #include <QFont>
/** /**
@brief QETXML::penToXml * @brief QETXML::penToXml
Write attribute of a QPen in xml element * Write attribute of a QPen in xml element
@param parent_document : parent document for create the QDomElement * @param parent_document : parent document for create the QDomElement
@param pen : the pen to store * @param pen : the pen to store
@return : A QDomElement with the attribute stored. * @return : A QDomElement with the attribute stored. The tagName of QDomeElement is "pen".
The tagName of QDomeElement is "pen".
*/ */
QDomElement QETXML::penToXml(QDomDocument &parent_document,const QPen& pen) QDomElement QETXML::penToXml(QDomDocument &parent_document,const QPen& pen)
{ {
@@ -53,11 +52,11 @@ QDomElement QETXML::penToXml(QDomDocument &parent_document,const QPen& pen)
} }
/** /**
@brief QETXML::penFromXml * @brief QETXML::penFromXml
Build a QPen from a xml description * Build a QPen from a xml description
@param element, The QDomElement that describe the pen * @param element, The QDomElement that describe the pen
@return the created pen. If @element is null or tagName isn't "pen" * @return the created pen. If @element is null or tagName isn't "pen"
return a default constructed QPen * return a default constructed QPen
*/ */
QPen QETXML::penFromXml(const QDomElement &element) QPen QETXML::penFromXml(const QDomElement &element)
{ {
@@ -87,15 +86,13 @@ QPen QETXML::penFromXml(const QDomElement &element)
} }
/** /**
@brief QETXML::brushToXml * @brief QETXML::brushToXml
Write attribute of a QBrush in xml element * Write attribute of a QBrush in xml element
@param parent_document : parent document for create the QDomElement * @param parent_document : parent document for create the QDomElement
@param brush : the brush to store * @param brush : the brush to store
@return A QDomElement with the attribute stored. * @return A QDomElement with the attribute stored. The tagName of QDomeElement is "brush".
The tagName of QDomeElement is "brush".
*/ */
QDomElement QETXML::brushToXml(QDomDocument &parent_document, QDomElement QETXML::brushToXml(QDomDocument &parent_document, const QBrush& brush)
const QBrush& brush)
{ {
QDomElement element = parent_document.createElement("brush"); QDomElement element = parent_document.createElement("brush");
@@ -126,11 +123,11 @@ QDomElement QETXML::brushToXml(QDomDocument &parent_document,
} }
/** /**
@brief QETXML::brushFromXml * @brief QETXML::brushFromXml
Build a QBrush from a xml description * Build a QBrush from a xml description
@param element, the QDomElement that describe the pen * @param element, the QDomElement that describe the pen
@return the created brush. If @element is null or tagName isn't "brush" * @return the created brush. If @element is null or tagName isn't "brush"
return a default constructed QBrush * return a default constructed QBrush
*/ */
QBrush QETXML::brushFromXml(const QDomElement &element) QBrush QETXML::brushFromXml(const QDomElement &element)
{ {
@@ -161,20 +158,15 @@ QBrush QETXML::brushFromXml(const QDomElement &element)
} }
/** /**
@brief QETXML::fileSystemDirToXmlCollectionDir * @brief QETXML::fileSystemDirToXmlCollectionDir
@param document : owner document of returned QDomElement, * @param document : owner document of returned QDomElement, use to create the QDomElement.
use to create the QDomElement. * @param dir : file system direcory to convert to QDomElement directory
@param dir : file system direcory to convert to QDomElement directory * @param rename : by default the attribute "name" of the returned QDomElement is the same name of @dir
@param rename : by default the attribute "name" of the returned * but we can override itwith @rename
QDomElement is the same name of @dir * @return A file system directory converted to a QDomElement directory ready to be inserted into a XmlElementCollection.
but we can override itwith @rename * If the QDomElement can't be created, return a null QDomElement.
@return A file system directory converted to a QDomElement directory
ready to be inserted into a XmlElementCollection.
If the QDomElement can't be created, return a null QDomElement.
*/ */
QDomElement QETXML::fileSystemDirToXmlCollectionDir(QDomDocument &document, QDomElement QETXML::fileSystemDirToXmlCollectionDir(QDomDocument &document, const QDir &dir, const QString& rename)
const QDir &dir,
const QString& rename)
{ {
if (!dir.exists()) return QDomElement(); if (!dir.exists()) return QDomElement();
@@ -183,9 +175,7 @@ QDomElement QETXML::fileSystemDirToXmlCollectionDir(QDomDocument &document,
//Get the traduction of this directory //Get the traduction of this directory
QFile qet_dir(dir.filePath("qet_directory")); QFile qet_dir(dir.filePath("qet_directory"));
if (qet_dir.exists() && qet_dir.open( if (qet_dir.exists() && qet_dir.open(QIODevice::ReadOnly | QIODevice::Text))
QIODevice::ReadOnly
| QIODevice::Text))
{ {
//Get the content of the file //Get the content of the file
QDomDocument trad_document; QDomDocument trad_document;
@@ -206,21 +196,15 @@ QDomElement QETXML::fileSystemDirToXmlCollectionDir(QDomDocument &document,
} }
/** /**
@brief QETXML::fileSystemElementToXmlCollectionElement * @brief QETXML::fileSystemElementToXmlCollectionElement
@param document : owner document of returned QDomElement, * @param document : owner document of returned QDomElement, use to create the QDomElement.
use to create the QDomElement. * @param file : file system element file to convert to QDomElement;
@param file : file system element file to convert to QDomElement; * @param rename : by default the attribute "name" of the returned QDomElement is the same name of @file
@param rename : by default the attribute "name" of * but we can override itwith @rename
the returned QDomElement is the same name of @file * @return A file system element converted to a QDomElement ready to be inserted into a XmlElementCollection
but we can override itwith @rename * If the QDomElement can't be created, return a null QDomElement
@return A file system element converted to a QDomElement
ready to be inserted into a XmlElementCollection
If the QDomElement can't be created, return a null QDomElement
*/ */
QDomElement QETXML::fileSystemElementToXmlCollectionElement( QDomElement QETXML::fileSystemElementToXmlCollectionElement(QDomDocument &document, QFile &file, const QString& rename)
QDomDocument &document,
QFile &file,
const QString& rename)
{ {
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
@@ -245,18 +229,14 @@ QDomElement QETXML::fileSystemElementToXmlCollectionElement(
} }
/** /**
@brief QETXML::writeXmlFile * @brief QETXML::writeXmlFile
Export an XML document to an UTF-8 text file indented with 4 spaces, * Export an XML document to an UTF-8 text file indented with 4 spaces, with LF end of lines and no BOM.
with LF end of lines and no BOM. * @param xml_document : An XML document to be exported
@param xml_document : An XML document to be exported * @param file_path : Path to the file to be written
@param file_path : Path to the file to be written * @param error_message : If non-zero, will contain an error message explaining what happened when this function returns false.
@param error_message : If non-zero, will contain an error message * @return false if an error occurred, true otherwise
explaining what happened when this function returns false.
@return false if an error occurred, true otherwise
*/ */
bool QETXML::writeXmlFile(const QDomDocument &xml_document, bool QETXML::writeXmlFile(const QDomDocument &xml_document, const QString &file_path, QString *error_message)
const QString &file_path,
QString *error_message)
{ {
QFile file(file_path); QFile file(file_path);
@@ -266,9 +246,7 @@ bool QETXML::writeXmlFile(const QDomDocument &xml_document,
{ {
if (error_message) if (error_message)
{ {
*error_message = QString( *error_message = QString(QObject::tr("Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
QObject::tr(
"Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
"error message when attempting to write an XML file") "error message when attempting to write an XML file")
).arg(file_path).arg(file.error()); ).arg(file_path).arg(file.error());
} }
@@ -285,17 +263,14 @@ bool QETXML::writeXmlFile(const QDomDocument &xml_document,
} }
/** /**
@brief QETXML::textToDomElement * @brief QETXML::textToDomElement
Return a QDomElement, created from @document, * Return a QDomElement, created from @document, with tag name @tag_name and text @value.
with tag name @tag_name and text @value. * @param document
@param document * @param tag_name
@param tag_name * @param value
@param value * @return
@return a QDomElement, created from @document
*/ */
QDomElement QETXML::textToDomElement(QDomDocument &document, QDomElement QETXML::textToDomElement(QDomDocument &document, const QString& tag_name, const QString& value)
const QString& tag_name,
const QString& value)
{ {
QDomElement element = document.createElement(tag_name); QDomElement element = document.createElement(tag_name);
QDomText text = document.createTextNode(value); QDomText text = document.createTextNode(value);
@@ -305,19 +280,15 @@ QDomElement QETXML::textToDomElement(QDomDocument &document,
} }
/** /**
@brief QETXML::directChild * @brief QETXML::directChild
@param element * @param element
@param tag_name * @param tag_name
@return All direct child of @element with the tag name @tag_name * @return All direct child of @element with the tag name @tag_name
*/ */
QVector<QDomElement> QETXML::directChild(const QDomElement &element, QVector<QDomElement> QETXML::directChild(const QDomElement &element, const QString &tag_name)
const QString &tag_name)
{ {
QVector<QDomElement> return_list; QVector<QDomElement> return_list;
for ( for (QDomNode node = element.firstChild() ; !node.isNull() ; node = node.nextSibling())
QDomNode node = element.firstChild() ;
!node.isNull() ;
node = node.nextSibling())
{ {
if (!node.isElement()) continue; if (!node.isElement()) continue;
QDomElement element = node.toElement(); QDomElement element = node.toElement();
@@ -329,34 +300,25 @@ QVector<QDomElement> QETXML::directChild(const QDomElement &element,
} }
/** /**
@brief QETXML::subChild * @brief QETXML::subChild
@param element * @param element
@param parent_tag_name * @param parent_tag_name
@param children_tag_name * @param children_tag_name
@return When given an xml dom element @element, * @return When given an xml dom element @element,
returns a vector of all children dom_elements tagged @children_tag_name * returns a vector of all children dom_elements tagged @children_tag_name
nested in the parent dom elements tagged parent_tag_name, * nested in the parent dom elements tagged parent_tag_name, themselves children of the dom element @element.
themselves children of the dom element @element.
*/ */
QVector<QDomElement> QETXML::subChild(const QDomElement &element, QVector<QDomElement> QETXML::subChild(const QDomElement &element, const QString parent_tag_name, const QString &children_tag_name)
const QString parent_tag_name,
const QString &children_tag_name)
{ {
QVector<QDomElement> return_list; QVector<QDomElement> return_list;
for ( for (QDomNode child = element.firstChild() ; !child.isNull() ; child = child.nextSibling())
QDomNode child = element.firstChild() ;
!child.isNull() ;
child = child.nextSibling())
{ {
QDomElement parents = child.toElement(); QDomElement parents = child.toElement();
if (parents.isNull() || parents.tagName() != parent_tag_name) if (parents.isNull() || parents.tagName() != parent_tag_name)
continue; continue;
for ( for (QDomNode node_children = parents.firstChild() ; !node_children.isNull() ; node_children = node_children.nextSibling())
QDomNode node_children = parents.firstChild() ;
!node_children.isNull() ;
node_children = node_children.nextSibling())
{ {
QDomElement n_children = node_children.toElement(); QDomElement n_children = node_children.toElement();
if (!n_children.isNull() && n_children.tagName() == children_tag_name) if (!n_children.isNull() && n_children.tagName() == children_tag_name)
@@ -368,33 +330,28 @@ QVector<QDomElement> QETXML::subChild(const QDomElement &element,
} }
/** /**
@brief QETXML::marginsToXml * @brief QETXML::marginsToXml
Save a QMargins to xml. the xml tag name is 'margins' * Save a QMargins to xml. the xml tag name is 'margins'
@param parent_document * @param parent_document
@param margins * @param margins
@return * @return
*/ */
QDomElement QETXML::marginsToXml(QDomDocument &parent_document, QDomElement QETXML::marginsToXml(QDomDocument &parent_document, const QMargins &margins)
const QMargins &margins)
{ {
auto dom_ = parent_document.createElement("margins"); auto dom_ = parent_document.createElement("margins");
auto text_ = parent_document.createTextNode( auto text_ = parent_document.createTextNode(QString::number(margins.left()) + QString(";") +
QString::number(margins.left()) QString::number(margins.top()) + QString(";") +
+ QString(";") QString::number(margins.right()) + QString(";") +
+ QString::number(margins.top()) QString::number(margins.bottom()));
+ QString(";")
+ QString::number(margins.right())
+ QString(";")
+ QString::number(margins.bottom()));
dom_.appendChild(text_); dom_.appendChild(text_);
return dom_; return dom_;
} }
/** /**
@brief QETXML::marginsFromXml * @brief QETXML::marginsFromXml
@param element * @param element
@return a QMargins from an xml description. * @return a QMargins from an xml description.
The tag name must ne 'margins' * The tag name must ne 'margins'
*/ */
QMargins QETXML::marginsFromXml(const QDomElement &element) QMargins QETXML::marginsFromXml(const QDomElement &element)
{ {
@@ -404,35 +361,22 @@ QMargins QETXML::marginsFromXml(const QDomElement &element)
auto margins_ = element.text().split(";"); auto margins_ = element.text().split(";");
if (margins_.size() == 4) { if (margins_.size() == 4) {
return QMargins( return QMargins(margins_.at(0).toInt(), margins_.at(1).toInt(), margins_.at(2).toInt(), margins_.at(3).toInt());
margins_.at(0).toInt(),
margins_.at(1).toInt(),
margins_.at(2).toInt(),
margins_.at(3).toInt());
} else { } else {
return QMargins(); return QMargins();
} }
} }
/** /**
@brief QETXML::modelHeaderDataToXml * @brief QETXML::modelHeaderDataToXml
Save to xml element all header data specified * Save to xml element all header data specified by @horizontal_section_role and @vertical_section_role
by @horizontal_section_role and @vertical_section_role * @param parent_document
@param parent_document * @param model
@param model * @param horizontal_section_role : key as header section and value as list of roles to save in xml
@param horizontal_section_role : key as header section and value * @param vertical_section_role :key as header section and value as list of roles to save in xml
as list of roles to save in xml * @return
@param vertical_section_role :key as header section and value
as list of roles to save in xml
@return
*/ */
QDomElement QETXML::modelHeaderDataToXml( QDomElement QETXML::modelHeaderDataToXml(QDomDocument &parent_document, const QAbstractItemModel *model, QHash<int, QList<int>> horizontal_section_role, QHash<int, QList<int>> vertical_section_role)
QDomDocument &parent_document,
const QAbstractItemModel *model,
QHash<int,
QList<int>> horizontal_section_role,
QHash<int,
QList<int>> vertical_section_role)
{ {
auto dom_element = parent_document.createElement("header_data"); auto dom_element = parent_document.createElement("header_data");
@@ -457,11 +401,7 @@ QDomElement QETXML::modelHeaderDataToXml(
dom_data.setAttribute("role", meta_enum_role.valueToKey(role)); dom_data.setAttribute("role", meta_enum_role.valueToKey(role));
auto text_node = parent_document.createTextNode(""); auto text_node = parent_document.createTextNode("");
if (role == Qt::DisplayRole if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole || role == Qt::StatusTipRole || role == Qt::WhatsThisRole)
|| role == Qt::EditRole
|| role == Qt::ToolTipRole
|| role == Qt::StatusTipRole
|| role == Qt::WhatsThisRole)
{ {
text_node.setData(variant.toString()); text_node.setData(variant.toString());
} }
@@ -493,13 +433,12 @@ QDomElement QETXML::modelHeaderDataToXml(
} }
/** /**
@brief QETXML::modelHeaderDataFromXml * @brief QETXML::modelHeaderDataFromXml
Restore from xml modele header data * Restore from xml modele header data
@param element * @param element
@param model * @param model
*/ */
void QETXML::modelHeaderDataFromXml(const QDomElement &element, void QETXML::modelHeaderDataFromXml(const QDomElement &element, QAbstractItemModel *model)
QAbstractItemModel *model)
{ {
if (element.tagName() != "header_data") if (element.tagName() != "header_data")
return; return;
@@ -510,25 +449,12 @@ void QETXML::modelHeaderDataFromXml(const QDomElement &element,
for (auto child : QETXML::directChild(element, "data")) for (auto child : QETXML::directChild(element, "data"))
{ {
auto section_ = child.attribute("section", "-1").toInt(); auto section_ = child.attribute("section", "-1").toInt();
auto orientation_ = Qt::Orientation( auto orientation_ = Qt::Orientation(meta_enum_orientation.keyToValue(child.attribute("orientation", "Horizontal").toStdString().data()));
meta_enum_orientation.keyToValue( auto role_ = meta_enum_role.keyToValue(child.attribute("role", "DisplayRole").toStdString().data());
child.attribute(
"orientation",
"Horizontal"
).toStdString().data()));
auto role_ = meta_enum_role.keyToValue(
child.attribute(
"role",
"DisplayRole"
).toStdString().data());
auto text_ = child.text(); auto text_ = child.text();
QVariant data_; QVariant data_;
if (role_ == Qt::DisplayRole if (role_ == Qt::DisplayRole || role_ == Qt::EditRole || role_ == Qt::ToolTipRole || role_ == Qt::StatusTipRole || role_ == Qt::WhatsThisRole) {
|| role_ == Qt::EditRole
|| role_ == Qt::ToolTipRole
|| role_ == Qt::StatusTipRole
|| role_ == Qt::WhatsThisRole) {
data_ = text_; data_ = text_;
} }
else if (role_ == Qt::FontRole) else if (role_ == Qt::FontRole)

View File

@@ -34,45 +34,24 @@ namespace QETXML
QDomElement penToXml(QDomDocument &parent_document, const QPen& pen); QDomElement penToXml(QDomDocument &parent_document, const QPen& pen);
QPen penFromXml (const QDomElement &element); QPen penFromXml (const QDomElement &element);
QDomElement brushToXml (QDomDocument &parent_document, QDomElement brushToXml (QDomDocument &parent_document, const QBrush& brush);
const QBrush& brush);
QBrush brushFromXml (const QDomElement &element); QBrush brushFromXml (const QDomElement &element);
QDomElement fileSystemDirToXmlCollectionDir ( QDomElement fileSystemDirToXmlCollectionDir (QDomDocument &document, const QDir &dir, const QString& rename = QString());
QDomDocument &document, QDomElement fileSystemElementToXmlCollectionElement (QDomDocument &document, QFile &file, const QString& rename = QString());
const QDir &dir,
const QString& rename = QString());
QDomElement fileSystemElementToXmlCollectionElement (
QDomDocument &document,
QFile &file,
const QString& rename = QString());
bool writeXmlFile(const QDomDocument &xml_document, bool writeXmlFile(const QDomDocument &xml_document, const QString &file_path, QString *error_message = nullptr);
const QString &file_path,
QString *error_message = nullptr);
QDomElement textToDomElement (QDomDocument &document, QDomElement textToDomElement (QDomDocument &document, const QString& tag_name, const QString& value);
const QString& tag_name,
const QString& value);
QVector <QDomElement> directChild(const QDomElement &element, QVector <QDomElement> directChild(const QDomElement &element, const QString &tag_name);
const QString &tag_name); QVector <QDomElement> subChild(const QDomElement &element, const QString parent_tag_name, const QString &children_tag_name);
QVector <QDomElement> subChild(const QDomElement &element,
const QString parent_tag_name,
const QString &children_tag_name);
QDomElement marginsToXml (QDomDocument &parent_document, QDomElement marginsToXml (QDomDocument &parent_document, const QMargins &margins);
const QMargins &margins);
QMargins marginsFromXml(const QDomElement &element); QMargins marginsFromXml(const QDomElement &element);
QDomElement modelHeaderDataToXml(QDomDocument &parent_document, QDomElement modelHeaderDataToXml(QDomDocument &parent_document, const QAbstractItemModel *model, QHash<int, QList<int>> horizontal_section_role, QHash<int, QList<int>> vertical_section_role);
const QAbstractItemModel *model, void modelHeaderDataFromXml(const QDomElement &element, QAbstractItemModel *model);
QHash<int,
QList<int>> horizontal_section_role,
QHash<int,
QList<int>> vertical_section_role);
void modelHeaderDataFromXml(const QDomElement &element,
QAbstractItemModel *model);
} }
#endif // QETXML_H #endif // QETXML_H

View File

@@ -739,7 +739,6 @@ QString RichTextEditor::text(Qt::TextFormat format) const
break; break;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#else #else
#pragma message("@TODO remove code for QT 5.14 or later")
case Qt::MarkdownText: //This enum value was added in Qt 5.14. case Qt::MarkdownText: //This enum value was added in Qt 5.14.
break; break;
#endif #endif

View File

@@ -338,7 +338,6 @@ void TitleBlockTemplate::parseRows(const QString &rows_string) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList rows_descriptions = rows_string.split(QChar(';'), QString::SkipEmptyParts); QStringList rows_descriptions = rows_string.split(QChar(';'), QString::SkipEmptyParts);
#else #else
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList rows_descriptions = rows_string.split(QChar(';'), Qt::SkipEmptyParts); QStringList rows_descriptions = rows_string.split(QChar(';'), Qt::SkipEmptyParts);
#endif #endif
foreach (QString rows_description, rows_descriptions) { foreach (QString rows_description, rows_descriptions) {
@@ -366,7 +365,6 @@ void TitleBlockTemplate::parseColumns(const QString &cols_string) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList cols_descriptions = cols_string.split(QChar(';'), QString::SkipEmptyParts); QStringList cols_descriptions = cols_string.split(QChar(';'), QString::SkipEmptyParts);
#else #else
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList cols_descriptions = cols_string.split(QChar(';'), Qt::SkipEmptyParts); QStringList cols_descriptions = cols_string.split(QChar(';'), Qt::SkipEmptyParts);
#endif #endif
foreach (QString cols_description, cols_descriptions) { foreach (QString cols_description, cols_descriptions) {

View File

@@ -21,13 +21,7 @@
#include <QThread> #include <QThread>
#include <QDate> #include <QDate>
#include <QScreen>
#include <QProcess>
/**
@brief AboutQETDialog::AboutQETDialog
@param parent
*/
AboutQETDialog::AboutQETDialog(QWidget *parent) : AboutQETDialog::AboutQETDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::AboutQETDialog) ui(new Ui::AboutQETDialog)
@@ -42,17 +36,11 @@ AboutQETDialog::AboutQETDialog(QWidget *parent) :
setLicence(); setLicence();
} }
/**
@brief AboutQETDialog::~AboutQETDialog
*/
AboutQETDialog::~AboutQETDialog() AboutQETDialog::~AboutQETDialog()
{ {
delete ui; delete ui;
} }
/**
@brief AboutQETDialog::setAbout
*/
void AboutQETDialog::setAbout() void AboutQETDialog::setAbout()
{ {
@@ -67,9 +55,6 @@ void AboutQETDialog::setAbout()
ui->m_about_label->setText(str); ui->m_about_label->setText(str);
} }
/**
@brief AboutQETDialog::setAuthors
*/
void AboutQETDialog::setAuthors() void AboutQETDialog::setAuthors()
{ {
addAuthor(ui->m_author_label, "Benoît Ansieau", "benoit@qelectrotech.org", tr("Idée originale")); addAuthor(ui->m_author_label, "Benoît Ansieau", "benoit@qelectrotech.org", tr("Idée originale"));
@@ -81,9 +66,6 @@ void AboutQETDialog::setAuthors()
addAuthor(ui->m_author_label, "Abhishek Bansal", "abhishek@qelectrotech.org", tr("Développement")); addAuthor(ui->m_author_label, "Abhishek Bansal", "abhishek@qelectrotech.org", tr("Développement"));
} }
/**
@brief AboutQETDialog::setTranslators
*/
void AboutQETDialog::setTranslators() void AboutQETDialog::setTranslators()
{ {
addAuthor(ui->m_translators_label, "Alfredo Carreto", "electronicos_mx@yahoo.com.mx", tr("Traduction en espagnol")); addAuthor(ui->m_translators_label, "Alfredo Carreto", "electronicos_mx@yahoo.com.mx", tr("Traduction en espagnol"));
@@ -112,9 +94,6 @@ void AboutQETDialog::setTranslators()
addAuthor(ui->m_translators_label, "Gábor Gubányi", "gubanyig@gmail.com", tr("Traduction en hongrois")); addAuthor(ui->m_translators_label, "Gábor Gubányi", "gubanyig@gmail.com", tr("Traduction en hongrois"));
} }
/**
@brief AboutQETDialog::setContributors
*/
void AboutQETDialog::setContributors() void AboutQETDialog::setContributors()
{ {
addAuthor(ui->m_contrib_label, "Remi Collet", "remi@fedoraproject.org", tr("Paquets Fedora et Red Hat")); addAuthor(ui->m_contrib_label, "Remi Collet", "remi@fedoraproject.org", tr("Paquets Fedora et Red Hat"));
@@ -138,9 +117,6 @@ void AboutQETDialog::setContributors()
addAuthor(ui->m_contrib_label, "Maximilian Federle", "", tr("Paquets Snap")); addAuthor(ui->m_contrib_label, "Maximilian Federle", "", tr("Paquets Snap"));
} }
/**
@brief AboutQETDialog::setVersion
*/
void AboutQETDialog::setVersion() void AboutQETDialog::setVersion()
{ {
QString str = "<span style=\"font-weight:bold;font-size:16pt;\">QElectroTech V " + QET::displayedVersion + "</span>"; QString str = "<span style=\"font-weight:bold;font-size:16pt;\">QElectroTech V " + QET::displayedVersion + "</span>";
@@ -153,12 +129,6 @@ void AboutQETDialog::setVersion()
compilation_info += " : " + QString(__TIME__); compilation_info += " : " + QString(__TIME__);
compilation_info += " <br>Run with Qt "+ QString(qVersion()); compilation_info += " <br>Run with Qt "+ QString(qVersion());
compilation_info += " using" + QString(" %1 thread(s)").arg(QThread::idealThreadCount()); compilation_info += " using" + QString(" %1 thread(s)").arg(QThread::idealThreadCount());
QProcess macoscpuinfo;
macoscpuinfo.start("bash", QStringList() << "-c" << "sysctl -n machdep.cpu.brand_string");
macoscpuinfo.waitForFinished();
QString macosOutput = macoscpuinfo.readAllStandardOutput();
compilation_info += "<br>"" CPU : " + QString(macosOutput.toLocal8Bit().constData());
compilation_info += "<br>" " OS : " + QString(QSysInfo::kernelType()); compilation_info += "<br>" " OS : " + QString(QSysInfo::kernelType());
compilation_info += " - " + QString(QSysInfo::currentCpuArchitecture()); compilation_info += " - " + QString(QSysInfo::currentCpuArchitecture());
compilation_info += " - Version : " + QString(QSysInfo::prettyProductName()); compilation_info += " - Version : " + QString(QSysInfo::prettyProductName());
@@ -170,61 +140,15 @@ void AboutQETDialog::setVersion()
compilation_info += " : " + QString(__TIME__); compilation_info += " : " + QString(__TIME__);
compilation_info += " <br>Run with Qt "+ QString(qVersion()); compilation_info += " <br>Run with Qt "+ QString(qVersion());
compilation_info += " using" + QString(" %1 thread(s)").arg(QThread::idealThreadCount()); compilation_info += " using" + QString(" %1 thread(s)").arg(QThread::idealThreadCount());
QString OSName = QSysInfo::kernelType();
if (OSName == "linux")
{
QProcess linuxcpuinfo;
linuxcpuinfo.start("bash", QStringList() << "-c" << "cat /proc/cpuinfo |grep 'model name' | uniq");
linuxcpuinfo.waitForFinished();
QString linuxOutput = linuxcpuinfo.readAllStandardOutput();
compilation_info += "<br>"" CPU : " + QString(linuxOutput.toLocal8Bit().constData());
QProcess p;
p.start("awk", QStringList() << "/MemTotal/ { print $2 }" << "/proc/meminfo");
p.waitForFinished();
QString memory = p.readAllStandardOutput();
compilation_info += "<br>" + QString("RAM Total : %1 MB").arg(memory.toLong() / 1024);
p.close();
QProcess qp;
qp.start("awk", QStringList() << "/MemAvailable/ {print $2}" << "/proc/meminfo");
qp.waitForFinished();
QString AvailableMemory = qp.readAllStandardOutput();
compilation_info += "<br>" + QString("RAM Available : %1 MB").arg(AvailableMemory.toLong() / 1024);
qp.close();
QProcess linuxgpuinfo;
linuxgpuinfo.start("bash", QStringList() << "-c" << "lspci | grep VGA | cut -d : -f 3");
linuxgpuinfo.waitForFinished();
QString linuxGPUOutput = linuxgpuinfo.readAllStandardOutput();
compilation_info += "<br>"" GPU : " + QString(linuxGPUOutput.toLocal8Bit().constData());
}
compilation_info += "<br>" " OS : " + QString(QSysInfo::kernelType()); compilation_info += "<br>" " OS : " + QString(QSysInfo::kernelType());
compilation_info += " - " + QString(QSysInfo::currentCpuArchitecture()); compilation_info += " - " + QString(QSysInfo::currentCpuArchitecture());
compilation_info += " - Version : " + QString(QSysInfo::prettyProductName()); compilation_info += " - Version : " + QString(QSysInfo::prettyProductName());
compilation_info += "</br>" " - Kernel : " + QString(QSysInfo::kernelVersion()); compilation_info += "</br>" " - Kernel : " + QString(QSysInfo::kernelVersion());
#endif #endif
#endif #endif
compilation_info += "<br> *** Qt screens *** </br>";
const auto screens = qApp->screens();
for (int ii = 0; ii < screens.count(); ++ii) {
compilation_info += "<br> ( "
+ QString::number(ii + 1)
+ " : "
+ QString::number(screens[ii]->geometry().width() * screens[ii]->devicePixelRatio())
+ " x "
+ QString::number(screens[ii]->geometry().height() * screens[ii]->devicePixelRatio())
+ " ) </br>";
}
ui->m_version_label->setText(str + compilation_info); ui->m_version_label->setText(str + compilation_info);
} }
/**
@brief AboutQETDialog::setLibraries
*/
void AboutQETDialog::setLibraries() void AboutQETDialog::setLibraries()
{ {
addLibrary(ui->m_libraries_label, "KDE lib", "https://api.kde.org"); addLibrary(ui->m_libraries_label, "KDE lib", "https://api.kde.org");
@@ -232,21 +156,18 @@ void AboutQETDialog::setLibraries()
addLibrary(ui->m_libraries_label, "pugixml", "https://pugixml.org"); addLibrary(ui->m_libraries_label, "pugixml", "https://pugixml.org");
} }
/**
@brief AboutQETDialog::setLicence
*/
void AboutQETDialog::setLicence() void AboutQETDialog::setLicence()
{ {
ui->m_license_text_edit->setPlainText(QET::license()); ui->m_license_text_edit->setPlainText(QET::license());
} }
/** /**
@brief AboutQETDialog::addAuthor * @brief AboutQETDialog::addAuthor
Adds a person to the list of authors * Adds a person to the list of authors
@param label : QLabel which will add the person * @param label : QLabel which will add the person
@param name : Name of person * @param name : Name of person
@param email : E-mail address of the person * @param email : E-mail address of the person
@param work : Function / work done by the person * @param work : Function / work done by the person
*/ */
void AboutQETDialog::addAuthor(QLabel *label, const QString &name, const QString &email, const QString &work) void AboutQETDialog::addAuthor(QLabel *label, const QString &name, const QString &email, const QString &work)
{ {
@@ -259,12 +180,6 @@ void AboutQETDialog::addAuthor(QLabel *label, const QString &name, const QString
label->setText(new_text); label->setText(new_text);
} }
/**
@brief AboutQETDialog::addLibrary
@param label
@param name
@param link
*/
void AboutQETDialog::addLibrary(QLabel *label, const QString &name, const QString &link) void AboutQETDialog::addLibrary(QLabel *label, const QString &name, const QString &link)
{ {
QString new_text = label->text(); QString new_text = label->text();

View File

@@ -26,9 +26,6 @@ namespace Ui {
class AboutQETDialog; class AboutQETDialog;
} }
/**
@brief The AboutQETDialog class
*/
class AboutQETDialog : public QDialog class AboutQETDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
@@ -45,13 +42,8 @@ class AboutQETDialog : public QDialog
void setVersion(); void setVersion();
void setLibraries(); void setLibraries();
void setLicence(); void setLicence();
void addAuthor(QLabel *label, void addAuthor(QLabel *label, const QString &name, const QString &email, const QString &work);
const QString &name, void addLibrary(QLabel *label, const QString &name, const QString &link);
const QString &email,
const QString &work);
void addLibrary(QLabel *label,
const QString &name,
const QString &link);
private: private:
Ui::AboutQETDialog *ui; Ui::AboutQETDialog *ui;

View File

@@ -61,7 +61,6 @@ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) :
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), [this](int id) connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), [this](int id)
#else #else
#pragma message("@TODO remove code for QT 5.15 or later")
connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idClicked), [this](int id) connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idClicked), [this](int id)
#endif #endif
{ {
@@ -155,7 +154,6 @@ int BOMExportDialog::exec()
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
stream << getBom() << endl; stream << getBom() << endl;
#else #else
#pragma message("@TODO remove code for QT 5.15 or later")
stream << getBom() << &Qt::endl(stream); stream << getBom() << &Qt::endl(stream);
#endif #endif
} }

View File

@@ -16,7 +16,6 @@ CompositeTextEditDialog::CompositeTextEditDialog(DynamicElementTextItem *text, Q
m_default_text = m_text->compositeText(); m_default_text = m_text->compositeText();
ui->m_plain_text_edit->setPlainText(m_default_text); ui->m_plain_text_edit->setPlainText(m_default_text);
#if QT_VERSION >= 0x050300 #if QT_VERSION >= 0x050300
#pragma message("@TODO remove code for QT 5.3 or later")
ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible")); ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible"));
#endif #endif
setUpComboBox(); setUpComboBox();
@@ -30,7 +29,6 @@ CompositeTextEditDialog::CompositeTextEditDialog(QString text, QWidget *parent)
m_default_text = std::move(text); m_default_text = std::move(text);
ui->m_plain_text_edit->setPlainText(m_default_text); ui->m_plain_text_edit->setPlainText(m_default_text);
#if QT_VERSION >= 0x050300 #if QT_VERSION >= 0x050300
#pragma message("@TODO remove code for QT 5.3 or later")
ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible")); ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible"));
#endif #endif
setUpComboBox(); setUpComboBox();

View File

@@ -186,6 +186,10 @@ QUndoCommand *DynamicElementTextItemEditor::associatedUndo() const
return nullptr; return nullptr;
} }
/*!
* \brief DynamicElementTextItemEditor::dataEdited
* Apply changes to the text item. It is called when dataChanged() signal is called
*/
void DynamicElementTextItemEditor::dataEdited() void DynamicElementTextItemEditor::dataEdited()
{ {
if (m_live_edit) if (m_live_edit)

View File

@@ -29,6 +29,10 @@ namespace Ui {
class DynamicElementTextItemEditor; class DynamicElementTextItemEditor;
} }
/*!
* \brief The DynamicElementTextItemEditor class
* Widget used to modify the properties of DynamicElementTextItem.
*/
class DynamicElementTextItemEditor : public AbstractElementPropertiesEditorWidget class DynamicElementTextItemEditor : public AbstractElementPropertiesEditorWidget
{ {
Q_OBJECT Q_OBJECT

View File

@@ -57,6 +57,10 @@ static int adjust_grp_row = 4;
static int frame_grp_row = 5; static int frame_grp_row = 5;
static int hold_to_bottom_grp_row = 6; static int hold_to_bottom_grp_row = 6;
const char* user_text = "Texte utilisateur";
const char* element_information = "Information de l'élément";
const char* composite_text = "Texte composé";
DynamicElementTextModel::DynamicElementTextModel(Element *element, QObject *parent) : DynamicElementTextModel::DynamicElementTextModel(Element *element, QObject *parent) :
QStandardItemModel(parent), QStandardItemModel(parent),
m_element(element) m_element(element)
@@ -136,9 +140,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
src->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); src->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QString title; QString title;
if (deti->textFrom() == DynamicElementTextItem::UserText) title = tr("Texte utilisateur"); if (deti->textFrom() == DynamicElementTextItem::UserText) title = tr(user_text);
else if (deti->textFrom() == DynamicElementTextItem::ElementInfo) title = tr("Information de l'élément"); else if (deti->textFrom() == DynamicElementTextItem::ElementInfo) title = tr(element_information);
else title = tr("Texte composé"); else title = tr(composite_text);
QStandardItem *srca = new QStandardItem(title); QStandardItem *srca = new QStandardItem(title);
srca->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); srca->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
srca->setData(textFrom, Qt::UserRole+1); srca->setData(textFrom, Qt::UserRole+1);
@@ -172,7 +176,7 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
qsi->appendRow(qsi_list); qsi->appendRow(qsi_list);
//Composite text //Composite text
QStandardItem *composite = new QStandardItem(tr("Texte composé")); QStandardItem *composite = new QStandardItem(tr(composite_text));
composite->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); composite->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
DiagramContext dc; DiagramContext dc;
@@ -397,7 +401,7 @@ DynamicElementTextItem *DynamicElementTextModel::textFromItem(QStandardItem *ite
QStandardItem *text_item = item; QStandardItem *text_item = item;
while (text_item->parent()) while (text_item->parent()) // recursive search for the highest parent
text_item = text_item->parent(); text_item = text_item->parent();
if (m_texts_list.values().contains(text_item)) //The item is a text if (m_texts_list.values().contains(text_item)) //The item is a text
@@ -458,26 +462,26 @@ QUndoCommand *DynamicElementTextModel::undoForEditedText(DynamicElementTextItem
QStandardItem *text_qsi = m_texts_list.value(deti); QStandardItem *text_qsi = m_texts_list.value(deti);
QString from = text_qsi->child(src_txt_row,1)->data(Qt::DisplayRole).toString(); QString from = text_qsi->child(src_txt_row,1)->data(Qt::DisplayRole).toString();
if ((from == tr("Texte utilisateur")) && (deti->textFrom() != DynamicElementTextItem::UserText)) if ((from == tr(user_text)) && (deti->textFrom() != DynamicElementTextItem::UserText))
new QPropertyUndoCommand(deti, "textFrom", QVariant(deti->textFrom()), QVariant(DynamicElementTextItem::UserText), undo); new QPropertyUndoCommand(deti, "textFrom", QVariant(deti->textFrom()), QVariant(DynamicElementTextItem::UserText), undo);
else if ((from == tr("Information de l'élément")) && (deti->textFrom() != DynamicElementTextItem::ElementInfo)) else if ((from == tr(element_information)) && (deti->textFrom() != DynamicElementTextItem::ElementInfo))
new QPropertyUndoCommand(deti, "textFrom", QVariant(deti->textFrom()), QVariant(DynamicElementTextItem::ElementInfo), undo); new QPropertyUndoCommand(deti, "textFrom", QVariant(deti->textFrom()), QVariant(DynamicElementTextItem::ElementInfo), undo);
else if ((from == tr("Texte composé")) && (deti->textFrom() != DynamicElementTextItem::CompositeText)) else if ((from == tr(composite_text)) && (deti->textFrom() != DynamicElementTextItem::CompositeText))
new QPropertyUndoCommand(deti, "textFrom", QVariant(deti->textFrom()), QVariant(DynamicElementTextItem::CompositeText), undo); new QPropertyUndoCommand(deti, "textFrom", QVariant(deti->textFrom()), QVariant(DynamicElementTextItem::CompositeText), undo);
if(from == tr("Texte utilisateur")) if(from == tr(user_text))
{ {
QString text = text_qsi->child(usr_txt_row,1)->data(Qt::DisplayRole).toString(); QString text = text_qsi->child(usr_txt_row,1)->data(Qt::DisplayRole).toString();
if (text != deti->text()) if (text != deti->text())
new QPropertyUndoCommand(deti, "text", QVariant(deti->text()), QVariant(text), undo); new QPropertyUndoCommand(deti, "text", QVariant(deti->text()), QVariant(text), undo);
} }
else if (from == tr("Information de l'élément")) else if (from == tr(element_information))
{ {
QString info_name = text_qsi->child(info_txt_row,1)->data(Qt::UserRole+2).toString(); QString info_name = text_qsi->child(info_txt_row,1)->data(Qt::UserRole+2).toString();
if(info_name != deti->infoName()) if(info_name != deti->infoName())
new QPropertyUndoCommand(deti, "infoName", QVariant(deti->infoName()), QVariant(info_name), undo); new QPropertyUndoCommand(deti, "infoName", QVariant(deti->infoName()), QVariant(info_name), undo);
} }
else if (from == tr("Texte composé")) else if (from == tr(composite_text))
{ {
QString composite_text = text_qsi->child(compo_txt_row,1)->data(Qt::UserRole+2).toString(); QString composite_text = text_qsi->child(compo_txt_row,1)->data(Qt::UserRole+2).toString();
if(composite_text != deti->compositeText()) if(composite_text != deti->compositeText())
@@ -1112,6 +1116,7 @@ void DynamicElementTextModel::enableSourceText(DynamicElementTextItem *deti, Dyn
case DynamicElementTextItem::CompositeText: compo = true;break; case DynamicElementTextItem::CompositeText: compo = true;break;
} }
m_ignore_item_change = true;
//User text //User text
qsi->child(usr_txt_row,0)->setEnabled(usr); qsi->child(usr_txt_row,0)->setEnabled(usr);
qsi->child(usr_txt_row,1)->setEnabled(usr); qsi->child(usr_txt_row,1)->setEnabled(usr);
@@ -1120,6 +1125,7 @@ void DynamicElementTextModel::enableSourceText(DynamicElementTextItem *deti, Dyn
qsi->child(info_txt_row,1)->setEnabled(info); qsi->child(info_txt_row,1)->setEnabled(info);
//Composite text //Composite text
qsi->child(compo_txt_row,0)->setEnabled(compo); qsi->child(compo_txt_row,0)->setEnabled(compo);
m_ignore_item_change = false;
qsi->child(compo_txt_row,1)->setEnabled(compo); qsi->child(compo_txt_row,1)->setEnabled(compo);
} }
@@ -1157,6 +1163,10 @@ void DynamicElementTextModel::enableGroupRotationAndPos(ElementTextItemGroup *gr
void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi) void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
{ {
if (m_ignore_item_change)
return;
DynamicElementTextItem *deti = textFromItem(qsi); DynamicElementTextItem *deti = textFromItem(qsi);
ElementTextItemGroup *etig = groupFromItem(qsi); ElementTextItemGroup *etig = groupFromItem(qsi);
if (!deti && !etig) if (!deti && !etig)
@@ -1170,15 +1180,15 @@ void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
dc = deti->elementUseForInfo()->elementInformations(); dc = deti->elementUseForInfo()->elementInformations();
if (qsi->data().toInt() == textFrom) if (qsi->data().toInt() == textFrom)
{ { // change textFrom
QString from = qsi->data(Qt::DisplayRole).toString(); QString from = qsi->data(Qt::DisplayRole).toString();
if (from == tr("Texte utilisateur")) if (from == tr(user_text))
{ {
enableSourceText(deti, DynamicElementTextItem::UserText); enableSourceText(deti, DynamicElementTextItem::UserText);
text_qsi->setData(text_qsi->child(usr_txt_row,1)->data(Qt::DisplayRole).toString()); text_qsi->setData(text_qsi->child(usr_txt_row,1)->data(Qt::DisplayRole).toString());
} }
else if (from == tr("Information de l'élément")) else if (from == tr(element_information))
{ {
enableSourceText(deti, DynamicElementTextItem::ElementInfo); enableSourceText(deti, DynamicElementTextItem::ElementInfo);
QString info = text_qsi->child(info_txt_row,1)->data(Qt::UserRole+2).toString(); QString info = text_qsi->child(info_txt_row,1)->data(Qt::UserRole+2).toString();
@@ -1213,7 +1223,7 @@ void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
//We emit the signal only if @qsi is in the second column, because the data are stored on this column //We emit the signal only if @qsi is in the second column, because the data are stored on this column
//the first column is use only for display the title of the property, except for the name of texts group //the first column is use only for display the title of the property, except for the name of texts group
if((m_groups_list.values().contains(qsi) || qsi->column() == 1) && !m_block_dataChanged) if((m_groups_list.values().contains(qsi) || qsi->column() == 1) && !m_block_dataChanged)
emit dataChanged(); emit dataChanged(); // TODO: where it goes?
if(deti) deti->updateXref(); if(deti) deti->updateXref();
} }
@@ -1309,9 +1319,9 @@ void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti, V
{ {
switch (deti->textFrom()) switch (deti->textFrom())
{ {
case DynamicElementTextItem::UserText: qsi->child(0,1)->setData(tr("Texte utilisateur"), Qt::DisplayRole); break; case DynamicElementTextItem::UserText: qsi->child(0,1)->setData(tr(user_text), Qt::DisplayRole); break;
case DynamicElementTextItem::ElementInfo : qsi->child(0,1)->setData(tr("Information de l'élément"), Qt::DisplayRole); break; case DynamicElementTextItem::ElementInfo : qsi->child(0,1)->setData(tr(element_information), Qt::DisplayRole); break;
case DynamicElementTextItem::CompositeText : qsi->child(0,1)->setData(tr("Texte composé"), Qt::DisplayRole); break; case DynamicElementTextItem::CompositeText : qsi->child(0,1)->setData(tr(composite_text), Qt::DisplayRole); break;
} }
enableSourceText(deti, deti->textFrom()); enableSourceText(deti, deti->textFrom());
qsi->setData(deti->toPlainText(), Qt::DisplayRole); qsi->setData(deti->toPlainText(), Qt::DisplayRole);
@@ -1448,6 +1458,15 @@ DynamicTextItemDelegate::DynamicTextItemDelegate(QObject *parent) :
QStyledItemDelegate(parent) QStyledItemDelegate(parent)
{} {}
/*!
* \brief DynamicTextItemDelegate::createEditor
* Different widgets are used depending of the data which should be shown in the view.
* For example for choosing color, a color chooser is used.
* \param parent
* \param option
* \param index
* \return
*/
QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{ {
switch (index.data(Qt::UserRole+1).toInt()) switch (index.data(Qt::UserRole+1).toInt())
@@ -1456,9 +1475,9 @@ QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOpti
{ {
QComboBox *qcb = new QComboBox(parent); QComboBox *qcb = new QComboBox(parent);
qcb->setObjectName("text_from"); qcb->setObjectName("text_from");
qcb->addItem(tr("Texte utilisateur")); qcb->addItem(tr(user_text));
qcb->addItem(tr("Information de l'élément")); qcb->addItem(tr(element_information));
qcb->addItem(tr("Texte composé")); qcb->addItem(tr(composite_text));
return qcb; return qcb;
} }
case DynamicElementTextModel::infoText: case DynamicElementTextModel::infoText:

View File

@@ -106,6 +106,7 @@ class DynamicElementTextModel : public QStandardItemModel
QHash <DynamicElementTextItem *, QList<QMetaObject::Connection>> m_hash_text_connect; QHash <DynamicElementTextItem *, QList<QMetaObject::Connection>> m_hash_text_connect;
QHash <ElementTextItemGroup *, QList<QMetaObject::Connection>> m_hash_group_connect; QHash <ElementTextItemGroup *, QList<QMetaObject::Connection>> m_hash_group_connect;
bool m_block_dataChanged = false; bool m_block_dataChanged = false;
bool m_ignore_item_change{false};
}; };
class DynamicTextItemDelegate : public QStyledItemDelegate class DynamicTextItemDelegate : public QStyledItemDelegate

View File

@@ -25,10 +25,10 @@
#include <linkelementcommand.h> #include <linkelementcommand.h>
/** /**
@brief MasterPropertiesWidget::MasterPropertiesWidget * @brief MasterPropertiesWidget::MasterPropertiesWidget
Default constructor * Default constructor
@param elmt * @param elmt
@param parent * @param parent
*/ */
MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) : MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
AbstractElementPropertiesEditorWidget(parent), AbstractElementPropertiesEditorWidget(parent),
@@ -43,16 +43,10 @@ MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
QStringList list; QStringList list;
QSettings settings; QSettings settings;
if (settings.value("genericpanel/folio", false).toBool()) { if (settings.value("genericpanel/folio", false).toBool()) {
list << tr("Vignette") list << tr("Vignette") << tr("Label de folio") << tr("Titre de folio") << tr("Position");
<< tr("Label de folio")
<< tr("Titre de folio")
<< tr("Position");
} }
else { else {
list << tr("Vignette") list << tr("Vignette") << tr("N° de folio") << tr("Titre de folio") << tr("Position");
<< tr("N° de folio")
<< tr("Titre de folio")
<< tr("Position");
} }
ui->m_free_tree_widget->setHeaderLabels(list); ui->m_free_tree_widget->setHeaderLabels(list);
ui->m_link_tree_widget->setHeaderLabels(list); ui->m_link_tree_widget->setHeaderLabels(list);
@@ -64,22 +58,15 @@ MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
m_show_element = new QAction(tr("Montrer l'élément maître"), this); m_show_element = new QAction(tr("Montrer l'élément maître"), this);
m_save_header_state = new QAction(tr("Enregistrer la disposition"), this); m_save_header_state = new QAction(tr("Enregistrer la disposition"), this);
connect(ui->m_free_tree_widget, &QTreeWidget::itemDoubleClicked, connect(ui->m_free_tree_widget, &QTreeWidget::itemDoubleClicked, this, &MasterPropertiesWidget::showElementFromTWI);
this, &MasterPropertiesWidget::showElementFromTWI); connect(ui->m_link_tree_widget, &QTreeWidget::itemDoubleClicked, this, &MasterPropertiesWidget::showElementFromTWI);
connect(ui->m_link_tree_widget, &QTreeWidget::itemDoubleClicked,
this, &MasterPropertiesWidget::showElementFromTWI);
connect(ui->m_free_tree_widget, &QTreeWidget::customContextMenuRequested, connect(ui->m_free_tree_widget, &QTreeWidget::customContextMenuRequested, [this](QPoint point) {this->customContextMenu(point, 1);});
[this](QPoint point) {this->customContextMenu(point, 1);}); connect(ui->m_link_tree_widget, &QTreeWidget::customContextMenuRequested, [this](QPoint point) {this->customContextMenu(point, 2);});
connect(ui->m_link_tree_widget, &QTreeWidget::customContextMenuRequested,
[this](QPoint point) {this->customContextMenu(point, 2);});
connect(m_link_action, &QAction::triggered, connect(m_link_action, &QAction::triggered, this, &MasterPropertiesWidget::on_link_button_clicked);
this, &MasterPropertiesWidget::on_link_button_clicked); connect(m_unlink_action, &QAction::triggered, this, &MasterPropertiesWidget::on_unlink_button_clicked);
connect(m_unlink_action, &QAction::triggered, connect(m_show_qtwi, &QAction::triggered, [this]() {this->showElementFromTWI(this->m_qtwi_at_context_menu,0);});
this, &MasterPropertiesWidget::on_unlink_button_clicked);
connect(m_show_qtwi, &QAction::triggered,
[this]() {this->showElementFromTWI(this->m_qtwi_at_context_menu,0);});
connect(m_show_element, &QAction::triggered, [this]() connect(m_show_element, &QAction::triggered, [this]()
{ {
@@ -91,8 +78,7 @@ MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
QHeaderView *qhv = ui->m_free_tree_widget->header(); QHeaderView *qhv = ui->m_free_tree_widget->header();
qhv->setContextMenuPolicy(Qt::CustomContextMenu); qhv->setContextMenuPolicy(Qt::CustomContextMenu);
connect(qhv, &QHeaderView::customContextMenuRequested, connect(qhv, &QHeaderView::customContextMenuRequested, this, &MasterPropertiesWidget::headerCustomContextMenuRequested);
this, &MasterPropertiesWidget::headerCustomContextMenuRequested);
connect(m_save_header_state, &QAction::triggered, [qhv]() connect(m_save_header_state, &QAction::triggered, [qhv]()
{ {
QByteArray qba = qhv->saveState(); QByteArray qba = qhv->saveState();
@@ -104,8 +90,8 @@ MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
} }
/** /**
@brief MasterPropertiesWidget::~MasterPropertiesWidget * @brief MasterPropertiesWidget::~MasterPropertiesWidget
Destructor * Destructor
*/ */
MasterPropertiesWidget::~MasterPropertiesWidget() MasterPropertiesWidget::~MasterPropertiesWidget()
{ {
@@ -119,9 +105,9 @@ MasterPropertiesWidget::~MasterPropertiesWidget()
} }
/** /**
@brief MasterPropertiesWidget::setElement * @brief MasterPropertiesWidget::setElement
Set the element to be edited * Set the element to be edited
@param element * @param element
*/ */
void MasterPropertiesWidget::setElement(Element *element) void MasterPropertiesWidget::setElement(Element *element)
{ {
@@ -137,37 +123,32 @@ void MasterPropertiesWidget::setElement(Element *element)
m_element->setHighlighted(false); m_element->setHighlighted(false);
if (m_project) if (m_project)
disconnect(m_project, SIGNAL(diagramRemoved(QETProject*,Diagram*)), disconnect(m_project, SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(diagramWasdeletedFromProject()));
this, SLOT(diagramWasdeletedFromProject()));
if(Q_LIKELY(element->diagram() && element->diagram()->project())) if(Q_LIKELY(element->diagram() && element->diagram()->project()))
{ {
m_project = element->diagram()->project(); m_project = element->diagram()->project();
connect(m_project, SIGNAL(diagramRemoved(QETProject*,Diagram*)), connect(m_project, SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(diagramWasdeletedFromProject()));
this, SLOT(diagramWasdeletedFromProject()));
} }
else else
m_project = nullptr; m_project = nullptr;
//Keep up to date this widget when the linked elements of m_element change //Keep up to date this widget when the linked elements of m_element change
if (m_element) if (m_element)
disconnect(m_element.data(), &Element::linkedElementChanged, disconnect(m_element.data(), &Element::linkedElementChanged, this, &MasterPropertiesWidget::updateUi);
this, &MasterPropertiesWidget::updateUi);
m_element = element; m_element = element;
connect(m_element.data(), &Element::linkedElementChanged, connect(m_element.data(), &Element::linkedElementChanged, this, &MasterPropertiesWidget::updateUi);
this, &MasterPropertiesWidget::updateUi);
updateUi(); updateUi();
} }
/** /**
@brief MasterPropertiesWidget::apply * @brief MasterPropertiesWidget::apply
If link betwen edited element and other change, * If link betwen edited element and other change,
apply the change with a QUndoCommand (got with method associatedUndo) * apply the change with a QUndoCommand (got with method associatedUndo)
pushed to the stack of element project. * pushed to the stack of element project.
Return true if link change, else false * Return true if link change, else false
@note is void no Return ???
*/ */
void MasterPropertiesWidget::apply() { void MasterPropertiesWidget::apply() {
if (QUndoCommand *undo = associatedUndo()) if (QUndoCommand *undo = associatedUndo())
@@ -175,8 +156,8 @@ void MasterPropertiesWidget::apply() {
} }
/** /**
@brief MasterPropertiesWidget::reset * @brief MasterPropertiesWidget::reset
Reset curent widget, clear eveything and rebuild widget. * Reset curent widget, clear eveything and rebuild widget.
*/ */
void MasterPropertiesWidget::reset() void MasterPropertiesWidget::reset()
{ {
@@ -188,11 +169,11 @@ void MasterPropertiesWidget::reset()
} }
/** /**
@brief MasterPropertiesWidget::associatedUndo * @brief MasterPropertiesWidget::associatedUndo
If link between the edited element and other change, * If link between the edited element and other change,
return a QUndoCommand with this change. * return a QUndoCommand with this change.
If no change return nullptr. * If no change return nullptr.
@return * @return
*/ */
QUndoCommand* MasterPropertiesWidget::associatedUndo() const QUndoCommand* MasterPropertiesWidget::associatedUndo() const
{ {
@@ -226,10 +207,10 @@ QUndoCommand* MasterPropertiesWidget::associatedUndo() const
} }
/** /**
@brief MasterPropertiesWidget::setLiveEdit * @brief MasterPropertiesWidget::setLiveEdit
@param live_edit = true : live edit is enable * @param live_edit = true : live edit is enable
else false : live edit is disable. * else false : live edit is disable.
@return always true because live edit is handled by this editor widget * @return always true because live edit is handled by this editor widget
*/ */
bool MasterPropertiesWidget::setLiveEdit(bool live_edit) bool MasterPropertiesWidget::setLiveEdit(bool live_edit)
{ {
@@ -238,8 +219,8 @@ bool MasterPropertiesWidget::setLiveEdit(bool live_edit)
} }
/** /**
@brief MasterPropertiesWidget::updateUi * @brief MasterPropertiesWidget::updateUi
Build the interface of the widget * Build the interface of the widget
*/ */
void MasterPropertiesWidget::updateUi() void MasterPropertiesWidget::updateUi()
{ {
@@ -264,24 +245,17 @@ void MasterPropertiesWidget::updateUi()
if(settings.value("genericpanel/folio", false).toBool()) if(settings.value("genericpanel/folio", false).toBool())
{ {
autonum::sequentialNumbers seq; autonum::sequentialNumbers seq;
QString F =autonum::AssignVariables::formulaToLabel( QString F =autonum::AssignVariables::formulaToLabel(elmt->diagram()->border_and_titleblock.folio(), seq, elmt->diagram(), elmt);
elmt->diagram()->border_and_titleblock.folio(),
seq,
elmt->diagram(),
elmt);
qtwi->setText(1, F); qtwi->setText(1, F);
} }
else else
{ {
qtwi->setText(1, QString::number( qtwi->setText(1, QString::number(elmt->diagram()->folioIndex() + 1));
elmt->diagram()->folioIndex()
+ 1));
} }
qtwi->setText(2, elmt->diagram()->title()); qtwi->setText(2, elmt->diagram()->title());
qtwi->setText(4, elmt->diagram()->convertPosition( qtwi->setText(4, elmt->diagram()->convertPosition(elmt->scenePos()).toString());
elmt->scenePos()).toString());
items_list.append(qtwi); items_list.append(qtwi);
m_qtwi_hash.insert(qtwi, elmt); m_qtwi_hash.insert(qtwi, elmt);
} }
@@ -299,23 +273,16 @@ void MasterPropertiesWidget::updateUi()
if(settings.value("genericpanel/folio", false).toBool()) if(settings.value("genericpanel/folio", false).toBool())
{ {
autonum::sequentialNumbers seq; autonum::sequentialNumbers seq;
QString F =autonum::AssignVariables::formulaToLabel( QString F =autonum::AssignVariables::formulaToLabel(elmt->diagram()->border_and_titleblock.folio(), seq, elmt->diagram(), elmt);
elmt->diagram()->border_and_titleblock.folio(),
seq,
elmt->diagram(),
elmt);
qtwi->setText(1, F); qtwi->setText(1, F);
} }
else else
{ {
qtwi->setText(1, QString::number( qtwi->setText(1, QString::number(elmt->diagram()->folioIndex() + 1));
elmt->diagram()->folioIndex()
+ 1));
} }
qtwi->setText(2, elmt->diagram()->title()); qtwi->setText(2, elmt->diagram()->title());
qtwi->setText(3, elmt->diagram()->convertPosition( qtwi->setText(3, elmt->diagram()->convertPosition(elmt->scenePos()).toString());
elmt->scenePos()).toString());
items_list.append(qtwi); items_list.append(qtwi);
m_qtwi_hash.insert(qtwi, elmt); m_qtwi_hash.insert(qtwi, elmt);
} }
@@ -331,10 +298,6 @@ void MasterPropertiesWidget::updateUi()
} }
} }
/**
@brief MasterPropertiesWidget::headerCustomContextMenuRequested
@param pos
*/
void MasterPropertiesWidget::headerCustomContextMenuRequested(const QPoint &pos) void MasterPropertiesWidget::headerCustomContextMenuRequested(const QPoint &pos)
{ {
m_context_menu->clear(); m_context_menu->clear();
@@ -343,8 +306,8 @@ void MasterPropertiesWidget::headerCustomContextMenuRequested(const QPoint &pos)
} }
/** /**
@brief MasterPropertiesWidget::on_link_button_clicked * @brief MasterPropertiesWidget::on_link_button_clicked
move curent item in the free_list to linked_list * move curent item in the free_list to linked_list
*/ */
void MasterPropertiesWidget::on_link_button_clicked() void MasterPropertiesWidget::on_link_button_clicked()
{ {
@@ -352,8 +315,7 @@ void MasterPropertiesWidget::on_link_button_clicked()
QTreeWidgetItem *qtwi = ui->m_free_tree_widget->currentItem(); QTreeWidgetItem *qtwi = ui->m_free_tree_widget->currentItem();
if (qtwi) if (qtwi)
{ {
ui->m_free_tree_widget->takeTopLevelItem( ui->m_free_tree_widget->takeTopLevelItem(ui->m_free_tree_widget->indexOfTopLevelItem(qtwi));
ui->m_free_tree_widget->indexOfTopLevelItem(qtwi));
ui->m_link_tree_widget->insertTopLevelItem(0, qtwi); ui->m_link_tree_widget->insertTopLevelItem(0, qtwi);
if(m_live_edit) if(m_live_edit)
@@ -362,8 +324,8 @@ void MasterPropertiesWidget::on_link_button_clicked()
} }
/** /**
@brief MasterPropertiesWidget::on_unlink_button_clicked * @brief MasterPropertiesWidget::on_unlink_button_clicked
move curent item in linked_list to free_list * move curent item in linked_list to free_list
*/ */
void MasterPropertiesWidget::on_unlink_button_clicked() void MasterPropertiesWidget::on_unlink_button_clicked()
{ {
@@ -371,8 +333,7 @@ void MasterPropertiesWidget::on_unlink_button_clicked()
QTreeWidgetItem *qtwi = ui->m_link_tree_widget->currentItem(); QTreeWidgetItem *qtwi = ui->m_link_tree_widget->currentItem();
if(qtwi) if(qtwi)
{ {
ui->m_link_tree_widget->takeTopLevelItem( ui->m_link_tree_widget->takeTopLevelItem(ui->m_link_tree_widget->indexOfTopLevelItem(qtwi));
ui->m_link_tree_widget->indexOfTopLevelItem(qtwi));
ui->m_free_tree_widget->insertTopLevelItem(0, qtwi); ui->m_free_tree_widget->insertTopLevelItem(0, qtwi);
if(m_live_edit) if(m_live_edit)
@@ -381,18 +342,17 @@ void MasterPropertiesWidget::on_unlink_button_clicked()
} }
/** /**
@brief MasterPropertiesWidget::showElementFromTWI * @brief MasterPropertiesWidget::showElementFromTWI
Show the element corresponding to the given QTreeWidgetItem * Show the element corresponding to the given QTreeWidgetItem
@param qtwi * @param qtwi
@param column * @param column
*/ */
void MasterPropertiesWidget::showElementFromTWI(QTreeWidgetItem *qtwi, int column) void MasterPropertiesWidget::showElementFromTWI(QTreeWidgetItem *qtwi, int column)
{ {
Q_UNUSED(column); Q_UNUSED(column);
if (m_showed_element) if (m_showed_element)
{ {
disconnect(m_showed_element, SIGNAL(destroyed()), disconnect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
this, SLOT(showedElementWasDeleted()));
m_showed_element -> setHighlighted(false); m_showed_element -> setHighlighted(false);
} }
if (m_element) if (m_element)
@@ -401,44 +361,39 @@ void MasterPropertiesWidget::showElementFromTWI(QTreeWidgetItem *qtwi, int colum
m_showed_element = m_qtwi_hash[qtwi]; m_showed_element = m_qtwi_hash[qtwi];
m_showed_element->diagram()->showMe(); m_showed_element->diagram()->showMe();
m_showed_element->setHighlighted(true); m_showed_element->setHighlighted(true);
connect(m_showed_element, SIGNAL(destroyed()), connect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
this, SLOT(showedElementWasDeleted()));
} }
/** /**
@brief MasterPropertiesWidget::showedElementWasDeleted * @brief MasterPropertiesWidget::showedElementWasDeleted
Set to nullptr the current showed element when he was deleted * Set to nullptr the current showed element when he was deleted
*/ */
void MasterPropertiesWidget::showedElementWasDeleted() { void MasterPropertiesWidget::showedElementWasDeleted() {
m_showed_element = nullptr; m_showed_element = nullptr;
} }
/** /**
@brief MasterPropertiesWidget::diagramWasdeletedFromProject * @brief MasterPropertiesWidget::diagramWasdeletedFromProject
This slot is called when a diagram is removed from the parent project * This slot is called when a diagram is removed from the parent project of edited element
of edited element to update the content of this widget * to update the content of this widget
*/ */
void MasterPropertiesWidget::diagramWasdeletedFromProject() void MasterPropertiesWidget::diagramWasdeletedFromProject()
{ {
// We use a timer because if the removed diagram //We use a timer because if the removed diagram contain slave element linked to the edited element
// contain slave element linked to the edited element //we must to wait for this elements be unlinked, else the linked list provide deleted elements.
// we must to wait for this elements be unlinked,
// else the linked list provide deleted elements.
QTimer::singleShot(10, this, SLOT(updateUi())); QTimer::singleShot(10, this, SLOT(updateUi()));
} }
/** /**
@brief MasterPropertiesWidget::customContextMenu * @brief MasterPropertiesWidget::customContextMenu
Display a context menu * Display a context menu
@param pos * @param pos
@param i : the tree widget where the context menu was requested. * @param i : the tree widget where the context menu was requested.
*/ */
void MasterPropertiesWidget::customContextMenu(const QPoint &pos, int i) void MasterPropertiesWidget::customContextMenu(const QPoint &pos, int i)
{ {
// add the size of the header to display the topleft of the QMenu //add the size of the header to display the topleft of the QMenu at the position of the mouse.
// at the position of the mouse. //See doc about QWidget::customContextMenuRequested section related to QAbstractScrollArea
// See doc about QWidget::customContextMenuRequested
// section related to QAbstractScrollArea
QPoint point = pos; QPoint point = pos;
point.ry()+=ui->m_free_tree_widget->header()->height(); point.ry()+=ui->m_free_tree_widget->header()->height();

View File

@@ -35,30 +35,24 @@ namespace Ui {
} }
/** /**
@brief The MasterPropertiesWidget class * @brief The MasterPropertiesWidget class
This class is a widget for make link between a master element * This class is a widget for make link between a master element with several slave element.
with several slave element. * This class embenddedthe undo/redo command when apply new connection.
This class embenddedthe undo/redo command when apply new connection.
*/ */
class MasterPropertiesWidget : public AbstractElementPropertiesEditorWidget class MasterPropertiesWidget : public AbstractElementPropertiesEditorWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MasterPropertiesWidget(Element *elmt, explicit MasterPropertiesWidget(Element *elmt, QWidget *parent = nullptr);
QWidget *parent = nullptr);
~MasterPropertiesWidget() override; ~MasterPropertiesWidget() override;
void setElement (Element *element) override; void setElement (Element *element) override;
void apply() override; void apply() override;
void reset() override; void reset() override;
QUndoCommand *associatedUndo () const override; QUndoCommand *associatedUndo () const override;
/** QString title() const override {return tr("Référence croisée (maître)");}
* @brief title
* @return QString title
*/
QString title() const override {
return tr("Référence croisée (maître)");}
bool setLiveEdit(bool live_edit) override; bool setLiveEdit(bool live_edit) override;
public slots: public slots:

View File

@@ -77,7 +77,6 @@ m_diagram(diagram)
#if QT_VERSION >= 0x050900 #if QT_VERSION >= 0x050900
else else
setObsolete(true); setObsolete(true);
#pragma message("@TODO remove code for QT 5.9 or later")
#endif #endif
} }
@@ -136,7 +135,6 @@ void RotateTextsCommand::openDialog()
#if QT_VERSION >= 0x050900 #if QT_VERSION >= 0x050900
else else
setObsolete(true); setObsolete(true);
#pragma message("@TODO remove code for QT 5.9 or later")
#endif #endif
} }