mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +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:
@@ -114,24 +114,27 @@ void ConductorAutoNumerotation::applyText(QString t)
|
|||||||
* @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()
|
||||||
|
{
|
||||||
QStringList strl;
|
QStringList strl;
|
||||||
foreach (const Conductor *cc, conductor_list) strl<<(cc->text());
|
foreach (const Conductor *cc, conductor_list) strl<<(cc->text());
|
||||||
|
|
||||||
//the texts is identicals
|
//the texts is identicals
|
||||||
if (QET::eachStrIsEqual(strl)) {
|
if (QET::eachStrIsEqual(strl))
|
||||||
|
{
|
||||||
ConductorProperties cp = conductor_ -> properties();
|
ConductorProperties cp = conductor_ -> properties();
|
||||||
cp.text = strl.at(0);
|
cp.text = strl.at(0);
|
||||||
conductor_ -> setProperties(cp);
|
conductor_ -> setProperties(cp);
|
||||||
conductor_ -> setText(strl.at(0));
|
conductor_ -> setText(strl.at(0));
|
||||||
}
|
}
|
||||||
//the texts isn't identicals
|
//the texts isn't identicals
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
PotentialTextsDialog ptd (conductor_, conductor_ -> diagramEditor());
|
PotentialTextsDialog ptd (conductor_, conductor_ -> diagramEditor());
|
||||||
if (ptd.exec() == QDialog::Accepted) {
|
ptd.exec();
|
||||||
applyText(ptd.selectedText());
|
applyText(ptd.selectedText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorAutoNumerotation::numerateNewConductor
|
* @brief ConductorAutoNumerotation::numerateNewConductor
|
||||||
|
|||||||
@@ -90,15 +90,11 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
|||||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
|
|
||||||
// ajout du champ de texte editable
|
// Add the text field
|
||||||
text_item = new ConductorTextItem(properties_.text, this);
|
text_item = new ConductorTextItem(properties_.text, this);
|
||||||
text_item -> setFlag(QGraphicsItem::ItemStacksBehindParent);
|
text_item -> setFlag(QGraphicsItem::ItemStacksBehindParent);
|
||||||
connect(
|
|
||||||
text_item,
|
connect(text_item, &ConductorTextItem::diagramTextChanged, this, &Conductor::displayedTextChanged);
|
||||||
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
|
||||||
this,
|
|
||||||
SLOT(displayedTextChanged())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1392,32 +1388,14 @@ void Conductor::setHighlighted(Conductor::Highlight hl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Met a jour les proprietes du conducteur apres modification du champ de texte affiche
|
* @brief Conductor::displayedTextChanged
|
||||||
|
* Update the properties (text) of this conductor and other conductors
|
||||||
|
* at the same potential of this conductor.
|
||||||
*/
|
*/
|
||||||
void Conductor::displayedTextChanged() {
|
void Conductor::displayedTextChanged()
|
||||||
// verifie que le texte a reellement change
|
{
|
||||||
if (text_item -> toPlainText() == properties_.text) return;
|
if ((text_item->toPlainText() == properties_.text) || !diagram()) return;
|
||||||
|
|
||||||
if (Diagram *my_diagram = diagram())
|
|
||||||
{
|
|
||||||
int qmbreturn=0;
|
|
||||||
//if conductor isn't alone at this potential
|
|
||||||
//ask user to apply text on every conductors of this potential
|
|
||||||
if (relatedPotentialConductors().size() >= 1)
|
|
||||||
{
|
|
||||||
qmbreturn = QMessageBox::question(diagramEditor(), tr("Textes de conducteurs"),
|
|
||||||
tr("Voulez-vous appliquer le nouveau texte \n"
|
|
||||||
"à l'ensemble des conducteurs de ce potentiel ?"),
|
|
||||||
QMessageBox::No| QMessageBox::Yes, QMessageBox::Yes);
|
|
||||||
if (qmbreturn == QMessageBox::Yes)
|
|
||||||
{
|
|
||||||
ConductorAutoNumerotation can(this, my_diagram);
|
|
||||||
can.applyText(text_item -> toPlainText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qmbreturn == 0 || qmbreturn == QMessageBox::No)
|
|
||||||
{
|
|
||||||
QVariant old_value, new_value;
|
QVariant old_value, new_value;
|
||||||
old_value.setValue(properties_);
|
old_value.setValue(properties_);
|
||||||
ConductorProperties new_properties(properties_);
|
ConductorProperties new_properties(properties_);
|
||||||
@@ -1426,9 +1404,22 @@ void Conductor::displayedTextChanged() {
|
|||||||
|
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "properties", old_value, new_value);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "properties", old_value, new_value);
|
||||||
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
||||||
my_diagram -> undoStack().push(undo);
|
|
||||||
|
if (!relatedPotentialConductors().isEmpty())
|
||||||
|
{
|
||||||
|
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
||||||
|
|
||||||
|
foreach (Conductor *potential_conductor, relatedPotentialConductors())
|
||||||
|
{
|
||||||
|
old_value.setValue(potential_conductor->properties());
|
||||||
|
ConductorProperties new_properties = potential_conductor->properties();
|
||||||
|
new_properties.text = text_item->toPlainText();
|
||||||
|
new_value.setValue(new_properties);
|
||||||
|
new QPropertyUndoCommand (potential_conductor, "properties", old_value, new_value, undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diagram()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ void ConductorPropertiesDialog::PropertiesDialog(Conductor *conductor, QWidget *
|
|||||||
{
|
{
|
||||||
ConductorPropertiesDialog cpd (conductor, parent);
|
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;
|
QVariant old_value, new_value;
|
||||||
old_value.setValue(conductor->properties());
|
old_value.setValue(conductor->properties());
|
||||||
new_value.setValue(cpd.properties());
|
new_value.setValue(cpd.properties());
|
||||||
@@ -70,20 +70,36 @@ void ConductorPropertiesDialog::PropertiesDialog(Conductor *conductor, QWidget *
|
|||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(conductor, "properties", old_value, new_value);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(conductor, "properties", old_value, new_value);
|
||||||
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
||||||
|
|
||||||
//Make undo for all related potiential conductors
|
if (!conductor->relatedPotentialConductors().isEmpty())
|
||||||
if (cpd.applyAll() && !conductor->relatedPotentialConductors().isEmpty())
|
|
||||||
{
|
{
|
||||||
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
||||||
foreach (Conductor *cond, conductor->relatedPotentialConductors())
|
QString old_text = conductor->properties().text;
|
||||||
|
QString new_text = cpd.properties().text;
|
||||||
|
|
||||||
|
foreach (Conductor *potential_conductor, conductor->relatedPotentialConductors())
|
||||||
{
|
{
|
||||||
old_value.setValue(cond->properties());
|
//"Apply to all conductors of potential" is checked,
|
||||||
new QPropertyUndoCommand (cond, "properties", old_value, new_value, undo);
|
//we apply the new properties for every conductors in the same potential.
|
||||||
|
if (cpd.applyAll())
|
||||||
|
{
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorPropertiesDialog::properties
|
* @brief ConductorPropertiesDialog::properties
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>403</width>
|
||||||
<height>94</height>
|
<height>94</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Les textes de ce potentiel électrique ne sont pas identiques.
|
<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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -48,7 +48,7 @@ Appliquer un texte à l'ensemble de ces conducteurs?</string>
|
|||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user