mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-25 00:14:15 +02:00
Terminal strip item: redraw the strip as soon as it changes
TerminalStripItem was connected to nothing: after applying the terminal strip editor (width, catalog terminal, color, type...), undo or redo, the strip drawn on the folio kept its old drawing until something else made the scene repaint, and its bounding rect was not updated when the width of the terminals changed. - TerminalStrip::dataChanged() is emitted when the data of the strip is set, and when the data of the element of one of its terminals changes (Element::setElementData(), Element::setElementInformations()). - TerminalStripItem connects to dataChanged(), orderChanged(), bridgeChanged() and bridgeColorChanged() of its strip, and updates its geometry and redraws itself.
This commit is contained in:
@@ -39,6 +39,8 @@
|
||||
#include "../undocommand/changeelementinformationcommand.h"
|
||||
#include "../undocommand/setautonumcontextcommand.h"
|
||||
#include "crossrefitem.h"
|
||||
#include "terminalelement.h"
|
||||
#include "../TerminalStrip/terminalstrip.h"
|
||||
#include "dynamicelementtextitem.h"
|
||||
#include "elementtextitemgroup.h"
|
||||
#include "iostream"
|
||||
@@ -2087,6 +2089,22 @@ void Element::setUuid(const QUuid &uuid)
|
||||
diagram()->project()->dataBase()->elementUuidChanged(this, old_uuid);
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
@brief notifyTerminalStrip
|
||||
If @a element is a terminal of a terminal strip, tell the strip that the
|
||||
data of the terminal changed, so that the strip is redrawn on the folios.
|
||||
*/
|
||||
void notifyTerminalStrip(Element *element)
|
||||
{
|
||||
if (auto terminal_ = dynamic_cast<TerminalElement *>(element)) {
|
||||
if (auto strip_ = terminal_->parentTerminalStrip()) {
|
||||
strip_->terminalDataChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Element::storeInformation
|
||||
Write this symbol's information to its project's store, once it is
|
||||
@@ -2116,6 +2134,7 @@ void Element::setElementInformations(DiagramContext dc)
|
||||
}
|
||||
storeInformation();
|
||||
emit elementInfoChange(old_info, m_data.m_informations);
|
||||
notifyTerminalStrip(this);
|
||||
|
||||
// Propagate label change to linked PLC slaves (label is changed via
|
||||
// setElementInformations through the undo stack, not via setElementData)
|
||||
@@ -2204,6 +2223,8 @@ void Element::setElementData(ElementData data)
|
||||
}
|
||||
emit elementInfoChange(old_info, m_data.m_informations);
|
||||
}
|
||||
//Type, function, led... of a terminal are not informations
|
||||
notifyTerminalStrip(this);
|
||||
|
||||
// Propagate PLC master data changes to linked slaves
|
||||
if (m_data.m_type == ElementData::Master && m_data.m_master_type == ElementData::PLC)
|
||||
|
||||
Reference in New Issue
Block a user