replace tabs by 4 spaces

This commit is contained in:
Martin Marmsoler
2020-10-16 11:45:17 +02:00
committed by Martin Marmsoler
parent 752f31513c
commit 73b394527d
62 changed files with 18489 additions and 18489 deletions

View File

@@ -1,30 +1,30 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "propertiesinterface.h"
/**
@brief PropertiesInterface::PropertiesInterface
@brief PropertiesInterface::PropertiesInterface
*/
PropertiesInterface::PropertiesInterface()
{
}
/**
@brief PropertiesInterface::~PropertiesInterface
@brief PropertiesInterface::~PropertiesInterface
*/
PropertiesInterface::~PropertiesInterface()
{

View File

@@ -1,19 +1,19 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROPERTIESINTERFACE_H
#define PROPERTIESINTERFACE_H
@@ -23,47 +23,47 @@
#include <QDomElement>
/**
@brief The PropertiesInterface class
This class is an interface for have common way
to use properties in QElectroTech
@brief The PropertiesInterface class
This class is an interface for have common way
to use properties in QElectroTech
*/
class PropertiesInterface
{
public:
PropertiesInterface();
virtual ~PropertiesInterface();
/**
@brief toSettings
Save properties to setting file.
@param settings : is use for prefix a word
befor the name of each paramètre
@param QString
*/
virtual void toSettings (QSettings &settings,
const QString = QString()) const =0;
/**
@brief fromSettings
load properties to setting file.
@param settings : is use for prefix a word
befor the name of each paramètre
@param QString
*/
virtual void fromSettings (const QSettings &settings,
const QString = QString()) =0;
/**
@brief toXml
Save properties to xml element
@param xml_document
@return QDomElement
*/
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
/**
@brief fromXml
load properties to xml element
@param xml_element
@return true / false
*/
virtual bool fromXml (const QDomElement &xml_element) =0;
public:
PropertiesInterface();
virtual ~PropertiesInterface();
/**
@brief toSettings
Save properties to setting file.
@param settings : is use for prefix a word
befor the name of each paramètre
@param QString
*/
virtual void toSettings (QSettings &settings,
const QString = QString()) const =0;
/**
@brief fromSettings
load properties to setting file.
@param settings : is use for prefix a word
befor the name of each paramètre
@param QString
*/
virtual void fromSettings (const QSettings &settings,
const QString = QString()) =0;
/**
@brief toXml
Save properties to xml element
@param xml_document
@return QDomElement
*/
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
/**
@brief fromXml
load properties to xml element
@param xml_element
@return true / false
*/
virtual bool fromXml (const QDomElement &xml_element) =0;
};
#endif // PROPERTIESINTERFACE_H

View File

@@ -3,16 +3,16 @@
#include <QGraphicsObject>
TerminalData::TerminalData():
PropertiesInterface()
PropertiesInterface()
{
init();
init();
}
TerminalData::TerminalData(QGraphicsObject *parent):
PropertiesInterface(),
q(parent)
PropertiesInterface(),
q(parent)
{
init();
init();
}
void TerminalData::init()
@@ -25,117 +25,117 @@ TerminalData::~TerminalData()
}
/**
@brief TerminalData::setParent
@param parent
@brief TerminalData::setParent
@param parent
*/
void TerminalData::setParent(QGraphicsObject* parent)
{
q = parent;
q = parent;
}
/**
@brief TerminalData::toSettings
Save properties to setting file.
@brief TerminalData::toSettings
Save properties to setting file.
QString is use for prefix a word befor the name of each paramètre
@param settings UNUSED
@param prefix UNUSED
QString is use for prefix a word befor the name of each paramètre
@param settings UNUSED
@param prefix UNUSED
*/
void TerminalData::toSettings(QSettings &settings, const QString prefix) const
{
Q_UNUSED(settings);
Q_UNUSED(prefix);
Q_UNUSED(settings);
Q_UNUSED(prefix);
}
/**
@brief TerminalData::fromSettings
load properties to setting file.
@brief TerminalData::fromSettings
load properties to setting file.
QString is use for prefix a word befor the name of each paramètre
@param settings UNUSED
@param prefix UNUSED
QString is use for prefix a word befor the name of each paramètre
@param settings UNUSED
@param prefix UNUSED
*/
void TerminalData::fromSettings(const QSettings &settings, const QString prefix)
{
Q_UNUSED(settings);
Q_UNUSED(prefix);
Q_UNUSED(settings);
Q_UNUSED(prefix);
}
/**
@brief TerminalData::toXml
Save properties to xml element
write the name, number, position and orientation of the terminal
to xml_element
@brief TerminalData::toXml
Save properties to xml element
write the name, number, position and orientation of the terminal
to xml_element
@note This method is only called from the PartTerminal
and should never called from the Terminal class
@param xml_document
@return xml_element : DomElement with
the name, number, position and orientation of the terminal
@note This method is only called from the PartTerminal
and should never called from the Terminal class
@param xml_document
@return xml_element : DomElement with
the name, number, position and orientation of the terminal
*/
QDomElement TerminalData::toXml(QDomDocument &xml_document) const
{
QDomElement xml_element = xml_document.createElement("terminal");
QDomElement xml_element = xml_document.createElement("terminal");
// write the position of the terminal
// ecrit la position de la borne
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
// write the position of the terminal
// ecrit la position de la borne
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
// Write name and number to XML
xml_element.setAttribute("uuid", m_uuid.toString());
xml_element.setAttribute("name", m_name);
// Write name and number to XML
xml_element.setAttribute("uuid", m_uuid.toString());
xml_element.setAttribute("name", m_name);
// write the orientation of the terminal
// ecrit l'orientation de la borne
xml_element.setAttribute("orientation",
Qet::orientationToString(m_orientation));
// write the orientation of the terminal
// ecrit l'orientation de la borne
xml_element.setAttribute("orientation",
Qet::orientationToString(m_orientation));
return(xml_element);
return(xml_element);
}
/**
@brief TerminalData::fromXml
load properties to xml element
@brief TerminalData::fromXml
load properties to xml element
@note This method is only called from the PartTerminal
and should never called from the Terminal class
@param xml_element
@return true if succeeded / false if the attribute is not real
@note This method is only called from the PartTerminal
and should never called from the Terminal class
@param xml_element
@return true if succeeded / false if the attribute is not real
*/
bool TerminalData::fromXml (const QDomElement &xml_element)
{
qreal term_x = 0.0;
qreal term_y = 0.0;
qreal term_x = 0.0;
qreal term_y = 0.0;
// reads the position of the terminal
// lit la position de la borne
if (!QET::attributeIsAReal(xml_element, "x", &term_x))
return false;
// reads the position of the terminal
// lit la position de la borne
if (!QET::attributeIsAReal(xml_element, "x", &term_x))
return false;
if (!QET::attributeIsAReal(xml_element, "y", &term_y))
return false;
if (!QET::attributeIsAReal(xml_element, "y", &term_y))
return false;
m_pos = QPointF(term_x, term_y);
m_pos = QPointF(term_x, term_y);
//emit posFromXML(QPointF(term_x, term_y));
//emit posFromXML(QPointF(term_x, term_y));
QString uuid = xml_element.attribute("uuid");
// update part and add uuid, which is used in the new version
// to connect terminals together
// if the attribute not exists, means, the element is created with an
// older version of qet. So use the legacy approach
// to identify terminals
if (!uuid.isEmpty())
m_uuid = QUuid(uuid);
QString uuid = xml_element.attribute("uuid");
// update part and add uuid, which is used in the new version
// to connect terminals together
// if the attribute not exists, means, the element is created with an
// older version of qet. So use the legacy approach
// to identify terminals
if (!uuid.isEmpty())
m_uuid = QUuid(uuid);
m_name = xml_element.attribute("name");
m_name = xml_element.attribute("name");
// read the orientation of the terminal
// lit l'orientation de la borne
m_orientation = Qet::orientationFromString(
xml_element.attribute("orientation"));
// read the orientation of the terminal
// lit l'orientation de la borne
m_orientation = Qet::orientationFromString(
xml_element.attribute("orientation"));
return true;
return true;
}

