mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
commit
7e6befdf0a
@ -226,7 +226,7 @@ void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button)
|
|||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else if (m_edited_type == 1)
|
||||||
{
|
{
|
||||||
QMessageBox::information (
|
QMessageBox::information (
|
||||||
this,
|
this,
|
||||||
@ -252,6 +252,32 @@ void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button)
|
|||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::information (
|
||||||
|
this,
|
||||||
|
tr("Element Autonumérotation",
|
||||||
|
"title window"),
|
||||||
|
tr("C'est ici que vous pouvez définir la manière dont seront numérotés les nouveaux elements.\n"
|
||||||
|
"-Une numérotation est composée d'une variable minimum.\n"
|
||||||
|
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
|
||||||
|
"-Une variable de numérotation comprend : un type, une valeur et une incrémentation.\n"
|
||||||
|
|
||||||
|
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représentent un type numérique défini dans le champ \"Valeur\", "
|
||||||
|
"qui s'incrémente à chaque nouveau conducteur de la valeur du champ \"Incrémentation\".\n"
|
||||||
|
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représentés sur le schéma par deux et trois digits minimum.\n"
|
||||||
|
"Si le chiffre défini dans le champ Valeur possède moins de digits que le type choisi,"
|
||||||
|
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
|
||||||
|
|
||||||
|
"\n-Le type \"Texte\", représente un texte fixe.\nLe champ \"Incrémentation\" n'est pas utilisé.\n"
|
||||||
|
|
||||||
|
"\n-Le type \"N° folio\" représente le n° du folio en cours.\nLes autres champs ne sont pas utilisés.\n"
|
||||||
|
|
||||||
|
"\n-Le type \"Folio\" représente le nom du folio en cours.\nLes autres champs ne sont pas utilisés.",
|
||||||
|
"help dialog about the element autonumerotation"
|
||||||
|
));
|
||||||
|
break;
|
||||||
|
}
|
||||||
//apply the context in the diagram displayed by @diagram_chooser.
|
//apply the context in the diagram displayed by @diagram_chooser.
|
||||||
case QDialogButtonBox::ApplyRole:
|
case QDialogButtonBox::ApplyRole:
|
||||||
applyEnable(false);
|
applyEnable(false);
|
||||||
|
@ -193,7 +193,7 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
*/
|
*/
|
||||||
QPen pen;
|
QPen pen;
|
||||||
Diagram::background_color == Qt::black? pen.setColor(Qt::white)
|
Diagram::background_color == Qt::black? pen.setColor(Qt::white)
|
||||||
: pen.setColor(Qt::black);
|
: pen.setColor(Qt::black);
|
||||||
pen.setCosmetic(true);
|
pen.setCosmetic(true);
|
||||||
p->setPen(pen);
|
p->setPen(pen);
|
||||||
|
|
||||||
@ -363,11 +363,11 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
#pragma message("@TODO move code to new function")
|
#pragma message("@TODO move code to new function")
|
||||||
#endif
|
#endif
|
||||||
//Move item with the keyboard arrow
|
//Move item with the keyboard arrow
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
if(event->modifiers() == Qt::KeypadModifier)
|
if(event->modifiers() == Qt::KeypadModifier)
|
||||||
#else
|
#else
|
||||||
if(event->modifiers() == Qt::NoModifier)
|
if(event->modifiers() == Qt::NoModifier)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
int xKeyGrid = settings.value(QStringLiteral("diagrameditor/key_Xgrid"),
|
int xKeyGrid = settings.value(QStringLiteral("diagrameditor/key_Xgrid"),
|
||||||
@ -376,26 +376,26 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
Diagram::yKeyGrid).toInt();
|
Diagram::yKeyGrid).toInt();
|
||||||
switch(event->key())
|
switch(event->key())
|
||||||
{
|
{
|
||||||
case Qt::Key_Left:
|
case Qt::Key_Left:
|
||||||
for (Element *item : dc.m_elements)
|
for (Element *item : dc.m_elements)
|
||||||
{
|
{
|
||||||
left_position = item->sceneBoundingRect().x();
|
left_position = item->sceneBoundingRect().x();
|
||||||
if(left_position <= 5)
|
if(left_position <= 5)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
movement = QPointF(-xKeyGrid, 0.0);
|
movement = QPointF(-xKeyGrid, 0.0);
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Right:
|
case Qt::Key_Right:
|
||||||
movement = QPointF(+xKeyGrid, 0.0);
|
movement = QPointF(+xKeyGrid, 0.0);
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
for(Element *item : dc.m_elements)
|
for(Element *item : dc.m_elements)
|
||||||
{
|
{
|
||||||
top_position = item->sceneBoundingRect().y();
|
top_position = item->sceneBoundingRect().y();
|
||||||
if(top_position <= 5)
|
if(top_position <= 5)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
movement = QPointF(0.0, -yKeyGrid);
|
movement = QPointF(0.0, -yKeyGrid);
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
movement = QPointF(0.0, +yKeyGrid);
|
movement = QPointF(0.0, +yKeyGrid);
|
||||||
@ -486,7 +486,7 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
Qt::AlignRight));
|
Qt::AlignRight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event->ignore();
|
event->ignore();
|
||||||
QGraphicsScene::keyPressEvent(event);
|
QGraphicsScene::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
@ -601,9 +601,9 @@ void Diagram::setConductorsAutonumName(const QString &name) {
|
|||||||
@return Une QImage representant le schema
|
@return Une QImage representant le schema
|
||||||
*/
|
*/
|
||||||
bool Diagram::toPaintDevice(QPaintDevice &pix,
|
bool Diagram::toPaintDevice(QPaintDevice &pix,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
Qt::AspectRatioMode aspectRatioMode) {
|
Qt::AspectRatioMode aspectRatioMode) {
|
||||||
// determine the source area = schema content + margins
|
// determine the source area = schema content + margins
|
||||||
// determine la zone source = contenu du schema + marges
|
// determine la zone source = contenu du schema + marges
|
||||||
QRectF source_area;
|
QRectF source_area;
|
||||||
@ -650,9 +650,9 @@ bool Diagram::toPaintDevice(QPaintDevice &pix,
|
|||||||
// renders itself
|
// renders itself
|
||||||
// effectue le rendu lui-meme
|
// effectue le rendu lui-meme
|
||||||
render(&p,
|
render(&p,
|
||||||
QRect(QPoint(0, 0),image_size),
|
QRect(QPoint(0, 0),image_size),
|
||||||
source_area,
|
source_area,
|
||||||
aspectRatioMode);
|
aspectRatioMode);
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
// restore selected items
|
// restore selected items
|
||||||
@ -767,7 +767,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
// Conductor autonum
|
// Conductor autonum
|
||||||
if (!m_conductors_autonum_name.isEmpty()) {
|
if (!m_conductors_autonum_name.isEmpty()) {
|
||||||
dom_root.setAttribute(QStringLiteral("conductorAutonum"),
|
dom_root.setAttribute(QStringLiteral("conductorAutonum"),
|
||||||
m_conductors_autonum_name);
|
m_conductors_autonum_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Default New Element
|
//Default New Element
|
||||||
@ -776,7 +776,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
|
|
||||||
//Default New Conductor
|
//Default New Conductor
|
||||||
dom_root.setAttribute(QStringLiteral("freezeNewConductor"),
|
dom_root.setAttribute(QStringLiteral("freezeNewConductor"),
|
||||||
m_freeze_new_conductors_
|
m_freeze_new_conductors_
|
||||||
? QStringLiteral("true") : QStringLiteral("false"));
|
? QStringLiteral("true") : QStringLiteral("false"));
|
||||||
|
|
||||||
//Element Folio Sequential Variables
|
//Element Folio Sequential Variables
|
||||||
@ -791,10 +791,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
QStringLiteral("elementunitfolioseq"));
|
QStringLiteral("elementunitfolioseq"));
|
||||||
folioSequentialsToXml(&m_elmt_unitfolio_max,
|
folioSequentialsToXml(&m_elmt_unitfolio_max,
|
||||||
&elmtfolioseq,
|
&elmtfolioseq,
|
||||||
QStringLiteral("sequf_"),
|
QStringLiteral("sequf_"),
|
||||||
QStringLiteral("unitfolioseq"),
|
QStringLiteral("unitfolioseq"),
|
||||||
&document);
|
&document);
|
||||||
elmtfoliosequential.appendChild(elmtfolioseq);
|
elmtfoliosequential.appendChild(elmtfolioseq);
|
||||||
}
|
}
|
||||||
if (!m_elmt_tenfolio_max.isEmpty()) {
|
if (!m_elmt_tenfolio_max.isEmpty()) {
|
||||||
@ -802,10 +802,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
QStringLiteral("elementtenfolioseq"));
|
QStringLiteral("elementtenfolioseq"));
|
||||||
folioSequentialsToXml(&m_elmt_tenfolio_max,
|
folioSequentialsToXml(&m_elmt_tenfolio_max,
|
||||||
&elmtfolioseq,
|
&elmtfolioseq,
|
||||||
QStringLiteral("seqtf_"),
|
QStringLiteral("seqtf_"),
|
||||||
QStringLiteral("tenfolioseq"),
|
QStringLiteral("tenfolioseq"),
|
||||||
&document);
|
&document);
|
||||||
elmtfoliosequential.appendChild(elmtfolioseq);
|
elmtfoliosequential.appendChild(elmtfolioseq);
|
||||||
}
|
}
|
||||||
if (!m_elmt_hundredfolio_max.isEmpty()) {
|
if (!m_elmt_hundredfolio_max.isEmpty()) {
|
||||||
@ -813,10 +813,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
QStringLiteral("elementhundredfolioseq"));
|
QStringLiteral("elementhundredfolioseq"));
|
||||||
folioSequentialsToXml(&m_elmt_hundredfolio_max,
|
folioSequentialsToXml(&m_elmt_hundredfolio_max,
|
||||||
&elmtfolioseq,
|
&elmtfolioseq,
|
||||||
QStringLiteral("seqhf_"),
|
QStringLiteral("seqhf_"),
|
||||||
QStringLiteral("hundredfolioseq"),
|
QStringLiteral("hundredfolioseq"),
|
||||||
&document);
|
&document);
|
||||||
elmtfoliosequential.appendChild(elmtfolioseq);
|
elmtfoliosequential.appendChild(elmtfolioseq);
|
||||||
}
|
}
|
||||||
dom_root.appendChild(elmtfoliosequential);
|
dom_root.appendChild(elmtfoliosequential);
|
||||||
@ -834,10 +834,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
QStringLiteral("conductorunitfolioseq"));
|
QStringLiteral("conductorunitfolioseq"));
|
||||||
folioSequentialsToXml(&m_cnd_unitfolio_max,
|
folioSequentialsToXml(&m_cnd_unitfolio_max,
|
||||||
&cndfolioseq,
|
&cndfolioseq,
|
||||||
QStringLiteral("sequf_"),
|
QStringLiteral("sequf_"),
|
||||||
QStringLiteral("unitfolioseq"),
|
QStringLiteral("unitfolioseq"),
|
||||||
&document);
|
&document);
|
||||||
cndfoliosequential.appendChild(cndfolioseq);
|
cndfoliosequential.appendChild(cndfolioseq);
|
||||||
}
|
}
|
||||||
if (!m_cnd_tenfolio_max.isEmpty()) {
|
if (!m_cnd_tenfolio_max.isEmpty()) {
|
||||||
@ -845,10 +845,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
QStringLiteral("conductortenfolioseq"));
|
QStringLiteral("conductortenfolioseq"));
|
||||||
folioSequentialsToXml(&m_cnd_tenfolio_max,
|
folioSequentialsToXml(&m_cnd_tenfolio_max,
|
||||||
&cndfolioseq,
|
&cndfolioseq,
|
||||||
QStringLiteral("seqtf_"),
|
QStringLiteral("seqtf_"),
|
||||||
QStringLiteral("tenfolioseq"),
|
QStringLiteral("tenfolioseq"),
|
||||||
&document);
|
&document);
|
||||||
cndfoliosequential.appendChild(cndfolioseq);
|
cndfoliosequential.appendChild(cndfolioseq);
|
||||||
}
|
}
|
||||||
if (!m_cnd_hundredfolio_max.isEmpty()) {
|
if (!m_cnd_hundredfolio_max.isEmpty()) {
|
||||||
@ -856,10 +856,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
QStringLiteral("conductorhundredfolioseq"));
|
QStringLiteral("conductorhundredfolioseq"));
|
||||||
folioSequentialsToXml(&m_cnd_hundredfolio_max,
|
folioSequentialsToXml(&m_cnd_hundredfolio_max,
|
||||||
&cndfolioseq,
|
&cndfolioseq,
|
||||||
QStringLiteral("seqhf_"),
|
QStringLiteral("seqhf_"),
|
||||||
QStringLiteral("hundredfolioseq"),
|
QStringLiteral("hundredfolioseq"),
|
||||||
&document);
|
&document);
|
||||||
cndfoliosequential.appendChild(cndfolioseq);
|
cndfoliosequential.appendChild(cndfolioseq);
|
||||||
}
|
}
|
||||||
dom_root.appendChild(cndfoliosequential);
|
dom_root.appendChild(cndfoliosequential);
|
||||||
@ -882,7 +882,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
QVector<DiagramImageItem *> list_images;
|
QVector<DiagramImageItem *> list_images;
|
||||||
QVector<QetShapeItem *> list_shapes;
|
QVector<QetShapeItem *> list_shapes;
|
||||||
QVector<QetGraphicsTableItem *> table_vector;
|
QVector<QetGraphicsTableItem *> table_vector;
|
||||||
QVector<TerminalStripItem *> strip_vector;
|
QVector<TerminalStripItem *> strip_vector;
|
||||||
|
|
||||||
//Ckeck graphics item to "XMLise"
|
//Ckeck graphics item to "XMLise"
|
||||||
for(QGraphicsItem *qgi : items())
|
for(QGraphicsItem *qgi : items())
|
||||||
@ -931,15 +931,15 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
auto table = static_cast<QetGraphicsTableItem *>(qgi);
|
auto table = static_cast<QetGraphicsTableItem *>(qgi);
|
||||||
if (whole_content || table->isSelected())
|
if (whole_content || table->isSelected())
|
||||||
table_vector << table;
|
table_vector << table;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case TerminalStripItem::Type: {
|
||||||
|
const auto strip = static_cast<TerminalStripItem *>(qgi);
|
||||||
|
if (whole_content || strip->isSelected()) {
|
||||||
|
strip_vector << strip;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TerminalStripItem::Type: {
|
|
||||||
const auto strip = static_cast<TerminalStripItem *>(qgi);
|
|
||||||
if (whole_content || strip->isSelected()) {
|
|
||||||
strip_vector << strip;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -951,7 +951,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
auto dom_elements = document.createElement(QStringLiteral("elements"));
|
auto dom_elements = document.createElement(QStringLiteral("elements"));
|
||||||
for (auto elmt : list_elements) {
|
for (auto elmt : list_elements) {
|
||||||
dom_elements.appendChild(elmt->toXml(document,
|
dom_elements.appendChild(elmt->toXml(document,
|
||||||
table_adr_id));
|
table_adr_id));
|
||||||
}
|
}
|
||||||
dom_root.appendChild(dom_elements);
|
dom_root.appendChild(dom_elements);
|
||||||
}
|
}
|
||||||
@ -997,9 +997,9 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
dom_root.appendChild(tables);
|
dom_root.appendChild(tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strip_vector.isEmpty()) {
|
if (!strip_vector.isEmpty()) {
|
||||||
dom_root.appendChild(TerminalStripItemXml::toXml(strip_vector, document));
|
dom_root.appendChild(TerminalStripItemXml::toXml(strip_vector, document));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return(document);
|
return(document);
|
||||||
@ -1015,10 +1015,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
@param doc
|
@param doc
|
||||||
*/
|
*/
|
||||||
void Diagram::folioSequentialsToXml(QHash<QString,
|
void Diagram::folioSequentialsToXml(QHash<QString,
|
||||||
QStringList> *hash,
|
QStringList> *hash,
|
||||||
QDomElement *domElement,
|
QDomElement *domElement,
|
||||||
const QString& seq_type,
|
const QString& seq_type,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
QDomDocument *doc)
|
QDomDocument *doc)
|
||||||
{
|
{
|
||||||
QHash<QString, QStringList>::iterator i;
|
QHash<QString, QStringList>::iterator i;
|
||||||
@ -1030,7 +1030,7 @@ void Diagram::folioSequentialsToXml(QHash<QString,
|
|||||||
|
|
||||||
for (int j = 0; j < i.value().size(); j++) {
|
for (int j = 0; j < i.value().size(); j++) {
|
||||||
folioseq.setAttribute(seq_type + QString::number(j+1),
|
folioseq.setAttribute(seq_type + QString::number(j+1),
|
||||||
i.value().at(j));
|
i.value().at(j));
|
||||||
}
|
}
|
||||||
domElement->appendChild(folioseq);
|
domElement->appendChild(folioseq);
|
||||||
}
|
}
|
||||||
@ -1068,9 +1068,9 @@ void Diagram::folioSequentialsToXml(QHash<QString,
|
|||||||
\~French true si l'import a reussi, false sinon
|
\~French true si l'import a reussi, false sinon
|
||||||
*/
|
*/
|
||||||
bool Diagram::fromXml(QDomDocument &document,
|
bool Diagram::fromXml(QDomDocument &document,
|
||||||
QPointF position,
|
QPointF position,
|
||||||
bool consider_informations,
|
bool consider_informations,
|
||||||
DiagramContent *content_ptr) {
|
DiagramContent *content_ptr) {
|
||||||
QDomElement root = document.documentElement();
|
QDomElement root = document.documentElement();
|
||||||
return(fromXml(root, position, consider_informations, content_ptr));
|
return(fromXml(root, position, consider_informations, content_ptr));
|
||||||
}
|
}
|
||||||
@ -1220,9 +1220,9 @@ Terminal* findTerminal(int conductor_index,
|
|||||||
\~French true si l'import a reussi, false sinon
|
\~French true si l'import a reussi, false sinon
|
||||||
*/
|
*/
|
||||||
bool Diagram::fromXml(QDomElement &document,
|
bool Diagram::fromXml(QDomElement &document,
|
||||||
QPointF position,
|
QPointF position,
|
||||||
bool consider_informations,
|
bool consider_informations,
|
||||||
DiagramContent *content_ptr)
|
DiagramContent *content_ptr)
|
||||||
{
|
{
|
||||||
const QDomElement& root = document;
|
const QDomElement& root = document;
|
||||||
// The first element must be a diagram
|
// The first element must be a diagram
|
||||||
@ -1323,7 +1323,7 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
type_id,
|
type_id,
|
||||||
other_project);
|
other_project);
|
||||||
ech.importFromProject(m_project,
|
ech.importFromProject(m_project,
|
||||||
location);
|
location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1446,8 +1446,8 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
added_tables << table;
|
added_tables << table;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load terminal strip item
|
//Load terminal strip item
|
||||||
QVector<TerminalStripItem *> added_strips { TerminalStripItemXml::fromXml(this, root) };
|
QVector<TerminalStripItem *> added_strips { TerminalStripItemXml::fromXml(this, root) };
|
||||||
|
|
||||||
//Translate items if a new position was given in parameter
|
//Translate items if a new position was given in parameter
|
||||||
if (position != QPointF())
|
if (position != QPointF())
|
||||||
@ -1459,7 +1459,7 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
for (auto text : qAsConst(added_texts )) added_items << text;
|
for (auto text : qAsConst(added_texts )) added_items << text;
|
||||||
for (auto image : qAsConst(added_images )) added_items << image;
|
for (auto image : qAsConst(added_images )) added_items << image;
|
||||||
for (auto table : qAsConst(added_tables )) added_items << table;
|
for (auto table : qAsConst(added_tables )) added_items << table;
|
||||||
for (const auto &strip : qAsConst(added_strips)) added_items << strip;
|
for (const auto &strip : qAsConst(added_strips)) added_items << strip;
|
||||||
|
|
||||||
//Get the top left corner of the rectangle that contain all added items
|
//Get the top left corner of the rectangle that contain all added items
|
||||||
QRectF items_rect;
|
QRectF items_rect;
|
||||||
@ -1500,9 +1500,9 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
content_ptr -> m_shapes = QSet<QetShapeItem *>(
|
content_ptr -> m_shapes = QSet<QetShapeItem *>(
|
||||||
added_shapes.begin(),
|
added_shapes.begin(),
|
||||||
added_shapes.end());
|
added_shapes.end());
|
||||||
content_ptr->m_terminal_strip.swap(added_strips);
|
content_ptr->m_terminal_strip.swap(added_strips);
|
||||||
#endif
|
#endif
|
||||||
content_ptr->m_tables.swap(added_tables);
|
content_ptr->m_tables.swap(added_tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustSceneRect();
|
adjustSceneRect();
|
||||||
@ -1556,25 +1556,25 @@ void Diagram::folioSequentialsFromXml(const QDomElement &root,
|
|||||||
*/
|
*/
|
||||||
void Diagram::refreshContents()
|
void Diagram::refreshContents()
|
||||||
{
|
{
|
||||||
DiagramContent dc_(this, false);
|
DiagramContent dc_(this, false);
|
||||||
|
|
||||||
for (auto &elmt : dc_.m_elements) {
|
for (auto &elmt : dc_.m_elements) {
|
||||||
elmt->initLink(project());
|
elmt->initLink(project());
|
||||||
for (auto &deti : elmt->dynamicTextItems())
|
for (auto &deti : elmt->dynamicTextItems())
|
||||||
deti->refreshLabelConnection();
|
deti->refreshLabelConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &conductor : dc_.conductors()) {
|
for (auto &conductor : dc_.conductors()) {
|
||||||
conductor->refreshText();
|
conductor->refreshText();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &table : qAsConst(dc_.m_tables)) {
|
for (auto &table : qAsConst(dc_.m_tables)) {
|
||||||
table->initLink();
|
table->initLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &strip :qAsConst(dc_.m_terminal_strip)) {
|
for (auto &strip :qAsConst(dc_.m_terminal_strip)) {
|
||||||
strip->refreshPending();
|
strip->refreshPending();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
/**
|
/**
|
||||||
This class represents a diagram context, i.e. the data (a list of key/value
|
This class represents a diagram context, i.e. the data (a list of key/value
|
||||||
pairs) of a diagram at a given time. It is notably used by titleblock
|
pairs) of a diagram at a given time. It is notably used by titleblock
|
||||||
templates to fetch the informations they need to do their rendering, or
|
templates to fetch the informations they need to do their rendering, or
|
||||||
element for retrieve information about itself
|
element for retrieve information about itself
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,6 +176,7 @@ qreal PartTerminal::rotation() const {
|
|||||||
case Qet::South : return 180;
|
case Qet::South : return 180;
|
||||||
case Qet::West : return 270;
|
case Qet::West : return 270;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,9 +93,9 @@ void ElementDialog::setUpWidget()
|
|||||||
prjs.append(prj);
|
prjs.append(prj);
|
||||||
|
|
||||||
if (m_mode == OpenElement)
|
if (m_mode == OpenElement)
|
||||||
m_model->loadCollections(true, true, true, prjs);
|
m_model->loadCollections(true, true, true, prjs);
|
||||||
else
|
else
|
||||||
m_model->loadCollections(false, true, true, prjs);
|
m_model->loadCollections(false, true, true, prjs);
|
||||||
|
|
||||||
m_tree_view->setModel(m_model);
|
m_tree_view->setModel(m_model);
|
||||||
m_tree_view->setHeaderHidden(true);
|
m_tree_view->setHeaderHidden(true);
|
||||||
|
@ -85,15 +85,15 @@ int ElementsMover::beginMovement(Diagram *diagram, QGraphicsItem *driver_item)
|
|||||||
m_moved_content = DiagramContent(diagram);
|
m_moved_content = DiagramContent(diagram);
|
||||||
m_moved_content.removeNonMovableItems();
|
m_moved_content.removeNonMovableItems();
|
||||||
|
|
||||||
//Remove element text and text group, if the parent element is selected.
|
//Remove element text and text group, if the parent element is selected.
|
||||||
const auto element_text{m_moved_content.m_element_texts};
|
const auto element_text{m_moved_content.m_element_texts};
|
||||||
for(const auto &deti : element_text) {
|
for(const auto &deti : element_text) {
|
||||||
if(m_moved_content.m_elements.contains(deti->parentElement())) {
|
if(m_moved_content.m_elements.contains(deti->parentElement())) {
|
||||||
m_moved_content.m_element_texts.remove(deti);
|
m_moved_content.m_element_texts.remove(deti);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto element_text_group{m_moved_content.m_texts_groups};
|
const auto element_text_group{m_moved_content.m_texts_groups};
|
||||||
for(const auto &etig : element_text_group) {
|
for(const auto &etig : element_text_group) {
|
||||||
if (m_moved_content.m_elements.contains(etig->parentElement())) {
|
if (m_moved_content.m_elements.contains(etig->parentElement())) {
|
||||||
m_moved_content.m_texts_groups.remove(etig);
|
m_moved_content.m_texts_groups.remove(etig);
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ void ElementsMover::continueMovement(const QPointF &movement)
|
|||||||
conductor->updatePath();
|
conductor->updatePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_status_bar && m_movement_driver)
|
if (m_status_bar && m_movement_driver)
|
||||||
{
|
{
|
||||||
const auto point_{m_movement_driver->scenePos()};
|
const auto point_{m_movement_driver->scenePos()};
|
||||||
m_status_bar->showMessage(QString("x %1 : y %2").arg(QString::number(point_.x()), QString::number(point_.y())));
|
m_status_bar->showMessage(QString("x %1 : y %2").arg(QString::number(point_.x()), QString::number(point_.y())));
|
||||||
@ -176,19 +176,19 @@ void ElementsMover::endMovement()
|
|||||||
|
|
||||||
//Create undo move if there is a movement
|
//Create undo move if there is a movement
|
||||||
if (!m_current_movement.isNull()) {
|
if (!m_current_movement.isNull()) {
|
||||||
QUndoCommand *quc{new MoveGraphicsItemCommand(m_diagram, m_moved_content, m_current_movement, undo_object)};
|
QUndoCommand *quc{new MoveGraphicsItemCommand(m_diagram, m_moved_content, m_current_movement, undo_object)};
|
||||||
undo_object->setText(quc->text());
|
undo_object->setText(quc->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
//There is only one element moved, and project authorize auto conductor,
|
//There is only one element moved, and project authorize auto conductor,
|
||||||
//we try auto connection of conductor;
|
//we try auto connection of conductor;
|
||||||
typedef DiagramContent dc;
|
typedef DiagramContent dc;
|
||||||
if (m_moved_content.items(dc::TextFields
|
if (m_moved_content.items(dc::TextFields
|
||||||
| dc::Images
|
| dc::Images
|
||||||
| dc::Shapes
|
| dc::Shapes
|
||||||
| dc::TerminalStrip).isEmpty()
|
| dc::TerminalStrip).isEmpty()
|
||||||
&& m_moved_content.items(dc::Elements).size() == 1
|
&& m_moved_content.items(dc::Elements).size() == 1
|
||||||
&& m_diagram->project()->autoConductor())
|
&& m_diagram->project()->autoConductor())
|
||||||
{
|
{
|
||||||
const Element *elmt{m_moved_content.m_elements.first()};
|
const Element *elmt{m_moved_content.m_elements.first()};
|
||||||
const auto aligned_free_terminals{elmt->AlignedFreeTerminals()};
|
const auto aligned_free_terminals{elmt->AlignedFreeTerminals()};
|
||||||
|
@ -435,8 +435,8 @@ void ExportDialog::generateSvg(
|
|||||||
*/
|
*/
|
||||||
void ExportDialog::generateDxf(
|
void ExportDialog::generateDxf(
|
||||||
Diagram *diagram,
|
Diagram *diagram,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
QString &file_path)
|
QString &file_path)
|
||||||
{
|
{
|
||||||
saveReloadDiagramParameters(diagram, true);
|
saveReloadDiagramParameters(diagram, true);
|
||||||
@ -451,8 +451,8 @@ void ExportDialog::generateDxf(
|
|||||||
|
|
||||||
//Add project elements (lines, rectangles, circles, texts) to dxf file
|
//Add project elements (lines, rectangles, circles, texts) to dxf file
|
||||||
if (epw -> exportProperties().draw_border) {
|
if (epw -> exportProperties().draw_border) {
|
||||||
QRectF rect(Diagram::margin,Diagram::margin,width,height);
|
QRectF rect(Diagram::margin,Diagram::margin,width,height);
|
||||||
Createdxf::drawRectangle(file_path,rect,0);
|
Createdxf::drawRectangle(file_path,rect,0);
|
||||||
}
|
}
|
||||||
diagram -> border_and_titleblock.drawDxf(file_path, 0);
|
diagram -> border_and_titleblock.drawDxf(file_path, 0);
|
||||||
|
|
||||||
@ -465,8 +465,8 @@ void ExportDialog::generateDxf(
|
|||||||
QList<QRectF *> list_rectangles;
|
QList<QRectF *> list_rectangles;
|
||||||
//QList<QRectF *> list_ellipses;
|
//QList<QRectF *> list_ellipses;
|
||||||
QList <QetShapeItem *> list_shapes;
|
QList <QetShapeItem *> list_shapes;
|
||||||
QList <QetGraphicsTableItem *> list_tables;
|
QList <QetGraphicsTableItem *> list_tables;
|
||||||
// QList <Terminal *> list_terminals;
|
// QList <Terminal *> list_terminals;
|
||||||
|
|
||||||
// Determine les elements a "XMLiser"
|
// Determine les elements a "XMLiser"
|
||||||
foreach(QGraphicsItem *qgi, diagram -> items()) {
|
foreach(QGraphicsItem *qgi, diagram -> items()) {
|
||||||
@ -482,18 +482,18 @@ void ExportDialog::generateDxf(
|
|||||||
list_shapes << dii;
|
list_shapes << dii;
|
||||||
} else if (DynamicElementTextItem *deti = qgraphicsitem_cast<DynamicElementTextItem *>(qgi)) {
|
} else if (DynamicElementTextItem *deti = qgraphicsitem_cast<DynamicElementTextItem *>(qgi)) {
|
||||||
list_texts << deti;
|
list_texts << deti;
|
||||||
} else if (QetGraphicsTableItem *gti = qgraphicsitem_cast<QetGraphicsTableItem *>(qgi)) {
|
} else if (QetGraphicsTableItem *gti = qgraphicsitem_cast<QetGraphicsTableItem *>(qgi)) {
|
||||||
list_tables << gti;
|
list_tables << gti;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw shapes
|
// Draw shapes
|
||||||
foreach (QetShapeItem *qsi, list_shapes) qsi->toDXF(file_path, qsi->pen());
|
foreach (QetShapeItem *qsi, list_shapes) qsi->toDXF(file_path, qsi->pen());
|
||||||
|
|
||||||
// Draw tables
|
// Draw tables
|
||||||
foreach (QetGraphicsTableItem *gti, list_tables) {
|
foreach (QetGraphicsTableItem *gti, list_tables) {
|
||||||
gti->toDXF(file_path);
|
gti->toDXF(file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw elements
|
//Draw elements
|
||||||
foreach(Element *elmt, list_elements)
|
foreach(Element *elmt, list_elements)
|
||||||
@ -507,179 +507,179 @@ void ExportDialog::generateDxf(
|
|||||||
|
|
||||||
for(QGraphicsSimpleTextItem *text : primitives.m_texts)
|
for(QGraphicsSimpleTextItem *text : primitives.m_texts)
|
||||||
{
|
{
|
||||||
qreal fontSize = text->font().pointSizeF();
|
qreal fontSize = text->font().pointSizeF();
|
||||||
if (fontSize < 0)
|
if (fontSize < 0)
|
||||||
fontSize = text->font().pixelSize();
|
fontSize = text->font().pixelSize();
|
||||||
|
|
||||||
qreal x = elem_pos_x + text->pos().x();
|
qreal x = elem_pos_x + text->pos().x();
|
||||||
qreal y = elem_pos_y + text->pos().y();
|
qreal y = elem_pos_y + text->pos().y();
|
||||||
|
|
||||||
qreal angle = text -> rotation() + rotation_angle;
|
qreal angle = text -> rotation() + rotation_angle;
|
||||||
qreal angler = angle * M_PI/180;
|
qreal angler = angle * M_PI/180;
|
||||||
int xdir = -sin(angler);
|
int xdir = -sin(angler);
|
||||||
int ydir = -cos(angler);
|
int ydir = -cos(angler);
|
||||||
|
|
||||||
QPointF transformed_point = rotation_transformed(x, y, elem_pos_x, elem_pos_y, -rotation_angle);
|
QPointF transformed_point = rotation_transformed(x, y, elem_pos_x, elem_pos_y, -rotation_angle);
|
||||||
x = transformed_point.x() - ydir * fontSize * 0.5;
|
x = transformed_point.x() - ydir * fontSize * 0.5;
|
||||||
y = transformed_point.y() - xdir * fontSize * 0.5;
|
y = transformed_point.y() - xdir * fontSize * 0.5;
|
||||||
QStringList lines = text->text().split('\n');
|
QStringList lines = text->text().split('\n');
|
||||||
qreal offset = fontSize * 1.6;
|
qreal offset = fontSize * 1.6;
|
||||||
for (QString line : lines)
|
for (QString line : lines)
|
||||||
{
|
{
|
||||||
if (line.size() > 0 && line != "_" ) {
|
if (line.size() > 0 && line != "_" ) {
|
||||||
Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360 - angle, 0, 0.72);
|
Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360 - angle, 0, 0.72);
|
||||||
}
|
}
|
||||||
x += offset * xdir;
|
x += offset * xdir;
|
||||||
y -= offset * ydir;
|
y -= offset * ydir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QLineF line : primitives.m_lines)
|
for (QLineF line : primitives.m_lines)
|
||||||
{
|
{
|
||||||
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
||||||
QLineF l = t.map(line);
|
QLineF l = t.map(line);
|
||||||
Createdxf::drawLine(file_path, l, 0);
|
Createdxf::drawLine(file_path, l, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QRectF rect : primitives.m_rectangles)
|
for (QRectF rect : primitives.m_rectangles)
|
||||||
{
|
{
|
||||||
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
||||||
QRectF r = t.mapRect(rect);
|
QRectF r = t.mapRect(rect);
|
||||||
Createdxf::drawRectangle(file_path,r,0);
|
Createdxf::drawRectangle(file_path,r,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QRectF circle_rect : primitives.m_circles)
|
for (QRectF circle_rect : primitives.m_circles)
|
||||||
{
|
{
|
||||||
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
||||||
QPointF c = t.map(QPointF(circle_rect.center().x(),circle_rect.center().y()));
|
QPointF c = t.map(QPointF(circle_rect.center().x(),circle_rect.center().y()));
|
||||||
Createdxf::drawCircle(file_path,c,circle_rect.width()/2,0);
|
Createdxf::drawCircle(file_path,c,circle_rect.width()/2,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QVector<QPointF> polygon : primitives.m_polygons)
|
for (QVector<QPointF> polygon : primitives.m_polygons)
|
||||||
{
|
{
|
||||||
if (polygon.size() == 0)
|
if (polygon.size() == 0)
|
||||||
continue;
|
continue;
|
||||||
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
||||||
QPolygonF poly = t.map(polygon);
|
QPolygonF poly = t.map(polygon);
|
||||||
if(poly.isClosed())
|
if(poly.isClosed())
|
||||||
Createdxf::drawPolygon(file_path,poly,0);
|
Createdxf::drawPolygon(file_path,poly,0);
|
||||||
else
|
else
|
||||||
Createdxf::drawPolyline(file_path,poly,0);
|
Createdxf::drawPolyline(file_path,poly,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw arcs and ellipses
|
// Draw arcs and ellipses
|
||||||
for (QVector<qreal> arc : primitives.m_arcs)
|
for (QVector<qreal> arc : primitives.m_arcs)
|
||||||
{
|
{
|
||||||
if (arc.size() == 0)
|
if (arc.size() == 0)
|
||||||
continue;
|
continue;
|
||||||
qreal x = (elem_pos_x + arc.at(0));
|
qreal x = (elem_pos_x + arc.at(0));
|
||||||
qreal y = (elem_pos_y + arc.at(1));
|
qreal y = (elem_pos_y + arc.at(1));
|
||||||
qreal w = arc.at(2);
|
qreal w = arc.at(2);
|
||||||
qreal h = arc.at(3);
|
qreal h = arc.at(3);
|
||||||
qreal startAngle = arc.at(4);
|
qreal startAngle = arc.at(4);
|
||||||
qreal spanAngle = arc .at(5);
|
qreal spanAngle = arc .at(5);
|
||||||
QRectF r(x,y,w,h);
|
QRectF r(x,y,w,h);
|
||||||
QPointF hotspot(elem_pos_x,elem_pos_y);
|
QPointF hotspot(elem_pos_x,elem_pos_y);
|
||||||
Createdxf::drawArcEllipse(file_path, r, startAngle, spanAngle, hotspot, rotation_angle, 0);
|
Createdxf::drawArcEllipse(file_path, r, startAngle, spanAngle, hotspot, rotation_angle, 0);
|
||||||
|
}
|
||||||
|
if (epw -> exportProperties().draw_terminals) {
|
||||||
|
// Draw terminals
|
||||||
|
QList<Terminal *> list_terminals = elmt->terminals();
|
||||||
|
QColor col("red");
|
||||||
|
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
||||||
|
foreach(Terminal *tp, list_terminals) {
|
||||||
|
QPointF c = t.map(QPointF(tp->dock_elmt_.x(),tp->dock_elmt_.y()));
|
||||||
|
Createdxf::drawCircle(file_path,c,3.0,Createdxf::dxfColor(col));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (epw -> exportProperties().draw_terminals) {
|
|
||||||
// Draw terminals
|
|
||||||
QList<Terminal *> list_terminals = elmt->terminals();
|
|
||||||
QColor col("red");
|
|
||||||
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
|
||||||
foreach(Terminal *tp, list_terminals) {
|
|
||||||
QPointF c = t.map(QPointF(tp->dock_elmt_.x(),tp->dock_elmt_.y()));
|
|
||||||
Createdxf::drawCircle(file_path,c,3.0,Createdxf::dxfColor(col));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw conductors
|
//Draw conductors
|
||||||
foreach(Conductor *cond, list_conductors) {
|
foreach(Conductor *cond, list_conductors) {
|
||||||
QPolygonF poly;
|
QPolygonF poly;
|
||||||
bool firstseg = true;
|
bool firstseg = true;
|
||||||
foreach(ConductorSegment *segment, cond -> segmentsList()) {
|
foreach(ConductorSegment *segment, cond -> segmentsList()) {
|
||||||
//Createdxf::drawLine(file_path,QLineF(cond->pos()+segment->firstPoint(),cond->pos()+segment->secondPoint()),0);
|
//Createdxf::drawLine(file_path,QLineF(cond->pos()+segment->firstPoint(),cond->pos()+segment->secondPoint()),0);
|
||||||
if(firstseg){
|
if(firstseg){
|
||||||
poly << cond->pos()+segment->firstPoint();
|
poly << cond->pos()+segment->firstPoint();
|
||||||
firstseg = false;
|
firstseg = false;
|
||||||
}
|
}
|
||||||
poly << cond->pos()+segment->secondPoint();
|
poly << cond->pos()+segment->secondPoint();
|
||||||
}
|
}
|
||||||
Createdxf::drawPolyline(file_path,poly,0);
|
Createdxf::drawPolyline(file_path,poly,0);
|
||||||
//Draw conductor text item
|
//Draw conductor text item
|
||||||
ConductorTextItem *textItem = cond -> textItem();
|
ConductorTextItem *textItem = cond -> textItem();
|
||||||
|
|
||||||
if (textItem) {
|
if (textItem) {
|
||||||
qreal fontSize = textItem -> font().pointSizeF();
|
qreal fontSize = textItem -> font().pointSizeF();
|
||||||
if (fontSize < 0)
|
if (fontSize < 0)
|
||||||
fontSize = textItem -> font().pixelSize();
|
fontSize = textItem -> font().pixelSize();
|
||||||
qreal angle = textItem -> rotation();
|
qreal angle = textItem -> rotation();
|
||||||
qreal angler = angle * M_PI/180;
|
qreal angler = angle * M_PI/180;
|
||||||
int xdir = -sin(angler);
|
int xdir = -sin(angler);
|
||||||
int ydir = -cos(angler);
|
int ydir = -cos(angler);
|
||||||
|
|
||||||
qreal x = (cond->pos().x() + textItem -> pos().x())
|
qreal x = (cond->pos().x() + textItem -> pos().x())
|
||||||
+ xdir * fontSize * 1.8
|
+ xdir * fontSize * 1.8
|
||||||
- ydir * fontSize;
|
- ydir * fontSize;
|
||||||
qreal y = (cond->pos().y() + textItem -> pos().y())
|
qreal y = (cond->pos().y() + textItem -> pos().y())
|
||||||
- ydir * fontSize * 1.8
|
- ydir * fontSize * 1.8
|
||||||
- xdir * fontSize * 0.9;
|
- xdir * fontSize * 0.9;
|
||||||
QStringList lines = textItem->toPlainText().split('\n');
|
QStringList lines = textItem->toPlainText().split('\n');
|
||||||
qreal offset = fontSize * 1.6;
|
qreal offset = fontSize * 1.6;
|
||||||
foreach (QString line, lines) {
|
foreach (QString line, lines) {
|
||||||
if (line.size() > 0 && line != "_" )
|
if (line.size() > 0 && line != "_" )
|
||||||
Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360-angle, 0, 0.72 );
|
Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360-angle, 0, 0.72 );
|
||||||
x += offset * xdir;
|
x += offset * xdir;
|
||||||
y -= offset * ydir;
|
y -= offset * ydir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the junctions
|
// Draw the junctions
|
||||||
QList<QPointF> junctions_list = cond->junctions();
|
QList<QPointF> junctions_list = cond->junctions();
|
||||||
if (!junctions_list.isEmpty()) {
|
if (!junctions_list.isEmpty()) {
|
||||||
foreach(QPointF point, junctions_list) {
|
foreach(QPointF point, junctions_list) {
|
||||||
Createdxf::drawEllipse(file_path,QRectF(cond->pos().x() + point.x() - 1.5, cond->pos().y() + point.y() - 1.5, 3.0, 3.0),0);
|
Createdxf::drawEllipse(file_path,QRectF(cond->pos().x() + point.x() - 1.5, cond->pos().y() + point.y() - 1.5, 3.0, 3.0),0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw text items
|
//Draw text items
|
||||||
foreach(DiagramTextItem *dti, list_texts) {
|
foreach(DiagramTextItem *dti, list_texts) {
|
||||||
qreal fontSize = dti -> font().pointSizeF();
|
qreal fontSize = dti -> font().pointSizeF();
|
||||||
if (fontSize < 0)
|
if (fontSize < 0)
|
||||||
fontSize = dti -> font().pixelSize();
|
fontSize = dti -> font().pixelSize();
|
||||||
|
|
||||||
qreal angle = dti -> rotation();
|
qreal angle = dti -> rotation();
|
||||||
|
|
||||||
QGraphicsItem *parent = dti->parentItem();
|
QGraphicsItem *parent = dti->parentItem();
|
||||||
while (parent) {
|
while (parent) {
|
||||||
angle += parent->rotation();
|
angle += parent->rotation();
|
||||||
parent = parent->parentItem();
|
parent = parent->parentItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal angler = angle * M_PI/180;
|
qreal angler = angle * M_PI/180;
|
||||||
int xdir = -sin(angler);
|
int xdir = -sin(angler);
|
||||||
int ydir = -cos(angler);
|
int ydir = -cos(angler);
|
||||||
qreal x = (dti->scenePos().x())
|
qreal x = (dti->scenePos().x())
|
||||||
+ xdir * fontSize * 1.8
|
+ xdir * fontSize * 1.8
|
||||||
- ydir * fontSize;
|
- ydir * fontSize;
|
||||||
qreal y = dti->scenePos().y()
|
qreal y = dti->scenePos().y()
|
||||||
- ydir * fontSize * 1.8
|
- ydir * fontSize * 1.8
|
||||||
- xdir * fontSize * 0.9;
|
- xdir * fontSize * 0.9;
|
||||||
QStringList lines = dti -> toPlainText().split('\n');
|
QStringList lines = dti -> toPlainText().split('\n');
|
||||||
qreal offset = fontSize * 1.6;
|
qreal offset = fontSize * 1.6;
|
||||||
foreach (QString line, lines) {
|
foreach (QString line, lines) {
|
||||||
if (line.size() > 0 && line != "_" )
|
if (line.size() > 0 && line != "_" )
|
||||||
Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360-angle, Createdxf::dxfColor(dti->color()), 0.72 );
|
Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360-angle, Createdxf::dxfColor(dti->color()), 0.72 );
|
||||||
x += offset * xdir;
|
x += offset * xdir;
|
||||||
y -= offset * ydir;
|
y -= offset * ydir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Createdxf::dxfEnd(file_path);
|
Createdxf::dxfEnd(file_path);
|
||||||
|
|
||||||
saveReloadDiagramParameters(diagram, false);
|
saveReloadDiagramParameters(diagram, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF ExportDialog::rotation_transformed(qreal px,
|
QPointF ExportDialog::rotation_transformed(qreal px,
|
||||||
|
@ -125,10 +125,10 @@ void MachineInfo::send_info_to_debug()
|
|||||||
if (strlen(GIT_COMMIT_SHA)) {
|
if (strlen(GIT_COMMIT_SHA)) {
|
||||||
qInfo() << "GitRevision " + QString(GIT_COMMIT_SHA);
|
qInfo() << "GitRevision " + QString(GIT_COMMIT_SHA);
|
||||||
}
|
}
|
||||||
qInfo()<< "QElectroTech V " + QetVersion::displayedVersion();
|
qInfo()<< "QElectroTech V " + QetVersion::displayedVersion();
|
||||||
qInfo()<< QObject::tr("Compilation : ") + pc.built.version;
|
qInfo()<< QObject::tr("Compilation : ") + pc.built.version;
|
||||||
qInfo()<< "Built with Qt " + pc.built.QT
|
qInfo()<< "Built with Qt " + pc.built.QT
|
||||||
+ " - " + pc.built.arch
|
+ " - " + pc.built.arch
|
||||||
+ " - Date : " + pc.built.date
|
+ " - Date : " + pc.built.date
|
||||||
+ " : " + pc.built.time;
|
+ " : " + pc.built.time;
|
||||||
qInfo()<< "Run with Qt "+ QString(qVersion())
|
qInfo()<< "Run with Qt "+ QString(qVersion())
|
||||||
@ -261,7 +261,7 @@ void MachineInfo::init_get_cpu_info_linux()
|
|||||||
QString linuxGPUOutput = linuxgpuinfo.readAllStandardOutput();
|
QString linuxGPUOutput = linuxgpuinfo.readAllStandardOutput();
|
||||||
pc.gpu.info=QString(linuxGPUOutput.toLocal8Bit().constData());
|
pc.gpu.info=QString(linuxGPUOutput.toLocal8Bit().constData());
|
||||||
linuxgpuinfo.close();
|
linuxgpuinfo.close();
|
||||||
|
|
||||||
QProcess linuxgpuRAM;
|
QProcess linuxgpuRAM;
|
||||||
linuxgpuRAM.start("bash",
|
linuxgpuRAM.start("bash",
|
||||||
QStringList()
|
QStringList()
|
||||||
@ -271,9 +271,6 @@ void MachineInfo::init_get_cpu_info_linux()
|
|||||||
QString linuxGPURAMOutput = linuxgpuRAM.readAllStandardOutput();
|
QString linuxGPURAMOutput = linuxgpuRAM.readAllStandardOutput();
|
||||||
pc.gpu.RAM=QString(linuxGPURAMOutput.toLocal8Bit().constData());
|
pc.gpu.RAM=QString(linuxGPURAMOutput.toLocal8Bit().constData());
|
||||||
linuxgpuRAM.close();
|
linuxgpuRAM.close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,15 +215,15 @@ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(QetSettings::hdpiScaleFacto
|
|||||||
QObject::connect(&app, &SingleApplication::receivedMessage,
|
QObject::connect(&app, &SingleApplication::receivedMessage,
|
||||||
&qetapp, &QETApp::receiveMessage);
|
&qetapp, &QETApp::receiveMessage);
|
||||||
|
|
||||||
QtConcurrent::run([=]()
|
QtConcurrent::run([=]()
|
||||||
{
|
{
|
||||||
// for debugging
|
// for debugging
|
||||||
qInstallMessageHandler(myMessageOutput);
|
qInstallMessageHandler(myMessageOutput);
|
||||||
qInfo("Start-up");
|
qInfo("Start-up");
|
||||||
// delete old log files of max 7 days old.
|
// delete old log files of max 7 days old.
|
||||||
delete_old_log_files(7);
|
delete_old_log_files(7);
|
||||||
MachineInfo::instance()->send_info_to_debug();
|
MachineInfo::instance()->send_info_to_debug();
|
||||||
});
|
});
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,6 +362,7 @@ QString ElementData::masterTypeToString(ElementData::MasterType type)
|
|||||||
case ElementData::Commutator:
|
case ElementData::Commutator:
|
||||||
return QStringLiteral("commutator");
|
return QStringLiteral("commutator");
|
||||||
}
|
}
|
||||||
|
return QStringLiteral("coil");
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementData::MasterType ElementData::masterTypeFromString(const QString &string)
|
ElementData::MasterType ElementData::masterTypeFromString(const QString &string)
|
||||||
@ -394,6 +395,7 @@ QString ElementData::slaveTypeToString(ElementData::SlaveType type)
|
|||||||
case ElementData::delayOnOff:
|
case ElementData::delayOnOff:
|
||||||
return QStringLiteral("delayOnOff");
|
return QStringLiteral("delayOnOff");
|
||||||
}
|
}
|
||||||
|
return QStringLiteral("simple");
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementData::SlaveType ElementData::slaveTypeFromString(const QString &string)
|
ElementData::SlaveType ElementData::slaveTypeFromString(const QString &string)
|
||||||
@ -428,6 +430,7 @@ QString ElementData::slaveStateToString(ElementData::SlaveState type)
|
|||||||
case Other:
|
case Other:
|
||||||
return QStringLiteral("Other");
|
return QStringLiteral("Other");
|
||||||
}
|
}
|
||||||
|
return QStringLiteral("NO");
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementData::SlaveState ElementData::slaveStateFromString(const QString &string)
|
ElementData::SlaveState ElementData::slaveStateFromString(const QString &string)
|
||||||
@ -462,6 +465,7 @@ QString ElementData::terminalTypeToString(ElementData::TerminalType type)
|
|||||||
case ElementData::TTGround:
|
case ElementData::TTGround:
|
||||||
return QStringLiteral("ground");
|
return QStringLiteral("ground");
|
||||||
}
|
}
|
||||||
|
return QStringLiteral("generic");
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementData::TerminalType ElementData::terminalTypeFromString(const QString &string)
|
ElementData::TerminalType ElementData::terminalTypeFromString(const QString &string)
|
||||||
@ -498,6 +502,7 @@ QString ElementData::translatedTerminalType(ElementData::TerminalType type)
|
|||||||
case ElementData::TTGround:
|
case ElementData::TTGround:
|
||||||
return QObject::tr("Terre", "ground terminal element type");
|
return QObject::tr("Terre", "ground terminal element type");
|
||||||
}
|
}
|
||||||
|
return QObject::tr("Générique", "generic terminal element type");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ElementData::terminalFunctionToString(ElementData::TerminalFunction function)
|
QString ElementData::terminalFunctionToString(ElementData::TerminalFunction function)
|
||||||
@ -510,6 +515,7 @@ QString ElementData::terminalFunctionToString(ElementData::TerminalFunction func
|
|||||||
case ElementData::TFNeutral:
|
case ElementData::TFNeutral:
|
||||||
return QStringLiteral("neutral");
|
return QStringLiteral("neutral");
|
||||||
}
|
}
|
||||||
|
return QStringLiteral("generic");
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementData::TerminalFunction ElementData::terminalFunctionFromString(const QString &string)
|
ElementData::TerminalFunction ElementData::terminalFunctionFromString(const QString &string)
|
||||||
@ -535,6 +541,7 @@ QString ElementData::translatedTerminalFunction(ElementData::TerminalFunction fu
|
|||||||
case TFPhase : return QObject::tr("Phase", "phase terminal element function" );
|
case TFPhase : return QObject::tr("Phase", "phase terminal element function" );
|
||||||
case TFNeutral : return QObject::tr("Neutre", "neutral terminal element function");
|
case TFNeutral : return QObject::tr("Neutre", "neutral terminal element function");
|
||||||
}
|
}
|
||||||
|
return QObject::tr("Générique", "generic terminal element function");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementData::kindInfoFromXml(const QDomElement &xml_element)
|
void ElementData::kindInfoFromXml(const QDomElement &xml_element)
|
||||||
|
@ -172,6 +172,7 @@ QString TerminalData::typeToString(TerminalData::Type type)
|
|||||||
case Outer :
|
case Outer :
|
||||||
return QString("Outer");
|
return QString("Outer");
|
||||||
}
|
}
|
||||||
|
return QString("Generic");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,7 +170,7 @@ QETApp::~QETApp()
|
|||||||
ElementFactory::dropInstance();
|
ElementFactory::dropInstance();
|
||||||
ElementPictureFactory::dropInstance();
|
ElementPictureFactory::dropInstance();
|
||||||
MachineInfo::dropInstance();
|
MachineInfo::dropInstance();
|
||||||
TerminalStripEditorWindow::dropInstance();
|
TerminalStripEditorWindow::dropInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -589,101 +589,101 @@ QString QETApp::commonElementsDir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QETApp::customElementsDir
|
@brief QETApp::customElementsDir
|
||||||
@return the dir path of user elements collection appended with a
|
@return the dir path of user elements collection appended with a
|
||||||
"/" separator
|
"/" separator
|
||||||
*/
|
*/
|
||||||
QString QETApp::customElementsDir()
|
QString QETApp::customElementsDir()
|
||||||
{
|
{
|
||||||
if (m_custom_element_dir_is_set)
|
if (m_custom_element_dir_is_set)
|
||||||
{
|
{
|
||||||
return m_custom_element_dir;
|
return m_custom_element_dir;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_custom_element_dir_is_set = true;
|
m_custom_element_dir_is_set = true;
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString path = settings.value(
|
QString path = settings.value(
|
||||||
"elements-collections/custom-collection-path",
|
"elements-collections/custom-collection-path",
|
||||||
"default").toString();
|
"default").toString();
|
||||||
if (path != "default" && !path.isEmpty())
|
if (path != "default" && !path.isEmpty())
|
||||||
{
|
{
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
if (dir.exists())
|
if (dir.exists())
|
||||||
{
|
{
|
||||||
m_custom_element_dir = path;
|
m_custom_element_dir = path;
|
||||||
if(!m_custom_element_dir.endsWith("/")) {
|
if(!m_custom_element_dir.endsWith("/")) {
|
||||||
m_custom_element_dir.append("/");
|
m_custom_element_dir.append("/");
|
||||||
}
|
}
|
||||||
return m_custom_element_dir;
|
return m_custom_element_dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_custom_element_dir = configDir() + "elements/";
|
m_custom_element_dir = configDir() + "elements/";
|
||||||
return m_custom_element_dir;
|
return m_custom_element_dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QETApp::companyElementsDir
|
@brief QETApp::companyElementsDir
|
||||||
@return the dir path of company elements collection appended with a
|
@return the dir path of company elements collection appended with a
|
||||||
"/" separator
|
"/" separator
|
||||||
*/
|
*/
|
||||||
QString QETApp::companyElementsDir()
|
QString QETApp::companyElementsDir()
|
||||||
{
|
{
|
||||||
if (m_company_element_dir_is_set)
|
if (m_company_element_dir_is_set)
|
||||||
{
|
{
|
||||||
return m_company_element_dir;
|
return m_company_element_dir;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_company_element_dir_is_set = true;
|
m_company_element_dir_is_set = true;
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString path = settings.value(
|
QString path = settings.value(
|
||||||
"elements-collections/company-collection-path",
|
"elements-collections/company-collection-path",
|
||||||
"default").toString();
|
"default").toString();
|
||||||
if (path != "default" && !path.isEmpty())
|
if (path != "default" && !path.isEmpty())
|
||||||
{
|
{
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
if (dir.exists())
|
if (dir.exists())
|
||||||
{
|
{
|
||||||
m_company_element_dir = path;
|
m_company_element_dir = path;
|
||||||
if(!m_company_element_dir.endsWith("/")) {
|
if(!m_company_element_dir.endsWith("/")) {
|
||||||
m_company_element_dir.append("/");
|
m_company_element_dir.append("/");
|
||||||
}
|
}
|
||||||
return m_company_element_dir;
|
return m_company_element_dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_company_element_dir = configDir() + "elements-company/";
|
m_company_element_dir = configDir() + "elements-company/";
|
||||||
return m_company_element_dir;
|
return m_company_element_dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QETApp::commonElementsDirN
|
@brief QETApp::commonElementsDirN
|
||||||
like QString QETApp::commonElementsDir but without "/" at the end
|
like QString QETApp::commonElementsDir but without "/" at the end
|
||||||
@return QString path
|
@return QString path
|
||||||
*/
|
*/
|
||||||
QString QETApp::commonElementsDirN()
|
QString QETApp::commonElementsDirN()
|
||||||
{
|
{
|
||||||
QString path = commonElementsDir();
|
QString path = commonElementsDir();
|
||||||
if (path.endsWith("/")) path.remove(path.length()-1, 1);
|
if (path.endsWith("/")) path.remove(path.length()-1, 1);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QETApp::companyElementsDirN
|
@brief QETApp::companyElementsDirN
|
||||||
like QString QETApp::companyElementsDir but without "/" at the end
|
like QString QETApp::companyElementsDir but without "/" at the end
|
||||||
@return QString path
|
@return QString path
|
||||||
*/
|
*/
|
||||||
QString QETApp::companyElementsDirN()
|
QString QETApp::companyElementsDirN()
|
||||||
{
|
{
|
||||||
QString path = companyElementsDir();
|
QString path = companyElementsDir();
|
||||||
if (path.endsWith("/")) path.remove(path.length()-1, 1);
|
if (path.endsWith("/")) path.remove(path.length()-1, 1);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1263,7 +1263,7 @@ QFont QETApp::indiTextsItemFont(qreal size)
|
|||||||
*/
|
*/
|
||||||
QList<QETDiagramEditor *> QETApp::diagramEditors()
|
QList<QETDiagramEditor *> QETApp::diagramEditors()
|
||||||
{
|
{
|
||||||
return(QETApp::instance() -> detectWindows<QETDiagramEditor>());
|
return(QETApp::instance() -> detectWindows<QETDiagramEditor>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1273,18 +1273,18 @@ QList<QETDiagramEditor *> QETApp::diagramEditors()
|
|||||||
*/
|
*/
|
||||||
QETDiagramEditor *QETApp::diagramEditor(QETProject *project)
|
QETDiagramEditor *QETApp::diagramEditor(QETProject *project)
|
||||||
{
|
{
|
||||||
for (const auto &editor : QETApp::instance()->detectWindows<QETDiagramEditor>())
|
for (const auto &editor : QETApp::instance()->detectWindows<QETDiagramEditor>())
|
||||||
{
|
{
|
||||||
for (const auto &project_view : editor->openedProjects())
|
for (const auto &project_view : editor->openedProjects())
|
||||||
{
|
{
|
||||||
if (project_view->project() == project)
|
if (project_view->project() == project)
|
||||||
{
|
{
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2044,21 +2044,21 @@ void QETApp::initConfiguration()
|
|||||||
QDir config_dir(QETApp::configDir());
|
QDir config_dir(QETApp::configDir());
|
||||||
if (!config_dir.exists()) config_dir.mkpath(QETApp::configDir());
|
if (!config_dir.exists()) config_dir.mkpath(QETApp::configDir());
|
||||||
|
|
||||||
QDir custom_elements_dir(QETApp::customElementsDir());
|
QDir custom_elements_dir(QETApp::customElementsDir());
|
||||||
if (!custom_elements_dir.exists())
|
if (!custom_elements_dir.exists())
|
||||||
custom_elements_dir.mkpath(QETApp::customElementsDir());
|
custom_elements_dir.mkpath(QETApp::customElementsDir());
|
||||||
|
|
||||||
QDir company_elements_dir(QETApp::companyElementsDir());
|
QDir company_elements_dir(QETApp::companyElementsDir());
|
||||||
if (!company_elements_dir.exists())
|
if (!company_elements_dir.exists())
|
||||||
company_elements_dir.mkpath(QETApp::companyElementsDir());
|
company_elements_dir.mkpath(QETApp::companyElementsDir());
|
||||||
|
|
||||||
QDir company_tbt_dir(QETApp::companyTitleBlockTemplatesDir());
|
QDir company_tbt_dir(QETApp::companyTitleBlockTemplatesDir());
|
||||||
if (!company_tbt_dir.exists())
|
if (!company_tbt_dir.exists())
|
||||||
company_tbt_dir.mkpath(QETApp::companyTitleBlockTemplatesDir());
|
company_tbt_dir.mkpath(QETApp::companyTitleBlockTemplatesDir());
|
||||||
|
|
||||||
QDir custom_tbt_dir(QETApp::customTitleBlockTemplatesDir());
|
QDir custom_tbt_dir(QETApp::customTitleBlockTemplatesDir());
|
||||||
if (!custom_tbt_dir.exists())
|
if (!custom_tbt_dir.exists())
|
||||||
custom_tbt_dir.mkpath(QETApp::customTitleBlockTemplatesDir());
|
custom_tbt_dir.mkpath(QETApp::customTitleBlockTemplatesDir());
|
||||||
|
|
||||||
/* recent files
|
/* recent files
|
||||||
* note:
|
* note:
|
||||||
@ -2454,7 +2454,7 @@ void QETApp::printHelp()
|
|||||||
*/
|
*/
|
||||||
void QETApp::printVersion()
|
void QETApp::printVersion()
|
||||||
{
|
{
|
||||||
std::cout << qPrintable(QetVersion::displayedVersion()) << std::endl;
|
std::cout << qPrintable(QetVersion::displayedVersion()) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,12 +81,12 @@ class QETApp : public QObject
|
|||||||
static QList<TitleBlockTemplatesCollection *> availableTitleBlockTemplatesCollections();
|
static QList<TitleBlockTemplatesCollection *> availableTitleBlockTemplatesCollections();
|
||||||
static TitleBlockTemplatesCollection *titleBlockTemplatesCollection(const QString &);
|
static TitleBlockTemplatesCollection *titleBlockTemplatesCollection(const QString &);
|
||||||
|
|
||||||
static QString commonElementsDir();
|
static QString commonElementsDir();
|
||||||
static QString companyElementsDir();
|
static QString companyElementsDir();
|
||||||
static QString customElementsDir();
|
static QString customElementsDir();
|
||||||
static QString commonElementsDirN();
|
static QString commonElementsDirN();
|
||||||
static QString companyElementsDirN();
|
static QString companyElementsDirN();
|
||||||
static QString customElementsDirN();
|
static QString customElementsDirN();
|
||||||
static void resetCollectionsPath();
|
static void resetCollectionsPath();
|
||||||
static QString commonTitleBlockTemplatesDir();
|
static QString commonTitleBlockTemplatesDir();
|
||||||
static QString companyTitleBlockTemplatesDir();
|
static QString companyTitleBlockTemplatesDir();
|
||||||
@ -153,8 +153,8 @@ class QETApp : public QObject
|
|||||||
static QFont indiTextsItemFont (qreal = -1.0);
|
static QFont indiTextsItemFont (qreal = -1.0);
|
||||||
static QETDiagramEditor *diagramEditorForFile(const QString &);
|
static QETDiagramEditor *diagramEditorForFile(const QString &);
|
||||||
static QETDiagramEditor *diagramEditorAncestorOf (const QWidget *child);
|
static QETDiagramEditor *diagramEditorAncestorOf (const QWidget *child);
|
||||||
static QList<QETDiagramEditor *> diagramEditors();
|
static QList<QETDiagramEditor *> diagramEditors();
|
||||||
static QETDiagramEditor* diagramEditor(QETProject *project);
|
static QETDiagramEditor* diagramEditor(QETProject *project);
|
||||||
static QList<QETElementEditor *> elementEditors();
|
static QList<QETElementEditor *> elementEditors();
|
||||||
static QList<QETElementEditor *> elementEditors(QETProject *);
|
static QList<QETElementEditor *> elementEditors(QETProject *);
|
||||||
static QList<QETTitleBlockTemplateEditor *> titleBlockTemplateEditors();
|
static QList<QETTitleBlockTemplateEditor *> titleBlockTemplateEditors();
|
||||||
|
@ -447,7 +447,7 @@ void QETDiagramEditor::setUpActions()
|
|||||||
{
|
{
|
||||||
if (auto project = this->currentProject())
|
if (auto project = this->currentProject())
|
||||||
{
|
{
|
||||||
TerminalStripEditorWindow::instance(project, this)->show();
|
TerminalStripEditorWindow::instance(project, this)->show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -675,19 +675,19 @@ void QETDiagramEditor::setUpActions()
|
|||||||
add_polyline ->setStatusTip(tr("Ajoute une polyligne sur le folio actuel"));
|
add_polyline ->setStatusTip(tr("Ajoute une polyligne sur le folio actuel"));
|
||||||
add_terminal_strip->setStatusTip(tr("Ajoute un plan de bornier sur le folio actuel"));
|
add_terminal_strip->setStatusTip(tr("Ajoute un plan de bornier sur le folio actuel"));
|
||||||
|
|
||||||
add_text ->setData(QStringLiteral("text"));
|
add_text ->setData(QStringLiteral("text"));
|
||||||
add_image ->setData(QStringLiteral("image"));
|
add_image ->setData(QStringLiteral("image"));
|
||||||
add_line ->setData(QStringLiteral("line"));
|
add_line ->setData(QStringLiteral("line"));
|
||||||
add_rectangle->setData(QStringLiteral("rectangle"));
|
add_rectangle->setData(QStringLiteral("rectangle"));
|
||||||
add_ellipse ->setData(QStringLiteral("ellipse"));
|
add_ellipse ->setData(QStringLiteral("ellipse"));
|
||||||
add_polyline ->setData(QStringLiteral("polyline"));
|
add_polyline ->setData(QStringLiteral("polyline"));
|
||||||
add_terminal_strip->setData(QStringLiteral("terminal_strip"));
|
add_terminal_strip->setData(QStringLiteral("terminal_strip"));
|
||||||
|
|
||||||
add_text->setCheckable(true);
|
add_text->setCheckable(true);
|
||||||
add_line->setCheckable(true);
|
add_line->setCheckable(true);
|
||||||
add_rectangle->setCheckable(true);
|
add_rectangle->setCheckable(true);
|
||||||
add_ellipse->setCheckable(true);
|
add_ellipse->setCheckable(true);
|
||||||
add_polyline->setCheckable(true);
|
add_polyline->setCheckable(true);
|
||||||
|
|
||||||
connect(&m_add_item_actions_group, &QActionGroup::triggered, this, &QETDiagramEditor::addItemGroupTriggered);
|
connect(&m_add_item_actions_group, &QActionGroup::triggered, this, &QETDiagramEditor::addItemGroupTriggered);
|
||||||
|
|
||||||
|
@ -952,31 +952,31 @@ bool QetShapeItem::toDXF(const QString &filepath,const QPen &pen)
|
|||||||
switch (m_shapeType)
|
switch (m_shapeType)
|
||||||
{
|
{
|
||||||
case Line:
|
case Line:
|
||||||
Createdxf::drawLine(filepath,
|
Createdxf::drawLine(filepath,
|
||||||
QLineF( mapToScene(m_P1),
|
QLineF( mapToScene(m_P1),
|
||||||
mapToScene(m_P2)),
|
mapToScene(m_P2)),
|
||||||
Createdxf::dxfColor(pen));
|
Createdxf::dxfColor(pen));
|
||||||
return true;
|
return true;
|
||||||
case Rectangle:
|
case Rectangle:
|
||||||
Createdxf::drawRectangle(filepath,
|
Createdxf::drawRectangle(filepath,
|
||||||
QRectF(mapToScene(m_P1),
|
QRectF(mapToScene(m_P1),
|
||||||
mapToScene(m_P2)).normalized(),
|
mapToScene(m_P2)).normalized(),
|
||||||
Createdxf::dxfColor(pen));
|
Createdxf::dxfColor(pen));
|
||||||
return true;
|
return true;
|
||||||
case Ellipse:
|
case Ellipse:
|
||||||
Createdxf::drawEllipse(filepath,
|
Createdxf::drawEllipse(filepath,
|
||||||
QRectF(mapToScene(m_P1),
|
QRectF(mapToScene(m_P1),
|
||||||
mapToScene(m_P2)).normalized(),
|
mapToScene(m_P2)).normalized(),
|
||||||
Createdxf::dxfColor(pen));
|
Createdxf::dxfColor(pen));
|
||||||
return true;
|
return true;
|
||||||
case Polygon:
|
case Polygon:
|
||||||
if(m_polygon.isClosed())
|
if(m_polygon.isClosed())
|
||||||
Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
|
Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
|
||||||
else
|
else
|
||||||
Createdxf::drawPolyline(filepath,m_polygon,Createdxf::dxfColor(pen));
|
Createdxf::drawPolyline(filepath,m_polygon,Createdxf::dxfColor(pen));
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,18 +52,18 @@ static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min
|
|||||||
QETProject::QETProject(QObject *parent) :
|
QETProject::QETProject(QObject *parent) :
|
||||||
QObject (parent),
|
QObject (parent),
|
||||||
m_titleblocks_collection(this),
|
m_titleblocks_collection(this),
|
||||||
m_data_base(this, this),
|
m_data_base(this, this),
|
||||||
m_project_properties_handler{this}
|
m_project_properties_handler{this}
|
||||||
{
|
{
|
||||||
setDefaultTitleBlockProperties(TitleBlockProperties::defaultProperties());
|
setDefaultTitleBlockProperties(TitleBlockProperties::defaultProperties());
|
||||||
|
|
||||||
m_elements_collection = new XmlElementCollection(this);
|
m_elements_collection = new XmlElementCollection(this);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectPropertiesHandler &QETProject::projectPropertiesHandler()
|
ProjectPropertiesHandler &QETProject::projectPropertiesHandler()
|
||||||
{
|
{
|
||||||
return m_project_properties_handler;
|
return m_project_properties_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,8 +75,8 @@ ProjectPropertiesHandler &QETProject::projectPropertiesHandler()
|
|||||||
QETProject::QETProject(const QString &path, QObject *parent) :
|
QETProject::QETProject(const QString &path, QObject *parent) :
|
||||||
QObject (parent),
|
QObject (parent),
|
||||||
m_titleblocks_collection(this),
|
m_titleblocks_collection(this),
|
||||||
m_data_base(this, this),
|
m_data_base(this, this),
|
||||||
m_project_properties_handler{this}
|
m_project_properties_handler{this}
|
||||||
{
|
{
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
m_state = openFile(&file);
|
m_state = openFile(&file);
|
||||||
@ -97,8 +97,8 @@ QETProject::QETProject(const QString &path, QObject *parent) :
|
|||||||
QETProject::QETProject(KAutoSaveFile *backup, QObject *parent) :
|
QETProject::QETProject(KAutoSaveFile *backup, QObject *parent) :
|
||||||
QObject (parent),
|
QObject (parent),
|
||||||
m_titleblocks_collection(this),
|
m_titleblocks_collection(this),
|
||||||
m_data_base(this, this),
|
m_data_base(this, this),
|
||||||
m_project_properties_handler{this}
|
m_project_properties_handler{this}
|
||||||
{
|
{
|
||||||
m_state = openFile(backup);
|
m_state = openFile(backup);
|
||||||
//Failed to open from the backup, try to open the crashed
|
//Failed to open from the backup, try to open the crashed
|
||||||
@ -234,7 +234,7 @@ QETProject::ProjectState QETProject::openFile(QFile *file)
|
|||||||
if(opened_here) {
|
if(opened_here) {
|
||||||
file->close();
|
file->close();
|
||||||
}
|
}
|
||||||
return m_state;
|
return m_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -244,23 +244,23 @@ QETProject::ProjectState QETProject::openFile(QFile *file)
|
|||||||
*/
|
*/
|
||||||
void QETProject::refresh()
|
void QETProject::refresh()
|
||||||
{
|
{
|
||||||
DialogWaiting *dlgWaiting { nullptr };
|
DialogWaiting *dlgWaiting { nullptr };
|
||||||
if(DialogWaiting::hasInstance())
|
if(DialogWaiting::hasInstance())
|
||||||
{
|
{
|
||||||
dlgWaiting = DialogWaiting::instance();
|
dlgWaiting = DialogWaiting::instance();
|
||||||
dlgWaiting->setModal(true);
|
dlgWaiting->setModal(true);
|
||||||
dlgWaiting->show();
|
dlgWaiting->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const auto &diagram : diagrams())
|
for(const auto &diagram : diagrams())
|
||||||
{
|
{
|
||||||
if(dlgWaiting)
|
if(dlgWaiting)
|
||||||
{
|
{
|
||||||
dlgWaiting->setProgressBar(dlgWaiting->progressBarValue()+1);
|
dlgWaiting->setProgressBar(dlgWaiting->progressBarValue()+1);
|
||||||
dlgWaiting->setDetail(diagram->title());
|
dlgWaiting->setDetail(diagram->title());
|
||||||
}
|
}
|
||||||
diagram->refreshContents();
|
diagram->refreshContents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -509,10 +509,10 @@ void QETProject::setDefaultTitleBlockProperties(const TitleBlockProperties &titl
|
|||||||
case QET::Common :
|
case QET::Common :
|
||||||
collection = QETApp::commonTitleBlockTemplatesCollection();
|
collection = QETApp::commonTitleBlockTemplatesCollection();
|
||||||
break;
|
break;
|
||||||
case QET::Company :
|
case QET::Company :
|
||||||
// collection = QETApp::companyTitleBlockTemplatesCollection();
|
// collection = QETApp::companyTitleBlockTemplatesCollection();
|
||||||
break;
|
break;
|
||||||
case QET::Custom :
|
case QET::Custom :
|
||||||
collection = QETApp::customTitleBlockTemplatesCollection();
|
collection = QETApp::customTitleBlockTemplatesCollection();
|
||||||
break;
|
break;
|
||||||
case QET::Embedded :
|
case QET::Embedded :
|
||||||
@ -919,7 +919,7 @@ QDomDocument QETProject::toXml()
|
|||||||
// racine du projet
|
// racine du projet
|
||||||
QDomDocument xml_doc;
|
QDomDocument xml_doc;
|
||||||
QDomElement project_root = xml_doc.createElement("project");
|
QDomElement project_root = xml_doc.createElement("project");
|
||||||
QetVersion::toXmlAttribute(project_root);
|
QetVersion::toXmlAttribute(project_root);
|
||||||
if (project_title_.isEmpty())
|
if (project_title_.isEmpty())
|
||||||
{
|
{
|
||||||
// if project_title_is Empty add title from m_file_path
|
// if project_title_is Empty add title from m_file_path
|
||||||
@ -1349,10 +1349,10 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
if (root_elmt.tagName() == QLatin1String("project"))
|
if (root_elmt.tagName() == QLatin1String("project"))
|
||||||
{
|
{
|
||||||
//Normal opening mode
|
//Normal opening mode
|
||||||
m_project_qet_version = QetVersion::fromXmlAttribute(root_elmt);
|
m_project_qet_version = QetVersion::fromXmlAttribute(root_elmt);
|
||||||
if (!m_project_qet_version.isNull())
|
if (!m_project_qet_version.isNull())
|
||||||
{
|
{
|
||||||
if (QetVersion::currentVersion() < m_project_qet_version)
|
if (QetVersion::currentVersion() < m_project_qet_version)
|
||||||
{
|
{
|
||||||
int ret = QET::QetMessageBox::warning(
|
int ret = QET::QetMessageBox::warning(
|
||||||
nullptr,
|
nullptr,
|
||||||
@ -1362,7 +1362,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
"\n qui est ultérieure à votre version !"
|
"\n qui est ultérieure à votre version !"
|
||||||
" \n"
|
" \n"
|
||||||
"Vous utilisez actuellement QElectroTech en version %2")
|
"Vous utilisez actuellement QElectroTech en version %2")
|
||||||
.arg(root_elmt.attribute(QStringLiteral("version")), QetVersion::currentVersion().toString() +
|
.arg(root_elmt.attribute(QStringLiteral("version")), QetVersion::currentVersion().toString() +
|
||||||
tr(".\n Il est alors possible que l'ouverture de tout ou partie de ce "
|
tr(".\n Il est alors possible que l'ouverture de tout ou partie de ce "
|
||||||
"document échoue.\n"
|
"document échoue.\n"
|
||||||
"Que désirez vous faire ?"),
|
"Que désirez vous faire ?"),
|
||||||
@ -1379,14 +1379,14 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
|
|
||||||
//Since QElectrotech 0.9 the compatibility with project made with
|
//Since QElectrotech 0.9 the compatibility with project made with
|
||||||
//Qet 0.6 or lower is break;
|
//Qet 0.6 or lower is break;
|
||||||
if (m_project_qet_version <= QetVersion::versionZeroDotSix())
|
if (m_project_qet_version <= QetVersion::versionZeroDotSix())
|
||||||
{
|
{
|
||||||
auto ret = QET::QetMessageBox::warning(
|
auto ret = QET::QetMessageBox::warning(
|
||||||
nullptr,
|
nullptr,
|
||||||
tr("Avertissement ", "message box title"),
|
tr("Avertissement ", "message box title"),
|
||||||
tr("Le projet que vous tentez d'ouvrir est partiellement "
|
tr("Le projet que vous tentez d'ouvrir est partiellement "
|
||||||
"compatible avec votre version %1 de QElectroTech.\n")
|
"compatible avec votre version %1 de QElectroTech.\n")
|
||||||
.arg(QetVersion::currentVersion().toString()) +
|
.arg(QetVersion::currentVersion().toString()) +
|
||||||
tr("Afin de le rendre totalement compatible veuillez ouvrir ce même projet "
|
tr("Afin de le rendre totalement compatible veuillez ouvrir ce même projet "
|
||||||
"avec la version 0.8, ou 0.80 de QElectroTech et sauvegarder le projet "
|
"avec la version 0.8, ou 0.80 de QElectroTech et sauvegarder le projet "
|
||||||
"et l'ouvrir à nouveau avec cette version.\n"
|
"et l'ouvrir à nouveau avec cette version.\n"
|
||||||
@ -1429,8 +1429,8 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
//Load the terminal strip
|
//Load the terminal strip
|
||||||
readTerminalStripXml(xml_project);
|
readTerminalStripXml(xml_project);
|
||||||
|
|
||||||
//Now that all are loaded we refresh content of the project.
|
//Now that all are loaded we refresh content of the project.
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
|
|
||||||
m_data_base.blockSignals(false);
|
m_data_base.blockSignals(false);
|
||||||
|
@ -89,7 +89,7 @@ class QETProject : public QObject
|
|||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
ProjectPropertiesHandler& projectPropertiesHandler();
|
ProjectPropertiesHandler& projectPropertiesHandler();
|
||||||
projectDataBase *dataBase();
|
projectDataBase *dataBase();
|
||||||
QUuid uuid() const;
|
QUuid uuid() const;
|
||||||
ProjectState state() const;
|
ProjectState state() const;
|
||||||
@ -238,7 +238,7 @@ class QETProject : public QObject
|
|||||||
void writeBackup();
|
void writeBackup();
|
||||||
void init();
|
void init();
|
||||||
ProjectState openFile(QFile *file);
|
ProjectState openFile(QFile *file);
|
||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
@ -296,7 +296,7 @@ class QETProject : public QObject
|
|||||||
projectDataBase m_data_base;
|
projectDataBase m_data_base;
|
||||||
QVector<TerminalStrip *> m_terminal_strip_vector;
|
QVector<TerminalStrip *> m_terminal_strip_vector;
|
||||||
|
|
||||||
ProjectPropertiesHandler m_project_properties_handler;
|
ProjectPropertiesHandler m_project_properties_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QETProject *)
|
Q_DECLARE_METATYPE(QETProject *)
|
||||||
|
@ -1,85 +1,85 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2024 The QElectroTech Team
|
Copyright 2006-2024 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "qetversion.h"
|
#include "qetversion.h"
|
||||||
|
|
||||||
namespace QetVersion
|
namespace QetVersion
|
||||||
{
|
{
|
||||||
QetVersion::VersionType VERSION_TYPE = QetVersion::dev;
|
QetVersion::VersionType VERSION_TYPE = QetVersion::dev;
|
||||||
|
|
||||||
QVersionNumber currentVersion()
|
QVersionNumber currentVersion()
|
||||||
{
|
{
|
||||||
return QVersionNumber{ 0, 100, 0 };
|
return QVersionNumber{ 0, 100, 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
QString displayedVersion()
|
QString displayedVersion()
|
||||||
{
|
{
|
||||||
auto str = currentVersion().toString();
|
auto str = currentVersion().toString();
|
||||||
|
|
||||||
switch (VERSION_TYPE) {
|
switch (VERSION_TYPE) {
|
||||||
case dev:
|
case dev:
|
||||||
str.append(QStringLiteral("-dev"));
|
str.append(QStringLiteral("-dev"));
|
||||||
break;
|
break;
|
||||||
case alpha1:
|
case alpha1:
|
||||||
str.append(QStringLiteral("-alpha 1 "));
|
str.append(QStringLiteral("-alpha 1 "));
|
||||||
break;
|
break;
|
||||||
case alpha2:
|
case alpha2:
|
||||||
str.append(QStringLiteral("-alpha 2 "));
|
str.append(QStringLiteral("-alpha 2 "));
|
||||||
break;
|
break;
|
||||||
case alpha3:
|
case alpha3:
|
||||||
str.append(QStringLiteral("-alpha 3 "));
|
str.append(QStringLiteral("-alpha 3 "));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief toXmlAttribute
|
* @brief toXmlAttribute
|
||||||
* Write @a version as an attribute of @a xml
|
* Write @a version as an attribute of @a xml
|
||||||
* @param xml
|
* @param xml
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
void toXmlAttribute(QDomElement &xml)
|
void toXmlAttribute(QDomElement &xml)
|
||||||
{
|
{
|
||||||
xml.setAttribute(QStringLiteral("version"), currentVersion().toString());
|
xml.setAttribute(QStringLiteral("version"), currentVersion().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief fromXmlAttribute
|
* @brief fromXmlAttribute
|
||||||
* Read and return a QVersionNumber
|
* Read and return a QVersionNumber
|
||||||
* stored as attribute of @a xml
|
* stored as attribute of @a xml
|
||||||
* @param xml
|
* @param xml
|
||||||
* @return the version stored in @a xml.
|
* @return the version stored in @a xml.
|
||||||
* Note that the returned version can be null
|
* Note that the returned version can be null
|
||||||
*/
|
*/
|
||||||
QVersionNumber fromXmlAttribute(const QDomElement &xml)
|
QVersionNumber fromXmlAttribute(const QDomElement &xml)
|
||||||
{
|
{
|
||||||
if (xml.hasAttribute(QStringLiteral("version"))) {
|
if (xml.hasAttribute(QStringLiteral("version"))) {
|
||||||
return QVersionNumber::fromString(xml.attribute(QStringLiteral("version")));
|
return QVersionNumber::fromString(xml.attribute(QStringLiteral("version")));
|
||||||
} else {
|
} else {
|
||||||
return QVersionNumber{};
|
return QVersionNumber{};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVersionNumber versionZeroDotSix()
|
QVersionNumber versionZeroDotSix()
|
||||||
{
|
{
|
||||||
return QVersionNumber{ 0, 60 };
|
return QVersionNumber{ 0, 60 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2024 The QElectroTech Team
|
Copyright 2006-2024 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef QETVERSION_H
|
#ifndef QETVERSION_H
|
||||||
#define QETVERSION_H
|
#define QETVERSION_H
|
||||||
@ -23,21 +23,21 @@
|
|||||||
|
|
||||||
namespace QetVersion
|
namespace QetVersion
|
||||||
{
|
{
|
||||||
enum VersionType {
|
enum VersionType {
|
||||||
dev = 0,
|
dev = 0,
|
||||||
alpha1 = 1,
|
alpha1 = 1,
|
||||||
alpha2 = 2,
|
alpha2 = 2,
|
||||||
alpha3 = 3,
|
alpha3 = 3,
|
||||||
stable = 4
|
stable = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
QVersionNumber currentVersion();
|
QVersionNumber currentVersion();
|
||||||
QString displayedVersion();
|
QString displayedVersion();
|
||||||
|
|
||||||
QVersionNumber versionZeroDotSix();
|
QVersionNumber versionZeroDotSix();
|
||||||
|
|
||||||
void toXmlAttribute(QDomElement &xml);
|
void toXmlAttribute(QDomElement &xml);
|
||||||
QVersionNumber fromXmlAttribute(const QDomElement &xml);
|
QVersionNumber fromXmlAttribute(const QDomElement &xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // QETVERSION_H
|
#endif // QETVERSION_H
|
||||||
|
@ -631,28 +631,28 @@ bool boolFromString(const QString &value, bool default_value, bool *conv_ok)
|
|||||||
|
|
||||||
PropertyFlags debugReadXml(PropertyFlags flag, const QDomElement &e, const QString& attribute_name, const QString& attr, const QString& type)
|
PropertyFlags debugReadXml(PropertyFlags flag, const QDomElement &e, const QString& attribute_name, const QString& attr, const QString& type)
|
||||||
{
|
{
|
||||||
if (flag == QETXML::PropertyFlags::NoValidConversion)
|
if (flag == QETXML::PropertyFlags::NoValidConversion)
|
||||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << type << ". value: " << attr;
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << type << ". value: " << attr;
|
||||||
|
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement createXmlProperty(const QString& name, const QString value) {
|
QDomElement createXmlProperty(const QString& name, const QString value) {
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", stringS);
|
p.setAttribute("type", stringS);
|
||||||
p.setAttribute("value", value);
|
p.setAttribute("value", value);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement createXmlProperty(const QString& name, const char* value) {
|
QDomElement createXmlProperty(const QString& name, const char* value) {
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", stringS);
|
p.setAttribute("type", stringS);
|
||||||
p.setAttribute("value", value);
|
p.setAttribute("value", value);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -665,48 +665,48 @@ QDomElement createXmlProperty(const QString& name, const char* value) {
|
|||||||
* \p entier is not valid and the return value is False
|
* \p entier is not valid and the return value is False
|
||||||
*/
|
*/
|
||||||
QDomElement createXmlProperty(const QString& name, const int value) {
|
QDomElement createXmlProperty(const QString& name, const int value) {
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", integerS);
|
p.setAttribute("type", integerS);
|
||||||
p.setAttribute("value", QString::number(value));
|
p.setAttribute("value", QString::number(value));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement createXmlProperty(const QString& name, const double value) {
|
QDomElement createXmlProperty(const QString& name, const double value) {
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", doubleS);
|
p.setAttribute("type", doubleS);
|
||||||
p.setAttribute("value", QString::number(value));
|
p.setAttribute("value", QString::number(value));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement createXmlProperty(const QString& name, const bool value) {
|
QDomElement createXmlProperty(const QString& name, const bool value) {
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", boolS);
|
p.setAttribute("type", boolS);
|
||||||
p.setAttribute("value", QString::number(value));
|
p.setAttribute("value", QString::number(value));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement createXmlProperty(const QString& name, const QUuid value) {
|
QDomElement createXmlProperty(const QString& name, const QUuid value) {
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", uuidS);
|
p.setAttribute("type", uuidS);
|
||||||
p.setAttribute("value", value.toString());
|
p.setAttribute("value", value.toString());
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement createXmlProperty(const QString& name, const QColor value) {
|
QDomElement createXmlProperty(const QString& name, const QColor value) {
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", colorS);
|
p.setAttribute("type", colorS);
|
||||||
p.setAttribute("value", value.name());
|
p.setAttribute("value", value.name());
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -720,159 +720,159 @@ QDomElement createXmlProperty(const QString& name, const QColor value) {
|
|||||||
*/
|
*/
|
||||||
PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier) {
|
PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, integerS, &attr)) {
|
if (!attribute(e, attribute_name, integerS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
return debugReadXml(propertyInteger(attr, entier), e, attribute_name, attr, integerS);
|
return debugReadXml(propertyInteger(attr, entier), e, attribute_name, attr, integerS);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyFlags propertyInteger(const QString& value, int* entier) {
|
PropertyFlags propertyInteger(const QString& value, int* entier) {
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
bool ok;
|
bool ok;
|
||||||
int tmp = value.toInt(&ok);
|
int tmp = value.toInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return QETXML::PropertyFlags::NoValidConversion;
|
return QETXML::PropertyFlags::NoValidConversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entier != nullptr)
|
if (entier != nullptr)
|
||||||
*entier = tmp;
|
*entier = tmp;
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel) {
|
PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, doubleS, &attr)) {
|
if (!attribute(e, attribute_name, doubleS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
return debugReadXml(propertyDouble(attr, reel), e, attribute_name, attr, doubleS);
|
return debugReadXml(propertyDouble(attr, reel), e, attribute_name, attr, doubleS);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyFlags propertyDouble(const QString& value, double* reel)
|
PropertyFlags propertyDouble(const QString& value, double* reel)
|
||||||
{
|
{
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
bool ok;
|
bool ok;
|
||||||
double tmp = value.toDouble(&ok);
|
double tmp = value.toDouble(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return QETXML::PropertyFlags::NoValidConversion;
|
return QETXML::PropertyFlags::NoValidConversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reel != nullptr)
|
if (reel != nullptr)
|
||||||
*reel = tmp;
|
*reel = tmp;
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean) {
|
PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, boolS, &attr)) {
|
if (!attribute(e, attribute_name, boolS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
return debugReadXml(propertyBool(attr, boolean), e, attribute_name, attr, boolS);
|
return debugReadXml(propertyBool(attr, boolean), e, attribute_name, attr, boolS);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyFlags propertyBool(const QString& value, bool* boolean)
|
PropertyFlags propertyBool(const QString& value, bool* boolean)
|
||||||
{
|
{
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
bool ok;
|
bool ok;
|
||||||
bool tmp = value.toInt(&ok);
|
bool tmp = value.toInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
if (value == "true" || value == "1")
|
if (value == "true" || value == "1")
|
||||||
tmp = true;
|
tmp = true;
|
||||||
else if (value == "false" || value == "0")
|
else if (value == "false" || value == "0")
|
||||||
tmp = false;
|
tmp = false;
|
||||||
else {
|
else {
|
||||||
return QETXML::PropertyFlags::NoValidConversion;
|
return QETXML::PropertyFlags::NoValidConversion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boolean != nullptr)
|
if (boolean != nullptr)
|
||||||
*boolean = tmp;
|
*boolean = tmp;
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color) {
|
PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, colorS, &attr)) {
|
if (!attribute(e, attribute_name, colorS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
return debugReadXml(propertyColor(attr, color), e, attribute_name, attr, colorS);
|
return debugReadXml(propertyColor(attr, color), e, attribute_name, attr, colorS);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyFlags propertyColor(const QString& value, QColor* color)
|
PropertyFlags propertyColor(const QString& value, QColor* color)
|
||||||
{
|
{
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
QColor tmp = QColor(value);
|
QColor tmp = QColor(value);
|
||||||
if (!tmp.isValid()) {
|
if (!tmp.isValid()) {
|
||||||
return QETXML::PropertyFlags::NoValidConversion;
|
return QETXML::PropertyFlags::NoValidConversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color != nullptr)
|
if (color != nullptr)
|
||||||
*color = tmp;
|
*color = tmp;
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid) {
|
PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid) {
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, uuidS, &attr)) {
|
if (!attribute(e, attribute_name, uuidS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
return debugReadXml(propertyUuid(attr, uuid), e, attribute_name, attr, uuidS);
|
return debugReadXml(propertyUuid(attr, uuid), e, attribute_name, attr, uuidS);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyFlags propertyUuid(const QString& value, QUuid* uuid)
|
PropertyFlags propertyUuid(const QString& value, QUuid* uuid)
|
||||||
{
|
{
|
||||||
if (QUuid(value).isNull()){
|
if (QUuid(value).isNull()){
|
||||||
return QETXML::PropertyFlags::NoValidConversion;
|
return QETXML::PropertyFlags::NoValidConversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (uuid != nullptr)
|
if (uuid != nullptr)
|
||||||
*uuid = QUuid(value);
|
*uuid = QUuid(value);
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string) {
|
PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
if (!attribute(e, attribute_name, stringS, &attr)) {
|
if (!attribute(e, attribute_name, stringS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
if (string != nullptr)
|
if (string != nullptr)
|
||||||
*string = attr;
|
*string = attr;
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement property(const QDomElement& e, const QString& name) {
|
QDomElement property(const QDomElement& e, const QString& name) {
|
||||||
for (int i=0; i < e.childNodes().count(); i++) {
|
for (int i=0; i < e.childNodes().count(); i++) {
|
||||||
QDomElement child = e.childNodes().at(i).toElement();
|
QDomElement child = e.childNodes().at(i).toElement();
|
||||||
if (!validXmlProperty(child))
|
if (!validXmlProperty(child))
|
||||||
continue; // there might also non property childs
|
continue; // there might also non property childs
|
||||||
|
|
||||||
if (child.attribute("name") == name)
|
if (child.attribute("name") == name)
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
return QDomElement();
|
return QDomElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -885,40 +885,40 @@ QDomElement property(const QDomElement& e, const QString& name) {
|
|||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr) {
|
bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr) {
|
||||||
QDomElement p = property(e, attribute_name);
|
QDomElement p = property(e, attribute_name);
|
||||||
if (p.isNull()) {
|
if (p.isNull()) {
|
||||||
// check if legacy property is available,
|
// check if legacy property is available,
|
||||||
// where the property is inside the element as attribute
|
// where the property is inside the element as attribute
|
||||||
if (!e.hasAttribute(attribute_name)) {
|
if (!e.hasAttribute(attribute_name)) {
|
||||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "Property " << attribute_name << "is not available";
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "Property " << attribute_name << "is not available";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*attr = e.attribute(attribute_name);
|
*attr = e.attribute(attribute_name);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (p.attribute("type") != type) {
|
if (p.attribute("type") != type) {
|
||||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ", Property: " << attribute_name << "(" << p.attribute("type") << ") has not type: " << type;
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ", Property: " << attribute_name << "(" << p.attribute("type") << ") has not type: " << type;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*attr = p.attribute("value");
|
*attr = p.attribute("value");
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool validXmlProperty(const QDomElement& e) {
|
bool validXmlProperty(const QDomElement& e) {
|
||||||
if (!e.hasAttribute("name"))
|
if (!e.hasAttribute("name"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!e.hasAttribute("type"))
|
if (!e.hasAttribute("type"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!e.hasAttribute("value"))
|
if (!e.hasAttribute("value"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -932,25 +932,25 @@ bool validXmlProperty(const QDomElement& e) {
|
|||||||
*/
|
*/
|
||||||
QDomElement qGraphicsItemPosToXml(QGraphicsItem *item, QDomDocument &document)
|
QDomElement qGraphicsItemPosToXml(QGraphicsItem *item, QDomDocument &document)
|
||||||
{
|
{
|
||||||
auto dom_pos = document.createElement(QStringLiteral("pos"));
|
auto dom_pos = document.createElement(QStringLiteral("pos"));
|
||||||
dom_pos.setAttribute(QStringLiteral("x"), QString::number(item->pos().x()));
|
dom_pos.setAttribute(QStringLiteral("x"), QString::number(item->pos().x()));
|
||||||
dom_pos.setAttribute(QStringLiteral("y"), QString::number(item->pos().y()));
|
dom_pos.setAttribute(QStringLiteral("y"), QString::number(item->pos().y()));
|
||||||
dom_pos.setAttribute(QStringLiteral("z"), QString::number(item->zValue()));
|
dom_pos.setAttribute(QStringLiteral("z"), QString::number(item->zValue()));
|
||||||
|
|
||||||
return dom_pos;
|
return dom_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qGraphicsItemPosFromXml(QGraphicsItem *item, const QDomElement &xml_elmt)
|
bool qGraphicsItemPosFromXml(QGraphicsItem *item, const QDomElement &xml_elmt)
|
||||||
{
|
{
|
||||||
if (xml_elmt.tagName() == QLatin1String("pos"))
|
if (xml_elmt.tagName() == QLatin1String("pos"))
|
||||||
{
|
{
|
||||||
item->setX(xml_elmt.attribute(QStringLiteral("x"), QStringLiteral("0")).toDouble());
|
item->setX(xml_elmt.attribute(QStringLiteral("x"), QStringLiteral("0")).toDouble());
|
||||||
item->setY(xml_elmt.attribute(QStringLiteral("y"), QStringLiteral("0")).toDouble());
|
item->setY(xml_elmt.attribute(QStringLiteral("y"), QStringLiteral("0")).toDouble());
|
||||||
item->setZValue(xml_elmt.attribute(QStringLiteral("z"), QStringLiteral("0")).toInt());
|
item->setZValue(xml_elmt.attribute(QStringLiteral("z"), QStringLiteral("0")).toInt());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -91,61 +91,61 @@ namespace QETXML
|
|||||||
QVector<QDomElement> findInDomElement(const QDomElement &dom_elmt,
|
QVector<QDomElement> findInDomElement(const QDomElement &dom_elmt,
|
||||||
const QString &tag_name);
|
const QString &tag_name);
|
||||||
|
|
||||||
QDomElement qGraphicsItemPosToXml(QGraphicsItem *item, QDomDocument &document);
|
QDomElement qGraphicsItemPosToXml(QGraphicsItem *item, QDomDocument &document);
|
||||||
bool qGraphicsItemPosFromXml(QGraphicsItem *item, const QDomElement &xml_elmt);
|
bool qGraphicsItemPosFromXml(QGraphicsItem *item, const QDomElement &xml_elmt);
|
||||||
|
|
||||||
QString boolToString(bool value);
|
QString boolToString(bool value);
|
||||||
bool boolFromString(const QString &value,
|
bool boolFromString(const QString &value,
|
||||||
bool default_value = true,
|
bool default_value = true,
|
||||||
bool *conv_ok = nullptr);
|
bool *conv_ok = nullptr);
|
||||||
|
|
||||||
const QString integerS = "int";
|
const QString integerS = "int";
|
||||||
const QString doubleS = "double";
|
const QString doubleS = "double";
|
||||||
const QString boolS = "bool";
|
const QString boolS = "bool";
|
||||||
const QString stringS = "string";
|
const QString stringS = "string";
|
||||||
const QString uuidS = "uuid";
|
const QString uuidS = "uuid";
|
||||||
const QString colorS = "color";
|
const QString colorS = "color";
|
||||||
|
|
||||||
enum PropertyFlags {
|
enum PropertyFlags {
|
||||||
Success = 0,
|
Success = 0,
|
||||||
NotFound = 1,
|
NotFound = 1,
|
||||||
NoValidConversion = 2,
|
NoValidConversion = 2,
|
||||||
// = 4
|
// = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Use this functions to add properties to the xml document
|
* Use this functions to add properties to the xml document
|
||||||
*/
|
*/
|
||||||
QDomElement createXmlProperty(const QString& name, const QString value);
|
QDomElement createXmlProperty(const QString& name, const QString value);
|
||||||
QDomElement createXmlProperty(const QString& name, const char* value);
|
QDomElement createXmlProperty(const QString& name, const char* value);
|
||||||
QDomElement createXmlProperty(const QString& name, const int value);
|
QDomElement createXmlProperty(const QString& name, const int value);
|
||||||
QDomElement createXmlProperty(const QString& name, const double value);
|
QDomElement createXmlProperty(const QString& name, const double value);
|
||||||
QDomElement createXmlProperty(const QString& name, const bool value);
|
QDomElement createXmlProperty(const QString& name, const bool value);
|
||||||
QDomElement createXmlProperty(const QString& name, const QUuid value);
|
QDomElement createXmlProperty(const QString& name, const QUuid value);
|
||||||
QDomElement createXmlProperty(const QString& name, const QColor value);
|
QDomElement createXmlProperty(const QString& name, const QColor value);
|
||||||
|
|
||||||
PropertyFlags propertyInteger(const QString& value, int* entry = nullptr);
|
PropertyFlags propertyInteger(const QString& value, int* entry = nullptr);
|
||||||
PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
|
PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
|
||||||
PropertyFlags propertyDouble(const QString& value, double* entry = nullptr);
|
PropertyFlags propertyDouble(const QString& value, double* entry = nullptr);
|
||||||
PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
|
PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
|
||||||
PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr);
|
PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr);
|
||||||
PropertyFlags propertyBool(const QString& value, bool* entry = nullptr);
|
PropertyFlags propertyBool(const QString& value, bool* entry = nullptr);
|
||||||
PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr);
|
PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr);
|
||||||
PropertyFlags propertyUuid(const QString& value, QUuid* entry = nullptr);
|
PropertyFlags propertyUuid(const QString& value, QUuid* entry = nullptr);
|
||||||
PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr);
|
PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr);
|
||||||
PropertyFlags propertyColor(const QString& value, QColor* entry = nullptr);
|
PropertyFlags propertyColor(const QString& value, QColor* entry = nullptr);
|
||||||
PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
|
PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
|
||||||
|
|
||||||
QDomElement property(const QDomElement& e, const QString& name);
|
QDomElement property(const QDomElement& e, const QString& name);
|
||||||
bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr);
|
bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief PropertiesInterface::validXmlProperty
|
* \brief PropertiesInterface::validXmlProperty
|
||||||
* Check if the Xml element contains the needed fields
|
* Check if the Xml element contains the needed fields
|
||||||
* \param e Xml Property
|
* \param e Xml Property
|
||||||
* \return True if name, type, value attribute are available, else false
|
* \return True if name, type, value attribute are available, else false
|
||||||
*/
|
*/
|
||||||
bool validXmlProperty(const QDomElement& e);
|
bool validXmlProperty(const QDomElement& e);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // QETXML_H
|
#endif // QETXML_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user