mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-19 05:44:13 +02:00
Merge branch 'master' into master-modernize-signal-slot
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "element.h"
|
||||
#include "../qetapp.h"
|
||||
#include "../qetproject.h"
|
||||
#include "../PropertiesEditor/propertieseditordialog.h"
|
||||
#include "../autoNum/assignvariables.h"
|
||||
@@ -33,6 +34,7 @@
|
||||
#include "../qetgraphicsitem/terminal.h"
|
||||
#include "../ui/elementpropertieswidget.h"
|
||||
#include "../undocommand/changeelementinformationcommand.h"
|
||||
#include "../undocommand/setautonumcontextcommand.h"
|
||||
#include "dynamicelementtextitem.h"
|
||||
#include "elementtextitemgroup.h"
|
||||
#include "iostream"
|
||||
@@ -860,6 +862,15 @@ bool Element::fromXml(QDomElement &e,
|
||||
}
|
||||
}
|
||||
|
||||
//Load PLC master data override from diagram XML
|
||||
if (m_data.m_type == ElementData::Master &&
|
||||
m_data.m_master_type == ElementData::PLC)
|
||||
{
|
||||
auto xml_plc = e.firstChildElement(QStringLiteral("plcMasterData"));
|
||||
if (!xml_plc.isNull())
|
||||
m_data.plcMasterDataFromXml(xml_plc);
|
||||
}
|
||||
|
||||
//We must block the update of the alignment when loading the information
|
||||
//otherwise the pos of the text will not be the same as it was at save time.
|
||||
for(DynamicElementTextItem *deti : m_dynamic_text_list)
|
||||
@@ -993,6 +1004,15 @@ QDomElement Element::toXml(
|
||||
element.appendChild(properties);
|
||||
}
|
||||
|
||||
//Save PLC master data override for elements on diagram
|
||||
if (m_data.m_type == ElementData::Master &&
|
||||
m_data.m_master_type == ElementData::PLC)
|
||||
{
|
||||
auto xml_plc = m_data.plcMasterDataToXml(document);
|
||||
if (!xml_plc.isNull())
|
||||
element.appendChild(xml_plc);
|
||||
}
|
||||
|
||||
//Dynamic texts
|
||||
QDomElement dyn_text = document.createElement(QStringLiteral("dynamic_texts"));
|
||||
for (DynamicElementTextItem *deti : m_dynamic_text_list)
|
||||
@@ -1626,7 +1646,7 @@ void Element::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
||||
(ex K for coil) with condition :
|
||||
formula is empty, text tagged "label" is emptty or "_";
|
||||
*/
|
||||
void Element::setUpFormula(bool code_letter)
|
||||
void Element::setUpFormula(bool code_letter, QUndoCommand *parent_undo)
|
||||
{
|
||||
Q_UNUSED(code_letter)
|
||||
|
||||
@@ -1655,8 +1675,21 @@ void Element::setUpFormula(bool code_letter)
|
||||
nc,
|
||||
diagram(),
|
||||
element_currentAutoNum);
|
||||
diagram()->project()->addElementAutoNum(element_currentAutoNum,
|
||||
ncc.next());
|
||||
|
||||
NumerotationContext new_context = ncc.next();
|
||||
QETProject *project = diagram()->project();
|
||||
auto setter = [project](const QString &k, const NumerotationContext &c) {project->addElementAutoNum(k, c);};
|
||||
|
||||
if (parent_undo)
|
||||
{
|
||||
new SetAutoNumContextCommand(setter, element_currentAutoNum, nc, new_context, parent_undo);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto *undo = new SetAutoNumContextCommand(setter, element_currentAutoNum, nc, new_context);
|
||||
undo->setText(tr("Numéroter automatiquement un élément", "undo caption"));
|
||||
diagram()->undoStack().push(undo);
|
||||
}
|
||||
|
||||
if(!m_freeze_label && !formula.isEmpty())
|
||||
{
|
||||
@@ -1876,12 +1909,12 @@ void Element::drawPlcTable(QPainter *painter)
|
||||
// Fonts
|
||||
QFont header_font = plc_data.headerFont;
|
||||
if (header_font.family().isEmpty()) {
|
||||
header_font = painter->font();
|
||||
header_font = QETApp::diagramTextsFont();
|
||||
header_font.setBold(true);
|
||||
}
|
||||
QFont cell_font = plc_data.cellFont;
|
||||
if (cell_font.family().isEmpty()) {
|
||||
cell_font = painter->font();
|
||||
cell_font = QETApp::diagramTextsFont();
|
||||
}
|
||||
|
||||
for (const QPointF &pos : positions) {
|
||||
|
||||
@@ -35,6 +35,7 @@ class Terminal;
|
||||
class Conductor;
|
||||
class DynamicElementTextItem;
|
||||
class ElementTextItemGroup;
|
||||
class QUndoCommand;
|
||||
|
||||
/**
|
||||
This is the base class for electrical elements.
|
||||
@@ -142,7 +143,7 @@ class Element : public QetGraphicsItem
|
||||
{return m_autoNum_seq;}
|
||||
autonum::sequentialNumbers& rSequenceStruct()
|
||||
{return m_autoNum_seq;}
|
||||
void setUpFormula(bool code_letter = true);
|
||||
void setUpFormula(bool code_letter = true, QUndoCommand *parent_undo = nullptr);
|
||||
void setPrefix(QString);
|
||||
QString getPrefix() const;
|
||||
void freezeLabel(bool freeze);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "../diagram.h"
|
||||
#include "../diagramcommands.h"
|
||||
#include "../lastusedstyle.h"
|
||||
#include "../qet.h"
|
||||
#include "../qetapp.h"
|
||||
#include "../utils/qetutils.h"
|
||||
@@ -33,7 +34,10 @@
|
||||
IndependentTextItem::IndependentTextItem() :
|
||||
DiagramTextItem(nullptr)
|
||||
{
|
||||
setFont(QETApp::indiTextsItemFont());
|
||||
//Start from the font last applied to a text item this session,
|
||||
//falling back to the app-wide Preferences default otherwise.
|
||||
setFont(LastUsedStyle::hasTextFont() ? LastUsedStyle::textFont()
|
||||
: QETApp::indiTextsItemFont());
|
||||
QSettings settings;
|
||||
setRotation(settings.value("diagrameditor/independent_text_rotation", 0).toInt());
|
||||
}
|
||||
|
||||
@@ -199,19 +199,21 @@ void Terminal::paint(
|
||||
|
||||
// dessin de la borne en rouge
|
||||
// draw the terminal in red
|
||||
t.setColor(Qt::red);
|
||||
painter -> setPen(t);
|
||||
painter -> drawLine(c, e);
|
||||
if (!diagram() || diagram()->drawTerminals()) {
|
||||
t.setColor(Qt::red);
|
||||
painter -> setPen(t);
|
||||
painter -> drawLine(c, e);
|
||||
|
||||
// dessin du point d'amarrage au conducteur en bleu
|
||||
// draw the docking point to the conductor in blue
|
||||
t.setColor(m_hovered_color);
|
||||
painter -> setPen(t);
|
||||
painter -> setBrush(m_hovered_color);
|
||||
if (m_hovered) {
|
||||
painter -> setRenderHint(QPainter::Antialiasing, true);
|
||||
painter -> drawEllipse(QRectF(c.x() - 2.5, c.y() - 2.5, 5.0, 5.0));
|
||||
} else painter -> drawPoint(c);
|
||||
// dessin du point d'amarrage au conducteur en bleu
|
||||
// draw the docking point to the conductor in blue
|
||||
t.setColor(m_hovered_color);
|
||||
painter -> setPen(t);
|
||||
painter -> setBrush(m_hovered_color);
|
||||
if (m_hovered) {
|
||||
painter -> setRenderHint(QPainter::Antialiasing, true);
|
||||
painter -> drawEllipse(QRectF(c.x() - 2.5, c.y() - 2.5, 5.0, 5.0));
|
||||
} else painter -> drawPoint(c);
|
||||
}
|
||||
|
||||
//Draw help line if needed,
|
||||
if (diagram() && m_draw_help_line)
|
||||
@@ -273,9 +275,10 @@ void Terminal::paint(
|
||||
m_help_line_a -> setLine(line);
|
||||
}
|
||||
|
||||
// Draw label if show_name is enabled
|
||||
// Draw label if show_name is enabled and terminal names are allowed
|
||||
const QString display_name = name();
|
||||
if (d->m_show_name && !display_name.isEmpty()) {
|
||||
if (d->m_show_name && !display_name.isEmpty()
|
||||
&& (!diagram() || diagram()->drawTerminalNames())) {
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
painter->setRenderHint(QPainter::TextAntialiasing, true);
|
||||
painter->setFont(d->m_label_font);
|
||||
|
||||
Reference in New Issue
Block a user