View File

@@ -10,78 +10,78 @@
class QGraphicsObject;
/**
@brief The TerminalData class
Data of the terminal.
Stored in extra class so it can be used by PartTerminal
and Terminal without defining everything again.
@note tis class needs to be work on
@brief The TerminalData class
Data of the terminal.
Stored in extra class so it can be used by PartTerminal
and Terminal without defining everything again.
@note tis class needs to be work on
*/
class TerminalData : public PropertiesInterface
{
public:
TerminalData();
TerminalData(QGraphicsObject* parent);
~TerminalData();
public:
TerminalData();
TerminalData(QGraphicsObject* parent);
~TerminalData();
void init();
void init();
void setParent(QGraphicsObject* parent);
void toSettings(QSettings &settings,
const QString prefix = QString()) const override;
void fromSettings(const QSettings &settings,
const QString prefix = QString()) override;
QDomElement toXml(QDomDocument &xml_element) const override;
bool fromXml(const QDomElement &xml_element) override;
void setParent(QGraphicsObject* parent);
void toSettings(QSettings &settings,
const QString prefix = QString()) const override;
void fromSettings(const QSettings &settings,
const QString prefix = QString()) override;
QDomElement toXml(QDomDocument &xml_element) const override;
bool fromXml(const QDomElement &xml_element) override;
// must be public, because this class is a private member
// of PartTerminal/Terminal and they must access this data
public:
/**
@brief m_orientation
Orientation of the terminal
*/
Qet::Orientation m_orientation;
/**
@brief second_point
Position of the second point of the terminal
in scene coordinates
*/
QPointF second_point;
/**
@brief m_uuid
Uuid of the terminal.
// must be public, because this class is a private member
// of PartTerminal/Terminal and they must access this data
public:
/**
@brief m_orientation
Orientation of the terminal
*/
Qet::Orientation m_orientation;
/**
@brief second_point
Position of the second point of the terminal
in scene coordinates
*/
QPointF second_point;
/**
@brief m_uuid
Uuid of the terminal.
In elementscene.cpp an element gets a new uuid when
saving the element. In the current state
each connection is made by using the local position
of the terminal and a dynamic id. In the new
case, each terminal should have it's own uuid to
identify it uniquely. When changing each time this
uuid, the conductor after updating the part is anymore
valid. So if in the loaded document a uuid exists,
use this one and don't create a new one.
*/
QUuid m_uuid;
/**
@brief m_name
Name of the element.
It can be used to create wiring harness tables
*/
QString m_name;
In elementscene.cpp an element gets a new uuid when
saving the element. In the current state
each connection is made by using the local position
of the terminal and a dynamic id. In the new
case, each terminal should have it's own uuid to
identify it uniquely. When changing each time this
uuid, the conductor after updating the part is anymore
valid. So if in the loaded document a uuid exists,
use this one and don't create a new one.
*/
QUuid m_uuid;
/**
@brief m_name
Name of the element.
It can be used to create wiring harness tables
*/
QString m_name;
/**
@brief m_pos
Position of the terminal. The second point is calculated
from this position and the orientation
@note
Important: this variable is only updated during read
from xml and not during mouse move!
It is used to store the initial position so that
PartTerminal and Terminal have access to it.
*/
QPointF m_pos;
private:
QGraphicsObject* q{nullptr};
/**
@brief m_pos
Position of the terminal. The second point is calculated
from this position and the orientation
@note
Important: this variable is only updated during read
from xml and not during mouse move!
It is used to store the initial position so that
PartTerminal and Terminal have access to it.
*/
QPointF m_pos;
private:
QGraphicsObject* q{nullptr};
};
#endif // TERMINALDATA_H

