mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-05-23 05:49:59 +02:00
New element: Line definition
This commit is contained in:
704
lang/qet_de.ts
704
lang/qet_de.ts
File diff suppressed because it is too large
Load Diff
@@ -220,7 +220,7 @@ void DynamicTextFieldEditor::fillInfoComboBox()
|
|||||||
QStringList strl;
|
QStringList strl;
|
||||||
auto type = elementEditor()->elementScene()->elementData().m_type;
|
auto type = elementEditor()->elementScene()->elementData().m_type;
|
||||||
|
|
||||||
if(type & ElementData::AllReport) {
|
if((type & ElementData::AllReport) || (type == ElementData::ConductorDefinition)) {
|
||||||
strl = QETInformation::folioReportInfoKeys();
|
strl = QETInformation::folioReportInfoKeys();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -365,7 +365,8 @@ void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index) {
|
|||||||
void DynamicTextFieldEditor::on_m_composite_text_pb_clicked()
|
void DynamicTextFieldEditor::on_m_composite_text_pb_clicked()
|
||||||
{
|
{
|
||||||
bool isReport = false;
|
bool isReport = false;
|
||||||
if (elementEditor()->elementScene()->elementData().m_type & ElementData::AllReport) {
|
auto type = elementEditor()->elementScene()->elementData().m_type;
|
||||||
|
if ((type & ElementData::AllReport) || (type == ElementData::ConductorDefinition)) {
|
||||||
isReport = true;
|
isReport = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ void ElementPropertiesEditorWidget::setUpInterface()
|
|||||||
ui->m_base_type_cb->addItem (tr("Renvoi de folio précédent"), ElementData::PreviousReport);
|
ui->m_base_type_cb->addItem (tr("Renvoi de folio précédent"), ElementData::PreviousReport);
|
||||||
ui->m_base_type_cb->addItem (tr("Bornier"), ElementData::Terminal);
|
ui->m_base_type_cb->addItem (tr("Bornier"), ElementData::Terminal);
|
||||||
ui->m_base_type_cb->addItem (tr("Vignette"), ElementData::Thumbnail);
|
ui->m_base_type_cb->addItem (tr("Vignette"), ElementData::Thumbnail);
|
||||||
|
ui->m_base_type_cb->addItem (tr("Définition de conducteur"), ElementData::ConductorDefinition);
|
||||||
|
|
||||||
// Slave option
|
// Slave option
|
||||||
ui->m_state_cb->addItem(tr("Normalement ouvert"), ElementData::NO);
|
ui->m_state_cb->addItem(tr("Normalement ouvert"), ElementData::NO);
|
||||||
@@ -188,6 +189,9 @@ void ElementPropertiesEditorWidget::updateTree()
|
|||||||
case ElementData::PreviousReport:
|
case ElementData::PreviousReport:
|
||||||
ui->m_tree->setDisabled(true);
|
ui->m_tree->setDisabled(true);
|
||||||
break;
|
break;
|
||||||
|
case ElementData::ConductorDefinition:
|
||||||
|
ui->m_tree->setDisabled(true);
|
||||||
|
break;
|
||||||
case ElementData::Master:
|
case ElementData::Master:
|
||||||
ui->m_tree->setEnabled(true);
|
ui->m_tree->setEnabled(true);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -737,9 +737,10 @@ bool QETElementEditor::checkElement()
|
|||||||
QList<QETWarning> errors;
|
QList<QETWarning> errors;
|
||||||
|
|
||||||
// Warning #1: Element haven't got terminal
|
// Warning #1: Element haven't got terminal
|
||||||
// (except for report, because report must have one terminal and this checking is do below)
|
// (except for report and conductor definition, because they must have one terminal and this checking is done below)
|
||||||
if (!m_elmt_scene -> containsTerminals() &&
|
if (!m_elmt_scene -> containsTerminals() &&
|
||||||
!(m_elmt_scene->elementData().m_type & ElementData::AllReport)) {
|
!(m_elmt_scene->elementData().m_type & ElementData::AllReport) &&
|
||||||
|
m_elmt_scene->elementData().m_type != ElementData::ConductorDefinition) {
|
||||||
warnings << qMakePair(
|
warnings << qMakePair(
|
||||||
tr("Absence de borne", "warning title"),
|
tr("Absence de borne", "warning title"),
|
||||||
tr(
|
tr(
|
||||||
@@ -771,6 +772,27 @@ bool QETElementEditor::checkElement()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check conductor definition element
|
||||||
|
if (m_elmt_scene->elementData().m_type == ElementData::ConductorDefinition)
|
||||||
|
{
|
||||||
|
int terminal =0;
|
||||||
|
|
||||||
|
for(auto qgi : m_elmt_scene -> items()) {
|
||||||
|
if (qgraphicsitem_cast<PartTerminal *>(qgi)) {
|
||||||
|
terminal ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error: Conductor definition must have exactly one terminal
|
||||||
|
if (terminal != 1) {
|
||||||
|
errors << qMakePair (tr("Nombre de bornes incorrect"),
|
||||||
|
tr("<br><b>Erreur</b> :"
|
||||||
|
"<br>Les définitions de conducteur ne peuvent posséder qu'une seule borne."
|
||||||
|
"<br><b>Solution</b> :"
|
||||||
|
"<br>Vérifier que l'élément ne possède qu'une seule borne"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!errors.count() && !warnings.count()) {
|
if (!errors.count() && !warnings.count()) {
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,19 @@ bool ElementData::fromXml(const QDomElement &xml_element)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_type = typeFromString(xml_element.attribute(QStringLiteral("link_type"), QStringLiteral("simple")));
|
// --- HIER STARTET UNSER DEBUG-BLOCK ---
|
||||||
|
// Wir holen den String aus der XML und speichern ihn kurz zwischen
|
||||||
|
QString raw_type_string = xml_element.attribute(QStringLiteral("link_type"), QStringLiteral("simple"));
|
||||||
|
|
||||||
|
qDebug() << "\n=== NEUES BAUTEIL WIRD GELADEN ===";
|
||||||
|
qDebug() << "[XML Parser] Roher 'link_type' String aus der .elmt Datei:" << raw_type_string;
|
||||||
|
|
||||||
|
// Jetzt übergeben wir ihn an deine Übersetzungs-Funktion
|
||||||
|
m_type = typeFromString(raw_type_string);
|
||||||
|
|
||||||
|
qDebug() << "[XML Parser] Übersetzter ElementData-Typ:" << typeToString(m_type);
|
||||||
|
// --- HIER ENDET UNSER DEBUG-BLOCK ---
|
||||||
|
|
||||||
kindInfoFromXml(xml_element);
|
kindInfoFromXml(xml_element);
|
||||||
m_informations.fromXml(xml_element.firstChildElement(QStringLiteral("elementInformations")),
|
m_informations.fromXml(xml_element.firstChildElement(QStringLiteral("elementInformations")),
|
||||||
QStringLiteral("elementInformation"));
|
QStringLiteral("elementInformation"));
|
||||||
@@ -323,6 +335,8 @@ QString ElementData::typeToString(ElementData::Type type)
|
|||||||
return QStringLiteral("terminal");
|
return QStringLiteral("terminal");
|
||||||
case ElementData::Thumbnail:
|
case ElementData::Thumbnail:
|
||||||
return QStringLiteral("thumbnail");
|
return QStringLiteral("thumbnail");
|
||||||
|
case ElementData::ConductorDefinition:
|
||||||
|
return QStringLiteral("conductor_definition");
|
||||||
default:
|
default:
|
||||||
qDebug() << "ElementData::typeToString : type don't exist"
|
qDebug() << "ElementData::typeToString : type don't exist"
|
||||||
<< "return failsafe value 'simple'";
|
<< "return failsafe value 'simple'";
|
||||||
@@ -346,6 +360,8 @@ ElementData::Type ElementData::typeFromString(const QString &string)
|
|||||||
return ElementData::Terminal;
|
return ElementData::Terminal;
|
||||||
} else if (string == QLatin1String("thumbnail")) {
|
} else if (string == QLatin1String("thumbnail")) {
|
||||||
return ElementData::Thumbnail;
|
return ElementData::Thumbnail;
|
||||||
|
} else if (string == QLatin1String("conductor_definition")) {
|
||||||
|
return ElementData::ConductorDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return simple if nothing match
|
//Return simple if nothing match
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ class ElementData : public PropertiesInterface
|
|||||||
Master = 8,
|
Master = 8,
|
||||||
Slave = 16,
|
Slave = 16,
|
||||||
Terminal = 32,
|
Terminal = 32,
|
||||||
Thumbnail = 64};
|
Thumbnail = 64,
|
||||||
|
ConductorDefinition = 128};
|
||||||
Q_ENUM(Type)
|
Q_ENUM(Type)
|
||||||
Q_DECLARE_FLAGS(Types, Type)
|
Q_DECLARE_FLAGS(Types, Type)
|
||||||
|
|
||||||
|
|||||||
@@ -302,7 +302,8 @@ void DynamicElementTextItem::refreshLabelConnection()
|
|||||||
if ((m_text_from == ElementInfo && m_info_name == "label") ||
|
if ((m_text_from == ElementInfo && m_info_name == "label") ||
|
||||||
(m_text_from == CompositeText && m_composite_text.contains("%{label}")))
|
(m_text_from == CompositeText && m_composite_text.contains("%{label}")))
|
||||||
{
|
{
|
||||||
if(m_parent_element.data()->linkType() & Element::AllReport)
|
if((m_parent_element.data()->linkType() & Element::AllReport) ||
|
||||||
|
m_parent_element.data()->linkType() == Element::ConductorDefinition)
|
||||||
{
|
{
|
||||||
updateReportFormulaConnection();
|
updateReportFormulaConnection();
|
||||||
updateReportText();
|
updateReportText();
|
||||||
@@ -418,7 +419,8 @@ void DynamicElementTextItem::setInfoName(const QString &info_name)
|
|||||||
updateXref();
|
updateXref();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_parent_element && (m_parent_element.data()->linkType() & Element::AllReport)) //special treatment for report
|
if (m_parent_element && ((m_parent_element.data()->linkType() & Element::AllReport) ||
|
||||||
|
m_parent_element.data()->linkType() == Element::ConductorDefinition)) //special treatment for report
|
||||||
{
|
{
|
||||||
if(old_info_name != info_name)
|
if(old_info_name != info_name)
|
||||||
{
|
{
|
||||||
@@ -472,7 +474,8 @@ void DynamicElementTextItem::setCompositeText(const QString &text)
|
|||||||
updateXref();
|
updateXref();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_parent_element && (m_parent_element.data()->linkType() & Element::AllReport)) //special treatment for report
|
if (m_parent_element && ((m_parent_element.data()->linkType() & Element::AllReport) ||
|
||||||
|
m_parent_element.data()->linkType() == Element::ConductorDefinition)) //special treatment for report
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* May be in some case the old and new composite text both have the var %{label},
|
* May be in some case the old and new composite text both have the var %{label},
|
||||||
@@ -726,7 +729,8 @@ QVariant DynamicElementTextItem::itemChange(QGraphicsItem::GraphicsItemChange ch
|
|||||||
if(!m_parent_element.data()->linkedElements().isEmpty())
|
if(!m_parent_element.data()->linkedElements().isEmpty())
|
||||||
masterChanged();
|
masterChanged();
|
||||||
}
|
}
|
||||||
else if(m_parent_element.data()->linkType() & Element::AllReport)
|
else if((m_parent_element.data()->linkType() & Element::AllReport) ||
|
||||||
|
m_parent_element.data()->linkType() == Element::ConductorDefinition)
|
||||||
{
|
{
|
||||||
//Get the report formula, and add connection to keep up to date the formula.
|
//Get the report formula, and add connection to keep up to date the formula.
|
||||||
if (m_parent_element.data()->diagram() && m_parent_element.data()->diagram()->project())
|
if (m_parent_element.data()->diagram() && m_parent_element.data()->diagram()->project())
|
||||||
@@ -1027,7 +1031,8 @@ void DynamicElementTextItem::clearFormulaConnection()
|
|||||||
|
|
||||||
void DynamicElementTextItem::updateReportFormulaConnection()
|
void DynamicElementTextItem::updateReportFormulaConnection()
|
||||||
{
|
{
|
||||||
if(!(m_parent_element.data()->linkType() & Element::AllReport))
|
if(!(m_parent_element.data()->linkType() & Element::AllReport) &&
|
||||||
|
m_parent_element.data()->linkType() != Element::ConductorDefinition)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
removeConnectionForReportFormula(m_report_formula);
|
removeConnectionForReportFormula(m_report_formula);
|
||||||
@@ -1041,7 +1046,8 @@ void DynamicElementTextItem::updateReportFormulaConnection()
|
|||||||
*/
|
*/
|
||||||
void DynamicElementTextItem::updateReportText()
|
void DynamicElementTextItem::updateReportText()
|
||||||
{
|
{
|
||||||
if(!(m_parent_element.data()->linkType() & Element::AllReport))
|
if(!(m_parent_element.data()->linkType() & Element::AllReport) &&
|
||||||
|
m_parent_element.data()->linkType() != Element::ConductorDefinition)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_text_from == ElementInfo && m_info_name == "label")
|
if (m_text_from == ElementInfo && m_info_name == "label")
|
||||||
@@ -1123,7 +1129,8 @@ void DynamicElementTextItem::conductorWasRemoved(Conductor *conductor)
|
|||||||
*/
|
*/
|
||||||
void DynamicElementTextItem::setPotentialConductor()
|
void DynamicElementTextItem::setPotentialConductor()
|
||||||
{
|
{
|
||||||
if(parentElement() && (parentElement()->linkType() & Element::AllReport))
|
if(parentElement() && ((parentElement()->linkType() & Element::AllReport) || (parentElement()->linkType() == Element::ConductorDefinition) ||
|
||||||
|
parentElement()->linkType() == Element::ConductorDefinition))
|
||||||
{
|
{
|
||||||
if(parentElement()->terminals().isEmpty())
|
if(parentElement()->terminals().isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -1156,6 +1163,7 @@ void DynamicElementTextItem::setPotentialConductor()
|
|||||||
connect(m_watched_conductor.data(), &Conductor::propertiesChange, this, &DynamicElementTextItem::conductorPropertiesChanged);
|
connect(m_watched_conductor.data(), &Conductor::propertiesChange, this, &DynamicElementTextItem::conductorPropertiesChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
conductorPropertiesChanged();
|
||||||
}
|
}
|
||||||
else //This text haven't got a parent element, then ther isn't a conductor in the potential
|
else //This text haven't got a parent element, then ther isn't a conductor in the potential
|
||||||
{
|
{
|
||||||
@@ -1172,7 +1180,8 @@ void DynamicElementTextItem::setPotentialConductor()
|
|||||||
*/
|
*/
|
||||||
void DynamicElementTextItem::conductorPropertiesChanged()
|
void DynamicElementTextItem::conductorPropertiesChanged()
|
||||||
{
|
{
|
||||||
if(m_parent_element && (m_parent_element.data()->linkType() & Element::AllReport))
|
if(m_parent_element && ((m_parent_element.data()->linkType() & Element::AllReport) || (m_parent_element.data()->linkType() == Element::ConductorDefinition) ||
|
||||||
|
m_parent_element.data()->linkType() == Element::ConductorDefinition))
|
||||||
{
|
{
|
||||||
if(m_text_from == ElementInfo)
|
if(m_text_from == ElementInfo)
|
||||||
{
|
{
|
||||||
@@ -1201,7 +1210,8 @@ QString DynamicElementTextItem::reportReplacedCompositeText() const
|
|||||||
{
|
{
|
||||||
QString string;
|
QString string;
|
||||||
|
|
||||||
if(m_parent_element.data()->linkType() & Element::AllReport)
|
if((m_parent_element.data()->linkType() & Element::AllReport) || (m_parent_element.data()->linkType() == Element::ConductorDefinition) ||
|
||||||
|
m_parent_element.data()->linkType() == Element::ConductorDefinition)
|
||||||
{
|
{
|
||||||
string = m_composite_text;
|
string = m_composite_text;
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "../qetxml.h"
|
#include "../qetxml.h"
|
||||||
#include "../qetversion.h"
|
#include "../qetversion.h"
|
||||||
#include "qgraphicsitemutility.h"
|
#include "qgraphicsitemutility.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -431,6 +432,11 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
m_data.fromXml(xml_def_elmt);
|
m_data.fromXml(xml_def_elmt);
|
||||||
setToolTip(name());
|
setToolTip(name());
|
||||||
|
|
||||||
|
QString my_type_str = xml_def_elmt.attribute(QStringLiteral("link_type"), QStringLiteral("simple"));
|
||||||
|
if (my_type_str == QLatin1String("conductor_definition")) {
|
||||||
|
m_link_type = Element::ConductorDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
//load kind informations
|
//load kind informations
|
||||||
m_kind_informations.fromXml(
|
m_kind_informations.fromXml(
|
||||||
xml_def_elmt.firstChildElement(QStringLiteral("kindInformations")),
|
xml_def_elmt.firstChildElement(QStringLiteral("kindInformations")),
|
||||||
@@ -627,6 +633,9 @@ Terminal *Element::parseTerminal(const QDomElement &dom_element)
|
|||||||
Terminal *new_terminal = new Terminal(data, this);
|
Terminal *new_terminal = new Terminal(data, this);
|
||||||
m_terminals << new_terminal;
|
m_terminals << new_terminal;
|
||||||
|
|
||||||
|
connect(new_terminal, &Terminal::conductorWasAdded, this, &Element::updateConductorTexts);
|
||||||
|
connect(new_terminal, &Terminal::conductorWasRemoved, this, &Element::updateConductorTexts);
|
||||||
|
|
||||||
//Sort from top to bottom and left to right
|
//Sort from top to bottom and left to right
|
||||||
std::sort(m_terminals.begin(),
|
std::sort(m_terminals.begin(),
|
||||||
m_terminals.end(),
|
m_terminals.end(),
|
||||||
@@ -1288,6 +1297,8 @@ QString Element::linkTypeToString() const
|
|||||||
return QStringLiteral("Terminale");
|
return QStringLiteral("Terminale");
|
||||||
case Thumbnail:
|
case Thumbnail:
|
||||||
return QStringLiteral("Thumbnail");
|
return QStringLiteral("Thumbnail");
|
||||||
|
case ConductorDefinition:
|
||||||
|
return QStringLiteral("ConductorDefinition");
|
||||||
default:
|
default:
|
||||||
return QStringLiteral("Unknown");
|
return QStringLiteral("Unknown");
|
||||||
}
|
}
|
||||||
@@ -1555,3 +1566,25 @@ ElementsLocation Element::location() const
|
|||||||
{
|
{
|
||||||
return m_location;
|
return m_location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Element::updateConductorTexts
|
||||||
|
*Slot that is triggered when a cable is *
|
||||||
|
*connected to or disconnected from a terminal on this component.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @brief Element::updateConductorTexts
|
||||||
|
*/
|
||||||
|
void Element::updateConductorTexts()
|
||||||
|
{
|
||||||
|
if (m_link_type != Element::ConductorDefinition) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DynamicElementTextItem *deti : m_dynamic_text_list) {
|
||||||
|
if (deti) {
|
||||||
|
deti->setPotentialConductor();
|
||||||
|
deti->updateLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ class Element : public QetGraphicsItem
|
|||||||
Master = 8,
|
Master = 8,
|
||||||
Slave = 16,
|
Slave = 16,
|
||||||
Terminale = 32,
|
Terminale = 32,
|
||||||
Thumbnail = 64};
|
Thumbnail = 64,
|
||||||
|
ConductorDefinition = 128};
|
||||||
|
|
||||||
Element(const ElementsLocation &location,
|
Element(const ElementsLocation &location,
|
||||||
QGraphicsItem * = nullptr,
|
QGraphicsItem * = nullptr,
|
||||||
@@ -95,6 +96,8 @@ class Element : public QetGraphicsItem
|
|||||||
DynamicElementTextItem *text,
|
DynamicElementTextItem *text,
|
||||||
ElementTextItemGroup *group);
|
ElementTextItemGroup *group);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void updateConductorTexts();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QList<Terminal *> terminals() const;
|
QList<Terminal *> terminals() const;
|
||||||
|
|||||||
@@ -308,6 +308,9 @@ void ElementPropertiesWidget::updateUi()
|
|||||||
case Element::Terminale:
|
case Element::Terminale:
|
||||||
m_list_editor << new ElementInfoWidget(m_element, this);
|
m_list_editor << new ElementInfoWidget(m_element, this);
|
||||||
break;
|
break;
|
||||||
|
case Element::ConductorDefinition:
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user