mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-14 20:33:05 +02:00
User can edit the label of terminal inside the terminal strip editor
This commit is contained in:
parent
4dd2dc259f
commit
b08c2bd90b
@ -442,6 +442,7 @@ void TerminalStripEditor::on_m_dialog_button_box_clicked(QAbstractButton *button
|
|||||||
current_data.setTerminalType(modified_data.type_);
|
current_data.setTerminalType(modified_data.type_);
|
||||||
current_data.setTerminalFunction(modified_data.function_);
|
current_data.setTerminalFunction(modified_data.function_);
|
||||||
current_data.setTerminalLED(modified_data.led_);
|
current_data.setTerminalLED(modified_data.led_);
|
||||||
|
current_data.m_informations.addValue(QStringLiteral("label"), modified_data.label_);
|
||||||
|
|
||||||
m_project->undoStack()->push(new ChangeElementDataCommand(element, current_data));
|
m_project->undoStack()->push(new ChangeElementDataCommand(element, current_data));
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,13 @@ bool TerminalStripModel::setData(const QModelIndex &index, const QVariant &value
|
|||||||
modified_ = true;
|
modified_ = true;
|
||||||
modified_cell = FUNCTION_CELL;
|
modified_cell = FUNCTION_CELL;
|
||||||
}
|
}
|
||||||
|
else if (column_ == LABEL_CELL &&
|
||||||
|
role == Qt::EditRole)
|
||||||
|
{
|
||||||
|
rtd.label_ = value.toString();
|
||||||
|
modified_ = true;
|
||||||
|
modified_cell = LABEL_CELL;
|
||||||
|
}
|
||||||
|
|
||||||
//Set the modification to the terminal data
|
//Set the modification to the terminal data
|
||||||
if (modified_)
|
if (modified_)
|
||||||
@ -384,5 +391,8 @@ void TerminalStripModelDelegate::setModelData(QWidget *editor, QAbstractItemMode
|
|||||||
model->setData(index, qcb->currentData(), Qt::EditRole);
|
model->setData(index, qcb->currentData(), Qt::EditRole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
QStyledItemDelegate::setModelData(editor, model, index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1327,6 +1327,26 @@ ElementData Element::elementData() const
|
|||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Element::setElementData
|
||||||
|
* Set new data for this element.
|
||||||
|
* If m_information of \p data is changed, emit elementInfoChange
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
void Element::setElementData(ElementData data)
|
||||||
|
{
|
||||||
|
auto old_info = m_data.m_informations;
|
||||||
|
m_data = data;
|
||||||
|
|
||||||
|
if (old_info != m_data.m_informations) {
|
||||||
|
m_data.m_informations.addValue(QStringLiteral("label"), actualLabel()); //Update the label if there is a formula
|
||||||
|
if (diagram()) {
|
||||||
|
diagram()->project()->dataBase()->elementInfoChanged(this);
|
||||||
|
}
|
||||||
|
emit elementInfoChange(old_info, m_data.m_informations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief comparPos
|
@brief comparPos
|
||||||
Compare position of the two elements. Compare 3 points:
|
Compare position of the two elements. Compare 3 points:
|
||||||
|
@ -42,7 +42,6 @@ class ElementTextItemGroup;
|
|||||||
class Element : public QetGraphicsItem
|
class Element : public QetGraphicsItem
|
||||||
{
|
{
|
||||||
friend class DiagramEventAddElement;
|
friend class DiagramEventAddElement;
|
||||||
friend class ChangeElementDataCommand;
|
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -106,6 +105,7 @@ class Element : public QetGraphicsItem
|
|||||||
virtual void setElementInformations(DiagramContext dc);
|
virtual void setElementInformations(DiagramContext dc);
|
||||||
|
|
||||||
ElementData elementData() const;
|
ElementData elementData() const;
|
||||||
|
void setElementData (ElementData data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief kindInformations
|
* @brief kindInformations
|
||||||
|
@ -28,12 +28,12 @@ ChangeElementDataCommand::ChangeElementDataCommand(Element *element, ElementData
|
|||||||
|
|
||||||
void ChangeElementDataCommand::undo() {
|
void ChangeElementDataCommand::undo() {
|
||||||
if (m_element) {
|
if (m_element) {
|
||||||
m_element.data()->m_data = m_old_data;
|
m_element.data()->setElementData(m_old_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeElementDataCommand::redo() {
|
void ChangeElementDataCommand::redo() {
|
||||||
if (m_element) {
|
if (m_element) {
|
||||||
m_element.data()->m_data = m_new_data;
|
m_element.data()->setElementData(m_new_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user