View File

@@ -1,19 +1,19 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QMetaEnum>
#include <QHash>
@@ -22,182 +22,182 @@
#include "qetapp.h"
/**
@brief XRefProperties::XRefProperties
Default Constructor
@brief XRefProperties::XRefProperties
Default Constructor
*/
XRefProperties::XRefProperties()
{
m_show_power_ctc = true;
m_display = Cross;
m_snap_to = Bottom;
m_prefix_keys << "power" << "delay" << "switch";
m_master_label = "%f-%l%c";
m_slave_label = "(%f-%l%c)";
m_offset = 0;
m_xref_pos = Qt::AlignBottom;
m_show_power_ctc = true;
m_display = Cross;
m_snap_to = Bottom;
m_prefix_keys << "power" << "delay" << "switch";
m_master_label = "%f-%l%c";
m_slave_label = "(%f-%l%c)";
m_offset = 0;
m_xref_pos = Qt::AlignBottom;
}
/**
@brief XRefProperties::toSettings
Save to settings
@param settings: QSettings to use
@param prefix: prefix before properties name
@brief XRefProperties::toSettings
Save to settings
@param settings: QSettings to use
@param prefix: prefix before properties name
*/
void XRefProperties::toSettings(QSettings &settings,
const QString prefix) const
const QString prefix) const
{
settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
QString display = m_display == Cross? "cross" : "contacts";
settings.setValue(prefix + "displayhas", display);
QString snap = m_snap_to == Bottom? "bottom" : "label";
settings.setValue(prefix + "snapto", snap);
int offset = m_offset;
settings.setValue(prefix + "offset", offset);
QString master_label = m_master_label;
settings.setValue(prefix + "master_label", master_label);
QString slave_label = m_slave_label;
settings.setValue(prefix + "slave_label", slave_label);
settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
QString display = m_display == Cross? "cross" : "contacts";
settings.setValue(prefix + "displayhas", display);
QString snap = m_snap_to == Bottom? "bottom" : "label";
settings.setValue(prefix + "snapto", snap);
int offset = m_offset;
settings.setValue(prefix + "offset", offset);
QString master_label = m_master_label;
settings.setValue(prefix + "master_label", master_label);
QString slave_label = m_slave_label;
settings.setValue(prefix + "slave_label", slave_label);
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
settings.setValue(prefix + "xrefpos", var.valueToKey(m_xref_pos));
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
settings.setValue(prefix + "xrefpos", var.valueToKey(m_xref_pos));
foreach (QString key, m_prefix.keys()) {
settings.setValue(prefix + key + "prefix", m_prefix.value(key));
}
foreach (QString key, m_prefix.keys()) {
settings.setValue(prefix + key + "prefix", m_prefix.value(key));
}
}
/**
@brief XRefProperties::fromSettings
load from settings
@param settings: QSettings to use
@param prefix: prefix before properties name
@brief XRefProperties::fromSettings
load from settings
@param settings: QSettings to use
@param prefix: prefix before properties name
*/
void XRefProperties::fromSettings(const QSettings &settings,
const QString prefix)
const QString prefix)
{
m_show_power_ctc = settings.value(prefix + "showpowerctc", true).toBool();
QString display = settings.value(prefix + "displayhas", "cross").toString();
display == "cross"? m_display = Cross : m_display = Contacts;
QString snap = settings.value(prefix + "snapto", "label").toString();
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
m_offset = settings.value(prefix + "offset", "0").toInt();
m_master_label = settings.value(prefix + "master_label", "%f-%l%c").toString();
m_slave_label = settings.value(prefix + "slave_label", "(%f-%l%c)").toString();
m_show_power_ctc = settings.value(prefix + "showpowerctc", true).toBool();
QString display = settings.value(prefix + "displayhas", "cross").toString();
display == "cross"? m_display = Cross : m_display = Contacts;
QString snap = settings.value(prefix + "snapto", "label").toString();
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
m_offset = settings.value(prefix + "offset", "0").toInt();
m_master_label = settings.value(prefix + "master_label", "%f-%l%c").toString();
m_slave_label = settings.value(prefix + "slave_label", "(%f-%l%c)").toString();
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
m_xref_pos = Qt::AlignmentFlag(var.keyToValue((settings.value(prefix + "xrefpos").toString()).toStdString().data()));
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
m_xref_pos = Qt::AlignmentFlag(var.keyToValue((settings.value(prefix + "xrefpos").toString()).toStdString().data()));
for (QString key : m_prefix_keys) {
m_prefix.insert(key, settings.value(prefix + key + "prefix").toString());
}
for (QString key : m_prefix_keys) {
m_prefix.insert(key, settings.value(prefix + key + "prefix").toString());
}
}
/**
@brief XRefProperties::toXml
Save to xml
@param xml_document : QDomElement to use for saving
@return QDomElement
@brief XRefProperties::toXml
Save to xml
@param xml_document : QDomElement to use for saving
@return QDomElement
*/
QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
{
QDomElement xml_element = xml_document.createElement("xref");
xml_element.setAttribute("type", m_key);
QDomElement xml_element = xml_document.createElement("xref");
xml_element.setAttribute("type", m_key);
xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "false");
QString display = m_display == Cross? "cross" : "contacts";
xml_element.setAttribute("displayhas", display);
QString snap = m_snap_to == Bottom? "bottom" : "label";
xml_element.setAttribute("snapto", snap);
xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "false");
QString display = m_display == Cross? "cross" : "contacts";
xml_element.setAttribute("displayhas", display);
QString snap = m_snap_to == Bottom? "bottom" : "label";
xml_element.setAttribute("snapto", snap);
QString xrefpos;
QString xrefpos;
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
xml_element.setAttribute("xrefpos", var.valueToKey(m_xref_pos));
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
xml_element.setAttribute("xrefpos", var.valueToKey(m_xref_pos));
int offset = m_offset;
xml_element.setAttribute("offset", QString::number(offset));
QString master_label = m_master_label;
xml_element.setAttribute("master_label", master_label);
QString slave_label = m_slave_label;
xml_element.setAttribute("slave_label", slave_label);
foreach (QString key, m_prefix.keys()) {
xml_element.setAttribute(key + "prefix", m_prefix.value(key));
}
int offset = m_offset;
xml_element.setAttribute("offset", QString::number(offset));
QString master_label = m_master_label;
xml_element.setAttribute("master_label", master_label);
QString slave_label = m_slave_label;
xml_element.setAttribute("slave_label", slave_label);
foreach (QString key, m_prefix.keys()) {
xml_element.setAttribute(key + "prefix", m_prefix.value(key));
}
return xml_element;
return xml_element;
}
/**
@brief XRefProperties::fromXml
Load from xml
@param xml_element: QDomElement to use for load
@brief XRefProperties::fromXml
Load from xml
@param xml_element: QDomElement to use for load
*/
bool XRefProperties::fromXml(const QDomElement &xml_element) {
m_show_power_ctc = xml_element.attribute("showpowerctc") == "true";
QString display = xml_element.attribute("displayhas", "cross");
display == "cross"? m_display = Cross : m_display = Contacts;
QString snap = xml_element.attribute("snapto", "label");
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
m_show_power_ctc = xml_element.attribute("showpowerctc") == "true";
QString display = xml_element.attribute("displayhas", "cross");
display == "cross"? m_display = Cross : m_display = Contacts;
QString snap = xml_element.attribute("snapto", "label");
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
QString xrefpos = xml_element.attribute("xrefpos","Left");
QString xrefpos = xml_element.attribute("xrefpos","Left");
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
if(xml_element.hasAttribute("xrefpos"))
m_xref_pos = Qt::AlignmentFlag(var.keyToValue(xml_element.attribute("xrefpos").toStdString().data()));
else
m_xref_pos = Qt::AlignBottom;
if(xml_element.hasAttribute("xrefpos"))
m_xref_pos = Qt::AlignmentFlag(var.keyToValue(xml_element.attribute("xrefpos").toStdString().data()));
else
m_xref_pos = Qt::AlignBottom;
m_offset = xml_element.attribute("offset", "0").toInt();
m_master_label = xml_element.attribute("master_label", "%f-%l%c");
m_slave_label = xml_element.attribute("slave_label","(%f-%l%c)");
foreach (QString key, m_prefix_keys) {
m_prefix.insert(key, xml_element.attribute(key + "prefix"));
}
return true;
m_offset = xml_element.attribute("offset", "0").toInt();
m_master_label = xml_element.attribute("master_label", "%f-%l%c");
m_slave_label = xml_element.attribute("slave_label","(%f-%l%c)");
foreach (QString key, m_prefix_keys) {
m_prefix.insert(key, xml_element.attribute(key + "prefix"));
}
return true;
}
/**
@brief XRefProperties::defaultProperties
@return the default properties stored in the setting file
For the xref, there is 2 propreties.
For coil, stored with the string "coil" in the returned QHash.
For protection, stored with the string "protection" in the returned QHash.
@brief XRefProperties::defaultProperties
@return the default properties stored in the setting file
For the xref, there is 2 propreties.
For coil, stored with the string "coil" in the returned QHash.
For protection, stored with the string "protection" in the returned QHash.
*/
QHash<QString, XRefProperties> XRefProperties::defaultProperties()
{
QHash <QString, XRefProperties> hash;
QStringList keys;
keys << "coil" << "protection" << "commutator";
QHash <QString, XRefProperties> hash;
QStringList keys;
keys << "coil" << "protection" << "commutator";
QSettings settings;
QSettings settings;
foreach (QString key, keys)
{
XRefProperties properties;
QString str("diagrameditor/defaultxref");
properties.fromSettings(settings, str += key);
hash.insert(key, properties);
}
foreach (QString key, keys)
{
XRefProperties properties;
QString str("diagrameditor/defaultxref");
properties.fromSettings(settings, str += key);
hash.insert(key, properties);
}
return hash;
return hash;
}
bool XRefProperties::operator ==(const XRefProperties &xrp) const{
return (m_show_power_ctc == xrp.m_show_power_ctc &&
m_display == xrp.m_display &&
m_snap_to == xrp.m_snap_to &&
m_prefix == xrp.m_prefix &&
m_master_label == xrp.m_master_label &&
m_offset == xrp.m_offset &&
m_xref_pos == xrp.m_xref_pos );
return (m_show_power_ctc == xrp.m_show_power_ctc &&
m_display == xrp.m_display &&
m_snap_to == xrp.m_snap_to &&
m_prefix == xrp.m_prefix &&
m_master_label == xrp.m_master_label &&
m_offset == xrp.m_offset &&
m_xref_pos == xrp.m_xref_pos );
}
bool XRefProperties::operator !=(const XRefProperties &xrp) const
{
return (! (*this == xrp));
return (! (*this == xrp));
}

