mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-14 21:49:57 +01:00
Conductor : remove the possibility to have different texts on the same potential
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4150 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -61,28 +61,44 @@ void ConductorPropertiesDialog::PropertiesDialog(Conductor *conductor, QWidget *
|
||||
{
|
||||
ConductorPropertiesDialog cpd (conductor, parent);
|
||||
|
||||
if (cpd.exec() == QDialog::Accepted && cpd.properties() != conductor->properties())
|
||||
if (cpd.exec() == QDialog::Rejected || cpd.properties() == conductor->properties()) return;
|
||||
|
||||
QVariant old_value, new_value;
|
||||
old_value.setValue(conductor->properties());
|
||||
new_value.setValue(cpd.properties());
|
||||
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(conductor, "properties", old_value, new_value);
|
||||
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
||||
|
||||
if (!conductor->relatedPotentialConductors().isEmpty())
|
||||
{
|
||||
QVariant old_value, new_value;
|
||||
old_value.setValue(conductor->properties());
|
||||
new_value.setValue(cpd.properties());
|
||||
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
||||
QString old_text = conductor->properties().text;
|
||||
QString new_text = cpd.properties().text;
|
||||
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(conductor, "properties", old_value, new_value);
|
||||
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
||||
|
||||
//Make undo for all related potiential conductors
|
||||
if (cpd.applyAll() && !conductor->relatedPotentialConductors().isEmpty())
|
||||
foreach (Conductor *potential_conductor, conductor->relatedPotentialConductors())
|
||||
{
|
||||
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
||||
foreach (Conductor *cond, conductor->relatedPotentialConductors())
|
||||
//"Apply to all conductors of potential" is checked,
|
||||
//we apply the new properties for every conductors in the same potential.
|
||||
if (cpd.applyAll())
|
||||
{
|
||||
old_value.setValue(cond->properties());
|
||||
new QPropertyUndoCommand (cond, "properties", old_value, new_value, undo);
|
||||
old_value.setValue(potential_conductor->properties());
|
||||
new QPropertyUndoCommand (potential_conductor, "properties", old_value, new_value, undo);
|
||||
}
|
||||
//The num of conductor isn't affected by "Apply to all conductors of potential"
|
||||
//we always apply it to the potential if he change.
|
||||
else if(old_text != new_text)
|
||||
{
|
||||
old_value.setValue(potential_conductor->properties());
|
||||
ConductorProperties new_properties = potential_conductor->properties();
|
||||
new_properties.text = new_text;
|
||||
new_value.setValue(new_properties);
|
||||
new QPropertyUndoCommand (potential_conductor, "properties", old_value, new_value, undo);
|
||||
}
|
||||
}
|
||||
|
||||
conductor->diagram()->undoStack().push(undo);
|
||||
}
|
||||
|
||||
conductor->diagram()->undoStack().push(undo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<width>403</width>
|
||||
<height>94</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -20,7 +20,7 @@
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Les textes de ce potentiel électrique ne sont pas identiques.
|
||||
Appliquer un texte à l'ensemble de ces conducteurs?</string>
|
||||
Appliquer un texte à l'ensemble de ces conducteurs.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -48,7 +48,7 @@ Appliquer un texte à l'ensemble de ces conducteurs?</string>
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user