mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Improve code style, Wrap code for better readability
This commit is contained in:
@@ -221,7 +221,9 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList<ConductorPro
|
||||
@param parent_undo : undo parent to use.
|
||||
@param parent : parent widget.
|
||||
*/
|
||||
PotentialSelectorDialog::PotentialSelectorDialog(Conductor *conductor, QUndoCommand *parent_undo, QWidget *parent) :
|
||||
PotentialSelectorDialog::PotentialSelectorDialog(Conductor *conductor,
|
||||
QUndoCommand *parent_undo,
|
||||
QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PotentialSelectorDialog),
|
||||
m_conductor(conductor),
|
||||
@@ -236,11 +238,14 @@ PotentialSelectorDialog::PotentialSelectorDialog(Conductor *conductor, QUndoComm
|
||||
/**
|
||||
@brief PotentialSelectorDialog::PotentialSelectorDialog
|
||||
Constructor when we link two potentiels together, with a folio report.
|
||||
@param report : one of the report used to link the potentials (report must be linked to another report)
|
||||
@param report : one of the report used to link the potentials
|
||||
(report must be linked to another report)
|
||||
@param parent_undo : undo parent to use
|
||||
@param parent : parent widget
|
||||
*/
|
||||
PotentialSelectorDialog::PotentialSelectorDialog(Element *report, QUndoCommand *parent_undo, QWidget *parent) :
|
||||
PotentialSelectorDialog::PotentialSelectorDialog(Element *report,
|
||||
QUndoCommand *parent_undo,
|
||||
QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PotentialSelectorDialog),
|
||||
m_conductor(nullptr),
|
||||
@@ -254,7 +259,7 @@ PotentialSelectorDialog::PotentialSelectorDialog(Element *report, QUndoCommand *
|
||||
|
||||
PotentialSelectorDialog::~PotentialSelectorDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
delete m_potential_selector;
|
||||
}
|
||||
|
||||
@@ -264,7 +269,9 @@ PotentialSelectorDialog::~PotentialSelectorDialog()
|
||||
*/
|
||||
void PotentialSelectorDialog::buildWidget()
|
||||
{
|
||||
QString text1(tr("%n conducteurs composent le potentiel suivant :", "", m_potential_selector->m_conductor_number_1));
|
||||
QString text1(tr("%n conducteurs composent le potentiel suivant :",
|
||||
"",
|
||||
m_potential_selector->m_conductor_number_1));
|
||||
|
||||
ConductorProperties cp1;
|
||||
if(!m_potential_selector->m_properties_list_1.isEmpty())
|
||||
@@ -275,13 +282,18 @@ void PotentialSelectorDialog::buildWidget()
|
||||
if(!cp1.m_function.isEmpty())
|
||||
text1.append(tr("\nFonction : %1").arg(cp1.m_function));
|
||||
if(!cp1.m_tension_protocol.isEmpty())
|
||||
text1.append(tr("\nTension/protocole : %1").arg(cp1.m_tension_protocol));
|
||||
text1.append(tr("\nTension/protocole : %1")
|
||||
.arg(cp1.m_tension_protocol));
|
||||
if(!cp1.m_wire_color.isEmpty())
|
||||
text1.append(tr("\nCouleur du conducteur : %1").arg(cp1.m_wire_color));
|
||||
text1.append(tr("\nCouleur du conducteur : %1")
|
||||
.arg(cp1.m_wire_color));
|
||||
if(!cp1.m_wire_section.isEmpty())
|
||||
text1.append(tr("\nSection du conducteur : %1").arg(cp1.m_wire_section));
|
||||
text1.append(tr("\nSection du conducteur : %1")
|
||||
.arg(cp1.m_wire_section));
|
||||
|
||||
QString text2(tr("%n conducteurs composent le potentiel suivant :", "", m_potential_selector->m_conductor_number_2));
|
||||
QString text2(tr("%n conducteurs composent le potentiel suivant :",
|
||||
"",
|
||||
m_potential_selector->m_conductor_number_2));
|
||||
ConductorProperties cp2;
|
||||
if(!m_potential_selector->m_properties_list_2.isEmpty())
|
||||
cp2 = m_potential_selector->m_properties_list_2.first();
|
||||
@@ -291,11 +303,14 @@ void PotentialSelectorDialog::buildWidget()
|
||||
if(!cp2.m_function.isEmpty())
|
||||
text2.append(tr("\nFonction : %1").arg(cp2.m_function));
|
||||
if(!cp2.m_tension_protocol.isEmpty())
|
||||
text2.append(tr("\nTension/protocole : %1").arg(cp2.m_tension_protocol));
|
||||
text2.append(tr("\nTension/protocole : %1")
|
||||
.arg(cp2.m_tension_protocol));
|
||||
if(!cp2.m_wire_color.isEmpty())
|
||||
text2.append(tr("\nCouleur du conducteur : %1").arg(cp2.m_wire_color));
|
||||
text2.append(tr("\nCouleur du conducteur : %1")
|
||||
.arg(cp2.m_wire_color));
|
||||
if(!cp2.m_wire_section.isEmpty())
|
||||
text2.append(tr("\nSection du conducteur : %1").arg(cp2.m_wire_section));
|
||||
text2.append(tr("\nSection du conducteur : %1")
|
||||
.arg(cp2.m_wire_section));
|
||||
|
||||
QRadioButton *rb1 = new QRadioButton(text1, this);
|
||||
QRadioButton *rb2 = new QRadioButton(text2, this);
|
||||
@@ -304,24 +319,35 @@ void PotentialSelectorDialog::buildWidget()
|
||||
{
|
||||
if(t)
|
||||
{
|
||||
this->m_sequential_num = this->m_potential_selector->m_seq_num_1;
|
||||
this->m_properties_list = this->m_potential_selector->m_properties_list_1;
|
||||
this->m_conductors_to_change = this->m_potential_selector->m_conductors_list_2;
|
||||
this->m_sequential_num =
|
||||
this->m_potential_selector->m_seq_num_1;
|
||||
this->m_properties_list =
|
||||
this->m_potential_selector
|
||||
->m_properties_list_1;
|
||||
this->m_conductors_to_change =
|
||||
this->m_potential_selector
|
||||
->m_conductors_list_2;
|
||||
}
|
||||
});
|
||||
connect(rb2, &QRadioButton::toggled, [this](bool t)
|
||||
{
|
||||
if(t)
|
||||
{
|
||||
this->m_sequential_num = this->m_potential_selector->m_seq_num_2;
|
||||
this->m_properties_list = this->m_potential_selector->m_properties_list_2;
|
||||
this->m_conductors_to_change = this->m_potential_selector->m_conductors_list_1;
|
||||
this->m_sequential_num =
|
||||
this->m_potential_selector->m_seq_num_2;
|
||||
this->m_properties_list =
|
||||
this->m_potential_selector
|
||||
->m_properties_list_2;
|
||||
this->m_conductors_to_change =
|
||||
this->m_potential_selector
|
||||
->m_conductors_list_1;
|
||||
}
|
||||
});
|
||||
|
||||
//Set the radio button of potential with the bigger number of conductors,
|
||||
//at first position, and check it
|
||||
if (m_potential_selector->m_conductor_number_1 >= m_potential_selector->m_conductor_number_2)
|
||||
//Set the radio button of potential with the bigger number of conductors,
|
||||
//at first position, and check it
|
||||
if (m_potential_selector->m_conductor_number_1 >=
|
||||
m_potential_selector->m_conductor_number_2)
|
||||
{
|
||||
ui->verticalLayout->insertWidget(1, rb1);
|
||||
ui->verticalLayout->insertWidget(2, rb2);
|
||||
@@ -348,13 +374,16 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
||||
if (m_parent_undo)
|
||||
undo = m_parent_undo;
|
||||
else
|
||||
undo = new QUndoCommand(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
||||
undo = new QUndoCommand(
|
||||
tr("Modifier les propriétés de plusieurs conducteurs",
|
||||
"undo caption"));
|
||||
|
||||
Diagram * diagram = nullptr;
|
||||
|
||||
if (m_report)
|
||||
{
|
||||
if ((m_report->linkType() & Element::AllReport) && !m_report->isFree())
|
||||
if ((m_report->linkType() & Element::AllReport)
|
||||
&& !m_report->isFree())
|
||||
{
|
||||
if (m_report->diagram())
|
||||
diagram = m_report->diagram();
|
||||
@@ -363,7 +392,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
||||
QVariant old_seq, new_seq;
|
||||
new_seq.setValue(m_sequential_num);
|
||||
|
||||
//Set the new properties for each conductors of the new potential
|
||||
//Set the new properties for each conductors of the new potential
|
||||
foreach(Conductor *cond, m_conductors_to_change)
|
||||
{
|
||||
ConductorProperties new_properties = cond->properties();
|
||||
@@ -371,18 +400,33 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
||||
old_value.setValue(cond->properties());
|
||||
new_value.setValue(new_properties);
|
||||
old_seq.setValue(cond->sequenceNum());
|
||||
new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo);
|
||||
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
|
||||
new QPropertyUndoCommand(cond,
|
||||
"sequenceNum",
|
||||
old_seq,
|
||||
new_seq,
|
||||
undo);
|
||||
new QPropertyUndoCommand(cond,
|
||||
"properties",
|
||||
old_value,
|
||||
new_value,
|
||||
undo);
|
||||
}
|
||||
|
||||
//Check if formula of the new potential have incompatible variable with folio report
|
||||
//Check if formula of the new potential
|
||||
// have incompatible variable with folio report
|
||||
QRegularExpression rx ("%sequf_|%seqtf_|%seqhf_|%id|%F|%M|%LM");
|
||||
foreach(ConductorProperties cp, m_properties_list)
|
||||
{
|
||||
if (cp.m_formula.contains(rx))
|
||||
{
|
||||
QStringList forbidden_str;
|
||||
forbidden_str << "%sequf_" << "%seqtf_" << "%seqhf_" << "%id" << "%F" << "%M" << "%LM";
|
||||
forbidden_str << "%sequf_"
|
||||
<< "%seqtf_"
|
||||
<< "%seqhf_"
|
||||
<< "%id"
|
||||
<< "%F"
|
||||
<< "%M"
|
||||
<< "%LM";
|
||||
|
||||
QString text(tr("La formule du nouveau potentiel contient des variables incompatibles avec les reports de folio.\n"
|
||||
"Veuillez saisir une formule compatible pour ce potentiel.\n"
|
||||
@@ -403,7 +447,11 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
||||
ConductorProperties new_properties = cond->properties();
|
||||
new_properties.m_formula = new_formula;
|
||||
new_value.setValue(new_properties);
|
||||
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
|
||||
new QPropertyUndoCommand(cond,
|
||||
"properties",
|
||||
old_value,
|
||||
new_value,
|
||||
undo);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -428,8 +476,16 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
||||
old_seq.setValue(m_conductor->sequenceNum());
|
||||
new_seq.setValue(m_sequential_num);
|
||||
|
||||
new QPropertyUndoCommand(m_conductor, "sequenceNum", old_seq, new_seq, undo);
|
||||
new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, undo);
|
||||
new QPropertyUndoCommand(m_conductor,
|
||||
"sequenceNum",
|
||||
old_seq,
|
||||
new_seq,
|
||||
undo);
|
||||
new QPropertyUndoCommand(m_conductor,
|
||||
"properties",
|
||||
old_value,
|
||||
new_value,
|
||||
undo);
|
||||
|
||||
//Set the new properties for each conductors of the new potential
|
||||
foreach(Conductor *cond, m_conductor->relatedPotentialConductors())
|
||||
@@ -439,15 +495,24 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
||||
old_value.setValue(cond->properties());
|
||||
new_value.setValue(new_properties);
|
||||
old_seq.setValue(cond->sequenceNum());
|
||||
new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo);
|
||||
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
|
||||
new QPropertyUndoCommand(cond,
|
||||
"sequenceNum",
|
||||
old_seq,
|
||||
new_seq,
|
||||
undo);
|
||||
new QPropertyUndoCommand(cond,
|
||||
"properties",
|
||||
old_value,
|
||||
new_value,
|
||||
undo);
|
||||
}
|
||||
}
|
||||
|
||||
//There is an undo parent, we stop here, the owner of m_parent_undo will push it to an undo stack
|
||||
//There is an undo parent, we stop here,
|
||||
//the owner of m_parent_undo will push it to an undo stack
|
||||
if (m_parent_undo)
|
||||
return;
|
||||
//There isn't a parent, we push the undo command to diagram undo stack.
|
||||
//There isn't a parent, we push the undo command to diagram undo stack.
|
||||
if (diagram)
|
||||
diagram->undoStack().push(undo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user