View File

@@ -1,19 +1,19 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XREFPROPERTIES_H
#define XREFPROPERTIES_H
@@ -24,72 +24,72 @@
#include "propertiesinterface.h"
/**
@brief The XRefProperties class
this class store properties used by XrefItem
@brief The XRefProperties class
this class store properties used by XrefItem
*/
class XRefProperties : public PropertiesInterface
{
public:
XRefProperties();
public:
XRefProperties();
enum DisplayHas {
Cross,
Contacts
};
enum DisplayHas {
Cross,
Contacts
};
enum SnapTo {
Bottom,
Label
};
enum SnapTo {
Bottom,
Label
};
void toSettings (QSettings &settings,
const QString = QString()) const override;
void fromSettings (const QSettings &settings,
const QString = QString()) override;
QDomElement toXml (QDomDocument &xml_document) const override;
bool fromXml(const QDomElement &xml_element) override;
void toSettings (QSettings &settings,
const QString = QString()) const override;
void fromSettings (const QSettings &settings,
const QString = QString()) override;
QDomElement toXml (QDomDocument &xml_document) const override;
bool fromXml(const QDomElement &xml_element) override;
static QHash<QString, XRefProperties> defaultProperties();
static QHash<QString, XRefProperties> defaultProperties();
bool operator == (const XRefProperties &xrp) const;
bool operator != (const XRefProperties &xrp) const;
bool operator == (const XRefProperties &xrp) const;
bool operator != (const XRefProperties &xrp) const;
void setShowPowerContac (const bool a) {m_show_power_ctc = a;}
bool showPowerContact () const {return m_show_power_ctc;}
void setShowPowerContac (const bool a) {m_show_power_ctc = a;}
bool showPowerContact () const {return m_show_power_ctc;}
void setDisplayHas (const DisplayHas dh) {m_display = dh;}
DisplayHas displayHas () const {return m_display;}
void setDisplayHas (const DisplayHas dh) {m_display = dh;}
DisplayHas displayHas () const {return m_display;}
void setSnapTo (const SnapTo st) {m_snap_to = st;}
SnapTo snapTo () const {return m_snap_to;}
void setSnapTo (const SnapTo st) {m_snap_to = st;}
SnapTo snapTo () const {return m_snap_to;}
void setXrefPos(const Qt::AlignmentFlag xref) {m_xref_pos = xref;}
Qt::AlignmentFlag getXrefPos() const {return m_xref_pos;}
void setPrefix (const QString &key, const QString &value) {m_prefix.insert(key, value);}
QString prefix (const QString &key) const {return m_prefix.value(key);}
void setXrefPos(const Qt::AlignmentFlag xref) {m_xref_pos = xref;}
Qt::AlignmentFlag getXrefPos() const {return m_xref_pos;}
void setPrefix (const QString &key, const QString &value) {m_prefix.insert(key, value);}
QString prefix (const QString &key) const {return m_prefix.value(key);}
void setMasterLabel (const QString master) {m_master_label = master;}
QString masterLabel () const {return m_master_label;}
void setMasterLabel (const QString master) {m_master_label = master;}
QString masterLabel () const {return m_master_label;}
void setSlaveLabel(const QString slave) {m_slave_label = slave;}
QString slaveLabel () const {return m_slave_label;}
void setSlaveLabel(const QString slave) {m_slave_label = slave;}
QString slaveLabel () const {return m_slave_label;}
void setOffset(const int offset) {m_offset = offset;}
int offset() const {return m_offset;}
void setOffset(const int offset) {m_offset = offset;}
int offset() const {return m_offset;}
void setKey(QString& key) {m_key = key;}
void setKey(QString& key) {m_key = key;}
private:
bool m_show_power_ctc;
DisplayHas m_display;
SnapTo m_snap_to;
Qt::AlignmentFlag m_xref_pos;
QHash <QString, QString> m_prefix;
QStringList m_prefix_keys;
QString m_master_label;
QString m_slave_label;
int m_offset;
QString m_key;
private:
bool m_show_power_ctc;
DisplayHas m_display;
SnapTo m_snap_to;
Qt::AlignmentFlag m_xref_pos;
QHash <QString, QString> m_prefix;
QStringList m_prefix_keys;
QString m_master_label;
QString m_slave_label;
int m_offset;
QString m_key;
};
#endif // XREFPROPERTIES_H