mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Element : edit an element text item (with tagg) directly on the folio, also update the information of the element.
For exemple, edit the element text item tagged "label", update the value with key "label" of element information. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4804 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "elementpropertieswidget.h"
|
||||
#include "numerotationcontextcommands.h"
|
||||
#include "diagramcontext.h"
|
||||
#include "changeelementinformationcommand.h"
|
||||
|
||||
class ElementXmlRetroCompatibility
|
||||
{
|
||||
@@ -436,12 +437,15 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
table_id_adr.insert(id_trouve, priv_id_adr.value(id_trouve));
|
||||
}
|
||||
}
|
||||
|
||||
// importe les valeurs des champs de texte
|
||||
|
||||
//import text filed value
|
||||
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input");
|
||||
foreach(QGraphicsItem *qgi, childItems()) {
|
||||
if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
|
||||
foreach(QDomElement input, inputs) {
|
||||
foreach(QGraphicsItem *qgi, childItems())
|
||||
{
|
||||
if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi))
|
||||
{
|
||||
foreach(QDomElement input, inputs)
|
||||
{
|
||||
eti -> fromXml(input);
|
||||
etiToElementLabels(eti);
|
||||
}
|
||||
@@ -778,6 +782,40 @@ ElementTextItem* Element::setTaggedText(const QString &tagg, const QString &news
|
||||
return eti;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Element::textItemChanged
|
||||
* Use to keep up to date the element information when text item changed.
|
||||
* @param dti
|
||||
* @param old_str
|
||||
* @param new_str
|
||||
*/
|
||||
void Element::textItemChanged(DiagramTextItem *dti, QString old_str, QString new_str)
|
||||
{
|
||||
Q_UNUSED(new_str)
|
||||
|
||||
if (!diagram())
|
||||
return;
|
||||
|
||||
ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(dti);
|
||||
if (!eti)
|
||||
return;
|
||||
|
||||
QString tagg = eti->tagg();
|
||||
if (m_element_informations.contains(tagg))
|
||||
{
|
||||
DiagramContext dc = m_element_informations;
|
||||
dc.addValue(tagg, eti->toPlainText(), dc.keyMustShow(tagg));
|
||||
if (tagg == "label")
|
||||
dc.addValue("formula", eti->toPlainText(), dc.keyMustShow("formula"));
|
||||
|
||||
diagram()->undoStack().push(new ChangeElementInformationCommand(this, m_element_informations, dc));
|
||||
}
|
||||
else
|
||||
{
|
||||
diagram()->undoStack().push(new ChangeDiagramTextCommand(eti, old_str, eti->toPlainText()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Element::getPrefix
|
||||
* get Element Prefix
|
||||
|
||||
Reference in New Issue
Block a user