mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Minor revamp
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4834 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -44,8 +44,8 @@ class NewConductorPotentialSelector : public AbstractPotentialSelector
|
||||
terminal_1->removeConductor(conductor);
|
||||
terminal_2->removeConductor(conductor);
|
||||
|
||||
getPotential(terminal_1, m_properties_1, m_seq_num_1, m_conductor_number_1, m_properties_list_1);
|
||||
getPotential(terminal_2, m_properties_2, m_seq_num_2, m_conductor_number_2, m_properties_list_2);
|
||||
getPotential(terminal_1, m_seq_num_1, m_conductor_number_1, m_properties_list_1, m_conductors_list_1);
|
||||
getPotential(terminal_2, m_seq_num_2, m_conductor_number_2, m_properties_list_2, m_conductors_list_2);
|
||||
|
||||
//There isn't a potential at terminal 1 or 2.
|
||||
if (m_conductor_number_1 == 0 && m_conductor_number_2 == 0) return;
|
||||
@@ -65,7 +65,7 @@ class NewConductorPotentialSelector : public AbstractPotentialSelector
|
||||
* @param properties
|
||||
* @param number
|
||||
*/
|
||||
void getPotential(Terminal *terminal, ConductorProperties &properties, autonum::sequentialNumbers &seq_num , int &number, QList<ConductorProperties> &properties_list)
|
||||
void getPotential(Terminal *terminal, autonum::sequentialNumbers &seq_num , int &number, QList<ConductorProperties> &properties_list, QList<Conductor*> &c_list)
|
||||
{
|
||||
Conductor *conductor_in_potential = nullptr;
|
||||
|
||||
@@ -100,11 +100,10 @@ class NewConductorPotentialSelector : public AbstractPotentialSelector
|
||||
|
||||
if (!conductor_in_potential)
|
||||
return;
|
||||
properties = conductor_in_potential->properties();
|
||||
seq_num = conductor_in_potential->sequenceNum();
|
||||
number = conductor_in_potential->relatedPotentialConductors().size()+1; //We add +1 because conductor_in_potential isn't count by relatedPotentialConductors
|
||||
|
||||
QList<Conductor *> c_list = conductor_in_potential->relatedPotentialConductors().toList();
|
||||
c_list = conductor_in_potential->relatedPotentialConductors().toList();
|
||||
c_list.append(conductor_in_potential);
|
||||
foreach(Conductor *c, c_list)
|
||||
properties_list.append(c->properties());
|
||||
@@ -135,24 +134,18 @@ class LinkReportPotentialSelector : public AbstractPotentialSelector
|
||||
if (report->conductors().isEmpty() || other_report->conductors().isEmpty())
|
||||
return;
|
||||
|
||||
QList <Conductor*> c_list;
|
||||
|
||||
m_properties_1 = report->conductors().first()->properties();
|
||||
m_conductor_number_1 = report->conductors().first()->relatedPotentialConductors().size() + 1;
|
||||
m_seq_num_1 = report->conductors().first()->sequenceNum();
|
||||
c_list.append(report->conductors().first()->relatedPotentialConductors().toList());
|
||||
c_list.append(report->conductors().first());
|
||||
foreach(Conductor *c, c_list)
|
||||
m_conductors_list_1.append(report->conductors().first()->relatedPotentialConductors().toList());
|
||||
m_conductors_list_1.append(report->conductors().first());
|
||||
foreach(Conductor *c, m_conductors_list_1)
|
||||
m_properties_list_1 << c->properties();
|
||||
|
||||
c_list.clear();
|
||||
|
||||
m_properties_2 = other_report->conductors().first()->properties();
|
||||
m_conductor_number_2 = other_report->conductors().first()->relatedPotentialConductors().size() + 1;
|
||||
m_seq_num_2 = other_report->conductors().first()->sequenceNum();
|
||||
c_list.append(other_report->conductors().first()->relatedPotentialConductors().toList());
|
||||
c_list.append(other_report->conductors().first());
|
||||
foreach(Conductor *c, c_list)
|
||||
m_conductors_list_2.append(other_report->conductors().first()->relatedPotentialConductors().toList());
|
||||
m_conductors_list_2.append(other_report->conductors().first());
|
||||
foreach(Conductor *c, m_conductors_list_2)
|
||||
m_properties_list_2 << c->properties();
|
||||
|
||||
//We relink the report
|
||||
@@ -221,27 +214,25 @@ PotentialSelectorDialog::~PotentialSelectorDialog()
|
||||
*/
|
||||
void PotentialSelectorDialog::buildWidget()
|
||||
{
|
||||
QRadioButton *rb1 = new QRadioButton(tr("Le potentiel avec numero de fil %1 est présent %2 fois").arg(m_potential_selector->m_properties_1.text).arg(m_potential_selector->m_conductor_number_1), this);
|
||||
QRadioButton *rb2 = new QRadioButton(tr("Le potentiel avec numero de fil %1 est présent %2 fois").arg(m_potential_selector->m_properties_2.text).arg(m_potential_selector->m_conductor_number_2), this);
|
||||
QRadioButton *rb1 = new QRadioButton(tr("Le potentiel avec numero de fil %1 est présent %2 fois").arg(m_potential_selector->m_properties_list_1.first().text).arg(m_potential_selector->m_conductor_number_1), this);
|
||||
QRadioButton *rb2 = new QRadioButton(tr("Le potentiel avec numero de fil %1 est présent %2 fois").arg(m_potential_selector->m_properties_list_2.first().text).arg(m_potential_selector->m_conductor_number_2), this);
|
||||
|
||||
connect(rb1, &QRadioButton::toggled, [this](bool t)
|
||||
{
|
||||
if(t)
|
||||
{
|
||||
this->m_selected_properties = this->m_potential_selector->m_properties_1;
|
||||
this->m_sequential_num = this->m_potential_selector->m_seq_num_1;
|
||||
this->m_properties_list = this->m_potential_selector->m_properties_list_1;
|
||||
m_selected = 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_selected_properties = this->m_potential_selector->m_properties_2;
|
||||
this->m_sequential_num = this->m_potential_selector->m_seq_num_2;
|
||||
this->m_properties_list = this->m_potential_selector->m_properties_list_2;
|
||||
m_selected = 2;
|
||||
this->m_conductors_to_change = this->m_potential_selector->m_conductors_list_1;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -285,30 +276,12 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
||||
if (m_report->diagram())
|
||||
diagram = m_report->diagram();
|
||||
|
||||
//We temporarily unlink report to get the two existing potential
|
||||
Element *other_report = m_report->linkedElements().first();
|
||||
m_report->unlinkAllElements();
|
||||
|
||||
QList<Conductor *> conductor_list;
|
||||
|
||||
if (m_selected == 1)
|
||||
{
|
||||
conductor_list.append(other_report->conductors().first()->relatedPotentialConductors().toList());
|
||||
conductor_list.append(other_report->conductors().first());
|
||||
}
|
||||
|
||||
else if (m_selected == 2)
|
||||
{
|
||||
conductor_list.append(m_report->conductors().first()->relatedPotentialConductors().toList());
|
||||
conductor_list.append(m_report->conductors().first());
|
||||
}
|
||||
|
||||
QVariant old_value, new_value;
|
||||
QVariant old_seq, new_seq;
|
||||
new_seq.setValue(m_sequential_num);
|
||||
|
||||
//Set the new properties for each conductors of the new potential
|
||||
foreach(Conductor *cond, conductor_list)
|
||||
foreach(Conductor *cond, m_conductors_to_change)
|
||||
{
|
||||
ConductorProperties new_properties = cond->properties();
|
||||
new_properties.applyForEqualAttributes(m_properties_list);
|
||||
@@ -318,8 +291,6 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
||||
new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo);
|
||||
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
|
||||
}
|
||||
//We relink the report
|
||||
m_report->linkToElement(other_report);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user