mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-21 20:49:59 +01:00
Merge branch 'master' of ssh://git.tuxfamily.org/gitroot/qet/qet
This commit is contained in:
BIN
lang/qet_de.qm
BIN
lang/qet_de.qm
Binary file not shown.
415
lang/qet_de.ts
415
lang/qet_de.ts
File diff suppressed because it is too large
Load Diff
@@ -76,6 +76,7 @@ include(sources/QWidgetAnimation/QWidgetAnimation.pri)
|
|||||||
DEFINES += QAPPLICATION_CLASS=QApplication
|
DEFINES += QAPPLICATION_CLASS=QApplication
|
||||||
DEFINES += QT_MESSAGELOGCONTEXT
|
DEFINES += QT_MESSAGELOGCONTEXT
|
||||||
DEFINES += GIT_COMMIT_SHA="\\\"$(shell git -C \""$$_PRO_FILE_PWD_"\" rev-parse --verify HEAD)\\\""
|
DEFINES += GIT_COMMIT_SHA="\\\"$(shell git -C \""$$_PRO_FILE_PWD_"\" rev-parse --verify HEAD)\\\""
|
||||||
|
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
|
||||||
|
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
DEPENDPATH += .
|
DEPENDPATH += .
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define ELEMENTSCOLLECTIONMODEL2_H
|
#define ELEMENTSCOLLECTIONMODEL2_H
|
||||||
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
#include <QHash>
|
||||||
#include "elementslocation.h"
|
#include "elementslocation.h"
|
||||||
|
|
||||||
class XmlProjectElementCollectionItem;
|
class XmlProjectElementCollectionItem;
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,25 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 NAMELISTWIDGET_H
|
#ifndef NAMELISTWIDGET_H
|
||||||
#define NAMELISTWIDGET_H
|
#define NAMELISTWIDGET_H
|
||||||
|
|
||||||
#include "nameslist.h"
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
|
#include "nameslist.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class NameListWidget;
|
class NameListWidget;
|
||||||
@@ -32,27 +34,27 @@ namespace Ui {
|
|||||||
class NameListWidget : public QWidget
|
class NameListWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NameListWidget(QWidget *parent = nullptr);
|
explicit NameListWidget(QWidget *parent = nullptr);
|
||||||
~NameListWidget();
|
~NameListWidget();
|
||||||
|
|
||||||
void addLine();
|
void addLine();
|
||||||
void setNames (const NamesList &name_list);
|
void setNames (const NamesList &name_list);
|
||||||
NamesList names() const;
|
NamesList names() const;
|
||||||
void setReadOnly(bool ro);
|
void setReadOnly(bool ro);
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
void setClipboardValue (QHash <QString, QString> value);
|
void setClipboardValue (QHash <QString, QString> value);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_clipboard_cb_activated(int index);
|
void on_m_clipboard_cb_activated(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clean();
|
void clean();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::NameListWidget *ui;
|
Ui::NameListWidget *ui;
|
||||||
bool m_read_only = false;
|
bool m_read_only = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NAMELISTWIDGET_H
|
#endif // NAMELISTWIDGET_H
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QLineF>
|
#include <QLineF>
|
||||||
#include <QColor>
|
|
||||||
#include <QPolygonF>
|
#include <QPolygonF>
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|||||||
@@ -16,9 +16,10 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "numerotationcontext.h"
|
#include "numerotationcontext.h"
|
||||||
|
#include "qet.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "qet.h"
|
#include <QRegularExpression>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructor
|
Constructor
|
||||||
@@ -141,7 +142,7 @@ QString NumerotationContext::validRegExpNumber() const
|
|||||||
*/
|
*/
|
||||||
bool NumerotationContext::keyIsAcceptable(const QString &type) const
|
bool NumerotationContext::keyIsAcceptable(const QString &type) const
|
||||||
{
|
{
|
||||||
return (type.contains(QRegExp(validRegExpNum())));
|
return (type.contains(QRegularExpression(validRegExpNum())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,7 +151,7 @@ bool NumerotationContext::keyIsAcceptable(const QString &type) const
|
|||||||
*/
|
*/
|
||||||
bool NumerotationContext::keyIsNumber(const QString &type) const
|
bool NumerotationContext::keyIsNumber(const QString &type) const
|
||||||
{
|
{
|
||||||
return (type.contains(QRegExp(validRegExpNumber())));
|
return (type.contains(QRegularExpression(validRegExpNumber())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 <QRegExp>
|
|
||||||
#include "numparteditorw.h"
|
#include "numparteditorw.h"
|
||||||
#include "ui_numparteditorw.h"
|
#include "ui_numparteditorw.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 <QPainter>
|
#include <QPainter>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
#include "titleblocktemplate.h"
|
#include "titleblocktemplate.h"
|
||||||
#include "titleblocktemplaterenderer.h"
|
#include "titleblocktemplaterenderer.h"
|
||||||
#include "bordertitleblock.h"
|
#include "bordertitleblock.h"
|
||||||
@@ -49,18 +51,19 @@ BorderTitleBlock::BorderTitleBlock(QObject *parent) :
|
|||||||
// at first, the internal titleblock template renderer uses the default titleblock template
|
// at first, the internal titleblock template renderer uses the default titleblock template
|
||||||
m_titleblock_template_renderer = new TitleBlockTemplateRenderer(this);
|
m_titleblock_template_renderer = new TitleBlockTemplateRenderer(this);
|
||||||
m_titleblock_template_renderer -> setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
|
m_titleblock_template_renderer -> setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
|
||||||
|
|
||||||
// disable the QPicture-based cache from Qt 4.8 to avoid rendering errors and crashes
|
// disable the QPicture-based cache from Qt 4.8 to avoid rendering errors and crashes
|
||||||
if (!QRegExp("4\\.[0-7]\\.").exactMatch(qVersion())) {
|
#if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) // ### Qt 6: remove
|
||||||
m_titleblock_template_renderer -> setUseCache(false);
|
#else
|
||||||
}
|
m_titleblock_template_renderer -> setUseCache(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
// dimensions par defaut du schema
|
// dimensions par defaut du schema
|
||||||
importBorder(BorderProperties());
|
importBorder(BorderProperties());
|
||||||
|
|
||||||
// contenu par defaut du cartouche
|
// contenu par defaut du cartouche
|
||||||
importTitleBlock(TitleBlockProperties());
|
importTitleBlock(TitleBlockProperties());
|
||||||
|
|
||||||
display_titleblock_ = true;
|
display_titleblock_ = true;
|
||||||
display_border_ = true;
|
display_border_ = true;
|
||||||
setFolioData(1, 1);
|
setFolioData(1, 1);
|
||||||
@@ -227,11 +230,11 @@ void BorderTitleBlock::borderToXml(QDomElement &xml_elmt) {
|
|||||||
xml_elmt.setAttribute("cols", columnsCount());
|
xml_elmt.setAttribute("cols", columnsCount());
|
||||||
xml_elmt.setAttribute("colsize", QString("%1").arg(columnsWidth()));
|
xml_elmt.setAttribute("colsize", QString("%1").arg(columnsWidth()));
|
||||||
xml_elmt.setAttribute("displaycols", columnsAreDisplayed() ? "true" : "false");
|
xml_elmt.setAttribute("displaycols", columnsAreDisplayed() ? "true" : "false");
|
||||||
|
|
||||||
xml_elmt.setAttribute("rows", rowsCount());
|
xml_elmt.setAttribute("rows", rowsCount());
|
||||||
xml_elmt.setAttribute("rowsize", QString("%1").arg(rowsHeight()));
|
xml_elmt.setAttribute("rowsize", QString("%1").arg(rowsHeight()));
|
||||||
xml_elmt.setAttribute("displayrows", rowsAreDisplayed() ? "true" : "false");
|
xml_elmt.setAttribute("displayrows", rowsAreDisplayed() ? "true" : "false");
|
||||||
|
|
||||||
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
||||||
xml_elmt.setAttribute("height", QString("%1").arg(diagramHeight()));
|
xml_elmt.setAttribute("height", QString("%1").arg(diagramHeight()));
|
||||||
}
|
}
|
||||||
@@ -246,18 +249,18 @@ void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
|
|||||||
// columns count
|
// columns count
|
||||||
int cols_count = xml_elmt.attribute("cols").toInt(&ok);
|
int cols_count = xml_elmt.attribute("cols").toInt(&ok);
|
||||||
if (ok) setColumnsCount(cols_count);
|
if (ok) setColumnsCount(cols_count);
|
||||||
|
|
||||||
// columns width
|
// columns width
|
||||||
double cols_width = xml_elmt.attribute("colsize").toDouble(&ok);
|
double cols_width = xml_elmt.attribute("colsize").toDouble(&ok);
|
||||||
if (ok) setColumnsWidth(cols_width);
|
if (ok) setColumnsWidth(cols_width);
|
||||||
|
|
||||||
// backward compatibility:
|
// backward compatibility:
|
||||||
// diagrams saved with 0.1 version have a "height" attribute
|
// diagrams saved with 0.1 version have a "height" attribute
|
||||||
if (xml_elmt.hasAttribute("rows") && xml_elmt.hasAttribute("rowsize")) {
|
if (xml_elmt.hasAttribute("rows") && xml_elmt.hasAttribute("rowsize")) {
|
||||||
// rows counts
|
// rows counts
|
||||||
int rows_count = xml_elmt.attribute("rows").toInt(&ok);
|
int rows_count = xml_elmt.attribute("rows").toInt(&ok);
|
||||||
if (ok) setRowsCount(rows_count);
|
if (ok) setRowsCount(rows_count);
|
||||||
|
|
||||||
// taille des lignes
|
// taille des lignes
|
||||||
double rows_size = xml_elmt.attribute("rowsize").toDouble(&ok);
|
double rows_size = xml_elmt.attribute("rowsize").toDouble(&ok);
|
||||||
if (ok) setRowsHeight(rows_size);
|
if (ok) setRowsHeight(rows_size);
|
||||||
@@ -266,7 +269,7 @@ void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
|
|||||||
double height = xml_elmt.attribute("height").toDouble(&ok);
|
double height = xml_elmt.attribute("height").toDouble(&ok);
|
||||||
if (ok) setDiagramHeight(height);
|
if (ok) setDiagramHeight(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rows and columns display
|
// rows and columns display
|
||||||
displayColumns(xml_elmt.attribute("displaycols") != "false");
|
displayColumns(xml_elmt.attribute("displaycols") != "false");
|
||||||
displayRows(xml_elmt.attribute("displayrows") != "false");
|
displayRows(xml_elmt.attribute("displayrows") != "false");
|
||||||
@@ -282,7 +285,7 @@ void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
|
|||||||
TitleBlockProperties BorderTitleBlock::exportTitleBlock()
|
TitleBlockProperties BorderTitleBlock::exportTitleBlock()
|
||||||
{
|
{
|
||||||
TitleBlockProperties ip;
|
TitleBlockProperties ip;
|
||||||
|
|
||||||
ip.author = author();
|
ip.author = author();
|
||||||
ip.date = date();
|
ip.date = date();
|
||||||
ip.title = title();
|
ip.title = title();
|
||||||
@@ -297,7 +300,7 @@ TitleBlockProperties BorderTitleBlock::exportTitleBlock()
|
|||||||
ip.auto_page_num = autoPageNum();
|
ip.auto_page_num = autoPageNum();
|
||||||
ip.context = additional_fields_;
|
ip.context = additional_fields_;
|
||||||
ip.collection = QET::QetCollection::Embedded;
|
ip.collection = QET::QetCollection::Embedded;
|
||||||
|
|
||||||
return(ip);
|
return(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +325,7 @@ void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) {
|
|||||||
emit(displayChanged());
|
emit(displayChanged());
|
||||||
}
|
}
|
||||||
additional_fields_ = ip.context;
|
additional_fields_ = ip.context;
|
||||||
|
|
||||||
emit(needFolioData()); // Note: we expect additional data to be provided
|
emit(needFolioData()); // Note: we expect additional data to be provided
|
||||||
// through setFolioData(),
|
// through setFolioData(),
|
||||||
// which in turn calls updateDiagramContextForTitleBlock().
|
// which in turn calls updateDiagramContextForTitleBlock().
|
||||||
@@ -422,7 +425,7 @@ void BorderTitleBlock::titleBlockTemplateRemoved(
|
|||||||
const QString &removed_template_name,
|
const QString &removed_template_name,
|
||||||
const TitleBlockTemplate *new_template) {
|
const TitleBlockTemplate *new_template) {
|
||||||
if (titleBlockTemplateName() != removed_template_name) return;
|
if (titleBlockTemplateName() != removed_template_name) return;
|
||||||
|
|
||||||
if (new_template) {
|
if (new_template) {
|
||||||
setTitleBlockTemplate(new_template);
|
setTitleBlockTemplate(new_template);
|
||||||
} else {
|
} else {
|
||||||
@@ -516,14 +519,14 @@ void BorderTitleBlock::draw(QPainter *painter)
|
|||||||
pen.setCosmetic(true);
|
pen.setCosmetic(true);
|
||||||
painter -> setPen(pen);
|
painter -> setPen(pen);
|
||||||
painter -> setBrush(Qt::NoBrush);
|
painter -> setBrush(Qt::NoBrush);
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
//Draw the borer
|
//Draw the borer
|
||||||
if (display_border_) painter -> drawRect(diagram_rect_);
|
if (display_border_) painter -> drawRect(diagram_rect_);
|
||||||
|
|
||||||
painter -> setFont(QETApp::diagramTextsFont());
|
painter -> setFont(QETApp::diagramTextsFont());
|
||||||
|
|
||||||
//Draw the empty case at the top left of diagram when there is header
|
//Draw the empty case at the top left of diagram when there is header
|
||||||
if (display_border_ && (display_columns_ || display_rows_))
|
if (display_border_ && (display_columns_ || display_rows_))
|
||||||
{
|
{
|
||||||
@@ -535,7 +538,7 @@ void BorderTitleBlock::draw(QPainter *painter)
|
|||||||
);
|
);
|
||||||
painter -> drawRect(first_rectangle);
|
painter -> drawRect(first_rectangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw the nums of columns
|
//Draw the nums of columns
|
||||||
if (display_border_ && display_columns_) {
|
if (display_border_ && display_columns_) {
|
||||||
for (int i = 1 ; i <= columns_count_ ; ++ i) {
|
for (int i = 1 ; i <= columns_count_ ; ++ i) {
|
||||||
@@ -561,7 +564,7 @@ void BorderTitleBlock::draw(QPainter *painter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw the nums of rows
|
//Draw the nums of rows
|
||||||
if (display_border_ && display_rows_) {
|
if (display_border_ && display_rows_) {
|
||||||
QString row_string("A");
|
QString row_string("A");
|
||||||
@@ -584,7 +587,7 @@ void BorderTitleBlock::draw(QPainter *painter)
|
|||||||
row_string = incrementLetters(row_string);
|
row_string = incrementLetters(row_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// render the titleblock, using the TitleBlockTemplate object
|
// render the titleblock, using the TitleBlockTemplate object
|
||||||
if (display_titleblock_) {
|
if (display_titleblock_) {
|
||||||
QRectF tbt_rect = titleBlockRectForQPainter();
|
QRectF tbt_rect = titleBlockRectForQPainter();
|
||||||
@@ -607,7 +610,7 @@ void BorderTitleBlock::draw(QPainter *painter)
|
|||||||
painter -> translate(-tbt_rect.topLeft());
|
painter -> translate(-tbt_rect.topLeft());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
painter -> restore();
|
painter -> restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,18 +649,18 @@ void BorderTitleBlock::drawDxf(
|
|||||||
}
|
}
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
// draw the numbering of the columns
|
// draw the numbering of the columns
|
||||||
// dessine la numerotation des colonnes
|
// dessine la numerotation des colonnes
|
||||||
if (display_border_ &&
|
if (display_border_ &&
|
||||||
display_columns_) {
|
display_columns_) {
|
||||||
int offset = settings.value("border-columns_0", true).toBool() ? -1 : 0;
|
int offset = settings.value("border-columns_0", true).toBool() ? -1 : 0;
|
||||||
for (int i = 1 ; i <= columns_count_ ; ++ i) {
|
for (int i = 1 ; i <= columns_count_ ; ++ i) {
|
||||||
double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale +
|
double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale +
|
||||||
(rows_header_width_ + ((i - 1) *
|
(rows_header_width_ + ((i - 1) *
|
||||||
columns_width_));
|
columns_width_));
|
||||||
double yCoord = Createdxf::sheetHeight
|
double yCoord = Createdxf::sheetHeight
|
||||||
- diagram_rect_.topLeft().y()*Createdxf::yScale
|
- diagram_rect_.topLeft().y()*Createdxf::yScale
|
||||||
- columns_header_height_;
|
- columns_header_height_;
|
||||||
double recWidth = columns_width_;
|
double recWidth = columns_width_;
|
||||||
double recHeight = columns_header_height_;
|
double recHeight = columns_header_height_;
|
||||||
@@ -665,18 +668,18 @@ void BorderTitleBlock::drawDxf(
|
|||||||
recWidth, recHeight, color);
|
recWidth, recHeight, color);
|
||||||
|
|
||||||
Createdxf::drawTextAligned(file_path,
|
Createdxf::drawTextAligned(file_path,
|
||||||
QString::number(i + offset),
|
QString::number(i + offset),
|
||||||
xCoord+recWidth/4,
|
xCoord+recWidth/4,
|
||||||
yCoord + recHeight*0.5,
|
yCoord + recHeight*0.5,
|
||||||
recHeight*0.7,
|
recHeight*0.7,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
2,
|
2,
|
||||||
xCoord+recWidth/2,
|
xCoord+recWidth/2,
|
||||||
1,
|
1,
|
||||||
color);
|
color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw line numbering
|
// draw line numbering
|
||||||
@@ -686,8 +689,8 @@ void BorderTitleBlock::drawDxf(
|
|||||||
for (int i = 1 ; i <= rows_count_ ; ++ i) {
|
for (int i = 1 ; i <= rows_count_ ; ++ i) {
|
||||||
double xCoord = diagram_rect_.topLeft().x()
|
double xCoord = diagram_rect_.topLeft().x()
|
||||||
* Createdxf::xScale;
|
* Createdxf::xScale;
|
||||||
double yCoord = Createdxf::sheetHeight
|
double yCoord = Createdxf::sheetHeight
|
||||||
- diagram_rect_.topLeft().y()
|
- diagram_rect_.topLeft().y()
|
||||||
*Createdxf::yScale
|
*Createdxf::yScale
|
||||||
- (
|
- (
|
||||||
columns_header_height_
|
columns_header_height_
|
||||||
@@ -700,15 +703,15 @@ void BorderTitleBlock::drawDxf(
|
|||||||
recWidth, recHeight, color);
|
recWidth, recHeight, color);
|
||||||
Createdxf::drawTextAligned(file_path,
|
Createdxf::drawTextAligned(file_path,
|
||||||
row_string,
|
row_string,
|
||||||
xCoord+recWidth*0.1,
|
xCoord+recWidth*0.1,
|
||||||
yCoord + recHeight*0.4,
|
yCoord + recHeight*0.4,
|
||||||
recWidth*0.7,
|
recWidth*0.7,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
2,
|
2,
|
||||||
xCoord+recWidth/2,
|
xCoord+recWidth/2,
|
||||||
1,
|
1,
|
||||||
color);
|
color);
|
||||||
row_string = incrementLetters(row_string);
|
row_string = incrementLetters(row_string);
|
||||||
}
|
}
|
||||||
@@ -869,11 +872,11 @@ DiagramPosition BorderTitleBlock::convertPosition(const QPointF &pos)
|
|||||||
QPointF relative_pos = pos - insideBorderRect().topLeft();
|
QPointF relative_pos = pos - insideBorderRect().topLeft();
|
||||||
int row_number = int(ceil(relative_pos.x() / columnsWidth()));
|
int row_number = int(ceil(relative_pos.x() / columnsWidth()));
|
||||||
int column_number = int(ceil(relative_pos.y() / rowsHeight()));
|
int column_number = int(ceil(relative_pos.y() / rowsHeight()));
|
||||||
|
|
||||||
QString letter = "A";
|
QString letter = "A";
|
||||||
for (int i = 1 ; i < column_number ; ++ i)
|
for (int i = 1 ; i < column_number ; ++ i)
|
||||||
letter = incrementLetters(letter);
|
letter = incrementLetters(letter);
|
||||||
|
|
||||||
return(DiagramPosition(letter, row_number));
|
return(DiagramPosition(letter, row_number));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -931,11 +934,14 @@ void BorderTitleBlock::updateDiagramContextForTitleBlock(
|
|||||||
foreach (QString key, additional_fields_.keys()) {
|
foreach (QString key, additional_fields_.keys()) {
|
||||||
context.addValue(key, additional_fields_[key]);
|
context.addValue(key, additional_fields_[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ... overridden by the historical and/or dynamically generated fields
|
// ... overridden by the historical and/or dynamically generated fields
|
||||||
|
QLocale var;
|
||||||
|
var.dateFormat(QLocale::ShortFormat);
|
||||||
context.addValue("author", btb_author_);
|
context.addValue("author", btb_author_);
|
||||||
context.addValue("date", btb_date_.toString(
|
context.addValue(
|
||||||
Qt::SystemLocaleShortDate));
|
"date",
|
||||||
|
QLocale::system().toString(btb_date_, QLocale::ShortFormat));
|
||||||
context.addValue("title", btb_title_);
|
context.addValue("title", btb_title_);
|
||||||
context.addValue("filename", btb_filename_);
|
context.addValue("filename", btb_filename_);
|
||||||
context.addValue("plant", btb_plant_);
|
context.addValue("plant", btb_plant_);
|
||||||
@@ -948,7 +954,7 @@ void BorderTitleBlock::updateDiagramContextForTitleBlock(
|
|||||||
context.addValue("auto_page_num", btb_auto_page_num_);
|
context.addValue("auto_page_num", btb_auto_page_num_);
|
||||||
context.addValue("previous-folio-num", m_previous_folio_num);
|
context.addValue("previous-folio-num", m_previous_folio_num);
|
||||||
context.addValue("next-folio-num", m_next_folio_num);
|
context.addValue("next-folio-num", m_next_folio_num);
|
||||||
|
|
||||||
m_titleblock_template_renderer -> setContext(context);
|
m_titleblock_template_renderer -> setContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1000,12 +1006,12 @@ void BorderTitleBlock::setFolioData(
|
|||||||
const QString& autonum,
|
const QString& autonum,
|
||||||
const DiagramContext &project_properties) {
|
const DiagramContext &project_properties) {
|
||||||
if (index < 1 || total < 1 || index > total) return;
|
if (index < 1 || total < 1 || index > total) return;
|
||||||
|
|
||||||
// memorize information
|
// memorize information
|
||||||
// memorise les informations
|
// memorise les informations
|
||||||
folio_index_ = index;
|
folio_index_ = index;
|
||||||
folio_total_ = total;
|
folio_total_ = total;
|
||||||
|
|
||||||
// regenerate the content of the folio field
|
// regenerate the content of the folio field
|
||||||
// regenere le contenu du champ folio
|
// regenere le contenu du champ folio
|
||||||
btb_final_folio_ = btb_folio_;
|
btb_final_folio_ = btb_folio_;
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
#include <QRegularExpression>
|
||||||
/**
|
/**
|
||||||
Constructeur par defaut
|
Constructeur par defaut
|
||||||
*/
|
*/
|
||||||
@@ -70,7 +70,7 @@ void SingleLineProperties::draw(QPainter *painter,
|
|||||||
const QRectF &rect) {
|
const QRectF &rect) {
|
||||||
// s'il n'y a rien a dessiner, on retourne immediatement
|
// s'il n'y a rien a dessiner, on retourne immediatement
|
||||||
if (!hasNeutral && !hasGround && !phases) return;
|
if (!hasNeutral && !hasGround && !phases) return;
|
||||||
|
|
||||||
// prepare le QPainter
|
// prepare le QPainter
|
||||||
painter -> save();
|
painter -> save();
|
||||||
QPen pen(painter -> pen());
|
QPen pen(painter -> pen());
|
||||||
@@ -80,12 +80,12 @@ void SingleLineProperties::draw(QPainter *painter,
|
|||||||
pen.setWidthF(1);
|
pen.setWidthF(1);
|
||||||
painter -> setPen(pen);
|
painter -> setPen(pen);
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, true);
|
painter -> setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
|
||||||
uint symbols_count = (hasNeutral ? 1 : 0) + (hasGround ? 1 : 0) - (isPen() ? 1 : 0) + phases;
|
uint symbols_count = (hasNeutral ? 1 : 0) + (hasGround ? 1 : 0) - (isPen() ? 1 : 0) + phases;
|
||||||
qreal interleave_base = (direction == QET::Horizontal ? rect.width() : rect.height());
|
qreal interleave_base = (direction == QET::Horizontal ? rect.width() : rect.height());
|
||||||
qreal interleave = interleave_base / (symbols_count + 1);;
|
qreal interleave = interleave_base / (symbols_count + 1);;
|
||||||
qreal symbol_width = interleave_base / 12;
|
qreal symbol_width = interleave_base / 12;
|
||||||
|
|
||||||
for (uint i = 1 ; i <= symbols_count ; ++ i) {
|
for (uint i = 1 ; i <= symbols_count ; ++ i) {
|
||||||
// dessine le tronc du symbole
|
// dessine le tronc du symbole
|
||||||
QPointF symbol_p1, symbol_p2;
|
QPointF symbol_p1, symbol_p2;
|
||||||
@@ -97,7 +97,7 @@ void SingleLineProperties::draw(QPainter *painter,
|
|||||||
symbol_p1 = QPointF(rect.x() + rect.width() * 0.25, rect.y() + (i * interleave) + symbol_width);
|
symbol_p1 = QPointF(rect.x() + rect.width() * 0.25, rect.y() + (i * interleave) + symbol_width);
|
||||||
}
|
}
|
||||||
painter -> drawLine(QLineF(symbol_p1, symbol_p2));
|
painter -> drawLine(QLineF(symbol_p1, symbol_p2));
|
||||||
|
|
||||||
// dessine le reste des symboles terre et neutre
|
// dessine le reste des symboles terre et neutre
|
||||||
if (isPen()) {
|
if (isPen()) {
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
@@ -126,13 +126,13 @@ void SingleLineProperties::drawGround(QPainter *painter,
|
|||||||
QPointF center,
|
QPointF center,
|
||||||
qreal size) {
|
qreal size) {
|
||||||
painter -> save();
|
painter -> save();
|
||||||
|
|
||||||
// prepare le QPainter
|
// prepare le QPainter
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
QPen pen2(painter -> pen());
|
QPen pen2(painter -> pen());
|
||||||
pen2.setCapStyle(Qt::SquareCap);
|
pen2.setCapStyle(Qt::SquareCap);
|
||||||
painter -> setPen(pen2);
|
painter -> setPen(pen2);
|
||||||
|
|
||||||
// dessine le segment representant la terre
|
// dessine le segment representant la terre
|
||||||
qreal half_size = size / 2.0;
|
qreal half_size = size / 2.0;
|
||||||
QPointF offset_point(
|
QPointF offset_point(
|
||||||
@@ -145,7 +145,7 @@ void SingleLineProperties::drawGround(QPainter *painter,
|
|||||||
center - offset_point
|
center - offset_point
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
painter -> restore();
|
painter -> restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,11 +161,11 @@ void SingleLineProperties::drawNeutral(
|
|||||||
qreal size)
|
qreal size)
|
||||||
{
|
{
|
||||||
painter -> save();
|
painter -> save();
|
||||||
|
|
||||||
// prepare le QPainter
|
// prepare le QPainter
|
||||||
if (painter -> brush() == Qt::NoBrush) painter -> setBrush(Qt::black);
|
if (painter -> brush() == Qt::NoBrush) painter -> setBrush(Qt::black);
|
||||||
painter -> setPen(Qt::NoPen);
|
painter -> setPen(Qt::NoPen);
|
||||||
|
|
||||||
// desine le cercle representant le neutre
|
// desine le cercle representant le neutre
|
||||||
painter -> drawEllipse(
|
painter -> drawEllipse(
|
||||||
QRectF(
|
QRectF(
|
||||||
@@ -173,7 +173,7 @@ void SingleLineProperties::drawNeutral(
|
|||||||
QSizeF(size, size)
|
QSizeF(size, size)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
painter -> restore();
|
painter -> restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ void SingleLineProperties::drawPen(QPainter *painter,
|
|||||||
QPointF center,
|
QPointF center,
|
||||||
qreal size) {
|
qreal size) {
|
||||||
painter -> save();
|
painter -> save();
|
||||||
|
|
||||||
//painter -> setBrush(Qt::white);
|
//painter -> setBrush(Qt::white);
|
||||||
// desine le cercle representant le neutre
|
// desine le cercle representant le neutre
|
||||||
//painter -> drawEllipse(
|
//painter -> drawEllipse(
|
||||||
@@ -202,7 +202,7 @@ void SingleLineProperties::drawPen(QPainter *painter,
|
|||||||
// )
|
// )
|
||||||
//);
|
//);
|
||||||
drawNeutral(painter, center, size * 1.5);
|
drawNeutral(painter, center, size * 1.5);
|
||||||
|
|
||||||
int offset = (size * 1.5 / 2.0);
|
int offset = (size * 1.5 / 2.0);
|
||||||
QPointF pos = center + (direction == QET::Horizontal ? QPointF(0.0, -offset - 0.5) : QPointF(offset + 0.5, 0.0));
|
QPointF pos = center + (direction == QET::Horizontal ? QPointF(0.0, -offset - 0.5) : QPointF(offset + 0.5, 0.0));
|
||||||
drawGround(painter, direction, pos, 2.0 * size);
|
drawGround(painter, direction, pos, 2.0 * size);
|
||||||
@@ -271,11 +271,11 @@ void ConductorProperties::toXml(QDomElement &e) const
|
|||||||
|
|
||||||
if (color != QColor(Qt::black))
|
if (color != QColor(Qt::black))
|
||||||
e.setAttribute("color", color.name());
|
e.setAttribute("color", color.name());
|
||||||
|
|
||||||
e.setAttribute("bicolor", m_bicolor? "true" : "false");
|
e.setAttribute("bicolor", m_bicolor? "true" : "false");
|
||||||
e.setAttribute("color2", m_color_2.name());
|
e.setAttribute("color2", m_color_2.name());
|
||||||
e.setAttribute("dash-size", QString::number(m_dash_size));
|
e.setAttribute("dash-size", QString::number(m_dash_size));
|
||||||
|
|
||||||
if (type == Single)
|
if (type == Single)
|
||||||
singleLineProperties.toXml(e);
|
singleLineProperties.toXml(e);
|
||||||
|
|
||||||
@@ -292,11 +292,11 @@ void ConductorProperties::toXml(QDomElement &e) const
|
|||||||
e.setAttribute("onetextperfolio", m_one_text_per_folio);
|
e.setAttribute("onetextperfolio", m_one_text_per_folio);
|
||||||
e.setAttribute("vertirotatetext", QString::number(verti_rotate_text));
|
e.setAttribute("vertirotatetext", QString::number(verti_rotate_text));
|
||||||
e.setAttribute("horizrotatetext", QString::number(horiz_rotate_text));
|
e.setAttribute("horizrotatetext", QString::number(horiz_rotate_text));
|
||||||
|
|
||||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
e.setAttribute("horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
e.setAttribute("horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
||||||
e.setAttribute("vertical-alignment", me.valueToKey(m_vertical_alignment));
|
e.setAttribute("vertical-alignment", me.valueToKey(m_vertical_alignment));
|
||||||
|
|
||||||
QString conductor_style = writeStyle();
|
QString conductor_style = writeStyle();
|
||||||
if (!conductor_style.isEmpty())
|
if (!conductor_style.isEmpty())
|
||||||
e.setAttribute("style", conductor_style);
|
e.setAttribute("style", conductor_style);
|
||||||
@@ -316,15 +316,15 @@ void ConductorProperties::fromXml(QDomElement &e)
|
|||||||
|
|
||||||
QString bicolor_str = e.attribute("bicolor", "false");
|
QString bicolor_str = e.attribute("bicolor", "false");
|
||||||
m_bicolor = bicolor_str == "true"? true : false;
|
m_bicolor = bicolor_str == "true"? true : false;
|
||||||
|
|
||||||
QColor xml_color_2 = QColor(e.attribute("color2"));
|
QColor xml_color_2 = QColor(e.attribute("color2"));
|
||||||
m_color_2 = xml_color_2.isValid()? xml_color_2 : QColor(Qt::black);
|
m_color_2 = xml_color_2.isValid()? xml_color_2 : QColor(Qt::black);
|
||||||
|
|
||||||
m_dash_size = e.attribute("dash-size", QString::number(1)).toInt();
|
m_dash_size = e.attribute("dash-size", QString::number(1)).toInt();
|
||||||
|
|
||||||
// read style of conductor
|
// read style of conductor
|
||||||
readStyle(e.attribute("style"));
|
readStyle(e.attribute("style"));
|
||||||
|
|
||||||
if (e.attribute("type") == typeToString(Single))
|
if (e.attribute("type") == typeToString(Single))
|
||||||
{
|
{
|
||||||
// get specific properties for single conductor
|
// get specific properties for single conductor
|
||||||
@@ -349,7 +349,7 @@ void ConductorProperties::fromXml(QDomElement &e)
|
|||||||
m_one_text_per_folio = e.attribute("onetextperfolio", QString::number(0)).toInt();
|
m_one_text_per_folio = e.attribute("onetextperfolio", QString::number(0)).toInt();
|
||||||
verti_rotate_text = e.attribute("vertirotatetext").toDouble();
|
verti_rotate_text = e.attribute("vertirotatetext").toDouble();
|
||||||
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
|
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
|
||||||
|
|
||||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
m_horizontal_alignment = Qt::Alignment(
|
m_horizontal_alignment = Qt::Alignment(
|
||||||
me.keyToValue(
|
me.keyToValue(
|
||||||
@@ -396,7 +396,7 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
|
|||||||
settings.setValue(prefix + "onetextperfolio", m_one_text_per_folio);
|
settings.setValue(prefix + "onetextperfolio", m_one_text_per_folio);
|
||||||
settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
|
settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
|
||||||
settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
|
settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
|
||||||
|
|
||||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
settings.setValue(prefix + "horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
settings.setValue(prefix + "horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
||||||
settings.setValue(prefix + "vertical-alignment", me.valueToKey(m_vertical_alignment));
|
settings.setValue(prefix + "vertical-alignment", me.valueToKey(m_vertical_alignment));
|
||||||
@@ -412,13 +412,13 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
|
|||||||
{
|
{
|
||||||
QColor settings_color = QColor(settings.value(prefix + "color").toString());
|
QColor settings_color = QColor(settings.value(prefix + "color").toString());
|
||||||
color = (settings_color.isValid()? settings_color : QColor(Qt::black));
|
color = (settings_color.isValid()? settings_color : QColor(Qt::black));
|
||||||
|
|
||||||
QColor settings_color_2 = QColor(settings.value(prefix + "color2").toString());
|
QColor settings_color_2 = QColor(settings.value(prefix + "color2").toString());
|
||||||
m_color_2 = (settings_color_2.isValid()? settings_color_2 : QColor(Qt::black));
|
m_color_2 = (settings_color_2.isValid()? settings_color_2 : QColor(Qt::black));
|
||||||
|
|
||||||
m_bicolor = settings.value(prefix + "bicolor", false).toBool();
|
m_bicolor = settings.value(prefix + "bicolor", false).toBool();
|
||||||
m_dash_size = settings.value(prefix + "dash-size", 1).toInt();
|
m_dash_size = settings.value(prefix + "dash-size", 1).toInt();
|
||||||
|
|
||||||
QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
|
QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
|
||||||
type = (setting_type == typeToString(Single)? Single : Multi);
|
type = (setting_type == typeToString(Single)? Single : Multi);
|
||||||
|
|
||||||
@@ -438,11 +438,11 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
|
|||||||
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
|
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
|
||||||
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
||||||
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
||||||
|
|
||||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
|
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
|
||||||
m_vertical_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "vertical-alignment", "AlignRight").toString().toStdString().data()));
|
m_vertical_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "vertical-alignment", "AlignRight").toString().toStdString().data()));
|
||||||
|
|
||||||
readStyle(settings.value(prefix + "style").toString());
|
readStyle(settings.value(prefix + "style").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,7 +468,7 @@ QString ConductorProperties::typeToString(ConductorType t)
|
|||||||
void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> list)
|
void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> list)
|
||||||
{
|
{
|
||||||
const QList<ConductorProperties> clist = std::move(list);
|
const QList<ConductorProperties> clist = std::move(list);
|
||||||
|
|
||||||
if (clist.isEmpty())
|
if (clist.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -505,7 +505,7 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
|
|||||||
int i_value;
|
int i_value;
|
||||||
double d_value;
|
double d_value;
|
||||||
Qt::Alignment align_value;
|
Qt::Alignment align_value;
|
||||||
|
|
||||||
//Color
|
//Color
|
||||||
c_value = clist.first().color;
|
c_value = clist.first().color;
|
||||||
for(ConductorProperties cp : clist)
|
for(ConductorProperties cp : clist)
|
||||||
@@ -516,7 +516,7 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
|
|||||||
if (equal)
|
if (equal)
|
||||||
color = c_value;
|
color = c_value;
|
||||||
equal = true;
|
equal = true;
|
||||||
|
|
||||||
//bicolor
|
//bicolor
|
||||||
b_value = clist.first().m_bicolor;
|
b_value = clist.first().m_bicolor;
|
||||||
for(ConductorProperties cp : clist)
|
for(ConductorProperties cp : clist)
|
||||||
@@ -527,7 +527,7 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
|
|||||||
if (equal)
|
if (equal)
|
||||||
m_bicolor = b_value;
|
m_bicolor = b_value;
|
||||||
equal = true;
|
equal = true;
|
||||||
|
|
||||||
//second color
|
//second color
|
||||||
c_value = clist.first().m_color_2;
|
c_value = clist.first().m_color_2;
|
||||||
for(ConductorProperties cp : clist)
|
for(ConductorProperties cp : clist)
|
||||||
@@ -538,7 +538,7 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
|
|||||||
if (equal)
|
if (equal)
|
||||||
m_color_2 = c_value;
|
m_color_2 = c_value;
|
||||||
equal = true;
|
equal = true;
|
||||||
|
|
||||||
//Dash size
|
//Dash size
|
||||||
i_value = clist.first().m_dash_size;
|
i_value = clist.first().m_dash_size;
|
||||||
for(ConductorProperties cp : clist)
|
for(ConductorProperties cp : clist)
|
||||||
@@ -693,7 +693,7 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
|
|||||||
if (equal)
|
if (equal)
|
||||||
horiz_rotate_text = d_value;
|
horiz_rotate_text = d_value;
|
||||||
equal = true;
|
equal = true;
|
||||||
|
|
||||||
//Text alignment for horizontal conducor
|
//Text alignment for horizontal conducor
|
||||||
align_value = clist.first().m_horizontal_alignment;
|
align_value = clist.first().m_horizontal_alignment;
|
||||||
for(ConductorProperties cp : clist)
|
for(ConductorProperties cp : clist)
|
||||||
@@ -704,7 +704,7 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
|
|||||||
if (equal)
|
if (equal)
|
||||||
m_horizontal_alignment = align_value;
|
m_horizontal_alignment = align_value;
|
||||||
equal = true;
|
equal = true;
|
||||||
|
|
||||||
//Text alignment for vertical conducor
|
//Text alignment for vertical conducor
|
||||||
align_value = clist.first().m_vertical_alignment;
|
align_value = clist.first().m_vertical_alignment;
|
||||||
for(ConductorProperties cp : clist)
|
for(ConductorProperties cp : clist)
|
||||||
@@ -778,9 +778,9 @@ bool ConductorProperties::operator!=(const ConductorProperties &other) const{
|
|||||||
*/
|
*/
|
||||||
void ConductorProperties::readStyle(const QString &style_string) {
|
void ConductorProperties::readStyle(const QString &style_string) {
|
||||||
style = Qt::SolidLine; // style par defaut
|
style = Qt::SolidLine; // style par defaut
|
||||||
|
|
||||||
if (style_string.isEmpty()) return;
|
if (style_string.isEmpty()) return;
|
||||||
|
|
||||||
// recupere la liste des couples style / valeur
|
// recupere la liste des couples style / valeur
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||||
QStringList styles = style_string.split(";", QString::SkipEmptyParts);
|
QStringList styles = style_string.split(";", QString::SkipEmptyParts);
|
||||||
@@ -788,12 +788,13 @@ void ConductorProperties::readStyle(const QString &style_string) {
|
|||||||
#pragma message("@TODO remove code QString::SkipEmptyParts for QT 5.14 or later")
|
#pragma message("@TODO remove code QString::SkipEmptyParts for QT 5.14 or later")
|
||||||
QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
|
QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*$");
|
QRegularExpression Rx("^\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*$");
|
||||||
foreach (QString style_str, styles) {
|
foreach (QString style_str, styles) {
|
||||||
if (rx.exactMatch(style_str)) {
|
if (Rx==QRegularExpression(style_str)) {
|
||||||
QString style_name = rx.cap(1);
|
|
||||||
QString style_value = rx.cap(2);
|
QString style_name = Rx.namedCaptureGroups().at(1);
|
||||||
|
QString style_value = Rx.namedCaptureGroups().at(2);
|
||||||
if (style_name == "line-style") {
|
if (style_name == "line-style") {
|
||||||
if (style_value == "dashed") style = Qt::DashLine;
|
if (style_value == "dashed") style = Qt::DashLine;
|
||||||
else if (style_value == "dashdotted") style = Qt::DashDotLine;
|
else if (style_value == "dashdotted") style = Qt::DashDotLine;
|
||||||
|
|||||||
@@ -1,20 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 <QFontDialog>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QSizePolicy>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "configpages.h"
|
#include "configpages.h"
|
||||||
#include "borderpropertieswidget.h"
|
#include "borderpropertieswidget.h"
|
||||||
#include "conductorpropertieswidget.h"
|
#include "conductorpropertieswidget.h"
|
||||||
@@ -27,10 +33,7 @@
|
|||||||
#include "qetproject.h"
|
#include "qetproject.h"
|
||||||
#include "reportproperties.h"
|
#include "reportproperties.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include <QFontDialog>
|
#include "nameslist.h"
|
||||||
#include <QFont>
|
|
||||||
#include <QSizePolicy>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief NewDiagramPage::NewDiagramPage
|
@brief NewDiagramPage::NewDiagramPage
|
||||||
@@ -249,13 +252,13 @@ void NewDiagramPage::loadSavedTbp()
|
|||||||
ExportConfigPage::ExportConfigPage(QWidget *parent) : ConfigPage(parent) {
|
ExportConfigPage::ExportConfigPage(QWidget *parent) : ConfigPage(parent) {
|
||||||
// epw contient les options d'export
|
// epw contient les options d'export
|
||||||
epw = new ExportPropertiesWidget(ExportProperties::defaultExportProperties());
|
epw = new ExportPropertiesWidget(ExportProperties::defaultExportProperties());
|
||||||
|
|
||||||
// layout vertical contenant le titre, une ligne horizontale et epw
|
// layout vertical contenant le titre, une ligne horizontale et epw
|
||||||
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
||||||
|
|
||||||
QLabel *title = new QLabel(this -> title());
|
QLabel *title = new QLabel(this -> title());
|
||||||
vlayout1 -> addWidget(title);
|
vlayout1 -> addWidget(title);
|
||||||
|
|
||||||
QFrame *horiz_line = new QFrame();
|
QFrame *horiz_line = new QFrame();
|
||||||
horiz_line -> setFrameShape(QFrame::HLine);
|
horiz_line -> setFrameShape(QFrame::HLine);
|
||||||
vlayout1 -> addWidget(horiz_line);
|
vlayout1 -> addWidget(horiz_line);
|
||||||
@@ -300,13 +303,13 @@ PrintConfigPage::PrintConfigPage(QWidget *parent) : ConfigPage(parent) {
|
|||||||
// epw contient les options d'export
|
// epw contient les options d'export
|
||||||
epw = new ExportPropertiesWidget(ExportProperties::defaultPrintProperties());
|
epw = new ExportPropertiesWidget(ExportProperties::defaultPrintProperties());
|
||||||
epw -> setPrintingMode(true);
|
epw -> setPrintingMode(true);
|
||||||
|
|
||||||
// layout vertical contenant le titre, une ligne horizontale et epw
|
// layout vertical contenant le titre, une ligne horizontale et epw
|
||||||
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
||||||
|
|
||||||
QLabel *title = new QLabel(this -> title());
|
QLabel *title = new QLabel(this -> title());
|
||||||
vlayout1 -> addWidget(title);
|
vlayout1 -> addWidget(title);
|
||||||
|
|
||||||
QFrame *horiz_line = new QFrame();
|
QFrame *horiz_line = new QFrame();
|
||||||
horiz_line -> setFrameShape(QFrame::HLine);
|
horiz_line -> setFrameShape(QFrame::HLine);
|
||||||
vlayout1 -> addWidget(horiz_line);
|
vlayout1 -> addWidget(horiz_line);
|
||||||
@@ -329,10 +332,10 @@ PrintConfigPage::~PrintConfigPage()
|
|||||||
void PrintConfigPage::applyConf()
|
void PrintConfigPage::applyConf()
|
||||||
{
|
{
|
||||||
QString prefix = "print/default";
|
QString prefix = "print/default";
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
epw -> exportProperties().toSettings(settings, prefix);
|
epw -> exportProperties().toSettings(settings, prefix);
|
||||||
|
|
||||||
// annule l'enregistrement de certaines proprietes non pertinentes
|
// annule l'enregistrement de certaines proprietes non pertinentes
|
||||||
settings.remove(prefix + "path");
|
settings.remove(prefix + "path");
|
||||||
settings.remove(prefix + "format");
|
settings.remove(prefix + "format");
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ Createdxf::Createdxf()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Createdxf::~Createdxf()
|
Createdxf::~Createdxf()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -438,32 +437,15 @@ int Createdxf::getcolorCode (const long red, const long green, const long blue)
|
|||||||
}
|
}
|
||||||
return minndx;
|
return minndx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Createdxf::dxfColor(QColor color) {
|
int Createdxf::dxfColor(QColor color) {
|
||||||
return Createdxf::getcolorCode(color.red(), color.green(), color.blue());
|
return Createdxf::getcolorCode(color.red(), color.green(), color.blue());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Createdxf::dxfColor(QPen pen) {
|
int Createdxf::dxfColor(QPen pen) {
|
||||||
return Createdxf::dxfColor(pen.color());
|
return Createdxf::dxfColor(pen.color());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Createdxf::drawLine
|
|
||||||
Conveniance function to draw line
|
|
||||||
@param filepath
|
|
||||||
@param line
|
|
||||||
@param colorcode
|
|
||||||
*/
|
|
||||||
void Createdxf::drawLine(
|
|
||||||
const QString &filepath,
|
|
||||||
const QLineF &line,
|
|
||||||
const int &colorcode)
|
|
||||||
{
|
|
||||||
drawLine(filepath, line.p1().x() * xScale,
|
|
||||||
sheetHeight - (line.p1().y() * yScale),
|
|
||||||
line.p2().x() * xScale,
|
|
||||||
sheetHeight - (line.p2().y() * yScale),
|
|
||||||
colorcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Createdxf::drawArcEllipse(
|
void Createdxf::drawArcEllipse(
|
||||||
const QString &file_path,
|
const QString &file_path,
|
||||||
qreal x,
|
qreal x,
|
||||||
@@ -611,26 +593,7 @@ void Createdxf::drawArcEllipse(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Createdxf::drawEllipse
|
|
||||||
Conveniance function for draw ellipse
|
|
||||||
@param filepath
|
|
||||||
@param rect
|
|
||||||
@param colorcode
|
|
||||||
*/
|
|
||||||
void Createdxf::drawEllipse(
|
|
||||||
const QString &filepath,
|
|
||||||
const QRectF &rect,
|
|
||||||
const int &colorcode)
|
|
||||||
{
|
|
||||||
drawArcEllipse(
|
|
||||||
filepath,
|
|
||||||
rect.topLeft().x() * xScale,
|
|
||||||
sheetHeight - (rect.topLeft().y() * yScale),
|
|
||||||
rect.width() * xScale,
|
|
||||||
rect.height() * yScale,
|
|
||||||
0, 360, 0, 0, 0, colorcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Createdxf::drawRectangle
|
@brief Createdxf::drawRectangle
|
||||||
@@ -655,44 +618,11 @@ void Createdxf::drawRectangle (
|
|||||||
drawPolyline(fileName,poly,colour,true);
|
drawPolyline(fileName,poly,colour,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QRectF scaleRect(QRectF rect)
|
|
||||||
{
|
|
||||||
QRectF ro(rect.bottomLeft().x() * Createdxf::xScale,
|
|
||||||
Createdxf::sheetHeight - (rect.bottomLeft().y() * Createdxf::yScale),
|
|
||||||
rect.width() * Createdxf::xScale,
|
|
||||||
rect.height() * Createdxf::yScale);
|
|
||||||
return ro;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Createdxf::drawRectangle
|
|
||||||
Convenience function for draw rectangle
|
|
||||||
@param filepath
|
|
||||||
@param rect
|
|
||||||
@param colorcode
|
|
||||||
*/
|
|
||||||
void Createdxf::drawRectangle(
|
|
||||||
const QString &filepath,
|
|
||||||
const QRectF &rect,
|
|
||||||
const int &colorcode) {
|
|
||||||
QPolygonF poly(scaleRect(rect));
|
|
||||||
drawPolyline(filepath,poly,colorcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Createdxf::drawPolygon
|
|
||||||
Convenience function for draw polygon
|
|
||||||
@param filepath
|
|
||||||
@param poly
|
|
||||||
@param colorcode
|
|
||||||
*/
|
|
||||||
void Createdxf::drawPolygon(
|
|
||||||
const QString &filepath,
|
|
||||||
const QPolygonF &poly,
|
|
||||||
const int &colorcode)
|
|
||||||
{
|
|
||||||
drawPolyline(filepath,poly,colorcode);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
@brief Createdxf::drawArc
|
@brief Createdxf::drawArc
|
||||||
draw arc in dx format
|
draw arc in dx format
|
||||||
@@ -767,7 +697,7 @@ void Createdxf::drawText(
|
|||||||
double height,
|
double height,
|
||||||
double rotation,
|
double rotation,
|
||||||
int colour,
|
int colour,
|
||||||
double xScale)
|
double xScaleW)
|
||||||
{
|
{
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
@@ -779,7 +709,7 @@ void Createdxf::drawText(
|
|||||||
errorFileOpen.exec();
|
errorFileOpen.exec();
|
||||||
} else {
|
} else {
|
||||||
QTextStream To_Dxf(&file);
|
QTextStream To_Dxf(&file);
|
||||||
// Draw the circle
|
// Draw the text
|
||||||
To_Dxf << 0 << "\r\n";
|
To_Dxf << 0 << "\r\n";
|
||||||
To_Dxf << "TEXT" << "\r\n";
|
To_Dxf << "TEXT" << "\r\n";
|
||||||
To_Dxf << 8 << "\r\n";
|
To_Dxf << 8 << "\r\n";
|
||||||
@@ -795,7 +725,7 @@ void Createdxf::drawText(
|
|||||||
To_Dxf << 40 << "\r\n";
|
To_Dxf << 40 << "\r\n";
|
||||||
To_Dxf << height << "\r\n"; // Text Height
|
To_Dxf << height << "\r\n"; // Text Height
|
||||||
To_Dxf << 41 << "\r\n";
|
To_Dxf << 41 << "\r\n";
|
||||||
To_Dxf << xScale << "\r\n"; // X Scale
|
To_Dxf << xScaleW << "\r\n"; // X Scale
|
||||||
To_Dxf << 1 << "\r\n";
|
To_Dxf << 1 << "\r\n";
|
||||||
To_Dxf << text << "\r\n"; // Text Value
|
To_Dxf << text << "\r\n"; // Text Value
|
||||||
To_Dxf << 50 << "\r\n";
|
To_Dxf << 50 << "\r\n";
|
||||||
@@ -819,7 +749,7 @@ void Createdxf::drawTextAligned(
|
|||||||
int hAlign,
|
int hAlign,
|
||||||
int vAlign,
|
int vAlign,
|
||||||
double xAlign,
|
double xAlign,
|
||||||
double xScale,
|
double xScaleW,
|
||||||
int colour)
|
int colour)
|
||||||
{
|
{
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
@@ -848,7 +778,7 @@ void Createdxf::drawTextAligned(
|
|||||||
To_Dxf << 40 << "\r\n";
|
To_Dxf << 40 << "\r\n";
|
||||||
To_Dxf << height << "\r\n"; // Text Height
|
To_Dxf << height << "\r\n"; // Text Height
|
||||||
To_Dxf << 41 << "\r\n";
|
To_Dxf << 41 << "\r\n";
|
||||||
To_Dxf << xScale << "\r\n"; // X Scale
|
To_Dxf << xScaleW << "\r\n"; // X Scale
|
||||||
To_Dxf << 1 << "\r\n";
|
To_Dxf << 1 << "\r\n";
|
||||||
To_Dxf << text << "\r\n"; // Text Value
|
To_Dxf << text << "\r\n"; // Text Value
|
||||||
To_Dxf << 50 << "\r\n";
|
To_Dxf << 50 << "\r\n";
|
||||||
@@ -961,3 +891,158 @@ void Createdxf::drawPolyline(const QString &filepath,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ================================================
|
||||||
|
* Majority of calls above here are must be passed
|
||||||
|
* parameters pre=scaled to DXF units
|
||||||
|
* Calls below use Qt scaling, and re-scale them to DXF
|
||||||
|
* ================================================
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
@brief Createdxf::drawCircle
|
||||||
|
draw circle in qt format
|
||||||
|
@param fileName
|
||||||
|
@param center
|
||||||
|
@param radius
|
||||||
|
@param colour
|
||||||
|
*/
|
||||||
|
void Createdxf::drawCircle(
|
||||||
|
const QString& fileName,
|
||||||
|
QPointF centre,
|
||||||
|
double radius,
|
||||||
|
int colour)
|
||||||
|
{
|
||||||
|
qreal x = centre.x() * xScale;
|
||||||
|
qreal y = sheetHeight - centre.y() * yScale;
|
||||||
|
qreal r = radius * xScale;
|
||||||
|
drawCircle(fileName,r,x,y,colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Createdxf::drawLine
|
||||||
|
Convenience function to draw line
|
||||||
|
@param filepath
|
||||||
|
@param line
|
||||||
|
@param colorcode
|
||||||
|
*/
|
||||||
|
void Createdxf::drawLine(
|
||||||
|
const QString &filepath,
|
||||||
|
const QLineF &line,
|
||||||
|
const int &colorcode)
|
||||||
|
{
|
||||||
|
drawLine(filepath, line.p1().x() * xScale,
|
||||||
|
sheetHeight - (line.p1().y() * yScale),
|
||||||
|
line.p2().x() * xScale,
|
||||||
|
sheetHeight - (line.p2().y() * yScale),
|
||||||
|
colorcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Createdxf::drawEllipse
|
||||||
|
Conveniance function for draw ellipse
|
||||||
|
@param filepath
|
||||||
|
@param rect
|
||||||
|
@param colorcode
|
||||||
|
*/
|
||||||
|
void Createdxf::drawEllipse(
|
||||||
|
const QString &filepath,
|
||||||
|
const QRectF &rect,
|
||||||
|
const int &colorcode)
|
||||||
|
{
|
||||||
|
drawArcEllipse(
|
||||||
|
filepath,
|
||||||
|
rect.topLeft().x() * xScale,
|
||||||
|
sheetHeight - (rect.topLeft().y() * yScale),
|
||||||
|
rect.width() * xScale,
|
||||||
|
rect.height() * yScale,
|
||||||
|
0, 360, 0, 0, 0, colorcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Createdxf::drawRectangle
|
||||||
|
Convenience function for draw rectangle
|
||||||
|
@param filepath
|
||||||
|
@param rect
|
||||||
|
@param colorcode
|
||||||
|
*/
|
||||||
|
void Createdxf::drawRectangle(
|
||||||
|
const QString &filepath,
|
||||||
|
const QRectF &rect,
|
||||||
|
const int &colorcode) {
|
||||||
|
//QPolygonF poly(scaleRect(rect));
|
||||||
|
QPolygonF poly(rect);
|
||||||
|
drawPolyline(filepath,poly,colorcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Createdxf::drawPolygon
|
||||||
|
Convenience function for draw polygon
|
||||||
|
@param filepath
|
||||||
|
@param poly
|
||||||
|
@param colorcode
|
||||||
|
*/
|
||||||
|
void Createdxf::drawPolygon(
|
||||||
|
const QString &filepath,
|
||||||
|
const QPolygonF &poly,
|
||||||
|
const int &colorcode)
|
||||||
|
{
|
||||||
|
QPolygonF pg = poly;
|
||||||
|
if(!poly.isClosed()) {
|
||||||
|
pg << poly.at(0); // Close it
|
||||||
|
}
|
||||||
|
drawPolyline(filepath,pg,colorcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Createdxf::drawText
|
||||||
|
draw simple text in dxf format without any alignment specified
|
||||||
|
@param fileName
|
||||||
|
@param text
|
||||||
|
@param point
|
||||||
|
@param height
|
||||||
|
@param rotation
|
||||||
|
@param colour
|
||||||
|
@param xScaleW=1
|
||||||
|
*/
|
||||||
|
void Createdxf::drawText(
|
||||||
|
const QString& fileName,
|
||||||
|
const QString& text,
|
||||||
|
QPointF point,
|
||||||
|
double height,
|
||||||
|
double rotation,
|
||||||
|
int colour,
|
||||||
|
double xScaleW)
|
||||||
|
{
|
||||||
|
qreal x = point.x() * xScale;
|
||||||
|
qreal y = sheetHeight - (point.y() * yScale);
|
||||||
|
drawText(fileName,text,x,y,height * yScale,rotation,colour,xScaleW);
|
||||||
|
}
|
||||||
|
void Createdxf::drawArcEllipse(
|
||||||
|
const QString &file_path,
|
||||||
|
QRectF rect,
|
||||||
|
qreal startAngle,
|
||||||
|
qreal spanAngle,
|
||||||
|
QPointF hotspot,
|
||||||
|
qreal rotation_angle,
|
||||||
|
const int &colorcode)
|
||||||
|
{
|
||||||
|
qreal x = rect.x() * xScale;
|
||||||
|
qreal y = sheetHeight - rect.y() * yScale;
|
||||||
|
qreal w = rect.width() * xScale;
|
||||||
|
qreal h = rect.height() * yScale;
|
||||||
|
qreal hotspot_x = hotspot.x() * xScale;
|
||||||
|
qreal hotspot_y = sheetHeight - hotspot.y() * yScale;
|
||||||
|
drawArcEllipse(file_path,x,y,w,h,startAngle,spanAngle,hotspot_x,hotspot_y,rotation_angle,colorcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Utility functions
|
||||||
|
*/
|
||||||
|
static QRectF scaleRect(QRectF rect)
|
||||||
|
{
|
||||||
|
QRectF ro(rect.bottomLeft().x() * Createdxf::xScale,
|
||||||
|
Createdxf::sheetHeight - (rect.bottomLeft().y() * Createdxf::yScale),
|
||||||
|
rect.width() * Createdxf::xScale,
|
||||||
|
rect.height() * Createdxf::yScale);
|
||||||
|
return ro;
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ class Createdxf
|
|||||||
double,
|
double,
|
||||||
double,
|
double,
|
||||||
int);
|
int);
|
||||||
|
|
||||||
|
static void drawCircle(
|
||||||
|
const QString& ,
|
||||||
|
QPointF,
|
||||||
|
double,
|
||||||
|
int );
|
||||||
|
|
||||||
static void drawArc(
|
static void drawArc(
|
||||||
const QString&,
|
const QString&,
|
||||||
double x,
|
double x,
|
||||||
@@ -62,6 +69,15 @@ class Createdxf
|
|||||||
qreal rotation_angle,
|
qreal rotation_angle,
|
||||||
const int &colorcode);
|
const int &colorcode);
|
||||||
|
|
||||||
|
static void drawArcEllipse(
|
||||||
|
const QString &file_path,
|
||||||
|
QRectF rect,
|
||||||
|
qreal startAngle,
|
||||||
|
qreal spanAngle,
|
||||||
|
QPointF hotspot,
|
||||||
|
qreal rotation_angle,
|
||||||
|
const int &colorcode);
|
||||||
|
|
||||||
static void drawEllipse (const QString &filepath,
|
static void drawEllipse (const QString &filepath,
|
||||||
const QRectF &rect,
|
const QRectF &rect,
|
||||||
const int &colorcode);
|
const int &colorcode);
|
||||||
@@ -103,6 +119,14 @@ class Createdxf
|
|||||||
double,
|
double,
|
||||||
int,
|
int,
|
||||||
double xScale=1.0);
|
double xScale=1.0);
|
||||||
|
static void drawText(
|
||||||
|
const QString&,
|
||||||
|
const QString&,
|
||||||
|
QPointF,
|
||||||
|
double,
|
||||||
|
double,
|
||||||
|
int,
|
||||||
|
double xScale=1.0);
|
||||||
static void drawTextAligned(
|
static void drawTextAligned(
|
||||||
const QString& fileName,
|
const QString& fileName,
|
||||||
const QString& text,
|
const QString& text,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "diagramposition.h"
|
#include "diagramposition.h"
|
||||||
|
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_WINDOWS)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_WINDOWS)
|
||||||
#include <QSqlDriver>
|
#include <QSqlDriver>
|
||||||
@@ -161,7 +162,11 @@ void projectDataBase::addDiagram(Diagram *diagram)
|
|||||||
for (auto key : QETApp::diagramInfoKeys())
|
for (auto key : QETApp::diagramInfoKeys())
|
||||||
{
|
{
|
||||||
if (key == "date") {
|
if (key == "date") {
|
||||||
m_insert_diagram_info_query.bindValue(":date", QDate::fromString(infos.value("date").toString(), Qt::SystemLocaleShortDate));
|
m_insert_diagram_info_query.bindValue(
|
||||||
|
":date",
|
||||||
|
QLocale::system().toString(
|
||||||
|
infos.value("date").toDate(),
|
||||||
|
QLocale::ShortFormat));
|
||||||
} else {
|
} else {
|
||||||
auto value = infos.value(key);
|
auto value = infos.value(key);
|
||||||
auto bind = key.prepend(":");
|
auto bind = key.prepend(":");
|
||||||
@@ -419,7 +424,11 @@ void projectDataBase::populateDiagramInfoTable()
|
|||||||
for (auto key : QETApp::diagramInfoKeys())
|
for (auto key : QETApp::diagramInfoKeys())
|
||||||
{
|
{
|
||||||
if (key == "date") {
|
if (key == "date") {
|
||||||
m_insert_diagram_info_query.bindValue(":date", QDate::fromString(infos.value("date").toString(), Qt::SystemLocaleShortDate));
|
m_insert_diagram_info_query.bindValue(
|
||||||
|
":date",
|
||||||
|
QLocale::system().toString(
|
||||||
|
infos.value("date").toDate(),
|
||||||
|
QLocale::ShortFormat));
|
||||||
} else {
|
} else {
|
||||||
auto value = infos.value(key);
|
auto value = infos.value(key);
|
||||||
auto bind = key.prepend(":");
|
auto bind = key.prepend(":");
|
||||||
@@ -521,7 +530,7 @@ sqlite3 *projectDataBase::sqliteHandle(QSqlDatabase *db)
|
|||||||
{
|
{
|
||||||
//sqlite 3 lib isn't availlable for the moment on macosx
|
//sqlite 3 lib isn't availlable for the moment on macosx
|
||||||
//need some help to add sqlite3 lib on macosx compilation
|
//need some help to add sqlite3 lib on macosx compilation
|
||||||
#if Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#else
|
#else
|
||||||
sqlite3 *handle = nullptr;
|
sqlite3 *handle = nullptr;
|
||||||
@@ -553,7 +562,9 @@ void projectDataBase::exportDb(projectDataBase *db,
|
|||||||
if (caption_.isEmpty()) {
|
if (caption_.isEmpty()) {
|
||||||
caption_ = tr("Exporter la base de données interne du projet");
|
caption_ = tr("Exporter la base de données interne du projet");
|
||||||
}
|
}
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
return;
|
||||||
|
#else
|
||||||
auto dir_ = dir;
|
auto dir_ = dir;
|
||||||
if(dir_.isEmpty()) {
|
if(dir_.isEmpty()) {
|
||||||
dir_ = db->project()->filePath();
|
dir_ = db->project()->filePath();
|
||||||
@@ -593,4 +604,5 @@ void projectDataBase::exportDb(projectDataBase *db,
|
|||||||
file_db.close();
|
file_db.close();
|
||||||
}
|
}
|
||||||
QSqlDatabase::removeDatabase(connection_name);
|
QSqlDatabase::removeDatabase(connection_name);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
#include <QRegExp>
|
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QRegularExpressionMatch>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief DiagramContext::add
|
@brief DiagramContext::add
|
||||||
@@ -241,8 +242,9 @@ bool DiagramContext::stringLongerThan(const QString &a, const QString &b) {
|
|||||||
*/
|
*/
|
||||||
bool DiagramContext::keyIsAcceptable(const QString &key) const
|
bool DiagramContext::keyIsAcceptable(const QString &key) const
|
||||||
{
|
{
|
||||||
QRegExp re(DiagramContext::validKeyRegExp());
|
QRegularExpression re(DiagramContext::validKeyRegExp());
|
||||||
return(re.exactMatch(key));
|
QRegularExpressionMatch match =re.match(key);
|
||||||
|
return match.hasMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator <<(QDebug debug, const DiagramContext &context)
|
QDebug operator <<(QDebug debug, const DiagramContext &context)
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
DiagramPosition::DiagramPosition(const QString &letter, unsigned int number) {
|
DiagramPosition::DiagramPosition(const QString &letter, unsigned int number) {
|
||||||
// purifie les lettres
|
// purifie les lettres
|
||||||
letter_ = letter.toUpper();
|
letter_ = letter.toUpper();
|
||||||
letter_.remove(QRegExp("[^A-Z]"));
|
letter_.remove(QRegularExpression("[^A-Z]"));
|
||||||
number_ = number;
|
number_ = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ QString DiagramPosition::toString()
|
|||||||
return("-");
|
return("-");
|
||||||
}
|
}
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
if (settings.value("border-columns_0", true).toBool()){
|
if (settings.value("border-columns_0", true).toBool()){
|
||||||
return(QString("%1%2").arg(letter_).arg(number_ - 1));
|
return(QString("%1%2").arg(letter_).arg(number_ - 1));
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
#define DIAGRAM_POSITION_H
|
#define DIAGRAM_POSITION_H
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QRegExp>
|
|
||||||
/**
|
/**
|
||||||
This class stores the position of an electrical element on its parent diagram.
|
This class stores the position of an electrical element on its parent diagram.
|
||||||
While exact coordinates can be stored for convenience, the concept of diagram
|
While exact coordinates can be stored for convenience, the concept of diagram
|
||||||
@@ -31,7 +30,7 @@ class DiagramPosition {
|
|||||||
public:
|
public:
|
||||||
DiagramPosition(const QString & = "", unsigned int = 0);
|
DiagramPosition(const QString & = "", unsigned int = 0);
|
||||||
virtual ~DiagramPosition();
|
virtual ~DiagramPosition();
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
QPointF position() const;
|
QPointF position() const;
|
||||||
@@ -40,7 +39,7 @@ class DiagramPosition {
|
|||||||
bool isOutOfBounds() const;
|
bool isOutOfBounds() const;
|
||||||
unsigned int number()const {return number_;}
|
unsigned int number()const {return number_;}
|
||||||
QString letter()const {return letter_;}
|
QString letter()const {return letter_;}
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
QString letter_;
|
QString letter_;
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -38,7 +38,7 @@ DiagramPrintDialog::DiagramPrintDialog(QETProject *project, QWidget *parent) :
|
|||||||
{
|
{
|
||||||
// initialise l'imprimante
|
// initialise l'imprimante
|
||||||
printer_ = new QPrinter();
|
printer_ = new QPrinter();
|
||||||
|
|
||||||
// orientation paysage par defaut
|
// orientation paysage par defaut
|
||||||
printer_ -> setOrientation(QPrinter::Landscape);
|
printer_ -> setOrientation(QPrinter::Landscape);
|
||||||
backup_diagram_background_color = Diagram::background_color;
|
backup_diagram_background_color = Diagram::background_color;
|
||||||
@@ -95,16 +95,16 @@ QRect DiagramPrintDialog::diagramRect(Diagram *diagram,
|
|||||||
const ExportProperties &options) const
|
const ExportProperties &options) const
|
||||||
{
|
{
|
||||||
if (!diagram) return(QRect());
|
if (!diagram) return(QRect());
|
||||||
|
|
||||||
QRectF diagram_rect = diagram -> border_and_titleblock.borderAndTitleBlockRect();
|
QRectF diagram_rect = diagram -> border_and_titleblock.borderAndTitleBlockRect();
|
||||||
if (!options.draw_titleblock) {
|
if (!options.draw_titleblock) {
|
||||||
qreal titleblock_height = diagram -> border_and_titleblock.titleBlockRect().height();
|
qreal titleblock_height = diagram -> border_and_titleblock.titleBlockRect().height();
|
||||||
diagram_rect.setHeight(diagram_rect.height() - titleblock_height);
|
diagram_rect.setHeight(diagram_rect.height() - titleblock_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ajuste la bordure du schema d'un pixel (epaisseur du trait)
|
// ajuste la bordure du schema d'un pixel (epaisseur du trait)
|
||||||
diagram_rect = diagram_rect.adjusted(0.0, 0.0, 1.0, 1.0);
|
diagram_rect = diagram_rect.adjusted(0.0, 0.0, 1.0, 1.0);
|
||||||
|
|
||||||
return(diagram_rect.toAlignedRect());
|
return(diagram_rect.toAlignedRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,16 +113,16 @@ QRect DiagramPrintDialog::diagramRect(Diagram *diagram,
|
|||||||
*/
|
*/
|
||||||
void DiagramPrintDialog::exec()
|
void DiagramPrintDialog::exec()
|
||||||
{
|
{
|
||||||
|
|
||||||
// prise en compte du nom du document
|
// prise en compte du nom du document
|
||||||
if (!doc_name_.isEmpty()) printer_ -> setDocName(doc_name_);
|
if (!doc_name_.isEmpty()) printer_ -> setDocName(doc_name_);
|
||||||
printer_ -> setCreator(QString("QElectroTech %1").arg(QET::displayedVersion));
|
printer_ -> setCreator(QString("QElectroTech %1").arg(QET::displayedVersion));
|
||||||
|
|
||||||
// affichage d'un premier dialogue demandant a l'utilisateur le type
|
// affichage d'un premier dialogue demandant a l'utilisateur le type
|
||||||
// d'impression qu'il souhaite effectuer
|
// d'impression qu'il souhaite effectuer
|
||||||
buildPrintTypeDialog();
|
buildPrintTypeDialog();
|
||||||
if (dialog_ -> exec() == QDialog::Rejected) return;
|
if (dialog_ -> exec() == QDialog::Rejected) return;
|
||||||
|
|
||||||
// parametrage de l'imprimante en fonction du type d'impression choisi
|
// parametrage de l'imprimante en fonction du type d'impression choisi
|
||||||
if (printer_choice_ -> isChecked()) {
|
if (printer_choice_ -> isChecked()) {
|
||||||
// affichage du dialogue d'impression standard pour parametrer l'imprimante
|
// affichage du dialogue d'impression standard pour parametrer l'imprimante
|
||||||
@@ -141,7 +141,7 @@ void DiagramPrintDialog::exec()
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadPageSetupForCurrentPrinter();
|
loadPageSetupForCurrentPrinter();
|
||||||
|
|
||||||
//Preview before print
|
//Preview before print
|
||||||
#if defined Q_OS_LINUX
|
#if defined Q_OS_LINUX
|
||||||
//Due to some bug with xfwm, we display this dialog has a windows on linux os (X11)
|
//Due to some bug with xfwm, we display this dialog has a windows on linux os (X11)
|
||||||
@@ -159,9 +159,9 @@ void DiagramPrintDialog::exec()
|
|||||||
DiagramsChooser *dc = preview_dialog.diagramsChooser();
|
DiagramsChooser *dc = preview_dialog.diagramsChooser();
|
||||||
dc -> setSelectedAllDiagrams();
|
dc -> setSelectedAllDiagrams();
|
||||||
if (preview_dialog.exec() == QDialog::Rejected) return;
|
if (preview_dialog.exec() == QDialog::Rejected) return;
|
||||||
|
|
||||||
savePageSetupForCurrentPrinter();
|
savePageSetupForCurrentPrinter();
|
||||||
|
|
||||||
// effectue l'impression en elle-meme
|
// effectue l'impression en elle-meme
|
||||||
print(
|
print(
|
||||||
dc -> selectedDiagrams(),
|
dc -> selectedDiagrams(),
|
||||||
@@ -194,7 +194,7 @@ int DiagramPrintDialog::horizontalPagesCount(Diagram *diagram, const ExportPrope
|
|||||||
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
||||||
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
|
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
|
||||||
QRect diagram_rect = diagramRect(diagram, options);
|
QRect diagram_rect = diagramRect(diagram, options);
|
||||||
|
|
||||||
int h_pages_count = int(ceil(qreal(diagram_rect.width()) / qreal(printable_area.width())));
|
int h_pages_count = int(ceil(qreal(diagram_rect.width()) / qreal(printable_area.width())));
|
||||||
return(h_pages_count);
|
return(h_pages_count);
|
||||||
}
|
}
|
||||||
@@ -211,7 +211,7 @@ int DiagramPrintDialog::verticalPagesCount(Diagram *diagram, const ExportPropert
|
|||||||
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
||||||
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
|
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
|
||||||
QRect diagram_rect = diagramRect(diagram, options);
|
QRect diagram_rect = diagramRect(diagram, options);
|
||||||
|
|
||||||
int v_pages_count = int(ceil(qreal(diagram_rect.height()) / qreal(printable_area.height())));
|
int v_pages_count = int(ceil(qreal(diagram_rect.height()) / qreal(printable_area.height())));
|
||||||
return(v_pages_count);
|
return(v_pages_count);
|
||||||
}
|
}
|
||||||
@@ -227,7 +227,7 @@ void DiagramPrintDialog::buildPrintTypeDialog()
|
|||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
dialog_ -> setWindowFlags(Qt::Sheet);
|
dialog_ -> setWindowFlags(Qt::Sheet);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printtype_label_ = new QLabel(tr("Quel type d'impression désirez-vous effectuer ?"));
|
printtype_label_ = new QLabel(tr("Quel type d'impression désirez-vous effectuer ?"));
|
||||||
printer_icon_ = new QLabel();
|
printer_icon_ = new QLabel();
|
||||||
pdf_icon_ = new QLabel();
|
pdf_icon_ = new QLabel();
|
||||||
@@ -239,7 +239,7 @@ void DiagramPrintDialog::buildPrintTypeDialog()
|
|||||||
filepath_field_ = new QLineEdit();
|
filepath_field_ = new QLineEdit();
|
||||||
browse_button_ = new QPushButton("...");
|
browse_button_ = new QPushButton("...");
|
||||||
buttons_ = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
buttons_ = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
dialog_ -> setWindowTitle(tr("Choix du type d'impression"));
|
dialog_ -> setWindowTitle(tr("Choix du type d'impression"));
|
||||||
printer_icon_ -> setPixmap(QET::Icons::Printer.pixmap(32, 32));
|
printer_icon_ -> setPixmap(QET::Icons::Printer.pixmap(32, 32));
|
||||||
pdf_icon_ -> setPixmap(QET::Icons::PDF.pixmap(32, 32));
|
pdf_icon_ -> setPixmap(QET::Icons::PDF.pixmap(32, 32));
|
||||||
@@ -249,19 +249,19 @@ void DiagramPrintDialog::buildPrintTypeDialog()
|
|||||||
|
|
||||||
printer_choice_ -> setChecked(true);
|
printer_choice_ -> setChecked(true);
|
||||||
if (!file_name_.isEmpty()) filepath_field_ -> setText(file_name_ + ".pdf");
|
if (!file_name_.isEmpty()) filepath_field_ -> setText(file_name_ + ".pdf");
|
||||||
|
|
||||||
// connexions signaux / slots
|
// connexions signaux / slots
|
||||||
connect(printer_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
|
connect(printer_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
|
||||||
connect(pdf_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
|
connect(pdf_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
|
||||||
connect(browse_button_, SIGNAL(clicked(bool)), this, SLOT(browseFilePrintTypeDialog()));
|
connect(browse_button_, SIGNAL(clicked(bool)), this, SLOT(browseFilePrintTypeDialog()));
|
||||||
connect(buttons_, SIGNAL(accepted()), this, SLOT(acceptPrintTypeDialog()));
|
connect(buttons_, SIGNAL(accepted()), this, SLOT(acceptPrintTypeDialog()));
|
||||||
connect(buttons_, SIGNAL(rejected()), dialog_, SLOT(reject()));
|
connect(buttons_, SIGNAL(rejected()), dialog_, SLOT(reject()));
|
||||||
|
|
||||||
// organisation graphique
|
// organisation graphique
|
||||||
glayout0_ = new QGridLayout();
|
glayout0_ = new QGridLayout();
|
||||||
hlayout0_ = new QHBoxLayout();
|
hlayout0_ = new QHBoxLayout();
|
||||||
vlayout0_ = new QVBoxLayout();
|
vlayout0_ = new QVBoxLayout();
|
||||||
|
|
||||||
hlayout0_ -> addWidget(filepath_field_);
|
hlayout0_ -> addWidget(filepath_field_);
|
||||||
hlayout0_ -> addWidget(browse_button_);
|
hlayout0_ -> addWidget(browse_button_);
|
||||||
glayout0_ -> addWidget(printer_icon_, 0, 0);
|
glayout0_ -> addWidget(printer_icon_, 0, 0);
|
||||||
@@ -269,13 +269,13 @@ void DiagramPrintDialog::buildPrintTypeDialog()
|
|||||||
glayout0_ -> addWidget(pdf_icon_, 1, 0);
|
glayout0_ -> addWidget(pdf_icon_, 1, 0);
|
||||||
glayout0_ -> addWidget(pdf_choice_, 1, 1);
|
glayout0_ -> addWidget(pdf_choice_, 1, 1);
|
||||||
glayout0_ -> addLayout(hlayout0_, 3, 1);
|
glayout0_ -> addLayout(hlayout0_, 3, 1);
|
||||||
|
|
||||||
vlayout0_ -> addWidget(printtype_label_);
|
vlayout0_ -> addWidget(printtype_label_);
|
||||||
vlayout0_ -> addLayout(glayout0_);
|
vlayout0_ -> addLayout(glayout0_);
|
||||||
vlayout0_ -> addWidget(buttons_);
|
vlayout0_ -> addWidget(buttons_);
|
||||||
|
|
||||||
dialog_ -> setLayout(vlayout0_);
|
dialog_ -> setLayout(vlayout0_);
|
||||||
|
|
||||||
updatePrintTypeDialog();
|
updatePrintTypeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,11 +286,11 @@ void DiagramPrintDialog::updatePrintTypeDialog()
|
|||||||
{
|
{
|
||||||
// imprime-t-on vers un fichier ?
|
// imprime-t-on vers un fichier ?
|
||||||
bool file_print = !(printer_choice_ -> isChecked());
|
bool file_print = !(printer_choice_ -> isChecked());
|
||||||
|
|
||||||
// on n'active le champ fichier que pour les impressions vers un fichier
|
// on n'active le champ fichier que pour les impressions vers un fichier
|
||||||
filepath_field_ -> setEnabled(file_print);
|
filepath_field_ -> setEnabled(file_print);
|
||||||
browse_button_ -> setEnabled(file_print);
|
browse_button_ -> setEnabled(file_print);
|
||||||
|
|
||||||
// on corrige eventuellement l'extension du fichier deja selectionne
|
// on corrige eventuellement l'extension du fichier deja selectionne
|
||||||
if (file_print)
|
if (file_print)
|
||||||
{
|
{
|
||||||
@@ -299,7 +299,9 @@ void DiagramPrintDialog::updatePrintTypeDialog()
|
|||||||
{
|
{
|
||||||
if (pdf_choice_ -> isChecked() && filepath.endsWith(".ps"))
|
if (pdf_choice_ -> isChecked() && filepath.endsWith(".ps"))
|
||||||
{
|
{
|
||||||
QRegExp re("\\.ps$", Qt::CaseInsensitive);
|
QRegularExpression re
|
||||||
|
("\\.ps$",
|
||||||
|
QRegularExpression::CaseInsensitiveOption);
|
||||||
filepath.replace(re, ".pdf");
|
filepath.replace(re, ".pdf");
|
||||||
filepath_field_ -> setText(filepath);
|
filepath_field_ -> setText(filepath);
|
||||||
}
|
}
|
||||||
@@ -331,7 +333,7 @@ void DiagramPrintDialog::acceptPrintTypeDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet a l'utilisateur de choisir un fichier
|
Permet a l'utilisateur de choisir un fichier
|
||||||
*/
|
*/
|
||||||
void DiagramPrintDialog::browseFilePrintTypeDialog()
|
void DiagramPrintDialog::browseFilePrintTypeDialog()
|
||||||
{
|
{
|
||||||
@@ -343,14 +345,14 @@ void DiagramPrintDialog::browseFilePrintTypeDialog()
|
|||||||
extension = ".pdf";
|
extension = ".pdf";
|
||||||
filter = tr("Fichiers PDF (*.pdf)", "file filter");
|
filter = tr("Fichiers PDF (*.pdf)", "file filter");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString filepath = QFileDialog::getSaveFileName(
|
QString filepath = QFileDialog::getSaveFileName(
|
||||||
parentWidget(),
|
parentWidget(),
|
||||||
QString(),
|
QString(),
|
||||||
filepath_field_ -> text(),
|
filepath_field_ -> text(),
|
||||||
filter
|
filter
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
if (!filepath.endsWith(extension)) filepath += extension;
|
if (!filepath.endsWith(extension)) filepath += extension;
|
||||||
filepath = QDir::toNativeSeparators(QDir::cleanPath(filepath));
|
filepath = QDir::toNativeSeparators(QDir::cleanPath(filepath));
|
||||||
@@ -390,13 +392,13 @@ void DiagramPrintDialog::print(const QList<Diagram *> &diagrams,
|
|||||||
#endif
|
#endif
|
||||||
// QPainter utiliser pour effectuer le rendu
|
// QPainter utiliser pour effectuer le rendu
|
||||||
QPainter qp(printer_);
|
QPainter qp(printer_);
|
||||||
|
|
||||||
// cas special : il n'y a aucun schema a imprimer
|
// cas special : il n'y a aucun schema a imprimer
|
||||||
if (!diagrams.count()) {
|
if (!diagrams.count()) {
|
||||||
qp.end();
|
qp.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// imprime les schemas
|
// imprime les schemas
|
||||||
for (int i = 0 ; i < diagrams.count() ; ++ i) {
|
for (int i = 0 ; i < diagrams.count() ; ++ i) {
|
||||||
printDiagram(diagrams[i], fit_page, options, &qp, printer_);
|
printDiagram(diagrams[i], fit_page, options, &qp, printer_);
|
||||||
@@ -422,18 +424,18 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
//qDebug() << printer -> paperSize() << printer -> paperRect() << diagram -> title();
|
//qDebug() << printer -> paperSize() << printer -> paperRect() << diagram -> title();
|
||||||
// l'imprimante utilise-t-elle toute la feuille ?
|
// l'imprimante utilise-t-elle toute la feuille ?
|
||||||
bool full_page = printer -> fullPage();
|
bool full_page = printer -> fullPage();
|
||||||
|
|
||||||
// impression physique (!= fichier PDF)
|
// impression physique (!= fichier PDF)
|
||||||
if (printer -> outputFileName().isEmpty()) {
|
if (printer -> outputFileName().isEmpty()) {
|
||||||
// utiliser cette condition pour agir differemment en cas d'impression physique
|
// utiliser cette condition pour agir differemment en cas d'impression physique
|
||||||
}
|
}
|
||||||
|
|
||||||
saveReloadDiagramParameters(diagram, options, true);
|
saveReloadDiagramParameters(diagram, options, true);
|
||||||
|
|
||||||
// deselectionne tous les elements
|
// deselectionne tous les elements
|
||||||
QList<QGraphicsItem *> selected_elmts = diagram -> selectedItems();
|
QList<QGraphicsItem *> selected_elmts = diagram -> selectedItems();
|
||||||
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(false);
|
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(false);
|
||||||
|
|
||||||
// enleve le flag focusable de tous les elements concernes pour eviter toute reprise de focus par un champ de texte editable
|
// enleve le flag focusable de tous les elements concernes pour eviter toute reprise de focus par un champ de texte editable
|
||||||
QList<QGraphicsItem *> focusable_items;
|
QList<QGraphicsItem *> focusable_items;
|
||||||
foreach (QGraphicsItem *qgi, diagram -> items()) {
|
foreach (QGraphicsItem *qgi, diagram -> items()) {
|
||||||
@@ -442,12 +444,12 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
qgi -> setFlag(QGraphicsItem::ItemIsFocusable, false);
|
qgi -> setFlag(QGraphicsItem::ItemIsFocusable, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// evite toute autre forme d'interaction
|
// evite toute autre forme d'interaction
|
||||||
foreach (QGraphicsView *view, diagram -> views()) {
|
foreach (QGraphicsView *view, diagram -> views()) {
|
||||||
view -> setInteractive(false);
|
view -> setInteractive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect diagram_rect = diagramRect(diagram, options);
|
QRect diagram_rect = diagramRect(diagram, options);
|
||||||
if (fit_page) {
|
if (fit_page) {
|
||||||
// impression adaptee sur une seule page
|
// impression adaptee sur une seule page
|
||||||
@@ -458,19 +460,19 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
//qDebug() << "impression sur une ou plusieurs pages";
|
//qDebug() << "impression sur une ou plusieurs pages";
|
||||||
//qDebug() << " schema :" << diagram_rect;
|
//qDebug() << " schema :" << diagram_rect;
|
||||||
//qDebug() << " page :" << printed_area;
|
//qDebug() << " page :" << printed_area;
|
||||||
|
|
||||||
int used_width = printed_area.width();
|
int used_width = printed_area.width();
|
||||||
int used_height = printed_area.height();
|
int used_height = printed_area.height();
|
||||||
int h_pages_count = horizontalPagesCount(diagram, options, full_page);
|
int h_pages_count = horizontalPagesCount(diagram, options, full_page);
|
||||||
int v_pages_count = verticalPagesCount(diagram, options, full_page);
|
int v_pages_count = verticalPagesCount(diagram, options, full_page);
|
||||||
|
|
||||||
QVector< QVector< QRect > > pages_grid;
|
QVector< QVector< QRect > > pages_grid;
|
||||||
// le schema est imprime sur une matrice de feuilles
|
// le schema est imprime sur une matrice de feuilles
|
||||||
// parcourt les lignes de la matrice
|
// parcourt les lignes de la matrice
|
||||||
int y_offset = 0;
|
int y_offset = 0;
|
||||||
for (int i = 0 ; i < v_pages_count ; ++ i) {
|
for (int i = 0 ; i < v_pages_count ; ++ i) {
|
||||||
pages_grid << QVector< QRect >();
|
pages_grid << QVector< QRect >();
|
||||||
|
|
||||||
// parcourt les feuilles de la ligne
|
// parcourt les feuilles de la ligne
|
||||||
int x_offset = 0;
|
int x_offset = 0;
|
||||||
for (int j = 0 ; j < h_pages_count ; ++ j) {
|
for (int j = 0 ; j < h_pages_count ; ++ j) {
|
||||||
@@ -483,10 +485,10 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
);
|
);
|
||||||
x_offset += used_width;
|
x_offset += used_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
y_offset += used_height;
|
y_offset += used_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ne retient que les pages a imprimer
|
// ne retient que les pages a imprimer
|
||||||
QVector<QRect> pages_to_print;
|
QVector<QRect> pages_to_print;
|
||||||
for (int i = 0 ; i < v_pages_count ; ++ i) {
|
for (int i = 0 ; i < v_pages_count ; ++ i) {
|
||||||
@@ -495,7 +497,7 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//qDebug() << " " << pages_to_print.count() << " pages a imprimer :";
|
//qDebug() << " " << pages_to_print.count() << " pages a imprimer :";
|
||||||
|
|
||||||
// parcourt les pages pour impression
|
// parcourt les pages pour impression
|
||||||
for (int i = 0 ; i < pages_to_print.count() ; ++ i) {
|
for (int i = 0 ; i < pages_to_print.count() ; ++ i) {
|
||||||
QRect current_rect(pages_to_print.at(i));
|
QRect current_rect(pages_to_print.at(i));
|
||||||
@@ -511,20 +513,20 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remet en place les interactions
|
// remet en place les interactions
|
||||||
foreach (QGraphicsView *view, diagram -> views()) {
|
foreach (QGraphicsView *view, diagram -> views()) {
|
||||||
view -> setInteractive(true);
|
view -> setInteractive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// restaure les flags focusable
|
// restaure les flags focusable
|
||||||
foreach (QGraphicsItem *qgi, focusable_items) {
|
foreach (QGraphicsItem *qgi, focusable_items) {
|
||||||
qgi -> setFlag(QGraphicsItem::ItemIsFocusable, true);
|
qgi -> setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// restaure les elements selectionnes
|
// restaure les elements selectionnes
|
||||||
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(true);
|
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(true);
|
||||||
|
|
||||||
saveReloadDiagramParameters(diagram, options, false);
|
saveReloadDiagramParameters(diagram, options, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,7 +539,7 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
*/
|
*/
|
||||||
void DiagramPrintDialog::saveReloadDiagramParameters(Diagram *diagram, const ExportProperties& options, bool save) {
|
void DiagramPrintDialog::saveReloadDiagramParameters(Diagram *diagram, const ExportProperties& options, bool save) {
|
||||||
static ExportProperties state_exportProperties;
|
static ExportProperties state_exportProperties;
|
||||||
|
|
||||||
if (save) {
|
if (save) {
|
||||||
// memorise les parametres relatifs au schema tout en appliquant les nouveaux
|
// memorise les parametres relatifs au schema tout en appliquant les nouveaux
|
||||||
state_exportProperties = diagram -> applyProperties(options);
|
state_exportProperties = diagram -> applyProperties(options);
|
||||||
@@ -556,11 +558,11 @@ void DiagramPrintDialog::savePageSetupForCurrentPrinter()
|
|||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString printer_section = settingsSectionName(printer_);
|
QString printer_section = settingsSectionName(printer_);
|
||||||
|
|
||||||
while (!settings.group().isEmpty()) settings.endGroup();
|
while (!settings.group().isEmpty()) settings.endGroup();
|
||||||
settings.beginGroup("printers");
|
settings.beginGroup("printers");
|
||||||
settings.beginGroup(printer_section);
|
settings.beginGroup(printer_section);
|
||||||
|
|
||||||
settings.setValue("orientation", printer_ -> orientation() == QPrinter::Portrait ? "portrait" : "landscape");
|
settings.setValue("orientation", printer_ -> orientation() == QPrinter::Portrait ? "portrait" : "landscape");
|
||||||
settings.setValue("papersize", int(printer_ -> paperSize()));
|
settings.setValue("papersize", int(printer_ -> paperSize()));
|
||||||
if (printer_ -> paperSize() == QPrinter::Custom) {
|
if (printer_ -> paperSize() == QPrinter::Custom) {
|
||||||
@@ -592,14 +594,14 @@ void DiagramPrintDialog::loadPageSetupForCurrentPrinter()
|
|||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString printer_section = settingsSectionName(printer_);
|
QString printer_section = settingsSectionName(printer_);
|
||||||
|
|
||||||
while (!settings.group().isEmpty()) settings.endGroup();
|
while (!settings.group().isEmpty()) settings.endGroup();
|
||||||
settings.beginGroup("printers");
|
settings.beginGroup("printers");
|
||||||
if (!settings.childGroups().contains(printer_section)) {
|
if (!settings.childGroups().contains(printer_section)) {
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.beginGroup(printer_section);
|
settings.beginGroup(printer_section);
|
||||||
if (settings.contains("orientation")) {
|
if (settings.contains("orientation")) {
|
||||||
QString value = settings.value("orientation", "landscape").toString();
|
QString value = settings.value("orientation", "landscape").toString();
|
||||||
@@ -618,7 +620,7 @@ void DiagramPrintDialog::loadPageSetupForCurrentPrinter()
|
|||||||
printer_ -> setPaperSize(static_cast<QPrinter::PaperSize>(value));
|
printer_ -> setPaperSize(static_cast<QPrinter::PaperSize>(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal margins[4];
|
qreal margins[4];
|
||||||
printer_ -> getPageMargins(&margins[0], &margins[1], &margins[2], &margins[3], QPrinter::Millimeter);
|
printer_ -> getPageMargins(&margins[0], &margins[1], &margins[2], &margins[3], QPrinter::Millimeter);
|
||||||
QStringList margins_names(QStringList() << "left" << "top" << "right" << "bottom");
|
QStringList margins_names(QStringList() << "left" << "top" << "right" << "bottom");
|
||||||
@@ -629,7 +631,7 @@ void DiagramPrintDialog::loadPageSetupForCurrentPrinter()
|
|||||||
}
|
}
|
||||||
printer_ -> setPageMargins(margins[0], margins[1], margins[2], margins[3], QPrinter::Millimeter);
|
printer_ -> setPageMargins(margins[0], margins[1], margins[2], margins[3], QPrinter::Millimeter);
|
||||||
printer_ -> setFullPage(settings.value("fullpage", "false").toString() == "true");
|
printer_ -> setFullPage(settings.value("fullpage", "false").toString() == "true");
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
#include "elementscene.h"
|
#include "elementscene.h"
|
||||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief CustomElementGraphicPart::CustomElementGraphicPart
|
@brief CustomElementGraphicPart::CustomElementGraphicPart
|
||||||
Default constructor.
|
Default constructor.
|
||||||
@@ -162,13 +164,13 @@ void CustomElementGraphicPart::setAntialiased(const bool b)
|
|||||||
void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
|
void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
|
||||||
{
|
{
|
||||||
QString css_like_styles;
|
QString css_like_styles;
|
||||||
|
|
||||||
css_like_styles += "line-style:";
|
css_like_styles += "line-style:";
|
||||||
if (_linestyle == DashedStyle) css_like_styles += "dashed";
|
if (_linestyle == DashedStyle) css_like_styles += "dashed";
|
||||||
else if (_linestyle == DottedStyle) css_like_styles += "dotted";
|
else if (_linestyle == DottedStyle) css_like_styles += "dotted";
|
||||||
else if (_linestyle == DashdottedStyle) css_like_styles += "dashdotted";
|
else if (_linestyle == DashdottedStyle) css_like_styles += "dashdotted";
|
||||||
else if (_linestyle == NormalStyle) css_like_styles += "normal";
|
else if (_linestyle == NormalStyle) css_like_styles += "normal";
|
||||||
|
|
||||||
css_like_styles += ";line-weight:";
|
css_like_styles += ";line-weight:";
|
||||||
if (_lineweight == NoneWeight) css_like_styles += "none";
|
if (_lineweight == NoneWeight) css_like_styles += "none";
|
||||||
else if (_lineweight == ThinWeight) css_like_styles += "thin";
|
else if (_lineweight == ThinWeight) css_like_styles += "thin";
|
||||||
@@ -508,7 +510,7 @@ void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
|
|||||||
void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
||||||
{
|
{
|
||||||
resetStyles();
|
resetStyles();
|
||||||
|
|
||||||
//Get the list of pair style/value
|
//Get the list of pair style/value
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||||
QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
|
QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
|
||||||
@@ -516,14 +518,14 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
|||||||
#pragma message("@TODO remove code for QT 5.14 or later")
|
#pragma message("@TODO remove code for QT 5.14 or later")
|
||||||
QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts);
|
QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Check each pair of style
|
//Check each pair of style
|
||||||
QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
|
QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
|
||||||
foreach (QString style, styles)
|
foreach (QString style, styles)
|
||||||
{
|
{
|
||||||
if (!rx.exactMatch(style)) continue;
|
if (rx!=QRegularExpression(style)) continue;
|
||||||
QString style_name = rx.cap(1);
|
QString style_name = rx.namedCaptureGroups().at(1);
|
||||||
QString style_value = rx.cap(2);
|
QString style_value = rx.namedCaptureGroups().at(2);
|
||||||
if (style_name == "line-style")
|
if (style_name == "line-style")
|
||||||
{
|
{
|
||||||
if (style_value == "dashed") _linestyle = DashedStyle;
|
if (style_value == "dashed") _linestyle = DashedStyle;
|
||||||
@@ -887,13 +889,13 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
|||||||
//Get the pen and brush
|
//Get the pen and brush
|
||||||
QPen pen = painter.pen();
|
QPen pen = painter.pen();
|
||||||
QBrush brush = painter.brush();
|
QBrush brush = painter.brush();
|
||||||
|
|
||||||
//Apply pen style
|
//Apply pen style
|
||||||
if (_linestyle == DashedStyle) pen.setStyle(Qt::DashLine);
|
if (_linestyle == DashedStyle) pen.setStyle(Qt::DashLine);
|
||||||
else if (_linestyle == DashdottedStyle) pen.setStyle(Qt::DashDotLine);
|
else if (_linestyle == DashdottedStyle) pen.setStyle(Qt::DashDotLine);
|
||||||
else if (_linestyle == DottedStyle) pen.setStyle(Qt::DotLine);
|
else if (_linestyle == DottedStyle) pen.setStyle(Qt::DotLine);
|
||||||
else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
|
else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
|
||||||
|
|
||||||
//Apply pen width
|
//Apply pen width
|
||||||
if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
|
if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
|
||||||
else if (_lineweight == ThinWeight) pen.setWidth(0);
|
else if (_lineweight == ThinWeight) pen.setWidth(0);
|
||||||
@@ -1064,7 +1066,7 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
|||||||
else if (_filling == HTMLGrayDarkSlateGrayFilling) brush.setColor(QColor(47, 79, 79));
|
else if (_filling == HTMLGrayDarkSlateGrayFilling) brush.setColor(QColor(47, 79, 79));
|
||||||
else if (_filling == HTMLGrayBlackFilling) brush.setColor(QColor(0, 0, 0));
|
else if (_filling == HTMLGrayBlackFilling) brush.setColor(QColor(0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Apply pen color
|
//Apply pen color
|
||||||
if (_color == WhiteColor) pen.setColor(QColor(255, 255, 255, pen.color().alpha()));
|
if (_color == WhiteColor) pen.setColor(QColor(255, 255, 255, pen.color().alpha()));
|
||||||
else if (_color == BlackColor) pen.setColor(QColor( 0, 0, 0, pen.color().alpha()));
|
else if (_color == BlackColor) pen.setColor(QColor( 0, 0, 0, pen.color().alpha()));
|
||||||
@@ -1220,12 +1222,12 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
|||||||
else if (_color == HTMLGrayDarkSlateGrayColor) pen.setColor(QColor(47, 79, 79));
|
else if (_color == HTMLGrayDarkSlateGrayColor) pen.setColor(QColor(47, 79, 79));
|
||||||
else if (_color == HTMLGrayBlackColor) pen.setColor(QColor(0, 0, 0));
|
else if (_color == HTMLGrayBlackColor) pen.setColor(QColor(0, 0, 0));
|
||||||
else if (_color == NoneColor) pen.setBrush(Qt::transparent);
|
else if (_color == NoneColor) pen.setBrush(Qt::transparent);
|
||||||
|
|
||||||
//Apply antialiasing
|
//Apply antialiasing
|
||||||
painter.setRenderHint(QPainter::Antialiasing, _antialiased);
|
painter.setRenderHint(QPainter::Antialiasing, _antialiased);
|
||||||
painter.setRenderHint(QPainter::TextAntialiasing, _antialiased);
|
painter.setRenderHint(QPainter::TextAntialiasing, _antialiased);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform, _antialiased);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform, _antialiased);
|
||||||
|
|
||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
painter.setBrush(brush);
|
painter.setBrush(brush);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,54 +407,6 @@ QPainterPath PartLine::shadowShape() const
|
|||||||
return (pps.createStroke(shape));
|
return (pps.createStroke(shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@brief PartLine::fourShapePoints
|
|
||||||
@return a list with the two points that delimite the line
|
|
||||||
+ the four points surrounding these two points
|
|
||||||
*/
|
|
||||||
QList<QPointF> PartLine::fourShapePoints() const
|
|
||||||
{
|
|
||||||
const qreal marge = 2.0;
|
|
||||||
|
|
||||||
QPointF a = m_line.p1();
|
|
||||||
QPointF b = m_line.p2();
|
|
||||||
|
|
||||||
QList<QPointF> result;
|
|
||||||
|
|
||||||
//Special case, the line is defined by one point
|
|
||||||
if (a == b)
|
|
||||||
{
|
|
||||||
result << QPointF(a.x() - marge, a.y() - marge);
|
|
||||||
result << QPointF(a.x() - marge, a.y() + marge);
|
|
||||||
result << QPointF(a.x() + marge, a.y() + marge);
|
|
||||||
result << QPointF(a.x() + marge, a.y() - marge);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//We calcule the vector AB : (xb-xa, yb-ya)
|
|
||||||
QPointF v_ab = b - a;
|
|
||||||
|
|
||||||
//And the distance AB: root of the coordinates of the vector squared
|
|
||||||
qreal ab = sqrt(pow(v_ab.x(), 2) + pow(v_ab.y(), 2));
|
|
||||||
|
|
||||||
//Next, we define the vector u(a, b) wich is equal to the vector AB divided
|
|
||||||
//by is length and multiplied by the length of marge.
|
|
||||||
QPointF u = v_ab / ab * marge;
|
|
||||||
|
|
||||||
//We define the vector v(-b, a) wich is perpendicular to AB
|
|
||||||
QPointF v(-u.y(), u.x());
|
|
||||||
QPointF m = -u + v; // we have vector M = -u + v
|
|
||||||
QPointF n = -u - v; // and vector N=-u-v
|
|
||||||
QPointF h = a + m; // H = A + M
|
|
||||||
QPointF k = a + n; // K = A + N
|
|
||||||
QPointF i = b - n; // I = B - N
|
|
||||||
QPointF j = b - m; // J = B - M
|
|
||||||
|
|
||||||
result << h << i << j << k;
|
|
||||||
}
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartLine::firstEndCircleRect
|
@brief PartLine::firstEndCircleRect
|
||||||
@return the rectangle bordering the entirety of the first extremity
|
@return the rectangle bordering the entirety of the first extremity
|
||||||
@@ -491,35 +443,6 @@ QRectF PartLine::secondEndCircleRect() const
|
|||||||
return(end_rect);
|
return(end_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@brief PartLine::debugPaint
|
|
||||||
Display several composante of the drawing
|
|
||||||
-the bounding rect
|
|
||||||
-special points at each extremity
|
|
||||||
-the quadrature of the circle at each extremity, even if itself is an other type
|
|
||||||
@param painter
|
|
||||||
*/
|
|
||||||
void PartLine::debugPaint(QPainter *painter)
|
|
||||||
{
|
|
||||||
painter -> save();
|
|
||||||
painter -> setPen(Qt::gray);
|
|
||||||
painter -> drawRect(boundingRect());
|
|
||||||
|
|
||||||
painter -> setPen(Qt::green);
|
|
||||||
painter -> drawRect(firstEndCircleRect());
|
|
||||||
painter -> drawRect(secondEndCircleRect());
|
|
||||||
|
|
||||||
painter -> setPen(Qt::red);
|
|
||||||
|
|
||||||
foreach(QPointF pointy, fourEndPoints(m_line.p1(), m_line.p2(), first_length))
|
|
||||||
painter -> drawEllipse(pointy, 0.1, 0.1);
|
|
||||||
|
|
||||||
foreach(QPointF pointy, fourEndPoints(m_line.p2(), m_line.p1(), second_length))
|
|
||||||
painter -> drawEllipse(pointy, 0.1, 0.1);
|
|
||||||
|
|
||||||
painter -> restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartLine::boundingRect
|
@brief PartLine::boundingRect
|
||||||
@return the bounding rect of this part
|
@return the bounding rect of this part
|
||||||
|
|||||||
@@ -110,10 +110,8 @@ class PartLine : public CustomElementGraphicPart
|
|||||||
void removeHandler();
|
void removeHandler();
|
||||||
|
|
||||||
QPainterPath path() const;
|
QPainterPath path() const;
|
||||||
QList<QPointF> fourShapePoints() const;
|
|
||||||
QRectF firstEndCircleRect() const;
|
QRectF firstEndCircleRect() const;
|
||||||
QRectF secondEndCircleRect() const;
|
QRectF secondEndCircleRect() const;
|
||||||
void debugPaint(QPainter *);
|
|
||||||
|
|
||||||
/*****************/
|
/*****************/
|
||||||
Qet::EndType first_end;
|
Qet::EndType first_end;
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -83,7 +83,7 @@ QETElementEditor::QETElementEditor(QWidget *parent) :
|
|||||||
// la fenetre est maximisee par defaut
|
// la fenetre est maximisee par defaut
|
||||||
setMinimumSize(QSize(500, 350));
|
setMinimumSize(QSize(500, 350));
|
||||||
setWindowState(Qt::WindowMaximized);
|
setWindowState(Qt::WindowMaximized);
|
||||||
|
|
||||||
// lecture des parametres
|
// lecture des parametres
|
||||||
readSettings();
|
readSettings();
|
||||||
slot_updateMenus();
|
slot_updateMenus();
|
||||||
@@ -165,7 +165,7 @@ void QETElementEditor::setupActions()
|
|||||||
open_dxf -> setStatusTip(tr("To install the plugin DXFtoQET\nVisit https://download.tuxfamily.org/qet/builds/dxf_to_elmt/\n"
|
open_dxf -> setStatusTip(tr("To install the plugin DXFtoQET\nVisit https://download.tuxfamily.org/qet/builds/dxf_to_elmt/\n"
|
||||||
"\n"
|
"\n"
|
||||||
">> Install on Windows\n"
|
">> Install on Windows\n"
|
||||||
"Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
|
"Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
|
||||||
));
|
));
|
||||||
#elif defined(Q_OS_MAC)
|
#elif defined(Q_OS_MAC)
|
||||||
open_dxf -> setStatusTip(tr("To install the plugin DXFtoQET\nVisit https://download.tuxfamily.org/qet/builds/dxf_to_elmt/\n"
|
open_dxf -> setStatusTip(tr("To install the plugin DXFtoQET\nVisit https://download.tuxfamily.org/qet/builds/dxf_to_elmt/\n"
|
||||||
@@ -188,7 +188,7 @@ void QETElementEditor::setupActions()
|
|||||||
"Put DXFtoQET binary on your /home/user_name/.qet/ directory\n"
|
"Put DXFtoQET binary on your /home/user_name/.qet/ directory\n"
|
||||||
"make it executable : chmod +x ./DXFtoQET\n"
|
"make it executable : chmod +x ./DXFtoQET\n"
|
||||||
">> Install on Windows\n"
|
">> Install on Windows\n"
|
||||||
"Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
|
"Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
|
||||||
"\n"
|
"\n"
|
||||||
">> Install on macOSX\n"
|
">> Install on macOSX\n"
|
||||||
"Put DXFtoQET.app binary on /Users/user_name/.qet/ directory \n"
|
"Put DXFtoQET.app binary on /Users/user_name/.qet/ directory \n"
|
||||||
@@ -491,7 +491,7 @@ void QETElementEditor::slot_updateMenus()
|
|||||||
// actions dependant du contenu du presse-papiers
|
// actions dependant du contenu du presse-papiers
|
||||||
paste -> setEnabled(clipboard_elmt);
|
paste -> setEnabled(clipboard_elmt);
|
||||||
paste_in_area -> setEnabled(clipboard_elmt);
|
paste_in_area -> setEnabled(clipboard_elmt);
|
||||||
|
|
||||||
// actions dependant de l'etat de la pile d'annulation
|
// actions dependant de l'etat de la pile d'annulation
|
||||||
save -> setEnabled(!read_only && !m_elmt_scene -> undoStack().isClean());
|
save -> setEnabled(!read_only && !m_elmt_scene -> undoStack().isClean());
|
||||||
undo -> setEnabled(!read_only && m_elmt_scene -> undoStack().canUndo());
|
undo -> setEnabled(!read_only && m_elmt_scene -> undoStack().canUndo());
|
||||||
@@ -534,7 +534,7 @@ void QETElementEditor::setupInterface()
|
|||||||
// m_tools_dock_scroll_area = new QScrollArea();
|
// m_tools_dock_scroll_area = new QScrollArea();
|
||||||
// m_tools_dock_scroll_area -> setFrameStyle(QFrame::NoFrame);
|
// m_tools_dock_scroll_area -> setFrameStyle(QFrame::NoFrame);
|
||||||
// m_tools_dock_scroll_area -> setAlignment(Qt::AlignHCenter|Qt::AlignTop);
|
// m_tools_dock_scroll_area -> setAlignment(Qt::AlignHCenter|Qt::AlignTop);
|
||||||
|
|
||||||
// Pile de widgets pour accueillir les deux widgets precedents
|
// Pile de widgets pour accueillir les deux widgets precedents
|
||||||
m_tools_dock_stack = new QStackedWidget();
|
m_tools_dock_stack = new QStackedWidget();
|
||||||
m_tools_dock_stack -> insertWidget(0, m_default_informations);
|
m_tools_dock_stack -> insertWidget(0, m_default_informations);
|
||||||
@@ -555,7 +555,10 @@ void QETElementEditor::setupInterface()
|
|||||||
m_tools_dock = new QDockWidget(tr("Informations", "dock title"), this);
|
m_tools_dock = new QDockWidget(tr("Informations", "dock title"), this);
|
||||||
m_tools_dock -> setObjectName("informations");
|
m_tools_dock -> setObjectName("informations");
|
||||||
m_tools_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
m_tools_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||||
m_tools_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
m_tools_dock -> setFeatures(
|
||||||
|
QDockWidget::DockWidgetClosable
|
||||||
|
|QDockWidget::DockWidgetMovable
|
||||||
|
|QDockWidget::DockWidgetFloatable);
|
||||||
//m_tools_dock -> setMinimumWidth(380);
|
//m_tools_dock -> setMinimumWidth(380);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, m_tools_dock);
|
addDockWidget(Qt::RightDockWidgetArea, m_tools_dock);
|
||||||
m_tools_dock -> setWidget(m_tools_dock_stack);
|
m_tools_dock -> setWidget(m_tools_dock_stack);
|
||||||
@@ -564,7 +567,10 @@ void QETElementEditor::setupInterface()
|
|||||||
m_undo_dock = new QDockWidget(tr("Annulations", "dock title"), this);
|
m_undo_dock = new QDockWidget(tr("Annulations", "dock title"), this);
|
||||||
m_undo_dock -> setObjectName("undo");
|
m_undo_dock -> setObjectName("undo");
|
||||||
m_undo_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
m_undo_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||||
m_undo_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
m_undo_dock -> setFeatures(
|
||||||
|
QDockWidget::DockWidgetClosable
|
||||||
|
|QDockWidget::DockWidgetMovable
|
||||||
|
|QDockWidget::DockWidgetFloatable);
|
||||||
m_undo_dock -> setMinimumWidth(290);
|
m_undo_dock -> setMinimumWidth(290);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, m_undo_dock);
|
addDockWidget(Qt::RightDockWidgetArea, m_undo_dock);
|
||||||
QUndoView* undo_view = new QUndoView(&(m_elmt_scene -> undoStack()), this);
|
QUndoView* undo_view = new QUndoView(&(m_elmt_scene -> undoStack()), this);
|
||||||
@@ -582,7 +588,10 @@ void QETElementEditor::setupInterface()
|
|||||||
m_parts_dock = new QDockWidget(tr("Parties", "dock title"), this);
|
m_parts_dock = new QDockWidget(tr("Parties", "dock title"), this);
|
||||||
m_parts_dock -> setObjectName("parts_list");
|
m_parts_dock -> setObjectName("parts_list");
|
||||||
m_parts_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
m_parts_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||||
m_parts_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
m_parts_dock -> setFeatures(
|
||||||
|
QDockWidget::DockWidgetClosable
|
||||||
|
|QDockWidget::DockWidgetMovable
|
||||||
|
|QDockWidget::DockWidgetFloatable);
|
||||||
m_parts_dock -> setMinimumWidth(290);
|
m_parts_dock -> setMinimumWidth(290);
|
||||||
tabifyDockWidget(m_undo_dock, m_parts_dock);
|
tabifyDockWidget(m_undo_dock, m_parts_dock);
|
||||||
m_parts_dock -> setWidget(m_parts_list);
|
m_parts_dock -> setWidget(m_parts_list);
|
||||||
@@ -1126,10 +1135,10 @@ void QETElementEditor::slot_openFile()
|
|||||||
{
|
{
|
||||||
// repertoire a afficher initialement dans le dialogue
|
// repertoire a afficher initialement dans le dialogue
|
||||||
QString open_dir = filename_.isEmpty() ? QETApp::customElementsDir() : QDir(filename_).absolutePath();
|
QString open_dir = filename_.isEmpty() ? QETApp::customElementsDir() : QDir(filename_).absolutePath();
|
||||||
|
|
||||||
// demande un nom de fichier a ouvrir a l'utilisateur
|
// demande un nom de fichier a ouvrir a l'utilisateur
|
||||||
QString user_filename = QETElementEditor::getOpenElementFileName(this, open_dir);
|
QString user_filename = QETElementEditor::getOpenElementFileName(this, open_dir);
|
||||||
|
|
||||||
// ouvre l'element
|
// ouvre l'element
|
||||||
openElement(user_filename);
|
openElement(user_filename);
|
||||||
}
|
}
|
||||||
@@ -1445,7 +1454,7 @@ void QETElementEditor::slot_createPartsList()
|
|||||||
m_parts_list -> blockSignals(true);
|
m_parts_list -> blockSignals(true);
|
||||||
m_parts_list -> clear();
|
m_parts_list -> clear();
|
||||||
QList<QGraphicsItem *> qgis = m_elmt_scene -> zItems();
|
QList<QGraphicsItem *> qgis = m_elmt_scene -> zItems();
|
||||||
|
|
||||||
// on ne construit plus la liste a partir de 200 primitives
|
// on ne construit plus la liste a partir de 200 primitives
|
||||||
// c'est ingerable : la maj de la liste prend trop de temps et le resultat
|
// c'est ingerable : la maj de la liste prend trop de temps et le resultat
|
||||||
// est inexploitable
|
// est inexploitable
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -200,7 +200,7 @@ StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p,
|
|||||||
line_style -> addItem(tr("Pointillé", "element part line style"), CustomElementGraphicPart::DottedStyle);
|
line_style -> addItem(tr("Pointillé", "element part line style"), CustomElementGraphicPart::DottedStyle);
|
||||||
line_style -> addItem(tr("Traits et points", "element part line style"), CustomElementGraphicPart::DashdottedStyle);
|
line_style -> addItem(tr("Traits et points", "element part line style"), CustomElementGraphicPart::DashdottedStyle);
|
||||||
//normal_style -> setChecked(true);
|
//normal_style -> setChecked(true);
|
||||||
|
|
||||||
// epaisseur
|
// epaisseur
|
||||||
size_weight = new QComboBox(this);
|
size_weight = new QComboBox(this);
|
||||||
size_weight -> addItem(tr("Nulle", "element part weight"), CustomElementGraphicPart::NoneWeight);
|
size_weight -> addItem(tr("Nulle", "element part weight"), CustomElementGraphicPart::NoneWeight);
|
||||||
@@ -374,16 +374,16 @@ StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p,
|
|||||||
|
|
||||||
// antialiasing
|
// antialiasing
|
||||||
antialiasing = new QCheckBox(tr("Antialiasing"));
|
antialiasing = new QCheckBox(tr("Antialiasing"));
|
||||||
|
|
||||||
updateForm();
|
updateForm();
|
||||||
|
|
||||||
auto main_layout = new QVBoxLayout();
|
auto main_layout = new QVBoxLayout();
|
||||||
main_layout -> setMargin(0);
|
main_layout -> setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
main_layout -> addWidget(new QLabel("<u>" + tr("Apparence :") + "</u> "));
|
main_layout -> addWidget(new QLabel("<u>" + tr("Apparence :") + "</u> "));
|
||||||
|
|
||||||
outline_color->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
|
outline_color->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||||
filling_color->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
|
filling_color->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||||
auto grid_layout = new QGridLayout(this);
|
auto grid_layout = new QGridLayout(this);
|
||||||
grid_layout->addWidget(new QLabel(tr("Contour :")), 0,0, Qt::AlignRight);
|
grid_layout->addWidget(new QLabel(tr("Contour :")), 0,0, Qt::AlignRight);
|
||||||
grid_layout->addWidget(outline_color, 0, 1);
|
grid_layout->addWidget(outline_color, 0, 1);
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
||||||
// initalise le panel d'elements
|
// initalise le panel d'elements
|
||||||
elements_panel = new ElementsPanel(this);
|
elements_panel = new ElementsPanel(this);
|
||||||
|
|
||||||
// initialise les actions
|
// initialise les actions
|
||||||
open_directory = new QAction(QET::Icons::FolderOpen, tr("Ouvrir le dossier correspondant"), this);
|
open_directory = new QAction(QET::Icons::FolderOpen, tr("Ouvrir le dossier correspondant"), this);
|
||||||
copy_path = new QAction(QET::Icons::IC_CopyFile, tr("Copier le chemin"), this);
|
copy_path = new QAction(QET::Icons::IC_CopyFile, tr("Copier le chemin"), this);
|
||||||
@@ -67,13 +67,13 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
|||||||
tbt_edit = new QAction(QET::Icons::TitleBlock, tr("Éditer ce modèle"), this);
|
tbt_edit = new QAction(QET::Icons::TitleBlock, tr("Éditer ce modèle"), this);
|
||||||
tbt_remove = new QAction(QET::Icons::TitleBlock, tr("Supprimer ce modèle"), this);
|
tbt_remove = new QAction(QET::Icons::TitleBlock, tr("Supprimer ce modèle"), this);
|
||||||
|
|
||||||
|
|
||||||
prj_del_diagram -> setShortcut(QKeySequence(Qt::Key_Delete));
|
prj_del_diagram -> setShortcut(QKeySequence(Qt::Key_Delete));
|
||||||
prj_move_diagram_up -> setShortcut(QKeySequence(Qt::Key_F3));
|
prj_move_diagram_up -> setShortcut(QKeySequence(Qt::Key_F3));
|
||||||
prj_move_diagram_down -> setShortcut(QKeySequence(Qt::Key_F4));
|
prj_move_diagram_down -> setShortcut(QKeySequence(Qt::Key_F4));
|
||||||
prj_move_diagram_top -> setShortcut(QKeySequence(Qt::Key_F5));
|
prj_move_diagram_top -> setShortcut(QKeySequence(Qt::Key_F5));
|
||||||
|
|
||||||
|
|
||||||
// initialise le champ de texte pour filtrer avec une disposition horizontale
|
// initialise le champ de texte pour filtrer avec une disposition horizontale
|
||||||
filter_textfield = new QLineEdit(this);
|
filter_textfield = new QLineEdit(this);
|
||||||
filter_textfield -> setClearButtonEnabled(true);
|
filter_textfield -> setClearButtonEnabled(true);
|
||||||
@@ -81,7 +81,7 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
|||||||
|
|
||||||
|
|
||||||
context_menu = new QMenu(this);
|
context_menu = new QMenu(this);
|
||||||
|
|
||||||
connect(open_directory, SIGNAL(triggered()), this, SLOT(openDirectoryForSelectedItem()));
|
connect(open_directory, SIGNAL(triggered()), this, SLOT(openDirectoryForSelectedItem()));
|
||||||
connect(copy_path, SIGNAL(triggered()), this, SLOT(copyPathForSelectedItem()));
|
connect(copy_path, SIGNAL(triggered()), this, SLOT(copyPathForSelectedItem()));
|
||||||
connect(prj_activate, SIGNAL(triggered()), this, SLOT(activateProject()));
|
connect(prj_activate, SIGNAL(triggered()), this, SLOT(activateProject()));
|
||||||
@@ -98,9 +98,9 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
|||||||
connect(tbt_add, SIGNAL(triggered()), this, SLOT(addTitleBlockTemplate()));
|
connect(tbt_add, SIGNAL(triggered()), this, SLOT(addTitleBlockTemplate()));
|
||||||
connect(tbt_edit, SIGNAL(triggered()), this, SLOT(editTitleBlockTemplate()));
|
connect(tbt_edit, SIGNAL(triggered()), this, SLOT(editTitleBlockTemplate()));
|
||||||
connect(tbt_remove, SIGNAL(triggered()), this, SLOT(removeTitleBlockTemplate()));
|
connect(tbt_remove, SIGNAL(triggered()), this, SLOT(removeTitleBlockTemplate()));
|
||||||
|
|
||||||
connect(filter_textfield, SIGNAL(textChanged(const QString &)), this, SLOT(filterEdited(const QString &)));
|
connect(filter_textfield, SIGNAL(textChanged(const QString &)), this, SLOT(filterEdited(const QString &)));
|
||||||
|
|
||||||
connect(elements_panel, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(updateButtons()));
|
connect(elements_panel, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(updateButtons()));
|
||||||
connect(elements_panel, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(handleContextMenu(const QPoint &)));
|
connect(elements_panel, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(handleContextMenu(const QPoint &)));
|
||||||
connect(elements_panel, SIGNAL(requestForDiagram(Diagram*)), this, SIGNAL(requestForDiagram(Diagram*)));
|
connect(elements_panel, SIGNAL(requestForDiagram(Diagram*)), this, SIGNAL(requestForDiagram(Diagram*)));
|
||||||
@@ -110,10 +110,10 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
|||||||
QETApp::instance(),
|
QETApp::instance(),
|
||||||
SLOT(openTitleBlockTemplate(const TitleBlockTemplateLocation &))
|
SLOT(openTitleBlockTemplate(const TitleBlockTemplateLocation &))
|
||||||
);
|
);
|
||||||
|
|
||||||
// disposition verticale
|
// disposition verticale
|
||||||
QVBoxLayout *vlayout = new QVBoxLayout(this);
|
QVBoxLayout *vlayout = new QVBoxLayout(this);
|
||||||
vlayout -> setMargin(0);
|
vlayout -> setContentsMargins(0,0,0,0);
|
||||||
vlayout -> setSpacing(0);
|
vlayout -> setSpacing(0);
|
||||||
vlayout -> addWidget(filter_textfield);
|
vlayout -> addWidget(filter_textfield);
|
||||||
vlayout -> addWidget(elements_panel);
|
vlayout -> addWidget(elements_panel);
|
||||||
@@ -290,7 +290,7 @@ void ElementsPanelWidget::addTitleBlockTemplate()
|
|||||||
{
|
{
|
||||||
QTreeWidgetItem *current_item = elements_panel -> currentItem();
|
QTreeWidgetItem *current_item = elements_panel -> currentItem();
|
||||||
if (!current_item) return;
|
if (!current_item) return;
|
||||||
|
|
||||||
if (current_item -> type() == QET::TitleBlockTemplatesCollection) {
|
if (current_item -> type() == QET::TitleBlockTemplatesCollection) {
|
||||||
QETApp::instance() -> openTitleBlockTemplate(
|
QETApp::instance() -> openTitleBlockTemplate(
|
||||||
elements_panel -> templateLocationForItem(current_item)
|
elements_panel -> templateLocationForItem(current_item)
|
||||||
@@ -332,18 +332,18 @@ void ElementsPanelWidget::updateButtons()
|
|||||||
{
|
{
|
||||||
QTreeWidgetItem *current_item = elements_panel -> currentItem();
|
QTreeWidgetItem *current_item = elements_panel -> currentItem();
|
||||||
int current_type = elements_panel -> currentItemType();
|
int current_type = elements_panel -> currentItemType();
|
||||||
|
|
||||||
if (current_type == QET::Project) {
|
if (current_type == QET::Project) {
|
||||||
bool is_writable = !(elements_panel -> selectedProject() -> isReadOnly());
|
bool is_writable = !(elements_panel -> selectedProject() -> isReadOnly());
|
||||||
prj_add_diagram -> setEnabled(is_writable);
|
prj_add_diagram -> setEnabled(is_writable);
|
||||||
} else if (current_type == QET::Diagram) {
|
} else if (current_type == QET::Diagram) {
|
||||||
Diagram *selected_diagram = elements_panel -> selectedDiagram();
|
Diagram *selected_diagram = elements_panel -> selectedDiagram();
|
||||||
QETProject *selected_diagram_project = selected_diagram -> project();
|
QETProject *selected_diagram_project = selected_diagram -> project();
|
||||||
|
|
||||||
bool is_writable = !(selected_diagram_project -> isReadOnly());
|
bool is_writable = !(selected_diagram_project -> isReadOnly());
|
||||||
int project_diagrams_count = selected_diagram_project -> diagrams().count();
|
int project_diagrams_count = selected_diagram_project -> diagrams().count();
|
||||||
int diagram_position = selected_diagram_project -> diagrams().indexOf(selected_diagram);
|
int diagram_position = selected_diagram_project -> diagrams().indexOf(selected_diagram);
|
||||||
|
|
||||||
prj_del_diagram -> setEnabled(is_writable);
|
prj_del_diagram -> setEnabled(is_writable);
|
||||||
prj_move_diagram_up -> setEnabled(is_writable && diagram_position > 0);
|
prj_move_diagram_up -> setEnabled(is_writable && diagram_position > 0);
|
||||||
prj_move_diagram_down -> setEnabled(is_writable && diagram_position < project_diagrams_count - 1);
|
prj_move_diagram_down -> setEnabled(is_writable && diagram_position < project_diagrams_count - 1);
|
||||||
@@ -373,17 +373,17 @@ void ElementsPanelWidget::handleContextMenu(const QPoint &pos) {
|
|||||||
// recupere l'item concerne par l'evenement ainsi que son chemin
|
// recupere l'item concerne par l'evenement ainsi que son chemin
|
||||||
QTreeWidgetItem *item = elements_panel -> itemAt(pos);
|
QTreeWidgetItem *item = elements_panel -> itemAt(pos);
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
updateButtons();
|
updateButtons();
|
||||||
context_menu -> clear();
|
context_menu -> clear();
|
||||||
|
|
||||||
QString dir_path = elements_panel -> dirPathForItem(item);
|
QString dir_path = elements_panel -> dirPathForItem(item);
|
||||||
if (!dir_path.isEmpty()) {
|
if (!dir_path.isEmpty()) {
|
||||||
context_menu -> addAction(open_directory);
|
context_menu -> addAction(open_directory);
|
||||||
context_menu -> addAction(copy_path);
|
context_menu -> addAction(copy_path);
|
||||||
context_menu -> addSeparator();
|
context_menu -> addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(item -> type()) {
|
switch(item -> type()) {
|
||||||
case QET::Project:
|
case QET::Project:
|
||||||
context_menu -> addAction(prj_activate);
|
context_menu -> addAction(prj_activate);
|
||||||
@@ -408,7 +408,7 @@ void ElementsPanelWidget::handleContextMenu(const QPoint &pos) {
|
|||||||
context_menu -> addAction(tbt_remove);
|
context_menu -> addAction(tbt_remove);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// affiche le menu
|
// affiche le menu
|
||||||
if (!context_menu -> isEmpty()) {
|
if (!context_menu -> isEmpty()) {
|
||||||
context_menu -> popup(mapToGlobal(elements_panel -> mapTo(this, pos + QPoint(2, 2))));
|
context_menu -> popup(mapToGlobal(elements_panel -> mapTo(this, pos + QPoint(2, 2))));
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
class DiagramTextItem;
|
class DiagramTextItem;
|
||||||
@@ -37,16 +38,16 @@ class ElementTextsMover
|
|||||||
ElementTextsMover();
|
ElementTextsMover();
|
||||||
private:
|
private:
|
||||||
ElementTextsMover(const ElementTextsMover &);
|
ElementTextsMover(const ElementTextsMover &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isReady() const;
|
bool isReady() const;
|
||||||
int beginMovement(Diagram *diagram, QGraphicsItem *driver_item = nullptr);
|
int beginMovement(Diagram *diagram, QGraphicsItem *driver_item = nullptr);
|
||||||
void continueMovement(QGraphicsSceneMouseEvent *event);
|
void continueMovement(QGraphicsSceneMouseEvent *event);
|
||||||
void endMovement();
|
void endMovement();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString undoText() const;
|
QString undoText() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_movement_running = false;
|
bool m_movement_running = false;
|
||||||
Diagram *m_diagram = nullptr;
|
Diagram *m_diagram = nullptr;
|
||||||
|
|||||||
@@ -443,18 +443,10 @@ 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) {
|
||||||
double bx0 = Diagram::margin * Createdxf::xScale;
|
QRectF rect(Diagram::margin,Diagram::margin,width,height);
|
||||||
double by0 = Diagram::margin * Createdxf::yScale;
|
Createdxf::drawRectangle(file_path,rect,0);
|
||||||
Createdxf::drawRectangle(
|
|
||||||
file_path,
|
|
||||||
bx0,
|
|
||||||
-by0,
|
|
||||||
double(width)*Createdxf::xScale,
|
|
||||||
double(height)*Createdxf::yScale,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
diagram -> border_and_titleblock.drawDxf(file_path,
|
diagram -> border_and_titleblock.drawDxf(file_path, 0);
|
||||||
0);
|
|
||||||
|
|
||||||
// Build the lists of elements.
|
// Build the lists of elements.
|
||||||
QList<Element *> list_elements;
|
QList<Element *> list_elements;
|
||||||
@@ -503,9 +495,6 @@ void ExportDialog::generateDxf(
|
|||||||
qreal elem_pos_x = elmt -> pos().x();
|
qreal elem_pos_x = elmt -> pos().x();
|
||||||
qreal elem_pos_y = elmt -> pos().y();// - (diagram -> margin / 2);
|
qreal elem_pos_y = elmt -> pos().y();// - (diagram -> margin / 2);
|
||||||
|
|
||||||
qreal hotspot_x = (elem_pos_x) * Createdxf::xScale;
|
|
||||||
qreal hotspot_y = Createdxf::sheetHeight - (elem_pos_y) * Createdxf::yScale;
|
|
||||||
|
|
||||||
ElementPictureFactory::primitives primitives = ElementPictureFactory::instance()->getPrimitives(elmt->location());
|
ElementPictureFactory::primitives primitives = ElementPictureFactory::instance()->getPrimitives(elmt->location());
|
||||||
|
|
||||||
for(QGraphicsSimpleTextItem *text : primitives.m_texts)
|
for(QGraphicsSimpleTextItem *text : primitives.m_texts)
|
||||||
@@ -514,125 +503,82 @@ void ExportDialog::generateDxf(
|
|||||||
if (fontSize < 0)
|
if (fontSize < 0)
|
||||||
fontSize = text->font().pixelSize();
|
fontSize = text->font().pixelSize();
|
||||||
|
|
||||||
fontSize *= Createdxf::yScale;
|
|
||||||
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();
|
||||||
x *= Createdxf::xScale;
|
|
||||||
y = Createdxf::sheetHeight - (y * Createdxf::yScale);
|
|
||||||
|
|
||||||
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, hotspot_x, hotspot_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, 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)
|
||||||
{
|
{
|
||||||
qreal x1 = (elem_pos_x + line.p1().x()) * Createdxf::xScale;
|
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
||||||
qreal y1 = Createdxf::sheetHeight - (elem_pos_y + line.p1().y()) * Createdxf::yScale;
|
QLineF l = t.map(line);
|
||||||
QPointF transformed_point = rotation_transformed(x1, y1, hotspot_x, hotspot_y, rotation_angle);
|
Createdxf::drawLine(file_path, l, 0);
|
||||||
x1 = transformed_point.x();
|
|
||||||
y1 = transformed_point.y();
|
|
||||||
qreal x2 = (elem_pos_x + line.p2().x()) * Createdxf::xScale;
|
|
||||||
qreal y2 = Createdxf::sheetHeight - (elem_pos_y + line.p2().y()) * Createdxf::yScale;
|
|
||||||
transformed_point = rotation_transformed(x2, y2, hotspot_x, hotspot_y, rotation_angle);
|
|
||||||
x2 = transformed_point.x();
|
|
||||||
y2 = transformed_point.y();
|
|
||||||
Createdxf::drawLine(file_path, x1, y1, x2, y2, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QRectF rect : primitives.m_rectangles)
|
for (QRectF rect : primitives.m_rectangles)
|
||||||
{
|
{
|
||||||
qreal x1 = (elem_pos_x + rect.bottomLeft().x()) * Createdxf::xScale;
|
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
||||||
qreal y1 = Createdxf::sheetHeight - (elem_pos_y + rect.bottomLeft().y()) * Createdxf::yScale;
|
QRectF r = t.mapRect(rect);
|
||||||
qreal w = rect.width() * Createdxf::xScale;
|
Createdxf::drawRectangle(file_path,r,0);
|
||||||
qreal h = rect.height() * Createdxf::yScale;
|
|
||||||
// opposite corner
|
|
||||||
qreal x2 = x1 + w;
|
|
||||||
qreal y2 = y1 + h;
|
|
||||||
QPointF transformed_point = rotation_transformed(x1, y1, hotspot_x, hotspot_y, rotation_angle);
|
|
||||||
x1 = transformed_point.x();
|
|
||||||
y1 = transformed_point.y();
|
|
||||||
transformed_point = rotation_transformed(x2, y2, hotspot_x, hotspot_y, rotation_angle);
|
|
||||||
x2 = transformed_point.x();
|
|
||||||
y2 = transformed_point.y();
|
|
||||||
qreal bottom_left_x = (x1 < x2) ? x1 : x2;
|
|
||||||
qreal bottom_left_y = (y1 < y2) ? y1 : y2;
|
|
||||||
w = (x1 < x2) ? x2-x1 : x1-x2;
|
|
||||||
h = (y1 < y2) ? y2-y1 : y1-y2;
|
|
||||||
Createdxf::drawRectangle(file_path, bottom_left_x, bottom_left_y, w, h, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QRectF circle_rect : primitives.m_circles)
|
for (QRectF circle_rect : primitives.m_circles)
|
||||||
{
|
{
|
||||||
qreal x1 = (elem_pos_x + circle_rect.center().x()) * Createdxf::xScale;
|
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
||||||
qreal y1 = Createdxf::sheetHeight - (elem_pos_y + circle_rect.center().y()) * Createdxf::yScale;
|
QPointF c = t.map(QPointF(circle_rect.center().x(),circle_rect.center().y()));
|
||||||
qreal r = circle_rect.width() * Createdxf::xScale / 2;
|
Createdxf::drawCircle(file_path,c,circle_rect.width()/2,0);
|
||||||
QPointF transformed_point = rotation_transformed(x1, y1, hotspot_x, hotspot_y, rotation_angle);
|
|
||||||
x1 = transformed_point.x();
|
|
||||||
y1 = transformed_point.y();
|
|
||||||
Createdxf::drawCircle(file_path, r, x1, y1, 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;
|
||||||
qreal x1 = (elem_pos_x + polygon.at(0).x()) * Createdxf::xScale;
|
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
||||||
qreal y1 = Createdxf::sheetHeight - (elem_pos_y + polygon.at(0).y()) * Createdxf::yScale;
|
QPolygonF poly = t.map(polygon);
|
||||||
QPointF transformed_point = rotation_transformed(x1, y1, hotspot_x, hotspot_y, rotation_angle);
|
Createdxf::drawPolygon(file_path,poly,0);
|
||||||
x1 = transformed_point.x();
|
|
||||||
y1 = transformed_point.y();
|
|
||||||
for (int i = 1; i < polygon.size(); ++i ) {
|
|
||||||
qreal x2 = (elem_pos_x + polygon.at(i).x()) * Createdxf::xScale;
|
|
||||||
qreal y2 = Createdxf::sheetHeight - (elem_pos_y + polygon.at(i).y()) * Createdxf::yScale;
|
|
||||||
QPointF transformed_point = rotation_transformed(x2, y2, hotspot_x, hotspot_y, rotation_angle);
|
|
||||||
x2 = transformed_point.x();
|
|
||||||
y2 = transformed_point.y();
|
|
||||||
Createdxf::drawLine(file_path, x1, y1, x2, y2, 0);
|
|
||||||
x1 = x2;
|
|
||||||
y1 = y2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)) * Createdxf::xScale;
|
qreal x = (elem_pos_x + arc.at(0));
|
||||||
qreal y = Createdxf::sheetHeight - (elem_pos_y + arc.at(1)) * Createdxf::yScale;
|
qreal y = (elem_pos_y + arc.at(1));
|
||||||
qreal w = arc.at(2) * Createdxf::xScale;
|
qreal w = arc.at(2);
|
||||||
qreal h = arc.at(3) * Createdxf::yScale;
|
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);
|
||||||
Createdxf::drawArcEllipse(file_path, x, y, w, h, startAngle, spanAngle, hotspot_x, hotspot_y, rotation_angle, 0);
|
QRectF r(x,y,w,h);
|
||||||
|
QPointF hotspot(elem_pos_x,elem_pos_y);
|
||||||
|
Createdxf::drawArcEllipse(file_path, r, startAngle, spanAngle, hotspot, rotation_angle, 0);
|
||||||
}
|
}
|
||||||
if (epw -> exportProperties().draw_terminals) {
|
if (epw -> exportProperties().draw_terminals) {
|
||||||
// Draw terminals
|
// Draw terminals
|
||||||
QList<Terminal *> list_terminals = elmt->terminals();
|
QList<Terminal *> list_terminals = elmt->terminals();
|
||||||
QColor col("red");
|
QColor col("red");
|
||||||
|
QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
|
||||||
foreach(Terminal *tp, list_terminals) {
|
foreach(Terminal *tp, list_terminals) {
|
||||||
qreal x = (elem_pos_x + tp->dock_elmt_.x()) * Createdxf::xScale;
|
QPointF c = t.map(QPointF(tp->dock_elmt_.x(),tp->dock_elmt_.y()));
|
||||||
qreal y = Createdxf::sheetHeight - (elem_pos_y + tp->dock_elmt_.y()) * Createdxf::yScale;
|
Createdxf::drawCircle(file_path,c,3.0,Createdxf::dxfColor(col));
|
||||||
QPointF transformed_point = rotation_transformed(x, y, hotspot_x, hotspot_y, rotation_angle);
|
|
||||||
x = transformed_point.x();
|
|
||||||
y = transformed_point.y();
|
|
||||||
Createdxf::drawCircle(file_path, 3.0* Createdxf::xScale, x, y, Createdxf::dxfColor(col));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -652,31 +598,32 @@ void ExportDialog::generateDxf(
|
|||||||
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) {
|
|
||||||
qreal fontSize = textItem -> font().pointSizeF();
|
if (textItem) {
|
||||||
if (fontSize < 0)
|
qreal fontSize = textItem -> font().pointSizeF();
|
||||||
fontSize = textItem -> font().pixelSize();
|
if (fontSize < 0)
|
||||||
fontSize *= Createdxf::yScale;
|
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()) * Createdxf::xScale
|
qreal x = (cond->pos().x() + textItem -> pos().x())
|
||||||
+ xdir * fontSize * 1.8
|
+ xdir * fontSize * 1.8
|
||||||
- ydir * fontSize;
|
- ydir * fontSize;
|
||||||
qreal y = Createdxf::sheetHeight - ((cond->pos().y() + textItem -> pos().y()) * Createdxf::yScale)
|
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, 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()) {
|
||||||
@@ -687,30 +634,38 @@ void ExportDialog::generateDxf(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//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();
|
||||||
fontSize *= Createdxf::yScale;
|
|
||||||
qreal angle = dti -> rotation();
|
qreal angle = dti -> rotation();
|
||||||
|
|
||||||
|
QGraphicsItem *parent = dti->parentItem();
|
||||||
|
while (parent) {
|
||||||
|
angle += parent->rotation();
|
||||||
|
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()) * Createdxf::xScale
|
qreal x = (dti->scenePos().x())
|
||||||
+ xdir * fontSize * 1.8
|
+ xdir * fontSize * 1.8
|
||||||
- ydir * fontSize;
|
- ydir * fontSize;
|
||||||
qreal y = Createdxf::sheetHeight - (dti->scenePos().y() * Createdxf::yScale)
|
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, x, y, fontSize, 360-angle, 0, 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);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QAbstractTextDocumentLayout>
|
#include <QAbstractTextDocumentLayout>
|
||||||
#include <QGraphicsSimpleTextItem>
|
#include <QGraphicsSimpleTextItem>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
ElementPictureFactory* ElementPictureFactory::m_factory = nullptr;
|
ElementPictureFactory* ElementPictureFactory::m_factory = nullptr;
|
||||||
|
|
||||||
@@ -44,14 +45,14 @@ void ElementPictureFactory::getPictures(const ElementsLocation &location, QPictu
|
|||||||
if(!location.exist()) {
|
if(!location.exist()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid uuid = location.uuid();
|
QUuid uuid = location.uuid();
|
||||||
if(Q_UNLIKELY(uuid.isNull()))
|
if(Q_UNLIKELY(uuid.isNull()))
|
||||||
{
|
{
|
||||||
build(location, &picture, &low_picture);
|
build(location, &picture, &low_picture);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_pictures_H.keys().contains(uuid))
|
if(m_pictures_H.keys().contains(uuid))
|
||||||
{
|
{
|
||||||
picture = m_pictures_H.value(uuid);
|
picture = m_pictures_H.value(uuid);
|
||||||
@@ -76,11 +77,11 @@ void ElementPictureFactory::getPictures(const ElementsLocation &location, QPictu
|
|||||||
QPixmap ElementPictureFactory::pixmap(const ElementsLocation &location)
|
QPixmap ElementPictureFactory::pixmap(const ElementsLocation &location)
|
||||||
{
|
{
|
||||||
QUuid uuid = location.uuid();
|
QUuid uuid = location.uuid();
|
||||||
|
|
||||||
if (m_pixmap_H.contains(uuid)) {
|
if (m_pixmap_H.contains(uuid)) {
|
||||||
return m_pixmap_H.value(uuid);
|
return m_pixmap_H.value(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(build(location))
|
if(build(location))
|
||||||
{
|
{
|
||||||
auto doc = location.pugiXml();
|
auto doc = location.pugiXml();
|
||||||
@@ -95,19 +96,19 @@ QPixmap ElementPictureFactory::pixmap(const ElementsLocation &location)
|
|||||||
|
|
||||||
QPixmap pix(w, h);
|
QPixmap pix(w, h);
|
||||||
pix.fill(QColor(255, 255, 255, 0));
|
pix.fill(QColor(255, 255, 255, 0));
|
||||||
|
|
||||||
QPainter painter(&pix);
|
QPainter painter(&pix);
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||||
painter.translate(hsx, hsy);
|
painter.translate(hsx, hsy);
|
||||||
painter.drawPicture(0, 0, m_pictures_H.value(uuid));
|
painter.drawPicture(0, 0, m_pictures_H.value(uuid));
|
||||||
|
|
||||||
if (!uuid.isNull()) {
|
if (!uuid.isNull()) {
|
||||||
m_pixmap_H.insert(uuid, pix);
|
m_pixmap_H.insert(uuid, pix);
|
||||||
}
|
}
|
||||||
return pix;
|
return pix;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QPixmap();
|
return QPixmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ ElementPictureFactory::primitives ElementPictureFactory::getPrimitives(
|
|||||||
{
|
{
|
||||||
if(!m_primitives_H.contains(location.uuid()))
|
if(!m_primitives_H.contains(location.uuid()))
|
||||||
build(location);
|
build(location);
|
||||||
|
|
||||||
return m_primitives_H.value(location.uuid());
|
return m_primitives_H.value(location.uuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,14 +144,14 @@ ElementPictureFactory::~ElementPictureFactory()
|
|||||||
this function draw on it and don't store it.
|
this function draw on it and don't store it.
|
||||||
if null, this function create a QPicture for normal and low zoom,
|
if null, this function create a QPicture for normal and low zoom,
|
||||||
draw on it and store it in m_pictures_H and m_low_pictures_H
|
draw on it and store it in m_pictures_H and m_low_pictures_H
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
bool ElementPictureFactory::build(const ElementsLocation &location,
|
bool ElementPictureFactory::build(const ElementsLocation &location,
|
||||||
QPicture *picture,
|
QPicture *picture,
|
||||||
QPicture *low_picture)
|
QPicture *low_picture)
|
||||||
{
|
{
|
||||||
QDomElement dom = location.xml();
|
QDomElement dom = location.xml();
|
||||||
|
|
||||||
//Check if the curent version can read the xml description
|
//Check if the curent version can read the xml description
|
||||||
if (dom.hasAttribute("version"))
|
if (dom.hasAttribute("version"))
|
||||||
{
|
{
|
||||||
@@ -165,7 +166,7 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
|
|||||||
) << std::endl;
|
) << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//This attributes must be present and valid
|
//This attributes must be present and valid
|
||||||
int w, h, hot_x, hot_y;
|
int w, h, hot_x, hot_y;
|
||||||
if (!QET::attributeIsAnInteger(dom, QString("width"), &w) ||\
|
if (!QET::attributeIsAnInteger(dom, QString("width"), &w) ||\
|
||||||
@@ -175,7 +176,7 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
|
|||||||
{
|
{
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
QPicture pic;
|
QPicture pic;
|
||||||
primitives primitives_;
|
primitives primitives_;
|
||||||
@@ -188,8 +189,8 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
|
|||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.setRenderHint(QPainter::TextAntialiasing, true);
|
painter.setRenderHint(QPainter::TextAntialiasing, true);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform,true);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform,true);
|
||||||
|
|
||||||
|
|
||||||
QPainter low_painter;
|
QPainter low_painter;
|
||||||
QPicture low_pic;
|
QPicture low_pic;
|
||||||
if (low_picture) {
|
if (low_picture) {
|
||||||
@@ -201,12 +202,12 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
|
|||||||
low_painter.setRenderHint(QPainter::Antialiasing, true);
|
low_painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
low_painter.setRenderHint(QPainter::TextAntialiasing, true);
|
low_painter.setRenderHint(QPainter::TextAntialiasing, true);
|
||||||
low_painter.setRenderHint(QPainter::SmoothPixmapTransform,true);
|
low_painter.setRenderHint(QPainter::SmoothPixmapTransform,true);
|
||||||
|
|
||||||
QPen tmp;
|
QPen tmp;
|
||||||
tmp.setWidthF(1.0); //Vaudoo line to take into account the setCosmetic - don't remove
|
tmp.setWidthF(1.0); //Vaudoo line to take into account the setCosmetic - don't remove
|
||||||
tmp.setCosmetic(true);
|
tmp.setCosmetic(true);
|
||||||
low_painter.setPen(tmp);
|
low_painter.setPen(tmp);
|
||||||
|
|
||||||
//scroll of the Children of the Definition: Parts of the Drawing
|
//scroll of the Children of the Definition: Parts of the Drawing
|
||||||
for (QDomNode node = dom.firstChild() ; !node.isNull() ; node = node.nextSibling())
|
for (QDomNode node = dom.firstChild() ; !node.isNull() ; node = node.nextSibling())
|
||||||
{
|
{
|
||||||
@@ -214,9 +215,9 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
|
|||||||
if (elmts.isNull()) {
|
if (elmts.isNull()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elmts.tagName() == "description")
|
if (elmts.tagName() == "description")
|
||||||
{
|
{
|
||||||
//Manage the graphic description = part of drawing
|
//Manage the graphic description = part of drawing
|
||||||
for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling())
|
for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling())
|
||||||
{
|
{
|
||||||
@@ -230,7 +231,7 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//End of the drawing
|
//End of the drawing
|
||||||
painter.end();
|
painter.end();
|
||||||
low_painter.end();
|
low_painter.end();
|
||||||
@@ -458,7 +459,7 @@ void ElementPictureFactory::parsePolygon(const QDomElement &dom, QPainter &paint
|
|||||||
if (i < 3) {
|
if (i < 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QPointF> points; // empty vector created instead of default initialized vector with i-1 elements.
|
QVector<QPointF> points; // empty vector created instead of default initialized vector with i-1 elements.
|
||||||
for (int j = 1 ; j < i ; ++ j) {
|
for (int j = 1 ; j < i ; ++ j) {
|
||||||
points.insert(
|
points.insert(
|
||||||
@@ -568,11 +569,11 @@ void ElementPictureFactory::setPainterStyle(const QDomElement &dom, QPainter &pa
|
|||||||
#pragma message("@TODO remove code for QT 5.14 or later")
|
#pragma message("@TODO remove code for QT 5.14 or later")
|
||||||
const QStringList styles = dom.attribute("style").split(";", Qt::SkipEmptyParts);
|
const QStringList styles = dom.attribute("style").split(";", Qt::SkipEmptyParts);
|
||||||
#endif
|
#endif
|
||||||
QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
|
QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
|
||||||
for (QString style : styles) {
|
for (QString style : styles) {
|
||||||
if (rx.exactMatch(style)) {
|
if (rx==QRegularExpression(style)) {
|
||||||
QString style_name = rx.cap(1);
|
QString style_name = rx.namedCaptureGroups().at(1);
|
||||||
QString style_value = rx.cap(2);
|
QString style_value = rx.namedCaptureGroups().at(2);
|
||||||
if (style_name == "line-style") {
|
if (style_name == "line-style") {
|
||||||
if (style_value == "dashed") pen.setStyle(Qt::DashLine);
|
if (style_value == "dashed") pen.setStyle(Qt::DashLine);
|
||||||
else if (style_value == "dotted") pen.setStyle(Qt::DotLine);
|
else if (style_value == "dotted") pen.setStyle(Qt::DotLine);
|
||||||
|
|||||||
@@ -77,26 +77,21 @@ PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(
|
|||||||
PropertiesEditorWidget *editor,
|
PropertiesEditorWidget *editor,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
{
|
{
|
||||||
int count_ = items.size();
|
const int count_ = items.size();
|
||||||
|
if (count_ == 0) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
QGraphicsItem *item = items.first();
|
||||||
|
const int type_ = item->type();
|
||||||
|
|
||||||
//The editor widget can only edit one item
|
//The editor widget can only edit one item
|
||||||
//or several items of the same type
|
//or several items of the same type
|
||||||
if (count_ != 1)
|
for (auto qgi : items) {
|
||||||
{
|
if (qgi->type() != type_) {
|
||||||
if (count_ == 0) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int type_ = items.first()->type();
|
|
||||||
for (QGraphicsItem *qgi : items) {
|
|
||||||
if (qgi->type() != type_) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsItem *item = items.first();
|
|
||||||
const int type_ = item->type();
|
|
||||||
QString class_name;
|
QString class_name;
|
||||||
if (editor) {
|
if (editor) {
|
||||||
class_name = editor->metaObject()->className();
|
class_name = editor->metaObject()->className();
|
||||||
|
|||||||
@@ -203,7 +203,6 @@ int main(int argc, char **argv)
|
|||||||
my_ma->send_info_to_debug();
|
my_ma->send_info_to_debug();
|
||||||
delete my_ma;
|
delete my_ma;
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
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 <QMetaEnum>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#include "xrefproperties.h"
|
#include "xrefproperties.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include <QMetaEnum>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief XRefProperties::XRefProperties
|
@brief XRefProperties::XRefProperties
|
||||||
@@ -56,7 +58,7 @@ void XRefProperties::toSettings(QSettings &settings,
|
|||||||
QString slave_label = m_slave_label;
|
QString slave_label = m_slave_label;
|
||||||
settings.setValue(prefix + "slave_label", slave_label);
|
settings.setValue(prefix + "slave_label", slave_label);
|
||||||
|
|
||||||
|
|
||||||
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
settings.setValue(prefix + "xrefpos", var.valueToKey(m_xref_pos));
|
settings.setValue(prefix + "xrefpos", var.valueToKey(m_xref_pos));
|
||||||
|
|
||||||
@@ -110,7 +112,7 @@ QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
|
|||||||
xml_element.setAttribute("snapto", snap);
|
xml_element.setAttribute("snapto", snap);
|
||||||
|
|
||||||
QString xrefpos;
|
QString xrefpos;
|
||||||
|
|
||||||
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
xml_element.setAttribute("xrefpos", var.valueToKey(m_xref_pos));
|
xml_element.setAttribute("xrefpos", var.valueToKey(m_xref_pos));
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,10 @@
|
|||||||
#ifndef XREFPROPERTIES_H
|
#ifndef XREFPROPERTIES_H
|
||||||
#define XREFPROPERTIES_H
|
#define XREFPROPERTIES_H
|
||||||
|
|
||||||
#include "propertiesinterface.h"
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
|
#include "propertiesinterface.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The XRefProperties class
|
@brief The XRefProperties class
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QSaveFile>
|
#include <QSaveFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
||||||
@@ -169,10 +170,10 @@ bool QET::orthogonalProjection(const QPointF &point,
|
|||||||
// recupere le vecteur normal de `line'
|
// recupere le vecteur normal de `line'
|
||||||
QLineF line_normal_vector(line.normalVector());
|
QLineF line_normal_vector(line.normalVector());
|
||||||
QPointF normal_vector(line_normal_vector.dx(), line_normal_vector.dy());
|
QPointF normal_vector(line_normal_vector.dx(), line_normal_vector.dy());
|
||||||
|
|
||||||
// cree une droite perpendiculaire a `line' passant par `point'
|
// cree une droite perpendiculaire a `line' passant par `point'
|
||||||
QLineF perpendicular_line(point, point + normal_vector);
|
QLineF perpendicular_line(point, point + normal_vector);
|
||||||
|
|
||||||
// determine le point d'intersection des deux droites = le projete orthogonal
|
// determine le point d'intersection des deux droites = le projete orthogonal
|
||||||
QPointF intersection_point;
|
QPointF intersection_point;
|
||||||
|
|
||||||
@@ -184,15 +185,15 @@ bool QET::orthogonalProjection(const QPointF &point,
|
|||||||
intersects
|
intersects
|
||||||
#endif
|
#endif
|
||||||
(perpendicular_line, &intersection_point);
|
(perpendicular_line, &intersection_point);
|
||||||
|
|
||||||
// ne devrait pas arriver (mais bon...)
|
// ne devrait pas arriver (mais bon...)
|
||||||
if (it == QLineF::NoIntersection) return(false);
|
if (it == QLineF::NoIntersection) return(false);
|
||||||
|
|
||||||
// fournit le point d'intersection a l'appelant si necessaire
|
// fournit le point d'intersection a l'appelant si necessaire
|
||||||
if (intersection) {
|
if (intersection) {
|
||||||
*intersection = intersection_point;
|
*intersection = intersection_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine si le point d'intersection appartient au segment de droite
|
// determine si le point d'intersection appartient au segment de droite
|
||||||
if (QET::lineContainsPoint(line, intersection_point)) {
|
if (QET::lineContainsPoint(line, intersection_point)) {
|
||||||
return(true);
|
return(true);
|
||||||
@@ -272,7 +273,7 @@ QString QET::ElementsAndConductorsSentence(int elements_count,
|
|||||||
elements_count
|
elements_count
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conductors_count) {
|
if (conductors_count) {
|
||||||
if (!text.isEmpty()) text += ", ";
|
if (!text.isEmpty()) text += ", ";
|
||||||
text += QObject::tr(
|
text += QObject::tr(
|
||||||
@@ -281,7 +282,7 @@ QString QET::ElementsAndConductorsSentence(int elements_count,
|
|||||||
conductors_count
|
conductors_count
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texts_count) {
|
if (texts_count) {
|
||||||
if (!text.isEmpty()) text += ", ";
|
if (!text.isEmpty()) text += ", ";
|
||||||
text += QObject::tr(
|
text += QObject::tr(
|
||||||
@@ -308,7 +309,7 @@ QString QET::ElementsAndConductorsSentence(int elements_count,
|
|||||||
shapes_count
|
shapes_count
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element_text_count) {
|
if (element_text_count) {
|
||||||
if (!text.isEmpty()) text += ", ";
|
if (!text.isEmpty()) text += ", ";
|
||||||
text += QObject::tr(
|
text += QObject::tr(
|
||||||
@@ -324,7 +325,7 @@ QString QET::ElementsAndConductorsSentence(int elements_count,
|
|||||||
"part of a sentence listing the content of diagram",
|
"part of a sentence listing the content of diagram",
|
||||||
tables_count);
|
tables_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(text);
|
return(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +355,7 @@ QList<QDomElement> QET::findInDomElement(const QDomElement &e,
|
|||||||
const QString &parent,
|
const QString &parent,
|
||||||
const QString &children) {
|
const QString &children) {
|
||||||
QList<QDomElement> return_list;
|
QList<QDomElement> return_list;
|
||||||
|
|
||||||
// parcours des elements parents
|
// parcours des elements parents
|
||||||
for (QDomNode enfant = e.firstChild() ; !enfant.isNull() ; enfant = enfant.nextSibling()) {
|
for (QDomNode enfant = e.firstChild() ; !enfant.isNull() ; enfant = enfant.nextSibling()) {
|
||||||
// on s'interesse a l'element XML "parent"
|
// on s'interesse a l'element XML "parent"
|
||||||
@@ -417,15 +418,15 @@ QList<QChar> QET::forbiddenCharacters()
|
|||||||
*/
|
*/
|
||||||
QString QET::stringToFileName(const QString &name) {
|
QString QET::stringToFileName(const QString &name) {
|
||||||
QString file_name(name.toLower());
|
QString file_name(name.toLower());
|
||||||
|
|
||||||
// remplace les caracteres interdits par des tirets
|
// remplace les caracteres interdits par des tirets
|
||||||
foreach(QChar c, QET::forbiddenCharacters()) {
|
foreach(QChar c, QET::forbiddenCharacters()) {
|
||||||
file_name.replace(c, '-');
|
file_name.replace(c, '-');
|
||||||
}
|
}
|
||||||
|
|
||||||
// remplace les espaces par des underscores
|
// remplace les espaces par des underscores
|
||||||
file_name.replace(' ', '_');
|
file_name.replace(' ', '_');
|
||||||
|
|
||||||
return(file_name);
|
return(file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,12 +456,12 @@ QString QET::unescapeSpaces(const QString &string) {
|
|||||||
*/
|
*/
|
||||||
QString QET::joinWithSpaces(const QStringList &string_list) {
|
QString QET::joinWithSpaces(const QStringList &string_list) {
|
||||||
QString returned_string;
|
QString returned_string;
|
||||||
|
|
||||||
for (int i = 0 ; i < string_list.count() ; ++ i) {
|
for (int i = 0 ; i < string_list.count() ; ++ i) {
|
||||||
returned_string += QET::escapeSpaces(string_list.at(i));
|
returned_string += QET::escapeSpaces(string_list.at(i));
|
||||||
if (i != string_list.count() - 1) returned_string += " ";
|
if (i != string_list.count() - 1) returned_string += " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
return(returned_string);
|
return(returned_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +476,7 @@ QStringList QET::splitWithSpaces(const QString &string) {
|
|||||||
// = avec un nombre nul ou pair de backslashes devant
|
// = avec un nombre nul ou pair de backslashes devant
|
||||||
|
|
||||||
#pragma message("@TODO remove code for QT 5.14 or later")
|
#pragma message("@TODO remove code for QT 5.14 or later")
|
||||||
QStringList escaped_strings = string.split(QRegExp("[^\\]?(?:\\\\)* "),
|
QStringList escaped_strings = string.split(QRegularExpression("[^\\]?(?:\\\\)* "),
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||||
QString
|
QString
|
||||||
#else
|
#else
|
||||||
@@ -570,13 +571,13 @@ bool QET::compareCanonicalFilePaths(const QString &first, const QString &second)
|
|||||||
|
|
||||||
QString second_canonical_path = QFileInfo(second).canonicalFilePath();
|
QString second_canonical_path = QFileInfo(second).canonicalFilePath();
|
||||||
if (second_canonical_path.isEmpty()) return(false);
|
if (second_canonical_path.isEmpty()) return(false);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// sous Windows, on ramene les chemins en minuscules
|
// sous Windows, on ramene les chemins en minuscules
|
||||||
first_canonical_path = first_canonical_path.toLower();
|
first_canonical_path = first_canonical_path.toLower();
|
||||||
second_canonical_path = second_canonical_path.toLower();
|
second_canonical_path = second_canonical_path.toLower();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return(first_canonical_path == second_canonical_path);
|
return(first_canonical_path == second_canonical_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,7 +593,7 @@ bool QET::compareCanonicalFilePaths(const QString &first, const QString &second)
|
|||||||
bool QET::writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *error_message)
|
bool QET::writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *error_message)
|
||||||
{
|
{
|
||||||
QSaveFile file(filepath);
|
QSaveFile file(filepath);
|
||||||
|
|
||||||
// Note: we do not set QIODevice::Text to avoid generating CRLF end of lines
|
// Note: we do not set QIODevice::Text to avoid generating CRLF end of lines
|
||||||
bool file_opening = file.open(QIODevice::WriteOnly);
|
bool file_opening = file.open(QIODevice::WriteOnly);
|
||||||
if (!file_opening)
|
if (!file_opening)
|
||||||
@@ -605,7 +606,7 @@ bool QET::writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *
|
|||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream out(&file);
|
QTextStream out(&file);
|
||||||
out.setCodec("UTF-8");
|
out.setCodec("UTF-8");
|
||||||
out.setGenerateByteOrderMark(false);
|
out.setGenerateByteOrderMark(false);
|
||||||
@@ -617,10 +618,10 @@ bool QET::writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *
|
|||||||
"Une erreur est survenue lors de l'écriture du fichier %1, erreur %2 rencontrée.",
|
"Une erreur est survenue lors de l'écriture du fichier %1, erreur %2 rencontrée.",
|
||||||
"error message when attempting to write an XML file")).arg(filepath).arg(file.error());
|
"error message when attempting to write an XML file")).arg(filepath).arg(file.error());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -687,7 +688,7 @@ QActionGroup *QET::depthActionGroup(QObject *parent)
|
|||||||
{
|
{
|
||||||
QActionGroup *action_group = new QActionGroup(parent);
|
QActionGroup *action_group = new QActionGroup(parent);
|
||||||
|
|
||||||
QAction *edit_forward = new QAction(QET::Icons::BringForward, QObject::tr("Amener au premier plan"), action_group);
|
QAction *edit_forward = new QAction(QET::Icons::BringForward, QObject::tr("Amener au premier plan"), action_group);
|
||||||
QAction *edit_raise = new QAction(QET::Icons::Raise, QObject::tr("Rapprocher"), action_group);
|
QAction *edit_raise = new QAction(QET::Icons::Raise, QObject::tr("Rapprocher"), action_group);
|
||||||
QAction *edit_lower = new QAction(QET::Icons::Lower, QObject::tr("Éloigner"), action_group);
|
QAction *edit_lower = new QAction(QET::Icons::Lower, QObject::tr("Éloigner"), action_group);
|
||||||
QAction *edit_backward = new QAction(QET::Icons::SendBackward, QObject::tr("Envoyer au fond"), action_group);
|
QAction *edit_backward = new QAction(QET::Icons::SendBackward, QObject::tr("Envoyer au fond"), action_group);
|
||||||
@@ -696,17 +697,17 @@ QActionGroup *QET::depthActionGroup(QObject *parent)
|
|||||||
edit_raise ->setStatusTip(QObject::tr("Rapproche la ou les sélections"));
|
edit_raise ->setStatusTip(QObject::tr("Rapproche la ou les sélections"));
|
||||||
edit_lower ->setStatusTip(QObject::tr("Éloigne la ou les sélections"));
|
edit_lower ->setStatusTip(QObject::tr("Éloigne la ou les sélections"));
|
||||||
edit_backward->setStatusTip(QObject::tr("Envoie en arrière plan la ou les sélections"));
|
edit_backward->setStatusTip(QObject::tr("Envoie en arrière plan la ou les sélections"));
|
||||||
|
|
||||||
edit_raise ->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+Up")));
|
edit_raise ->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+Up")));
|
||||||
edit_lower ->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+Down")));
|
edit_lower ->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+Down")));
|
||||||
edit_backward->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+End")));
|
edit_backward->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+End")));
|
||||||
edit_forward ->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+Home")));
|
edit_forward ->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+Home")));
|
||||||
|
|
||||||
edit_forward ->setData(QET::BringForward);
|
edit_forward ->setData(QET::BringForward);
|
||||||
edit_raise ->setData(QET::Raise);
|
edit_raise ->setData(QET::Raise);
|
||||||
edit_lower ->setData(QET::Lower);
|
edit_lower ->setData(QET::Lower);
|
||||||
edit_backward->setData(QET::SendBackward);
|
edit_backward->setData(QET::SendBackward);
|
||||||
|
|
||||||
return action_group;
|
return action_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,14 +33,14 @@
|
|||||||
#include "projectview.h"
|
#include "projectview.h"
|
||||||
#include "elementpicturefactory.h"
|
#include "elementpicturefactory.h"
|
||||||
#include "aboutqetdialog.h"
|
#include "aboutqetdialog.h"
|
||||||
|
#include "factory/elementfactory.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#define QUOTE(x) STRINGIFY(x)
|
#define QUOTE(x) STRINGIFY(x)
|
||||||
#define STRINGIFY(x) #x
|
#define STRINGIFY(x) #x
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include "factory/elementfactory.h"
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include <KAutoSaveFile>
|
#include <KAutoSaveFile>
|
||||||
|
|
||||||
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
|
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
|
||||||
@@ -97,7 +97,7 @@ QETApp::QETApp() :
|
|||||||
"splash screen caption"));
|
"splash screen caption"));
|
||||||
if (!collections_cache_) {
|
if (!collections_cache_) {
|
||||||
QString cache_path = QETApp::configDir() + "/elements_cache.sqlite";
|
QString cache_path = QETApp::configDir() + "/elements_cache.sqlite";
|
||||||
|
|
||||||
collections_cache_ = new ElementsCollectionCache(cache_path, this);
|
collections_cache_ = new ElementsCollectionCache(cache_path, this);
|
||||||
collections_cache_->setLocale(langFromSetting());
|
collections_cache_->setLocale(langFromSetting());
|
||||||
}
|
}
|
||||||
@@ -113,12 +113,12 @@ QETApp::QETApp() :
|
|||||||
"splash screen caption"));
|
"splash screen caption"));
|
||||||
openFiles(qet_arguments_);
|
openFiles(qet_arguments_);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildSystemTrayMenu();
|
buildSystemTrayMenu();
|
||||||
if (m_splash_screen) {
|
if (m_splash_screen) {
|
||||||
m_splash_screen -> hide();
|
m_splash_screen -> hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
checkBackupFiles();
|
checkBackupFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,17 +129,17 @@ QETApp::~QETApp()
|
|||||||
{
|
{
|
||||||
m_elements_recent_files->save();
|
m_elements_recent_files->save();
|
||||||
m_projects_recent_files->save();
|
m_projects_recent_files->save();
|
||||||
|
|
||||||
delete m_splash_screen;
|
delete m_splash_screen;
|
||||||
delete m_elements_recent_files;
|
delete m_elements_recent_files;
|
||||||
delete m_projects_recent_files;
|
delete m_projects_recent_files;
|
||||||
delete m_qsti;
|
delete m_qsti;
|
||||||
|
|
||||||
if (m_custom_tbt_collection)
|
if (m_custom_tbt_collection)
|
||||||
delete m_custom_tbt_collection;
|
delete m_custom_tbt_collection;
|
||||||
if (m_common_tbt_collection)
|
if (m_common_tbt_collection)
|
||||||
delete m_common_tbt_collection;
|
delete m_common_tbt_collection;
|
||||||
|
|
||||||
ElementFactory::dropInstance();
|
ElementFactory::dropInstance();
|
||||||
ElementPictureFactory::dropInstance();
|
ElementPictureFactory::dropInstance();
|
||||||
}
|
}
|
||||||
@@ -409,12 +409,12 @@ QString QETApp::elementTranslatedInfoKey(const QString &info)
|
|||||||
else if (info == "label") return tr("Label");
|
else if (info == "label") return tr("Label");
|
||||||
else if (info == "plant") return tr("Installation");
|
else if (info == "plant") return tr("Installation");
|
||||||
else if (info == "location") return tr("Localisation");
|
else if (info == "location") return tr("Localisation");
|
||||||
|
|
||||||
else if (info == "comment") return tr("Commentaire");
|
else if (info == "comment") return tr("Commentaire");
|
||||||
else if (info == "function") return tr("Fonction");
|
else if (info == "function") return tr("Fonction");
|
||||||
else if (info == "auxiliary1") return tr("Bloc auxiliaire 1");
|
else if (info == "auxiliary1") return tr("Bloc auxiliaire 1");
|
||||||
else if (info == "auxiliary2") return tr("Bloc auxiliaire 2");
|
else if (info == "auxiliary2") return tr("Bloc auxiliaire 2");
|
||||||
|
|
||||||
else if (info == "description") return tr("Description textuelle");
|
else if (info == "description") return tr("Description textuelle");
|
||||||
else if (info == "designation") return tr("Numéro d'article");
|
else if (info == "designation") return tr("Numéro d'article");
|
||||||
else if (info == "manufacturer") return tr("Fabricant");
|
else if (info == "manufacturer") return tr("Fabricant");
|
||||||
@@ -455,7 +455,7 @@ QStringList QETApp::conductorInfoKeys()
|
|||||||
keys.append("tension/protocol");
|
keys.append("tension/protocol");
|
||||||
keys.append("conductor_color");
|
keys.append("conductor_color");
|
||||||
keys.append("conductor_section");
|
keys.append("conductor_section");
|
||||||
|
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,7 +492,7 @@ QStringList QETApp::diagramInfoKeys()
|
|||||||
list.append("indexrev");
|
list.append("indexrev");
|
||||||
list.append("date");
|
list.append("date");
|
||||||
list.append("display_folio");
|
list.append("display_folio");
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -625,7 +625,7 @@ QString QETApp::commonElementsDir()
|
|||||||
else if (m_user_common_elements_dir != "default") {
|
else if (m_user_common_elements_dir != "default") {
|
||||||
return m_user_common_elements_dir;
|
return m_user_common_elements_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
|
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
|
||||||
if (common_elements_dir != QString()) return(common_elements_dir);
|
if (common_elements_dir != QString()) return(common_elements_dir);
|
||||||
#endif
|
#endif
|
||||||
@@ -687,7 +687,7 @@ QString QETApp::customElementsDir()
|
|||||||
else if (m_user_custom_elements_dir != "default") {
|
else if (m_user_custom_elements_dir != "default") {
|
||||||
return m_user_custom_elements_dir;
|
return m_user_custom_elements_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(configDir() + "elements/");
|
return(configDir() + "elements/");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -786,7 +786,7 @@ QString QETApp::customTitleBlockTemplatesDir()
|
|||||||
else if (m_user_custom_tbt_dir != "default") {
|
else if (m_user_custom_tbt_dir != "default") {
|
||||||
return m_user_custom_tbt_dir;
|
return m_user_custom_tbt_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(configDir() + "titleblocks/");
|
return(configDir() + "titleblocks/");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,7 +911,7 @@ QStringList QETApp::handledFileExtensions()
|
|||||||
if (!ext.count()) {
|
if (!ext.count()) {
|
||||||
ext << "qet";
|
ext << "qet";
|
||||||
ext << "elmt";
|
ext << "elmt";
|
||||||
ext << QString(TITLEBLOCKS_FILE_EXTENSION).remove(QRegExp("^\\."));
|
ext << QString(TITLEBLOCKS_FILE_EXTENSION).remove(QRegularExpression("^\\."));
|
||||||
}
|
}
|
||||||
return(ext);
|
return(ext);
|
||||||
}
|
}
|
||||||
@@ -1159,7 +1159,7 @@ QFont QETApp::diagramTextsItemFont(qreal size)
|
|||||||
).toDouble();
|
).toDouble();
|
||||||
QString diagram_texts_item_style = settings.value("diagramitemstyle",
|
QString diagram_texts_item_style = settings.value("diagramitemstyle",
|
||||||
"normal").toString();
|
"normal").toString();
|
||||||
|
|
||||||
if (size != -1.0) {
|
if (size != -1.0) {
|
||||||
diagram_texts_item_size = size;
|
diagram_texts_item_size = size;
|
||||||
}
|
}
|
||||||
@@ -1359,9 +1359,9 @@ QList<QETElementEditor *> QETApp::elementEditors(QETProject *project) {
|
|||||||
void QETApp::receiveMessage(int instanceId, QByteArray message)
|
void QETApp::receiveMessage(int instanceId, QByteArray message)
|
||||||
{
|
{
|
||||||
Q_UNUSED(instanceId);
|
Q_UNUSED(instanceId);
|
||||||
|
|
||||||
QString str(message);
|
QString str(message);
|
||||||
|
|
||||||
if (str.startsWith("launched-with-args: "))
|
if (str.startsWith("launched-with-args: "))
|
||||||
{
|
{
|
||||||
QString my_message(str.mid(20));
|
QString my_message(str.mid(20));
|
||||||
@@ -2102,10 +2102,10 @@ template <class T> void QETApp::addWindowsListToMenu(
|
|||||||
or -1 if none could be found.
|
or -1 if none could be found.
|
||||||
*/
|
*/
|
||||||
int QETApp::projectIdFromString(const QString &url) {
|
int QETApp::projectIdFromString(const QString &url) {
|
||||||
QRegExp embedded("^project([0-9]+)\\+embed.*$", Qt::CaseInsensitive);
|
QRegularExpression embedded("^project([0-9]+)\\+embed.*$", QRegularExpression::CaseInsensitiveOption);
|
||||||
if (embedded.exactMatch(url)) {
|
if (embedded==QRegularExpression(url)) {
|
||||||
bool conv_ok = false;
|
bool conv_ok = false;
|
||||||
int project_id = embedded.capturedTexts().at(1).toInt(&conv_ok);
|
int project_id = embedded.namedCaptureGroups().at(1).toInt(&conv_ok);
|
||||||
if (conv_ok) {
|
if (conv_ok) {
|
||||||
return(project_id);
|
return(project_id);
|
||||||
}
|
}
|
||||||
@@ -2191,7 +2191,7 @@ void QETApp::buildSystemTrayMenu()
|
|||||||
void QETApp::checkBackupFiles()
|
void QETApp::checkBackupFiles()
|
||||||
{
|
{
|
||||||
QList<KAutoSaveFile *> stale_files = KAutoSaveFile::allStaleFiles();
|
QList<KAutoSaveFile *> stale_files = KAutoSaveFile::allStaleFiles();
|
||||||
|
|
||||||
//Remove from the list @stale_files, the stales file of opened project
|
//Remove from the list @stale_files, the stales file of opened project
|
||||||
const QList<KAutoSaveFile *> sf = stale_files;
|
const QList<KAutoSaveFile *> sf = stale_files;
|
||||||
for (KAutoSaveFile *kasf : sf)
|
for (KAutoSaveFile *kasf : sf)
|
||||||
@@ -2227,10 +2227,10 @@ void QETApp::checkBackupFiles()
|
|||||||
for(const KAutoSaveFile *kasf : stale_files)
|
for(const KAutoSaveFile *kasf : stale_files)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
//Remove the first character '/' before the name of the drive
|
//Remove the first character '/' before the name of the drive
|
||||||
text.append("<br>" + kasf->managedFile().path().remove(0,1));
|
text.append("<br>" + kasf->managedFile().path().remove(0,1));
|
||||||
#else
|
#else
|
||||||
text.append("<br>" + kasf->managedFile().path());
|
text.append("<br>" + kasf->managedFile().path());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2319,12 +2319,12 @@ void QETApp::fetchWindowStats(
|
|||||||
bool QETApp::eventFiltrer(QObject *object, QEvent *e) {
|
bool QETApp::eventFiltrer(QObject *object, QEvent *e) {
|
||||||
// gere l'ouverture de fichiers (sous MacOs)
|
// gere l'ouverture de fichiers (sous MacOs)
|
||||||
if (e -> type() == QEvent::FileOpen) {
|
if (e -> type() == QEvent::FileOpen) {
|
||||||
// nom du fichier a ouvrir
|
// nom du fichier a ouvrir
|
||||||
QString filename = static_cast<QFileOpenEvent *>(e) -> file();
|
QString filename = static_cast<QFileOpenEvent *>(e) -> file();
|
||||||
openFiles(QStringList() << filename);
|
openFiles(QStringList() << filename);
|
||||||
return(true);
|
return(true);
|
||||||
} else {
|
} else {
|
||||||
return QObject::eventFilter(object, e);
|
return QObject::eventFilter(object, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -60,7 +60,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
|||||||
open_dialog_dir (QStandardPaths::writableLocation(QStandardPaths::DesktopLocation))
|
open_dialog_dir (QStandardPaths::writableLocation(QStandardPaths::DesktopLocation))
|
||||||
{
|
{
|
||||||
activeSubWindowIndex = 0;
|
activeSubWindowIndex = 0;
|
||||||
|
|
||||||
QSplitter *splitter_ = new QSplitter(this);
|
QSplitter *splitter_ = new QSplitter(this);
|
||||||
splitter_->setChildrenCollapsible(false);
|
splitter_->setChildrenCollapsible(false);
|
||||||
splitter_->setOrientation(Qt::Vertical);
|
splitter_->setOrientation(Qt::Vertical);
|
||||||
@@ -77,19 +77,19 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
|||||||
anim->setObjectName("search and replace animator");
|
anim->setObjectName("search and replace animator");
|
||||||
m_search_and_replace_widget.setHidden(true);
|
m_search_and_replace_widget.setHidden(true);
|
||||||
anim->setLastShowSize(m_search_and_replace_widget.minimumSizeHint().height());
|
anim->setLastShowSize(m_search_and_replace_widget.minimumSizeHint().height());
|
||||||
|
|
||||||
//Set object name to be retrieved by the stylesheets
|
//Set object name to be retrieved by the stylesheets
|
||||||
m_workspace.setBackground(QBrush(Qt::NoBrush));
|
m_workspace.setBackground(QBrush(Qt::NoBrush));
|
||||||
m_workspace.setObjectName("mdiarea");
|
m_workspace.setObjectName("mdiarea");
|
||||||
m_workspace.setTabsClosable(true);
|
m_workspace.setTabsClosable(true);
|
||||||
|
|
||||||
//Set the signal mapper
|
//Set the signal mapper
|
||||||
connect(&windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(activateWidget(QWidget *)));
|
connect(&windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(activateWidget(QWidget *)));
|
||||||
|
|
||||||
setWindowTitle(tr("QElectroTech", "window title"));
|
setWindowTitle(tr("QElectroTech", "window title"));
|
||||||
setWindowIcon(QET::Icons::QETLogo);
|
setWindowIcon(QET::Icons::QETLogo);
|
||||||
statusBar() -> showMessage(tr("QElectroTech", "status bar message"));
|
statusBar() -> showMessage(tr("QElectroTech", "status bar message"));
|
||||||
|
|
||||||
setUpElementsPanel();
|
setUpElementsPanel();
|
||||||
setUpElementsCollectionWidget();
|
setUpElementsCollectionWidget();
|
||||||
setUpUndoStack();
|
setUpUndoStack();
|
||||||
@@ -101,11 +101,11 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
|||||||
setUpMenu();
|
setUpMenu();
|
||||||
|
|
||||||
tabifyDockWidget(qdw_undo, qdw_pa);
|
tabifyDockWidget(qdw_undo, qdw_pa);
|
||||||
|
|
||||||
//By default the windows is maximised
|
//By default the windows is maximised
|
||||||
setMinimumSize(QSize(500, 350));
|
setMinimumSize(QSize(500, 350));
|
||||||
setWindowState(Qt::WindowMaximized);
|
setWindowState(Qt::WindowMaximized);
|
||||||
|
|
||||||
connect (&m_workspace,
|
connect (&m_workspace,
|
||||||
SIGNAL(subWindowActivated(QMdiSubWindow *)),
|
SIGNAL(subWindowActivated(QMdiSubWindow *)),
|
||||||
this,
|
this,
|
||||||
@@ -117,7 +117,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
|||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
show();
|
show();
|
||||||
|
|
||||||
//If valid file path is given as arguments
|
//If valid file path is given as arguments
|
||||||
uint opened_projects = 0;
|
uint opened_projects = 0;
|
||||||
if (files.count())
|
if (files.count())
|
||||||
@@ -149,7 +149,10 @@ void QETDiagramEditor::setUpElementsPanel()
|
|||||||
|
|
||||||
qdw_pa -> setObjectName ("projects panel");
|
qdw_pa -> setObjectName ("projects panel");
|
||||||
qdw_pa -> setAllowedAreas (Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
qdw_pa -> setAllowedAreas (Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||||
qdw_pa -> setFeatures (QDockWidget::AllDockWidgetFeatures);
|
qdw_pa -> setFeatures (
|
||||||
|
QDockWidget::DockWidgetClosable
|
||||||
|
|QDockWidget::DockWidgetMovable
|
||||||
|
|QDockWidget::DockWidgetFloatable);
|
||||||
qdw_pa -> setMinimumWidth (160);
|
qdw_pa -> setMinimumWidth (160);
|
||||||
qdw_pa -> setWidget (pa = new ElementsPanelWidget(qdw_pa));
|
qdw_pa -> setWidget (pa = new ElementsPanelWidget(qdw_pa));
|
||||||
|
|
||||||
@@ -179,7 +182,10 @@ void QETDiagramEditor::setUpElementsCollectionWidget()
|
|||||||
m_qdw_elmt_collection = new QDockWidget(tr("Collections"), this);
|
m_qdw_elmt_collection = new QDockWidget(tr("Collections"), this);
|
||||||
m_qdw_elmt_collection->setObjectName("elements_collection_widget");
|
m_qdw_elmt_collection->setObjectName("elements_collection_widget");
|
||||||
m_qdw_elmt_collection->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
m_qdw_elmt_collection->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||||
m_qdw_elmt_collection->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
m_qdw_elmt_collection->setFeatures(
|
||||||
|
QDockWidget::DockWidgetClosable
|
||||||
|
|QDockWidget::DockWidgetMovable
|
||||||
|
|QDockWidget::DockWidgetFloatable);
|
||||||
|
|
||||||
m_element_collection_widget = new ElementsCollectionWidget(m_qdw_elmt_collection);
|
m_element_collection_widget = new ElementsCollectionWidget(m_qdw_elmt_collection);
|
||||||
m_qdw_elmt_collection->setWidget(m_element_collection_widget);
|
m_qdw_elmt_collection->setWidget(m_element_collection_widget);
|
||||||
@@ -205,7 +211,10 @@ void QETDiagramEditor::setUpUndoStack()
|
|||||||
qdw_undo -> setObjectName("diagram_undo");
|
qdw_undo -> setObjectName("diagram_undo");
|
||||||
|
|
||||||
qdw_undo -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
qdw_undo -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||||
qdw_undo -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
qdw_undo -> setFeatures(
|
||||||
|
QDockWidget::DockWidgetClosable
|
||||||
|
|QDockWidget::DockWidgetMovable
|
||||||
|
|QDockWidget::DockWidgetFloatable);
|
||||||
qdw_undo -> setMinimumWidth(160);
|
qdw_undo -> setMinimumWidth(160);
|
||||||
qdw_undo -> setWidget(undo_view);
|
qdw_undo -> setWidget(undo_view);
|
||||||
|
|
||||||
@@ -231,7 +240,10 @@ void QETDiagramEditor::setUpAutonumberingWidget()
|
|||||||
{
|
{
|
||||||
m_autonumbering_dock = new AutoNumberingDockWidget(this);
|
m_autonumbering_dock = new AutoNumberingDockWidget(this);
|
||||||
m_autonumbering_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
m_autonumbering_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||||
m_autonumbering_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
m_autonumbering_dock -> setFeatures(
|
||||||
|
QDockWidget::DockWidgetClosable
|
||||||
|
|QDockWidget::DockWidgetMovable
|
||||||
|
|QDockWidget::DockWidgetFloatable);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, m_autonumbering_dock);
|
addDockWidget(Qt::RightDockWidgetArea, m_autonumbering_dock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +263,7 @@ void QETDiagramEditor::setUpActions()
|
|||||||
current_project -> exportProject();
|
current_project -> exportProject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Print
|
//Print
|
||||||
m_print = new QAction(QET::Icons::DocumentPrint, tr("Imprimer"), this);
|
m_print = new QAction(QET::Icons::DocumentPrint, tr("Imprimer"), this);
|
||||||
m_print->setShortcut(QKeySequence(QKeySequence::Print));
|
m_print->setShortcut(QKeySequence(QKeySequence::Print));
|
||||||
@@ -262,7 +274,7 @@ void QETDiagramEditor::setUpActions()
|
|||||||
current_project -> printProject();
|
current_project -> printProject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Quit editor
|
//Quit editor
|
||||||
m_quit_editor = new QAction(QET::Icons::ApplicationExit, tr("&Quitter"), this);
|
m_quit_editor = new QAction(QET::Icons::ApplicationExit, tr("&Quitter"), this);
|
||||||
m_quit_editor->setShortcut(QKeySequence(tr("Ctrl+Q")));
|
m_quit_editor->setShortcut(QKeySequence(tr("Ctrl+Q")));
|
||||||
@@ -314,7 +326,7 @@ void QETDiagramEditor::setUpActions()
|
|||||||
if (DiagramView *dv = currentDiagramView())
|
if (DiagramView *dv = currentDiagramView())
|
||||||
dv->resetConductors();
|
dv->resetConductors();
|
||||||
});
|
});
|
||||||
|
|
||||||
//AutoConductor
|
//AutoConductor
|
||||||
m_auto_conductor = new QAction (QET::Icons::Autoconnect, tr("Création automatique de conducteur(s)","Tool tip of auto conductor"), this);
|
m_auto_conductor = new QAction (QET::Icons::Autoconnect, tr("Création automatique de conducteur(s)","Tool tip of auto conductor"), this);
|
||||||
m_auto_conductor->setStatusTip (tr("Utiliser la création automatique de conducteur(s) quand cela est possible", "Status tip of auto conductor"));
|
m_auto_conductor->setStatusTip (tr("Utiliser la création automatique de conducteur(s) quand cela est possible", "Status tip of auto conductor"));
|
||||||
@@ -358,13 +370,13 @@ void QETDiagramEditor::setUpActions()
|
|||||||
project_view->editCurrentDiagramProperties();
|
project_view->editCurrentDiagramProperties();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Edit current project properties
|
//Edit current project properties
|
||||||
m_project_edit_properties = new QAction(QET::Icons::ProjectProperties, tr("Propriétés du projet"), this);
|
m_project_edit_properties = new QAction(QET::Icons::ProjectProperties, tr("Propriétés du projet"), this);
|
||||||
connect(m_project_edit_properties, &QAction::triggered, [this]() {
|
connect(m_project_edit_properties, &QAction::triggered, [this]() {
|
||||||
editProjectProperties(currentProjectView());
|
editProjectProperties(currentProjectView());
|
||||||
});
|
});
|
||||||
|
|
||||||
//Add new folio to current project
|
//Add new folio to current project
|
||||||
m_project_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un folio"), this);
|
m_project_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un folio"), this);
|
||||||
m_project_add_diagram->setShortcut(QKeySequence(tr("Ctrl+T")));
|
m_project_add_diagram->setShortcut(QKeySequence(tr("Ctrl+T")));
|
||||||
@@ -373,11 +385,11 @@ void QETDiagramEditor::setUpActions()
|
|||||||
current_project->project()->addNewDiagram();
|
current_project->project()->addNewDiagram();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Remove current folio from current project
|
//Remove current folio from current project
|
||||||
m_remove_diagram_from_project = new QAction(QET::Icons::DiagramDelete, tr("Supprimer le folio"), this);
|
m_remove_diagram_from_project = new QAction(QET::Icons::DiagramDelete, tr("Supprimer le folio"), this);
|
||||||
connect(m_remove_diagram_from_project, &QAction::triggered, this, &QETDiagramEditor::removeDiagramFromProject);
|
connect(m_remove_diagram_from_project, &QAction::triggered, this, &QETDiagramEditor::removeDiagramFromProject);
|
||||||
|
|
||||||
//Clean the current project
|
//Clean the current project
|
||||||
m_clean_project = new QAction(QET::Icons::EditClear, tr("Nettoyer le projet"), this);
|
m_clean_project = new QAction(QET::Icons::EditClear, tr("Nettoyer le projet"), this);
|
||||||
connect(m_clean_project, &QAction::triggered, [this]() {
|
connect(m_clean_project, &QAction::triggered, [this]() {
|
||||||
@@ -394,7 +406,7 @@ void QETDiagramEditor::setUpActions()
|
|||||||
BOMExportDialog bom(currentProjectView()->project(), this);
|
BOMExportDialog bom(currentProjectView()->project(), this);
|
||||||
bom.exec();
|
bom.exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
//Add a nomenclature item
|
//Add a nomenclature item
|
||||||
m_add_nomenclature = new QAction(QET::Icons::TableOfContent, tr("Ajouter une nomenclature"), this);
|
m_add_nomenclature = new QAction(QET::Icons::TableOfContent, tr("Ajouter une nomenclature"), this);
|
||||||
connect(m_add_nomenclature, &QAction::triggered, [this]() {
|
connect(m_add_nomenclature, &QAction::triggered, [this]() {
|
||||||
@@ -430,27 +442,27 @@ void QETDiagramEditor::setUpActions()
|
|||||||
connect(m_export_project_db, &QAction::triggered, [this]() {
|
connect(m_export_project_db, &QAction::triggered, [this]() {
|
||||||
projectDataBase::exportDb(this->currentProject()->dataBase(), this);
|
projectDataBase::exportDb(this->currentProject()->dataBase(), this);
|
||||||
});
|
});
|
||||||
|
|
||||||
//MDI view style
|
//MDI view style
|
||||||
m_tabbed_view_mode = new QAction(tr("en utilisant des onglets"), this);
|
m_tabbed_view_mode = new QAction(tr("en utilisant des onglets"), this);
|
||||||
m_tabbed_view_mode->setStatusTip(tr("Présente les différents projets ouverts des onglets", "status bar tip"));
|
m_tabbed_view_mode->setStatusTip(tr("Présente les différents projets ouverts des onglets", "status bar tip"));
|
||||||
m_tabbed_view_mode->setCheckable(true);
|
m_tabbed_view_mode->setCheckable(true);
|
||||||
connect(m_tabbed_view_mode, &QAction::triggered, this, &QETDiagramEditor::setTabbedMode);
|
connect(m_tabbed_view_mode, &QAction::triggered, this, &QETDiagramEditor::setTabbedMode);
|
||||||
|
|
||||||
m_windowed_view_mode = new QAction(tr("en utilisant des fenêtres"), this);
|
m_windowed_view_mode = new QAction(tr("en utilisant des fenêtres"), this);
|
||||||
m_windowed_view_mode->setStatusTip(tr("Présente les différents projets ouverts dans des sous-fenêtres", "status bar tip"));
|
m_windowed_view_mode->setStatusTip(tr("Présente les différents projets ouverts dans des sous-fenêtres", "status bar tip"));
|
||||||
m_windowed_view_mode->setCheckable(true);
|
m_windowed_view_mode->setCheckable(true);
|
||||||
connect(m_windowed_view_mode, &QAction::triggered, this, &QETDiagramEditor::setWindowedMode);
|
connect(m_windowed_view_mode, &QAction::triggered, this, &QETDiagramEditor::setWindowedMode);
|
||||||
|
|
||||||
m_group_view_mode = new QActionGroup(this);
|
m_group_view_mode = new QActionGroup(this);
|
||||||
m_group_view_mode -> addAction(m_windowed_view_mode);
|
m_group_view_mode -> addAction(m_windowed_view_mode);
|
||||||
m_group_view_mode -> addAction(m_tabbed_view_mode);
|
m_group_view_mode -> addAction(m_tabbed_view_mode);
|
||||||
m_group_view_mode -> setExclusive(true);
|
m_group_view_mode -> setExclusive(true);
|
||||||
|
|
||||||
m_tile_window = new QAction(tr("&Mosaïque"), this);
|
m_tile_window = new QAction(tr("&Mosaïque"), this);
|
||||||
m_tile_window->setStatusTip(tr("Dispose les fenêtres en mosaïque", "status bar tip"));
|
m_tile_window->setStatusTip(tr("Dispose les fenêtres en mosaïque", "status bar tip"));
|
||||||
connect(m_tile_window, &QAction::triggered, &m_workspace, &QMdiArea::tileSubWindows);
|
connect(m_tile_window, &QAction::triggered, &m_workspace, &QMdiArea::tileSubWindows);
|
||||||
|
|
||||||
m_cascade_window = new QAction(tr("&Cascade"), this);
|
m_cascade_window = new QAction(tr("&Cascade"), this);
|
||||||
m_cascade_window->setStatusTip(tr("Dispose les fenêtres en cascade", "status bar tip"));
|
m_cascade_window->setStatusTip(tr("Dispose les fenêtres en cascade", "status bar tip"));
|
||||||
connect(m_cascade_window, &QAction::triggered, &m_workspace, &QMdiArea::cascadeSubWindows);
|
connect(m_cascade_window, &QAction::triggered, &m_workspace, &QMdiArea::cascadeSubWindows);
|
||||||
@@ -467,7 +479,7 @@ void QETDiagramEditor::setUpActions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
m_mode_visualise = new QAction(QET::Icons::ViewMove, tr("Mode Visualisation"), this);
|
m_mode_visualise = new QAction(QET::Icons::ViewMove, tr("Mode Visualisation"), this);
|
||||||
m_mode_visualise->setStatusTip(tr("Permet de visualiser le folio sans pouvoir le modifier", "status bar tip"));
|
m_mode_visualise->setStatusTip(tr("Permet de visualiser le folio sans pouvoir le modifier", "status bar tip"));
|
||||||
m_mode_visualise->setCheckable(true);
|
m_mode_visualise->setCheckable(true);
|
||||||
@@ -489,7 +501,7 @@ void QETDiagramEditor::setUpActions()
|
|||||||
m_next_window->setShortcut(QKeySequence::NextChild);
|
m_next_window->setShortcut(QKeySequence::NextChild);
|
||||||
m_next_window->setStatusTip(tr("Active le projet suivant", "status bar tip"));
|
m_next_window->setStatusTip(tr("Active le projet suivant", "status bar tip"));
|
||||||
connect(m_next_window, &QAction::triggered, &m_workspace, &QMdiArea::activateNextSubWindow);
|
connect(m_next_window, &QAction::triggered, &m_workspace, &QMdiArea::activateNextSubWindow);
|
||||||
|
|
||||||
m_previous_window = new QAction(tr("Projet précédent"), this);
|
m_previous_window = new QAction(tr("Projet précédent"), this);
|
||||||
m_previous_window->setShortcut(QKeySequence::PreviousChild);
|
m_previous_window->setShortcut(QKeySequence::PreviousChild);
|
||||||
m_previous_window->setStatusTip(tr("Active le projet précédent", "status bar tip"));
|
m_previous_window->setStatusTip(tr("Active le projet précédent", "status bar tip"));
|
||||||
@@ -645,11 +657,11 @@ void QETDiagramEditor::setUpActions()
|
|||||||
//Depth action
|
//Depth action
|
||||||
m_depth_action_group = QET::depthActionGroup(this);
|
m_depth_action_group = QET::depthActionGroup(this);
|
||||||
m_depth_action_group->setDisabled(true);
|
m_depth_action_group->setDisabled(true);
|
||||||
|
|
||||||
connect(m_depth_action_group, &QActionGroup::triggered, [this](QAction *action) {
|
connect(m_depth_action_group, &QActionGroup::triggered, [this](QAction *action) {
|
||||||
this->currentDiagramView()->diagram()->changeZValue(action->data().value<QET::DepthOption>());
|
this->currentDiagramView()->diagram()->changeZValue(action->data().value<QET::DepthOption>());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_find = new QAction(tr("Chercher/remplacer"), this);
|
m_find = new QAction(tr("Chercher/remplacer"), this);
|
||||||
m_find->setShortcut(QKeySequence::Find);
|
m_find->setShortcut(QKeySequence::Find);
|
||||||
connect(m_find, &QAction::triggered, [this]()
|
connect(m_find, &QAction::triggered, [this]()
|
||||||
@@ -705,7 +717,7 @@ void QETDiagramEditor::setUpToolBar()
|
|||||||
m_add_item_tool_bar = new QToolBar(tr("Ajouter"), this);
|
m_add_item_tool_bar = new QToolBar(tr("Ajouter"), this);
|
||||||
m_add_item_tool_bar->setObjectName("adding");
|
m_add_item_tool_bar->setObjectName("adding");
|
||||||
m_add_item_tool_bar->addActions(m_add_item_actions_group.actions());
|
m_add_item_tool_bar->addActions(m_add_item_actions_group.actions());
|
||||||
|
|
||||||
m_depth_tool_bar = new QToolBar(tr("Profondeur", "toolbar title"));
|
m_depth_tool_bar = new QToolBar(tr("Profondeur", "toolbar title"));
|
||||||
m_depth_tool_bar->setObjectName("diagram_depth_toolbar");
|
m_depth_tool_bar->setObjectName("diagram_depth_toolbar");
|
||||||
m_depth_tool_bar->addActions(m_depth_action_group->actions());
|
m_depth_tool_bar->addActions(m_depth_action_group->actions());
|
||||||
@@ -792,7 +804,7 @@ void QETDiagramEditor::setUpMenu()
|
|||||||
diagram_tool_bar -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la barre d'outils Schéma"));
|
diagram_tool_bar -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la barre d'outils Schéma"));
|
||||||
qdw_pa -> toggleViewAction() -> setStatusTip(tr("Affiche ou non le panel d'appareils"));
|
qdw_pa -> toggleViewAction() -> setStatusTip(tr("Affiche ou non le panel d'appareils"));
|
||||||
qdw_undo -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la liste des modifications"));
|
qdw_undo -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la liste des modifications"));
|
||||||
|
|
||||||
|
|
||||||
// menu Affichage
|
// menu Affichage
|
||||||
QMenu *projects_view_mode = menu_affichage -> addMenu(QET::Icons::ConfigureToolbars, tr("Afficher les projets"));
|
QMenu *projects_view_mode = menu_affichage -> addMenu(QET::Icons::ConfigureToolbars, tr("Afficher les projets"));
|
||||||
@@ -848,7 +860,7 @@ void QETDiagramEditor::closeEvent(QCloseEvent *qce)
|
|||||||
Reimplemented to :
|
Reimplemented to :
|
||||||
-Load elements collection when WindowActivate.
|
-Load elements collection when WindowActivate.
|
||||||
@param e
|
@param e
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
bool QETDiagramEditor::event(QEvent *e)
|
bool QETDiagramEditor::event(QEvent *e)
|
||||||
{
|
{
|
||||||
@@ -916,10 +928,10 @@ void QETDiagramEditor::saveAs()
|
|||||||
bool QETDiagramEditor::newProject()
|
bool QETDiagramEditor::newProject()
|
||||||
{
|
{
|
||||||
auto new_project = new QETProject(this);
|
auto new_project = new QETProject(this);
|
||||||
|
|
||||||
// add new diagram
|
// add new diagram
|
||||||
new_project -> addNewDiagram();
|
new_project -> addNewDiagram();
|
||||||
|
|
||||||
return addProject(new_project);
|
return addProject(new_project);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -952,10 +964,10 @@ bool QETDiagramEditor::openProject()
|
|||||||
tr("Projets QElectroTech (*.qet);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
tr("Projets QElectroTech (*.qet);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
||||||
);
|
);
|
||||||
if (filepath.isEmpty()) return(false);
|
if (filepath.isEmpty()) return(false);
|
||||||
|
|
||||||
// retient le dossier contenant le dernier projet ouvert
|
// retient le dossier contenant le dernier projet ouvert
|
||||||
open_dialog_dir = QDir(filepath);
|
open_dialog_dir = QDir(filepath);
|
||||||
|
|
||||||
// ouvre le fichier
|
// ouvre le fichier
|
||||||
return(openAndAddProject(filepath));
|
return(openAndAddProject(filepath));
|
||||||
}
|
}
|
||||||
@@ -1002,7 +1014,7 @@ bool QETDiagramEditor::openAndAddProject(
|
|||||||
bool interactive)
|
bool interactive)
|
||||||
{
|
{
|
||||||
if (filepath.isEmpty()) return(false);
|
if (filepath.isEmpty()) return(false);
|
||||||
|
|
||||||
QFileInfo filepath_info(filepath);
|
QFileInfo filepath_info(filepath);
|
||||||
|
|
||||||
//Check if project is not open in another editor
|
//Check if project is not open in another editor
|
||||||
@@ -1024,7 +1036,7 @@ bool QETDiagramEditor::openAndAddProject(
|
|||||||
return(diagram_editor -> openAndAddProject(filepath));
|
return(diagram_editor -> openAndAddProject(filepath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the file exists
|
// check the file exists
|
||||||
if (!filepath_info.exists())
|
if (!filepath_info.exists())
|
||||||
{
|
{
|
||||||
@@ -1056,7 +1068,7 @@ bool QETDiagramEditor::openAndAddProject(
|
|||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if file is read only
|
//Check if file is read only
|
||||||
if (!filepath_info.isWritable())
|
if (!filepath_info.isWritable())
|
||||||
{
|
{
|
||||||
@@ -1070,10 +1082,10 @@ bool QETDiagramEditor::openAndAddProject(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create the project
|
//Create the project
|
||||||
DialogWaiting::instance(this);
|
DialogWaiting::instance(this);
|
||||||
|
|
||||||
QETProject *project = new QETProject(filepath);
|
QETProject *project = new QETProject(filepath);
|
||||||
if (project -> state() != QETProject::Ok)
|
if (project -> state() != QETProject::Ok)
|
||||||
{
|
{
|
||||||
@@ -1120,14 +1132,14 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel)
|
|||||||
undo_group.addStack(project -> undoStack());
|
undo_group.addStack(project -> undoStack());
|
||||||
|
|
||||||
m_element_collection_widget->addProject(project);
|
m_element_collection_widget->addProject(project);
|
||||||
|
|
||||||
// met a jour le panel d'elements
|
// met a jour le panel d'elements
|
||||||
if (update_panel) {
|
if (update_panel) {
|
||||||
pa -> elementsPanel().projectWasOpened(project);
|
pa -> elementsPanel().projectWasOpened(project);
|
||||||
if (currentDiagramView() != nullptr)
|
if (currentDiagramView() != nullptr)
|
||||||
m_autonumbering_dock->setProject(project, project_view);
|
m_autonumbering_dock->setProject(project, project_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1154,10 +1166,10 @@ ProjectView *QETDiagramEditor::currentProjectView() const
|
|||||||
{
|
{
|
||||||
QMdiSubWindow *current_window = m_workspace.activeSubWindow();
|
QMdiSubWindow *current_window = m_workspace.activeSubWindow();
|
||||||
if (!current_window) return(nullptr);
|
if (!current_window) return(nullptr);
|
||||||
|
|
||||||
QWidget *current_widget = current_window -> widget();
|
QWidget *current_widget = current_window -> widget();
|
||||||
if (!current_widget) return(nullptr);
|
if (!current_widget) return(nullptr);
|
||||||
|
|
||||||
if (ProjectView *project_view = qobject_cast<ProjectView *>(current_widget)) {
|
if (ProjectView *project_view = qobject_cast<ProjectView *>(current_widget)) {
|
||||||
return(project_view);
|
return(project_view);
|
||||||
}
|
}
|
||||||
@@ -1203,11 +1215,11 @@ Element *QETDiagramEditor::currentElement() const
|
|||||||
DiagramView *dv = currentDiagramView();
|
DiagramView *dv = currentDiagramView();
|
||||||
if (!dv)
|
if (!dv)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
QList<Element *> selected_elements = DiagramContent(dv->diagram()).m_elements;
|
QList<Element *> selected_elements = DiagramContent(dv->diagram()).m_elements;
|
||||||
if (selected_elements.count() != 1)
|
if (selected_elements.count() != 1)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
return(selected_elements.first());
|
return(selected_elements.first());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1426,7 +1438,7 @@ void QETDiagramEditor::selectionGroupTriggered(QAction *action)
|
|||||||
QList<DynamicElementTextItem *> deti_list = dc.m_element_texts.values();
|
QList<DynamicElementTextItem *> deti_list = dc.m_element_texts.values();
|
||||||
if(deti_list.size() <= 1)
|
if(deti_list.size() <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
diagram->undoStack().push(new AddTextsGroupCommand(deti_list.first()->parentElement(), tr("Groupe"), deti_list));
|
diagram->undoStack().push(new AddTextsGroupCommand(deti_list.first()->parentElement(), tr("Groupe"), deti_list));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1441,7 +1453,7 @@ void QETDiagramEditor::rowColumnGroupTriggered(QAction *action)
|
|||||||
Diagram *d = dv->diagram();
|
Diagram *d = dv->diagram();
|
||||||
BorderProperties old_bp = d->border_and_titleblock.exportBorder();
|
BorderProperties old_bp = d->border_and_titleblock.exportBorder();
|
||||||
BorderProperties new_bp = d->border_and_titleblock.exportBorder();
|
BorderProperties new_bp = d->border_and_titleblock.exportBorder();
|
||||||
|
|
||||||
if (value == "add_column")
|
if (value == "add_column")
|
||||||
new_bp.columns_count += 1;
|
new_bp.columns_count += 1;
|
||||||
else if (value == "remove_column")
|
else if (value == "remove_column")
|
||||||
@@ -1450,7 +1462,7 @@ void QETDiagramEditor::rowColumnGroupTriggered(QAction *action)
|
|||||||
new_bp.rows_count += 1;
|
new_bp.rows_count += 1;
|
||||||
else if (value == "remove_row")
|
else if (value == "remove_row")
|
||||||
new_bp.rows_count -= 1;
|
new_bp.rows_count -= 1;
|
||||||
|
|
||||||
d->undoStack().push(new ChangeBorderCommand(d, old_bp, new_bp));
|
d->undoStack().push(new ChangeBorderCommand(d, old_bp, new_bp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1542,23 +1554,23 @@ void QETDiagramEditor::slot_updateComplexActions()
|
|||||||
<< m_group_selected_texts;
|
<< m_group_selected_texts;
|
||||||
for(QAction *action : action_list)
|
for(QAction *action : action_list)
|
||||||
action->setEnabled(false);
|
action->setEnabled(false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Diagram *diagram_ = dv->diagram();
|
Diagram *diagram_ = dv->diagram();
|
||||||
DiagramContent dc(diagram_);
|
DiagramContent dc(diagram_);
|
||||||
bool ro = diagram_->isReadOnly();
|
bool ro = diagram_->isReadOnly();
|
||||||
|
|
||||||
|
|
||||||
//Number of selected conductors
|
//Number of selected conductors
|
||||||
int selected_conductors_count = diagram_->selectedConductors().count();
|
int selected_conductors_count = diagram_->selectedConductors().count();
|
||||||
m_conductor_reset->setEnabled(!ro && selected_conductors_count);
|
m_conductor_reset->setEnabled(!ro && selected_conductors_count);
|
||||||
|
|
||||||
// number of selected elements
|
// number of selected elements
|
||||||
int selected_elements_count = dc.count(DiagramContent::Elements);
|
int selected_elements_count = dc.count(DiagramContent::Elements);
|
||||||
m_find_element->setEnabled(selected_elements_count == 1);
|
m_find_element->setEnabled(selected_elements_count == 1);
|
||||||
|
|
||||||
//Action that need items (elements, conductors, texts...) selected, to be enabled
|
//Action that need items (elements, conductors, texts...) selected, to be enabled
|
||||||
bool copiable_items = dc.hasCopiableItems();
|
bool copiable_items = dc.hasCopiableItems();
|
||||||
bool deletable_items = dc.hasDeletableItems();
|
bool deletable_items = dc.hasDeletableItems();
|
||||||
@@ -1584,7 +1596,7 @@ void QETDiagramEditor::slot_updateComplexActions()
|
|||||||
selected_dynamic_elmt_text++;
|
selected_dynamic_elmt_text++;
|
||||||
}
|
}
|
||||||
m_rotate_texts->setEnabled(!ro && (selected_texts || groups.size()));
|
m_rotate_texts->setEnabled(!ro && (selected_texts || groups.size()));
|
||||||
|
|
||||||
//Action that need only element text selected
|
//Action that need only element text selected
|
||||||
QList<DynamicElementTextItem *> deti_list = dc.m_element_texts.values();
|
QList<DynamicElementTextItem *> deti_list = dc.m_element_texts.values();
|
||||||
if(deti_list.size() > 1 && dc.count() == deti_list.count())
|
if(deti_list.size() > 1 && dc.count() == deti_list.count())
|
||||||
@@ -1653,7 +1665,7 @@ void QETDiagramEditor::slot_updateComplexActions()
|
|||||||
m_edit_selection -> setIcon(QET::Icons::ElementEdit);
|
m_edit_selection -> setIcon(QET::Icons::ElementEdit);
|
||||||
m_edit_selection -> setEnabled(false);
|
m_edit_selection -> setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Actions for edit Z value
|
//Actions for edit Z value
|
||||||
QList<QGraphicsItem *> list = dc.items(
|
QList<QGraphicsItem *> list = dc.items(
|
||||||
DiagramContent::SelectedOnly
|
DiagramContent::SelectedOnly
|
||||||
@@ -1670,7 +1682,7 @@ void QETDiagramEditor::slot_updateComplexActions()
|
|||||||
void QETDiagramEditor::slot_updateModeActions()
|
void QETDiagramEditor::slot_updateModeActions()
|
||||||
{
|
{
|
||||||
DiagramView *dv = currentDiagramView();
|
DiagramView *dv = currentDiagramView();
|
||||||
|
|
||||||
if (!dv)
|
if (!dv)
|
||||||
grp_visu_sel -> setEnabled(false);
|
grp_visu_sel -> setEnabled(false);
|
||||||
else
|
else
|
||||||
@@ -1708,7 +1720,7 @@ void QETDiagramEditor::slot_updatePasteAction()
|
|||||||
{
|
{
|
||||||
DiagramView *dv = currentDiagramView();
|
DiagramView *dv = currentDiagramView();
|
||||||
bool editable_diagram = (dv && !dv -> diagram() -> isReadOnly());
|
bool editable_diagram = (dv && !dv -> diagram() -> isReadOnly());
|
||||||
|
|
||||||
// pour coller, il faut un schema ouvert et un schema dans le presse-papier
|
// pour coller, il faut un schema ouvert et un schema dans le presse-papier
|
||||||
m_paste -> setEnabled(editable_diagram && Diagram::clipboardMayContainDiagram());
|
m_paste -> setEnabled(editable_diagram && Diagram::clipboardMayContainDiagram());
|
||||||
}
|
}
|
||||||
@@ -1725,7 +1737,7 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
|
|||||||
|
|
||||||
foreach(DiagramView *dv, project_view -> diagram_views())
|
foreach(DiagramView *dv, project_view -> diagram_views())
|
||||||
diagramWasAdded(dv);
|
diagramWasAdded(dv);
|
||||||
|
|
||||||
//Manage the close event of project
|
//Manage the close event of project
|
||||||
connect(project_view, SIGNAL(projectClosed(ProjectView*)),
|
connect(project_view, SIGNAL(projectClosed(ProjectView*)),
|
||||||
this, SLOT(projectWasClosed(ProjectView *)));
|
this, SLOT(projectWasClosed(ProjectView *)));
|
||||||
@@ -1736,13 +1748,13 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
|
|||||||
if (QETProject *project = project_view -> project())
|
if (QETProject *project = project_view -> project())
|
||||||
connect(project, SIGNAL(readOnlyChanged(QETProject *, bool)),
|
connect(project, SIGNAL(readOnlyChanged(QETProject *, bool)),
|
||||||
this, SLOT(slot_updateActions()));
|
this, SLOT(slot_updateActions()));
|
||||||
|
|
||||||
//Manage request for edit or find element and titleblock
|
//Manage request for edit or find element and titleblock
|
||||||
connect (project_view, &ProjectView::findElementRequired,
|
connect (project_view, &ProjectView::findElementRequired,
|
||||||
this, &QETDiagramEditor::findElementInPanel);
|
this, &QETDiagramEditor::findElementInPanel);
|
||||||
connect (project_view, &ProjectView::editElementRequired,
|
connect (project_view, &ProjectView::editElementRequired,
|
||||||
this, &QETDiagramEditor::editElementInEditor);
|
this, &QETDiagramEditor::editElementInEditor);
|
||||||
|
|
||||||
// display error messages sent by the project view
|
// display error messages sent by the project view
|
||||||
connect(project_view, SIGNAL(errorEncountered(QString)),
|
connect(project_view, SIGNAL(errorEncountered(QString)),
|
||||||
this, SLOT(showError(const QString &)));
|
this, SLOT(showError(const QString &)));
|
||||||
@@ -1757,7 +1769,7 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
|
|||||||
QMdiSubWindow *sub_window = m_workspace.addSubWindow(project_view);
|
QMdiSubWindow *sub_window = m_workspace.addSubWindow(project_view);
|
||||||
sub_window -> setWindowIcon(project_view -> windowIcon());
|
sub_window -> setWindowIcon(project_view -> windowIcon());
|
||||||
sub_window -> systemMenu() -> clear();
|
sub_window -> systemMenu() -> clear();
|
||||||
|
|
||||||
//By defaut QMdiSubWindow have a QAction "close" with shortcut QKeySequence::Close
|
//By defaut QMdiSubWindow have a QAction "close" with shortcut QKeySequence::Close
|
||||||
//But the QAction m_close_file of this class have the same shortcut too.
|
//But the QAction m_close_file of this class have the same shortcut too.
|
||||||
//We remove the shortcut of the QAction of QMdiSubWindow for avoid conflic
|
//We remove the shortcut of the QAction of QMdiSubWindow for avoid conflic
|
||||||
@@ -1796,7 +1808,7 @@ QList<QString> QETDiagramEditor::editedFiles() const
|
|||||||
ProjectView *QETDiagramEditor::viewForFile(const QString &filepath) const
|
ProjectView *QETDiagramEditor::viewForFile(const QString &filepath) const
|
||||||
{
|
{
|
||||||
if (filepath.isEmpty()) return(nullptr);
|
if (filepath.isEmpty()) return(nullptr);
|
||||||
|
|
||||||
QString searched_can_file_path = QFileInfo(filepath).canonicalFilePath();
|
QString searched_can_file_path = QFileInfo(filepath).canonicalFilePath();
|
||||||
if (searched_can_file_path.isEmpty()) {
|
if (searched_can_file_path.isEmpty()) {
|
||||||
// QFileInfo returns an empty path for non-existent files
|
// QFileInfo returns an empty path for non-existent files
|
||||||
@@ -1858,29 +1870,29 @@ void QETDiagramEditor::slot_updateWindowsMenu()
|
|||||||
{
|
{
|
||||||
// nettoyage du menu
|
// nettoyage du menu
|
||||||
foreach(QAction *a, windows_menu -> actions()) windows_menu -> removeAction(a);
|
foreach(QAction *a, windows_menu -> actions()) windows_menu -> removeAction(a);
|
||||||
|
|
||||||
// actions de fermeture
|
// actions de fermeture
|
||||||
windows_menu -> addAction(m_close_file);
|
windows_menu -> addAction(m_close_file);
|
||||||
//windows_menu -> addAction(closeAllAct);
|
//windows_menu -> addAction(closeAllAct);
|
||||||
|
|
||||||
// actions de reorganisation des fenetres
|
// actions de reorganisation des fenetres
|
||||||
windows_menu -> addSeparator();
|
windows_menu -> addSeparator();
|
||||||
windows_menu -> addAction(m_tile_window);
|
windows_menu -> addAction(m_tile_window);
|
||||||
windows_menu -> addAction(m_cascade_window);
|
windows_menu -> addAction(m_cascade_window);
|
||||||
|
|
||||||
// actions de deplacement entre les fenetres
|
// actions de deplacement entre les fenetres
|
||||||
windows_menu -> addSeparator();
|
windows_menu -> addSeparator();
|
||||||
windows_menu -> addAction(m_next_window);
|
windows_menu -> addAction(m_next_window);
|
||||||
windows_menu -> addAction(m_previous_window);
|
windows_menu -> addAction(m_previous_window);
|
||||||
|
|
||||||
// liste des fenetres
|
// liste des fenetres
|
||||||
QList<ProjectView *> windows = openedProjects();
|
QList<ProjectView *> windows = openedProjects();
|
||||||
|
|
||||||
m_tile_window -> setEnabled(!windows.isEmpty() && m_workspace.viewMode() == QMdiArea::SubWindowView);
|
m_tile_window -> setEnabled(!windows.isEmpty() && m_workspace.viewMode() == QMdiArea::SubWindowView);
|
||||||
m_cascade_window -> setEnabled(!windows.isEmpty() && m_workspace.viewMode() == QMdiArea::SubWindowView);
|
m_cascade_window -> setEnabled(!windows.isEmpty() && m_workspace.viewMode() == QMdiArea::SubWindowView);
|
||||||
m_next_window -> setEnabled(windows.count() > 1);
|
m_next_window -> setEnabled(windows.count() > 1);
|
||||||
m_previous_window -> setEnabled(windows.count() > 1);
|
m_previous_window -> setEnabled(windows.count() > 1);
|
||||||
|
|
||||||
if (!windows.isEmpty()) windows_menu -> addSeparator();
|
if (!windows.isEmpty()) windows_menu -> addSeparator();
|
||||||
QActionGroup *windows_actions = new QActionGroup(this);
|
QActionGroup *windows_actions = new QActionGroup(this);
|
||||||
foreach(ProjectView *project_view, windows) {
|
foreach(ProjectView *project_view, windows) {
|
||||||
@@ -1946,15 +1958,15 @@ void QETDiagramEditor::setTabbedMode()
|
|||||||
void QETDiagramEditor::readSettings()
|
void QETDiagramEditor::readSettings()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
// dimensions et position de la fenetre
|
// dimensions et position de la fenetre
|
||||||
QVariant geometry = settings.value("diagrameditor/geometry");
|
QVariant geometry = settings.value("diagrameditor/geometry");
|
||||||
if (geometry.isValid()) restoreGeometry(geometry.toByteArray());
|
if (geometry.isValid()) restoreGeometry(geometry.toByteArray());
|
||||||
|
|
||||||
// etat de la fenetre (barres d'outils, docks...)
|
// etat de la fenetre (barres d'outils, docks...)
|
||||||
QVariant state = settings.value("diagrameditor/state");
|
QVariant state = settings.value("diagrameditor/state");
|
||||||
if (state.isValid()) restoreState(state.toByteArray());
|
if (state.isValid()) restoreState(state.toByteArray());
|
||||||
|
|
||||||
// gestion des projets (onglets ou fenetres)
|
// gestion des projets (onglets ou fenetres)
|
||||||
bool tabbed = settings.value("diagrameditor/viewmode", "tabbed") == "tabbed";
|
bool tabbed = settings.value("diagrameditor/viewmode", "tabbed") == "tabbed";
|
||||||
if (tabbed) {
|
if (tabbed) {
|
||||||
@@ -2018,7 +2030,7 @@ void QETDiagramEditor::activateProject(ProjectView *project_view)
|
|||||||
void QETDiagramEditor::projectWasClosed(ProjectView *project_view)
|
void QETDiagramEditor::projectWasClosed(ProjectView *project_view)
|
||||||
{
|
{
|
||||||
QETProject *project = project_view -> project();
|
QETProject *project = project_view -> project();
|
||||||
if (project)
|
if (project)
|
||||||
{
|
{
|
||||||
pa -> elementsPanel().projectWasClosed(project);
|
pa -> elementsPanel().projectWasClosed(project);
|
||||||
m_element_collection_widget->removeProject(project);
|
m_element_collection_widget->removeProject(project);
|
||||||
@@ -2064,7 +2076,7 @@ void QETDiagramEditor::addDiagramToProject(QETProject *project)
|
|||||||
if (!project) {
|
if (!project) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ProjectView *project_view = findProject(project))
|
if (ProjectView *project_view = findProject(project))
|
||||||
{
|
{
|
||||||
activateProject(project);
|
activateProject(project);
|
||||||
@@ -2079,15 +2091,15 @@ void QETDiagramEditor::addDiagramToProject(QETProject *project)
|
|||||||
void QETDiagramEditor::removeDiagram(Diagram *diagram)
|
void QETDiagramEditor::removeDiagram(Diagram *diagram)
|
||||||
{
|
{
|
||||||
if (!diagram) return;
|
if (!diagram) return;
|
||||||
|
|
||||||
// recupere le projet contenant le schema
|
// recupere le projet contenant le schema
|
||||||
if (QETProject *diagram_project = diagram -> project()) {
|
if (QETProject *diagram_project = diagram -> project()) {
|
||||||
// recupere la vue sur ce projet
|
// recupere la vue sur ce projet
|
||||||
if (ProjectView *project_view = findProject(diagram_project)) {
|
if (ProjectView *project_view = findProject(diagram_project)) {
|
||||||
|
|
||||||
// affiche le schema en question
|
// affiche le schema en question
|
||||||
project_view -> showDiagram(diagram);
|
project_view -> showDiagram(diagram);
|
||||||
|
|
||||||
// supprime le schema
|
// supprime le schema
|
||||||
project_view -> removeDiagram(diagram);
|
project_view -> removeDiagram(diagram);
|
||||||
}
|
}
|
||||||
@@ -2102,11 +2114,11 @@ void QETDiagramEditor::removeDiagram(Diagram *diagram)
|
|||||||
void QETDiagramEditor::moveDiagramUp(Diagram *diagram)
|
void QETDiagramEditor::moveDiagramUp(Diagram *diagram)
|
||||||
{
|
{
|
||||||
if (!diagram) return;
|
if (!diagram) return;
|
||||||
|
|
||||||
// recupere le projet contenant le schema
|
// recupere le projet contenant le schema
|
||||||
if (QETProject *diagram_project = diagram -> project()) {
|
if (QETProject *diagram_project = diagram -> project()) {
|
||||||
if (diagram_project -> isReadOnly()) return;
|
if (diagram_project -> isReadOnly()) return;
|
||||||
|
|
||||||
// recupere la vue sur ce projet
|
// recupere la vue sur ce projet
|
||||||
if (ProjectView *project_view = findProject(diagram_project)) {
|
if (ProjectView *project_view = findProject(diagram_project)) {
|
||||||
project_view -> moveDiagramUp(diagram);
|
project_view -> moveDiagramUp(diagram);
|
||||||
@@ -2122,11 +2134,11 @@ void QETDiagramEditor::moveDiagramUp(Diagram *diagram)
|
|||||||
void QETDiagramEditor::moveDiagramDown(Diagram *diagram)
|
void QETDiagramEditor::moveDiagramDown(Diagram *diagram)
|
||||||
{
|
{
|
||||||
if (!diagram) return;
|
if (!diagram) return;
|
||||||
|
|
||||||
// recupere le projet contenant le schema
|
// recupere le projet contenant le schema
|
||||||
if (QETProject *diagram_project = diagram -> project()) {
|
if (QETProject *diagram_project = diagram -> project()) {
|
||||||
if (diagram_project -> isReadOnly()) return;
|
if (diagram_project -> isReadOnly()) return;
|
||||||
|
|
||||||
// recupere la vue sur ce projet
|
// recupere la vue sur ce projet
|
||||||
if (ProjectView *project_view = findProject(diagram_project)) {
|
if (ProjectView *project_view = findProject(diagram_project)) {
|
||||||
project_view -> moveDiagramDown(diagram);
|
project_view -> moveDiagramDown(diagram);
|
||||||
@@ -2313,7 +2325,7 @@ void QETDiagramEditor::generateTerminalBlock()
|
|||||||
{
|
{
|
||||||
bool success;
|
bool success;
|
||||||
QProcess *process = new QProcess(qApp);
|
QProcess *process = new QProcess(qApp);
|
||||||
|
|
||||||
// If launched under control:
|
// If launched under control:
|
||||||
//connect(process, SIGNAL(errorOcurred(int error)), this, SLOT(slot_generateTerminalBlock_error()));
|
//connect(process, SIGNAL(errorOcurred(int error)), this, SLOT(slot_generateTerminalBlock_error()));
|
||||||
//process->start("qet_tb_generator");
|
//process->start("qet_tb_generator");
|
||||||
@@ -2351,7 +2363,7 @@ void QETDiagramEditor::generateTerminalBlock()
|
|||||||
else {
|
else {
|
||||||
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator.app", {("")});
|
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator.app", {("")});
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if (openedProjects().count()){
|
if (openedProjects().count()){
|
||||||
success = process->startDetached("qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
|
success = process->startDetached("qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
|
||||||
@@ -2365,7 +2377,7 @@ void QETDiagramEditor::generateTerminalBlock()
|
|||||||
else {
|
else {
|
||||||
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator", {("")});
|
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator", {("")});
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
|
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
|
||||||
QString message=QObject::tr(
|
QString message=QObject::tr(
|
||||||
|
|||||||
@@ -1,23 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 ELEMENT_H
|
#ifndef ELEMENT_H
|
||||||
#define ELEMENT_H
|
#define ELEMENT_H
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <QPicture>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
#include "qetgraphicsitem.h"
|
#include "qetgraphicsitem.h"
|
||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
@@ -25,9 +29,6 @@
|
|||||||
#include "elementslocation.h"
|
#include "elementslocation.h"
|
||||||
#include "nameslist.h"
|
#include "nameslist.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <QPicture>
|
|
||||||
|
|
||||||
class QETProject;
|
class QETProject;
|
||||||
class Terminal;
|
class Terminal;
|
||||||
class Conductor;
|
class Conductor;
|
||||||
@@ -40,7 +41,7 @@ class ElementTextItemGroup;
|
|||||||
class Element : public QetGraphicsItem
|
class Element : public QetGraphicsItem
|
||||||
{
|
{
|
||||||
friend class DiagramEventAddElement;
|
friend class DiagramEventAddElement;
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@@ -64,7 +65,7 @@ class Element : public QetGraphicsItem
|
|||||||
~Element() override;
|
~Element() override;
|
||||||
private:
|
private:
|
||||||
Element(const Element &);
|
Element(const Element &);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +75,7 @@ class Element : public QetGraphicsItem
|
|||||||
*/
|
*/
|
||||||
enum { Type = UserType + 1000 };
|
enum { Type = UserType + 1000 };
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void linkedElementChanged(); //This signal is emited when the linked elements with this element change
|
void linkedElementChanged(); //This signal is emited when the linked elements with this element change
|
||||||
void elementInfoChange(
|
void elementInfoChange(
|
||||||
@@ -91,12 +92,12 @@ class Element : public QetGraphicsItem
|
|||||||
DynamicElementTextItem *text,
|
DynamicElementTextItem *text,
|
||||||
ElementTextItemGroup *group);
|
ElementTextItemGroup *group);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QList<Terminal *> terminals() const;
|
QList<Terminal *> terminals() const;
|
||||||
QList<Conductor *> conductors() const;
|
QList<Conductor *> conductors() const;
|
||||||
QList<QPair<Terminal *,Terminal *>> AlignedFreeTerminals() const;
|
QList<QPair<Terminal *,Terminal *>> AlignedFreeTerminals() const;
|
||||||
|
|
||||||
//METHODS related to information
|
//METHODS related to information
|
||||||
DiagramContext elementInformations()const
|
DiagramContext elementInformations()const
|
||||||
{return m_element_informations;}
|
{return m_element_informations;}
|
||||||
@@ -118,7 +119,7 @@ class Element : public QetGraphicsItem
|
|||||||
bool isFreezeLabel() const {return m_freeze_label;}
|
bool isFreezeLabel() const {return m_freeze_label;}
|
||||||
void freezeNewAddedElement();
|
void freezeNewAddedElement();
|
||||||
QString actualLabel();
|
QString actualLabel();
|
||||||
|
|
||||||
QString name() const override;
|
QString name() const override;
|
||||||
ElementsLocation location() const;
|
ElementsLocation location() const;
|
||||||
virtual void setHighlighted(bool);
|
virtual void setHighlighted(bool);
|
||||||
@@ -140,7 +141,7 @@ class Element : public QetGraphicsItem
|
|||||||
int> &) const;
|
int> &) const;
|
||||||
QUuid uuid() const;
|
QUuid uuid() const;
|
||||||
int orientation() const;
|
int orientation() const;
|
||||||
|
|
||||||
//METHODS related to texts
|
//METHODS related to texts
|
||||||
void addDynamicTextItem(DynamicElementTextItem *deti = nullptr);
|
void addDynamicTextItem(DynamicElementTextItem *deti = nullptr);
|
||||||
void removeDynamicTextItem(DynamicElementTextItem *deti);
|
void removeDynamicTextItem(DynamicElementTextItem *deti);
|
||||||
@@ -156,7 +157,7 @@ class Element : public QetGraphicsItem
|
|||||||
bool removeTextFromGroup(
|
bool removeTextFromGroup(
|
||||||
DynamicElementTextItem *text,
|
DynamicElementTextItem *text,
|
||||||
ElementTextItemGroup *group);
|
ElementTextItemGroup *group);
|
||||||
|
|
||||||
//METHODS related to linked element
|
//METHODS related to linked element
|
||||||
bool isFree() const;
|
bool isFree() const;
|
||||||
virtual void linkToElement(Element *) {}
|
virtual void linkToElement(Element *) {}
|
||||||
@@ -171,7 +172,7 @@ class Element : public QetGraphicsItem
|
|||||||
protected:
|
protected:
|
||||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
void setSize(int, int);
|
void setSize(int, int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawSelection(
|
void drawSelection(
|
||||||
QPainter *,
|
QPainter *,
|
||||||
@@ -212,25 +213,25 @@ class Element : public QetGraphicsItem
|
|||||||
// to be use in the function element::fromXml
|
// to be use in the function element::fromXml
|
||||||
QHash <DynamicElementTextItem *, QPointF>
|
QHash <DynamicElementTextItem *, QPointF>
|
||||||
m_converted_text_from_xml_description;
|
m_converted_text_from_xml_description;
|
||||||
|
|
||||||
//ATTRIBUTES related to linked element
|
//ATTRIBUTES related to linked element
|
||||||
QList <Element *> connected_elements;
|
QList <Element *> connected_elements;
|
||||||
QList <QUuid> tmp_uuids_link;
|
QList <QUuid> tmp_uuids_link;
|
||||||
QUuid m_uuid;
|
QUuid m_uuid;
|
||||||
kind m_link_type = Element::Simple;
|
kind m_link_type = Element::Simple;
|
||||||
|
|
||||||
//ATTRIBUTES related to informations
|
//ATTRIBUTES related to informations
|
||||||
DiagramContext m_element_informations, m_kind_informations;
|
DiagramContext m_element_informations, m_kind_informations;
|
||||||
autonum::sequentialNumbers m_autoNum_seq;
|
autonum::sequentialNumbers m_autoNum_seq;
|
||||||
bool m_freeze_label = false;
|
bool m_freeze_label = false;
|
||||||
QString m_F_str;
|
QString m_F_str;
|
||||||
|
|
||||||
ElementsLocation m_location;
|
ElementsLocation m_location;
|
||||||
NamesList m_names;
|
NamesList m_names;
|
||||||
QList <Terminal *> m_terminals;
|
QList <Terminal *> m_terminals;
|
||||||
const QPicture m_picture;
|
const QPicture m_picture;
|
||||||
const QPicture m_low_zoom_picture;
|
const QPicture m_low_zoom_picture;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_must_highlight = false;
|
bool m_must_highlight = false;
|
||||||
QSize dimensions;
|
QSize dimensions;
|
||||||
|
|||||||
@@ -965,30 +965,28 @@ 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::getcolorCode(pen.color().red(),
|
Createdxf::dxfColor(pen));
|
||||||
pen.color().green(),
|
return true;
|
||||||
pen.color().blue()));
|
|
||||||
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::getcolorCode(pen.color().red(),
|
Createdxf::dxfColor(pen));
|
||||||
pen.color().green(),
|
return true;
|
||||||
pen.color().blue()));
|
|
||||||
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::getcolorCode(pen.color().red(),
|
Createdxf::dxfColor(pen));
|
||||||
pen.color().green(),
|
return true;
|
||||||
pen.color().blue()));
|
case Polygon:
|
||||||
return true;
|
Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
|
||||||
default: return false;
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 "qetinformation.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
|
#include "qetinformation.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QETInformation::titleblockInfoKeys
|
@brief QETInformation::titleblockInfoKeys
|
||||||
@return all available key for use with a titleblock
|
@return all available key for use with a titleblock
|
||||||
@@ -47,7 +48,7 @@ QStringList QETInformation::titleblockInfoKeys()
|
|||||||
info_list << "savedtime";
|
info_list << "savedtime";
|
||||||
info_list << "savedfilename";
|
info_list << "savedfilename";
|
||||||
info_list << "savedfilepath";
|
info_list << "savedfilepath";
|
||||||
|
|
||||||
return info_list;
|
return info_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#define QETINFORMATION_H
|
#define QETINFORMATION_H
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
namespace QETInformation
|
namespace QETInformation
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,20 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 <QTimer>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <utility>
|
||||||
|
#include <QtConcurrent>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#include "qetproject.h"
|
#include "qetproject.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
@@ -30,11 +37,6 @@
|
|||||||
#include "numerotationcontextcommands.h"
|
#include "numerotationcontextcommands.h"
|
||||||
#include "assignvariables.h"
|
#include "assignvariables.h"
|
||||||
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <utility>
|
|
||||||
#include <QtConcurrent>
|
|
||||||
|
|
||||||
static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min
|
static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,7 +281,7 @@ void QETProject::setFilePath(const QString &filepath)
|
|||||||
m_backup_file.setManagedFile(QUrl::fromLocalFile(filepath));
|
m_backup_file.setManagedFile(QUrl::fromLocalFile(filepath));
|
||||||
|
|
||||||
m_file_path = filepath;
|
m_file_path = filepath;
|
||||||
|
|
||||||
QFileInfo fi(m_file_path);
|
QFileInfo fi(m_file_path);
|
||||||
if (fi.isWritable()) {
|
if (fi.isWritable()) {
|
||||||
setReadOnly(false);
|
setReadOnly(false);
|
||||||
@@ -290,9 +292,9 @@ void QETProject::setFilePath(const QString &filepath)
|
|||||||
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
|
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
|
||||||
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
|
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
|
||||||
m_project_properties.addValue("savedfilepath", filePath());
|
m_project_properties.addValue("savedfilepath", filePath());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
emit(projectFilePathChanged(this, m_file_path));
|
emit(projectFilePathChanged(this, m_file_path));
|
||||||
emit(projectInformationsChanged(this));
|
emit(projectInformationsChanged(this));
|
||||||
updateDiagramsFolioData();
|
updateDiagramsFolioData();
|
||||||
@@ -315,7 +317,7 @@ QString QETProject::currentDir() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@return une chaine de caractere du type "Projet titre du projet".
|
@return une chaine de caractere du type "Projet titre du projet".
|
||||||
Si le projet n'a pas de titre, le nom du fichier est utilise.
|
Si le projet n'a pas de titre, le nom du fichier est utilise.
|
||||||
Si le projet n'est pas associe a un fichier, cette methode retourne "Projet
|
Si le projet n'est pas associe a un fichier, cette methode retourne "Projet
|
||||||
@@ -326,7 +328,7 @@ QString QETProject::currentDir() const
|
|||||||
QString QETProject::pathNameTitle() const
|
QString QETProject::pathNameTitle() const
|
||||||
{
|
{
|
||||||
QString final_title;
|
QString final_title;
|
||||||
|
|
||||||
if (!project_title_.isEmpty()) {
|
if (!project_title_.isEmpty()) {
|
||||||
final_title = QString(
|
final_title = QString(
|
||||||
tr(
|
tr(
|
||||||
@@ -349,7 +351,7 @@ QString QETProject::pathNameTitle() const
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isReadOnly()) {
|
if (isReadOnly()) {
|
||||||
final_title = QString(
|
final_title = QString(
|
||||||
tr(
|
tr(
|
||||||
@@ -366,7 +368,7 @@ QString QETProject::pathNameTitle() const
|
|||||||
)
|
)
|
||||||
).arg(final_title);
|
).arg(final_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(final_title);
|
return(final_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,10 +396,10 @@ qreal QETProject::declaredQElectroTechVersion()
|
|||||||
void QETProject::setTitle(const QString &title) {
|
void QETProject::setTitle(const QString &title) {
|
||||||
// ne fait rien si le projet est en lecture seule
|
// ne fait rien si le projet est en lecture seule
|
||||||
if (isReadOnly()) return;
|
if (isReadOnly()) return;
|
||||||
|
|
||||||
// ne fait rien si le titre du projet n'est pas change par l'appel de cette methode
|
// ne fait rien si le titre du projet n'est pas change par l'appel de cette methode
|
||||||
if (project_title_ == title) return;
|
if (project_title_ == title) return;
|
||||||
|
|
||||||
project_title_ = title;
|
project_title_ = title;
|
||||||
emit(projectTitleChanged(this, project_title_));
|
emit(projectTitleChanged(this, project_title_));
|
||||||
emit(projectInformationsChanged(this));
|
emit(projectInformationsChanged(this));
|
||||||
@@ -487,7 +489,7 @@ void QETProject::setDefaultReportProperties(const QString &properties)
|
|||||||
{
|
{
|
||||||
QString old = m_default_report_properties;
|
QString old = m_default_report_properties;
|
||||||
m_default_report_properties = properties;
|
m_default_report_properties = properties;
|
||||||
|
|
||||||
emit reportPropertiesChanged(old, properties);
|
emit reportPropertiesChanged(old, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -856,7 +858,7 @@ QDomDocument QETProject::toXml()
|
|||||||
project_root.setAttribute("version", QET::version);
|
project_root.setAttribute("version", QET::version);
|
||||||
project_root.setAttribute("title", project_title_);
|
project_root.setAttribute("title", project_title_);
|
||||||
xml_doc.appendChild(project_root);
|
xml_doc.appendChild(project_root);
|
||||||
|
|
||||||
// titleblock templates, if any
|
// titleblock templates, if any
|
||||||
if (m_titleblocks_collection.templates().count()) {
|
if (m_titleblocks_collection.templates().count()) {
|
||||||
QDomElement titleblocktemplates_elmt = xml_doc.createElement("titleblocktemplates");
|
QDomElement titleblocktemplates_elmt = xml_doc.createElement("titleblocktemplates");
|
||||||
@@ -866,19 +868,19 @@ QDomDocument QETProject::toXml()
|
|||||||
}
|
}
|
||||||
project_root.appendChild(titleblocktemplates_elmt);
|
project_root.appendChild(titleblocktemplates_elmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// project-wide properties
|
// project-wide properties
|
||||||
QDomElement project_properties = xml_doc.createElement("properties");
|
QDomElement project_properties = xml_doc.createElement("properties");
|
||||||
writeProjectPropertiesXml(project_properties);
|
writeProjectPropertiesXml(project_properties);
|
||||||
project_root.appendChild(project_properties);
|
project_root.appendChild(project_properties);
|
||||||
|
|
||||||
// Properties for news diagrams
|
// Properties for news diagrams
|
||||||
QDomElement new_diagrams_properties = xml_doc.createElement("newdiagrams");
|
QDomElement new_diagrams_properties = xml_doc.createElement("newdiagrams");
|
||||||
writeDefaultPropertiesXml(new_diagrams_properties);
|
writeDefaultPropertiesXml(new_diagrams_properties);
|
||||||
project_root.appendChild(new_diagrams_properties);
|
project_root.appendChild(new_diagrams_properties);
|
||||||
|
|
||||||
// schemas
|
// schemas
|
||||||
|
|
||||||
qDebug() << "Export XML de" << m_diagrams_list.count() << "schemas";
|
qDebug() << "Export XML de" << m_diagrams_list.count() << "schemas";
|
||||||
int order_num = 1;
|
int order_num = 1;
|
||||||
const QList<Diagram *> diagrams_list = m_diagrams_list;
|
const QList<Diagram *> diagrams_list = m_diagrams_list;
|
||||||
@@ -895,10 +897,10 @@ QDomDocument QETProject::toXml()
|
|||||||
QDomNode appended_diagram = project_root.appendChild(xml_node);
|
QDomNode appended_diagram = project_root.appendChild(xml_node);
|
||||||
appended_diagram.toElement().setAttribute("order", order_num ++);
|
appended_diagram.toElement().setAttribute("order", order_num ++);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the elements collection.
|
// Write the elements collection.
|
||||||
project_root.appendChild(m_elements_collection->root().cloneNode(true));
|
project_root.appendChild(m_elements_collection->root().cloneNode(true));
|
||||||
|
|
||||||
return(xml_doc);
|
return(xml_doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -932,16 +934,20 @@ QETResult QETProject::write()
|
|||||||
QString error_message;
|
QString error_message;
|
||||||
if (!QET::writeXmlFile(xml_project, m_file_path, &error_message))
|
if (!QET::writeXmlFile(xml_project, m_file_path, &error_message))
|
||||||
return(error_message);
|
return(error_message);
|
||||||
|
|
||||||
//title block variables should be updated after file save dialog is confirmed, before file is saved.
|
//title block variables should be updated after file save dialog is confirmed, before file is saved.
|
||||||
m_project_properties.addValue("saveddate", QDate::currentDate().toString(Qt::SystemLocaleShortDate));
|
m_project_properties.addValue(
|
||||||
|
"saveddate",
|
||||||
|
QDate::currentDate().toString(
|
||||||
|
QLocale::system().toString(
|
||||||
|
QLocale::ShortFormat)));
|
||||||
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
|
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
|
||||||
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
|
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
|
||||||
m_project_properties.addValue("savedfilepath", filePath());
|
m_project_properties.addValue("savedfilepath", filePath());
|
||||||
|
|
||||||
emit(projectInformationsChanged(this));
|
emit(projectInformationsChanged(this));
|
||||||
updateDiagramsFolioData();
|
updateDiagramsFolioData();
|
||||||
|
|
||||||
setModified(false);
|
setModified(false);
|
||||||
return(QETResult());
|
return(QETResult());
|
||||||
}
|
}
|
||||||
@@ -981,15 +987,15 @@ bool QETProject::isEmpty() const
|
|||||||
{
|
{
|
||||||
// si le projet a un titre, on considere qu'il n'est pas vide
|
// si le projet a un titre, on considere qu'il n'est pas vide
|
||||||
if (!project_title_.isEmpty()) return(false);
|
if (!project_title_.isEmpty()) return(false);
|
||||||
|
|
||||||
//@TODO check if the embedded element collection is empty
|
//@TODO check if the embedded element collection is empty
|
||||||
|
|
||||||
// compte le nombre de schemas non vides
|
// compte le nombre de schemas non vides
|
||||||
int pertinent_diagrams = 0;
|
int pertinent_diagrams = 0;
|
||||||
foreach(Diagram *diagram, m_diagrams_list) {
|
foreach(Diagram *diagram, m_diagrams_list) {
|
||||||
if (!diagram -> isEmpty()) ++ pertinent_diagrams;
|
if (!diagram -> isEmpty()) ++ pertinent_diagrams;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(pertinent_diagrams > 0);
|
return(pertinent_diagrams > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1089,13 +1095,13 @@ ElementsLocation QETProject::importElement(ElementsLocation &location)
|
|||||||
Integrate a title block template into this project.
|
Integrate a title block template into this project.
|
||||||
@param src_tbt The location of the title block template
|
@param src_tbt The location of the title block template
|
||||||
to be integrated into this project
|
to be integrated into this project
|
||||||
@param handler
|
@param handler
|
||||||
@return the name of the template after integration,
|
@return the name of the template after integration,
|
||||||
or an empty QString if a problem occurred.
|
or an empty QString if a problem occurred.
|
||||||
*/
|
*/
|
||||||
QString QETProject::integrateTitleBlockTemplate(const TitleBlockTemplateLocation &src_tbt, MoveTitleBlockTemplatesHandler *handler) {
|
QString QETProject::integrateTitleBlockTemplate(const TitleBlockTemplateLocation &src_tbt, MoveTitleBlockTemplatesHandler *handler) {
|
||||||
TitleBlockTemplateLocation dst_tbt(src_tbt.name(), &m_titleblocks_collection);
|
TitleBlockTemplateLocation dst_tbt(src_tbt.name(), &m_titleblocks_collection);
|
||||||
|
|
||||||
// check whether a TBT having the same name already exists within this project
|
// check whether a TBT having the same name already exists within this project
|
||||||
QString target_name = dst_tbt.name();
|
QString target_name = dst_tbt.name();
|
||||||
while (m_titleblocks_collection.templates().contains(target_name))
|
while (m_titleblocks_collection.templates().contains(target_name))
|
||||||
@@ -1113,7 +1119,7 @@ QString QETProject::integrateTitleBlockTemplate(const TitleBlockTemplateLocation
|
|||||||
return(target_name);
|
return(target_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_titleblocks_collection.setTemplateXmlDescription(target_name, src_tbt.getTemplateXmlDescription()))
|
if (!m_titleblocks_collection.setTemplateXmlDescription(target_name, src_tbt.getTemplateXmlDescription()))
|
||||||
{
|
{
|
||||||
handler -> errorWithATemplate(src_tbt, tr("Une erreur s'est produite durant l'intégration du modèle.", "error message"));
|
handler -> errorWithATemplate(src_tbt, tr("Une erreur s'est produite durant l'intégration du modèle.", "error message"));
|
||||||
@@ -1164,7 +1170,7 @@ QList<ElementsLocation> QETProject::unusedElements() const
|
|||||||
bool QETProject::usesTitleBlockTemplate(const TitleBlockTemplateLocation &location) {
|
bool QETProject::usesTitleBlockTemplate(const TitleBlockTemplateLocation &location) {
|
||||||
// a diagram can only use a title block template embedded wihtin its parent project
|
// a diagram can only use a title block template embedded wihtin its parent project
|
||||||
if (location.parentProject() != this) return(false);
|
if (location.parentProject() != this) return(false);
|
||||||
|
|
||||||
foreach (Diagram *diagram, diagrams()) {
|
foreach (Diagram *diagram, diagrams()) {
|
||||||
if (diagram -> usesTitleBlockTemplate(location.name())) {
|
if (diagram -> usesTitleBlockTemplate(location.name())) {
|
||||||
return(true);
|
return(true);
|
||||||
@@ -1184,9 +1190,9 @@ Diagram *QETProject::addNewDiagram(int pos)
|
|||||||
if (isReadOnly()) {
|
if (isReadOnly()) {
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Diagram *diagram = new Diagram(this);
|
Diagram *diagram = new Diagram(this);
|
||||||
|
|
||||||
diagram->border_and_titleblock.importBorder(defaultBorderProperties());
|
diagram->border_and_titleblock.importBorder(defaultBorderProperties());
|
||||||
diagram->border_and_titleblock.importTitleBlock(defaultTitleBlockProperties());
|
diagram->border_and_titleblock.importTitleBlock(defaultTitleBlockProperties());
|
||||||
diagram->defaultConductorProperties = defaultConductorProperties();
|
diagram->defaultConductorProperties = defaultConductorProperties();
|
||||||
@@ -1214,7 +1220,7 @@ void QETProject::removeDiagram(Diagram *diagram)
|
|||||||
emit(diagramRemoved(this, diagram));
|
emit(diagramRemoved(this, diagram));
|
||||||
diagram->deleteLater();
|
diagram->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDiagramsFolioData();
|
updateDiagramsFolioData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1228,10 +1234,10 @@ void QETProject::removeDiagram(Diagram *diagram)
|
|||||||
*/
|
*/
|
||||||
void QETProject::diagramOrderChanged(int old_index, int new_index) {
|
void QETProject::diagramOrderChanged(int old_index, int new_index) {
|
||||||
if (old_index < 0 || new_index < 0) return;
|
if (old_index < 0 || new_index < 0) return;
|
||||||
|
|
||||||
int diagram_max_index = m_diagrams_list.size() - 1;
|
int diagram_max_index = m_diagrams_list.size() - 1;
|
||||||
if (old_index > diagram_max_index || new_index > diagram_max_index) return;
|
if (old_index > diagram_max_index || new_index > diagram_max_index) return;
|
||||||
|
|
||||||
m_diagrams_list.move(old_index, new_index);
|
m_diagrams_list.move(old_index, new_index);
|
||||||
updateDiagramsFolioData();
|
updateDiagramsFolioData();
|
||||||
setModified(true);
|
setModified(true);
|
||||||
@@ -1258,7 +1264,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
{
|
{
|
||||||
QDomElement root_elmt = xml_project.documentElement();
|
QDomElement root_elmt = xml_project.documentElement();
|
||||||
m_state = ProjectParsingRunning;
|
m_state = ProjectParsingRunning;
|
||||||
|
|
||||||
//The roots of the xml document must be a "project" element
|
//The roots of the xml document must be a "project" element
|
||||||
if (root_elmt.tagName() == "project")
|
if (root_elmt.tagName() == "project")
|
||||||
{
|
{
|
||||||
@@ -1282,7 +1288,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
"message box content"),
|
"message box content"),
|
||||||
QMessageBox::Open | QMessageBox::Cancel
|
QMessageBox::Open | QMessageBox::Cancel
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ret == QMessageBox::Cancel)
|
if (ret == QMessageBox::Cancel)
|
||||||
{
|
{
|
||||||
m_state = FileOpenDiscard;
|
m_state = FileOpenDiscard;
|
||||||
@@ -1296,7 +1302,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
{
|
{
|
||||||
m_state = ProjectParsingFailed;
|
m_state = ProjectParsingFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data_base.blockSignals(true);
|
m_data_base.blockSignals(true);
|
||||||
//Load the project-wide properties
|
//Load the project-wide properties
|
||||||
readProjectPropertiesXml(xml_project);
|
readProjectPropertiesXml(xml_project);
|
||||||
@@ -1310,7 +1316,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
readDiagramsXml(xml_project);
|
readDiagramsXml(xml_project);
|
||||||
m_data_base.blockSignals(false);
|
m_data_base.blockSignals(false);
|
||||||
m_data_base.updateDB();
|
m_data_base.updateDB();
|
||||||
|
|
||||||
m_state = Ok;
|
m_state = Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1336,18 +1342,18 @@ void QETProject::readDiagramsXml(QDomDocument &xml_project)
|
|||||||
"Création des folios"
|
"Création des folios"
|
||||||
"</p>"));
|
"</p>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Search the diagrams in the project
|
//Search the diagrams in the project
|
||||||
QDomNodeList diagram_nodes = xml_project.elementsByTagName("diagram");
|
QDomNodeList diagram_nodes = xml_project.elementsByTagName("diagram");
|
||||||
|
|
||||||
if(dlgWaiting)
|
if(dlgWaiting)
|
||||||
dlgWaiting->setProgressBarRange(0, diagram_nodes.length()*3);
|
dlgWaiting->setProgressBarRange(0, diagram_nodes.length()*3);
|
||||||
|
|
||||||
for (int i = 0 ; i < diagram_nodes.length() ; ++ i)
|
for (int i = 0 ; i < diagram_nodes.length() ; ++ i)
|
||||||
{
|
{
|
||||||
if(dlgWaiting)
|
if(dlgWaiting)
|
||||||
dlgWaiting->setProgressBar(i+1);
|
dlgWaiting->setProgressBar(i+1);
|
||||||
|
|
||||||
if (diagram_nodes.at(i).isElement())
|
if (diagram_nodes.at(i).isElement())
|
||||||
{
|
{
|
||||||
QDomElement diagram_xml_element = diagram_nodes
|
QDomElement diagram_xml_element = diagram_nodes
|
||||||
@@ -1543,17 +1549,17 @@ void QETProject::writeProjectPropertiesXml(QDomElement &xml_element) {
|
|||||||
void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
|
void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
|
||||||
{
|
{
|
||||||
QDomDocument xml_document = xml_element.ownerDocument();
|
QDomDocument xml_document = xml_element.ownerDocument();
|
||||||
|
|
||||||
// export size of border
|
// export size of border
|
||||||
QDomElement border_elmt = xml_document.createElement("border");
|
QDomElement border_elmt = xml_document.createElement("border");
|
||||||
default_border_properties_.toXml(border_elmt);
|
default_border_properties_.toXml(border_elmt);
|
||||||
xml_element.appendChild(border_elmt);
|
xml_element.appendChild(border_elmt);
|
||||||
|
|
||||||
// export content of titleblock
|
// export content of titleblock
|
||||||
QDomElement titleblock_elmt = xml_document.createElement("inset");
|
QDomElement titleblock_elmt = xml_document.createElement("inset");
|
||||||
default_titleblock_properties_.toXml(titleblock_elmt);
|
default_titleblock_properties_.toXml(titleblock_elmt);
|
||||||
xml_element.appendChild(titleblock_elmt);
|
xml_element.appendChild(titleblock_elmt);
|
||||||
|
|
||||||
// exporte default conductor
|
// exporte default conductor
|
||||||
QDomElement conductor_elmt = xml_document.createElement("conductors");
|
QDomElement conductor_elmt = xml_document.createElement("conductors");
|
||||||
default_conductor_properties_.toXml(conductor_elmt);
|
default_conductor_properties_.toXml(conductor_elmt);
|
||||||
@@ -1728,7 +1734,7 @@ bool QETProject::projectWasModified()
|
|||||||
!m_undo_stack -> isClean() ||
|
!m_undo_stack -> isClean() ||
|
||||||
m_titleblocks_collection.templates().count() )
|
m_titleblocks_collection.templates().count() )
|
||||||
return(true);
|
return(true);
|
||||||
|
|
||||||
else
|
else
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@@ -1740,19 +1746,19 @@ bool QETProject::projectWasModified()
|
|||||||
void QETProject::updateDiagramsFolioData()
|
void QETProject::updateDiagramsFolioData()
|
||||||
{
|
{
|
||||||
int total_folio = m_diagrams_list.count();
|
int total_folio = m_diagrams_list.count();
|
||||||
|
|
||||||
DiagramContext project_wide_properties = m_project_properties;
|
DiagramContext project_wide_properties = m_project_properties;
|
||||||
project_wide_properties.addValue("projecttitle", title());
|
project_wide_properties.addValue("projecttitle", title());
|
||||||
project_wide_properties.addValue("projectpath", filePath());
|
project_wide_properties.addValue("projectpath", filePath());
|
||||||
project_wide_properties.addValue("projectfilename", QFileInfo(filePath()).baseName());
|
project_wide_properties.addValue("projectfilename", QFileInfo(filePath()).baseName());
|
||||||
|
|
||||||
for (int i = 0 ; i < total_folio ; ++ i)
|
for (int i = 0 ; i < total_folio ; ++ i)
|
||||||
{
|
{
|
||||||
QString autopagenum = m_diagrams_list[i]->border_and_titleblock.autoPageNum();
|
QString autopagenum = m_diagrams_list[i]->border_and_titleblock.autoPageNum();
|
||||||
NumerotationContext nC = folioAutoNum(autopagenum);
|
NumerotationContext nC = folioAutoNum(autopagenum);
|
||||||
NumerotationContextCommands nCC = NumerotationContextCommands(nC);
|
NumerotationContextCommands nCC = NumerotationContextCommands(nC);
|
||||||
|
|
||||||
if ((m_diagrams_list[i]->border_and_titleblock.folio().contains("%autonum")) &&
|
if ((m_diagrams_list[i]->border_and_titleblock.folio().contains("%autonum")) &&
|
||||||
(!autopagenum.isNull()))
|
(!autopagenum.isNull()))
|
||||||
{
|
{
|
||||||
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nCC.toRepresentedString(), project_wide_properties);
|
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nCC.toRepresentedString(), project_wide_properties);
|
||||||
@@ -1761,12 +1767,12 @@ void QETProject::updateDiagramsFolioData()
|
|||||||
else {
|
else {
|
||||||
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nullptr, project_wide_properties);
|
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nullptr, project_wide_properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
m_diagrams_list.at(i)->border_and_titleblock.setPreviousFolioNum(m_diagrams_list.at(i-1)->border_and_titleblock.finalfolio());
|
m_diagrams_list.at(i)->border_and_titleblock.setPreviousFolioNum(m_diagrams_list.at(i-1)->border_and_titleblock.finalfolio());
|
||||||
m_diagrams_list.at(i-1)->border_and_titleblock.setNextFolioNum(m_diagrams_list.at(i)->border_and_titleblock.finalfolio());
|
m_diagrams_list.at(i-1)->border_and_titleblock.setNextFolioNum(m_diagrams_list.at(i)->border_and_titleblock.finalfolio());
|
||||||
|
|
||||||
if (i == total_folio-1) {
|
if (i == total_folio-1) {
|
||||||
m_diagrams_list.at(i)->border_and_titleblock.setNextFolioNum(QString());
|
m_diagrams_list.at(i)->border_and_titleblock.setNextFolioNum(QString());
|
||||||
}
|
}
|
||||||
@@ -1775,7 +1781,7 @@ void QETProject::updateDiagramsFolioData()
|
|||||||
m_diagrams_list.at(i)->border_and_titleblock.setPreviousFolioNum(QString());
|
m_diagrams_list.at(i)->border_and_titleblock.setPreviousFolioNum(QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Diagram *d : m_diagrams_list) {
|
for (Diagram *d : m_diagrams_list) {
|
||||||
d->update();
|
d->update();
|
||||||
}
|
}
|
||||||
@@ -1788,7 +1794,7 @@ void QETProject::updateDiagramsFolioData()
|
|||||||
*/
|
*/
|
||||||
void QETProject::updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
|
void QETProject::updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
|
||||||
Q_UNUSED(collection)
|
Q_UNUSED(collection)
|
||||||
|
|
||||||
foreach (Diagram *diagram, m_diagrams_list) {
|
foreach (Diagram *diagram, m_diagrams_list) {
|
||||||
diagram -> titleBlockTemplateChanged(template_name);
|
diagram -> titleBlockTemplateChanged(template_name);
|
||||||
}
|
}
|
||||||
@@ -1801,7 +1807,7 @@ void QETProject::updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection
|
|||||||
*/
|
*/
|
||||||
void QETProject::removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
|
void QETProject::removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
|
||||||
Q_UNUSED(collection)
|
Q_UNUSED(collection)
|
||||||
|
|
||||||
// warn diagrams that the given template is about to be removed
|
// warn diagrams that the given template is about to be removed
|
||||||
foreach (Diagram *diagram, m_diagrams_list) {
|
foreach (Diagram *diagram, m_diagrams_list) {
|
||||||
diagram -> titleBlockTemplateRemoved(template_name);
|
diagram -> titleBlockTemplateRemoved(template_name);
|
||||||
|
|||||||
@@ -1,23 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 QET_PROJECT_H
|
#ifndef QET_PROJECT_H
|
||||||
#define QET_PROJECT_H
|
#define QET_PROJECT_H
|
||||||
|
|
||||||
|
#include <KAutoSaveFile>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#include "nameslist.h"
|
#include "nameslist.h"
|
||||||
#include "elementslocation.h"
|
#include "elementslocation.h"
|
||||||
#include "borderproperties.h"
|
#include "borderproperties.h"
|
||||||
@@ -28,8 +31,6 @@
|
|||||||
#include "projectdatabase.h"
|
#include "projectdatabase.h"
|
||||||
#include "reportproperties.h"
|
#include "reportproperties.h"
|
||||||
|
|
||||||
#include <KAutoSaveFile>
|
|
||||||
|
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class ElementsLocation;
|
class ElementsLocation;
|
||||||
class QETResult;
|
class QETResult;
|
||||||
@@ -62,7 +63,7 @@ class QETProject : public QObject
|
|||||||
};
|
};
|
||||||
|
|
||||||
Q_PROPERTY(bool autoConductor READ autoConductor WRITE setAutoConductor)
|
Q_PROPERTY(bool autoConductor READ autoConductor WRITE setAutoConductor)
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
QETProject (QObject *parent = nullptr);
|
QETProject (QObject *parent = nullptr);
|
||||||
@@ -72,7 +73,7 @@ class QETProject : public QObject
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QETProject(const QETProject &);
|
QETProject(const QETProject &);
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
projectDataBase *dataBase();
|
projectDataBase *dataBase();
|
||||||
@@ -166,13 +167,13 @@ class QETProject : public QObject
|
|||||||
DiagramContext projectProperties();
|
DiagramContext projectProperties();
|
||||||
void setProjectProperties(const DiagramContext &);
|
void setProjectProperties(const DiagramContext &);
|
||||||
QUndoStack* undoStack() {return m_undo_stack;}
|
QUndoStack* undoStack() {return m_undo_stack;}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
Diagram *addNewDiagram(int pos = -1);
|
Diagram *addNewDiagram(int pos = -1);
|
||||||
void removeDiagram(Diagram *);
|
void removeDiagram(Diagram *);
|
||||||
void diagramOrderChanged(int, int);
|
void diagramOrderChanged(int, int);
|
||||||
void setModified(bool);
|
void setModified(bool);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void projectFilePathChanged(QETProject *, const QString &);
|
void projectFilePathChanged(QETProject *, const QString &);
|
||||||
void projectTitleChanged(QETProject *, const QString &);
|
void projectTitleChanged(QETProject *, const QString &);
|
||||||
@@ -195,14 +196,14 @@ class QETProject : public QObject
|
|||||||
void folioAutoNumChanged(QString);
|
void folioAutoNumChanged(QString);
|
||||||
void defaultTitleBlockPropertiesChanged();
|
void defaultTitleBlockPropertiesChanged();
|
||||||
void conductorAutoNumChanged();
|
void conductorAutoNumChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateDiagramsFolioData();
|
void updateDiagramsFolioData();
|
||||||
void updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
|
void updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
|
||||||
void removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
|
void removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
|
||||||
void usedTitleBlockTemplateChanged(const QString &);
|
void usedTitleBlockTemplateChanged(const QString &);
|
||||||
void undoStackChanged (bool a) {if (!a) setModified(true);}
|
void undoStackChanged (bool a) {if (!a) setModified(true);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readProjectXml(QDomDocument &xml_project);
|
void readProjectXml(QDomDocument &xml_project);
|
||||||
void readDiagramsXml(QDomDocument &xml_project);
|
void readDiagramsXml(QDomDocument &xml_project);
|
||||||
@@ -217,7 +218,7 @@ class QETProject : public QObject
|
|||||||
void writeBackup();
|
void writeBackup();
|
||||||
void init();
|
void init();
|
||||||
ProjectState openFile(QFile *file);
|
ProjectState openFile(QFile *file);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
/// File path this project is saved to
|
/// File path this project is saved to
|
||||||
|
|||||||
@@ -1,27 +1,30 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 "qetregexpvalidator.h"
|
#include "qetregexpvalidator.h"
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param parent QObject parent
|
@param parent QObject parent
|
||||||
*/
|
*/
|
||||||
QETRegExpValidator::QETRegExpValidator(QObject *parent) : QRegExpValidator(parent) {
|
QETRegExpValidator::QETRegExpValidator(QObject *parent)
|
||||||
|
: QRegularExpressionValidator(parent)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +32,10 @@ QETRegExpValidator::QETRegExpValidator(QObject *parent) : QRegExpValidator(paren
|
|||||||
@param regexp Expression reguliere a valider
|
@param regexp Expression reguliere a valider
|
||||||
@param parent QObject parent
|
@param parent QObject parent
|
||||||
*/
|
*/
|
||||||
QETRegExpValidator::QETRegExpValidator(const QRegExp ®exp, QObject *parent) : QRegExpValidator(regexp, parent) {
|
QETRegExpValidator::QETRegExpValidator(
|
||||||
|
const QRegularExpression ®exp, QObject *parent) :
|
||||||
|
QRegularExpressionValidator(regexp, parent)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,13 +46,15 @@ QETRegExpValidator::~QETRegExpValidator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@see QRegExpValidator::validate
|
@see QRegularExpressionValidator::validate
|
||||||
@see validationFailed()
|
@see validationFailed()
|
||||||
Emet le signal validationFailed si la validation echoue
|
Emet le signal validationFailed si la validation echoue
|
||||||
*/
|
*/
|
||||||
QValidator::State QETRegExpValidator::validate(QString &input, int &pos) const
|
QValidator::State QETRegExpValidator::validate(QString &input, int &pos) const
|
||||||
{
|
{
|
||||||
QValidator::State result = QRegExpValidator::validate(input, pos);
|
QValidator::State result = QRegularExpressionValidator::validate(
|
||||||
if (result == QValidator::Invalid) emit(validationFailed());
|
input, pos);
|
||||||
|
if (result == QValidator::Invalid)
|
||||||
|
emit(validationFailed());
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,42 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 QET_REGEXP_VALIDATOR_H
|
#ifndef QET_REGEXP_VALIDATOR_H
|
||||||
#define QET_REGEXP_VALIDATOR_H
|
#define QET_REGEXP_VALIDATOR_H
|
||||||
#include <QRegExpValidator>
|
#include <QRegularExpressionValidator>
|
||||||
/**
|
/**
|
||||||
This class acts like a QRegExpValidator except it emits a signal when the
|
This class acts like a QRegularExpressionValidator
|
||||||
input validation fails.
|
except it emits a signal when the input validation fails.
|
||||||
*/
|
*/
|
||||||
class QETRegExpValidator : public QRegExpValidator {
|
class QETRegExpValidator : public QRegularExpressionValidator {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
QETRegExpValidator(QObject *);
|
QETRegExpValidator(QObject *);
|
||||||
QETRegExpValidator(const QRegExp &, QObject *);
|
QETRegExpValidator(const QRegularExpression &, QObject *);
|
||||||
~QETRegExpValidator() override;
|
~QETRegExpValidator() override;
|
||||||
private:
|
private:
|
||||||
QETRegExpValidator(const QETRegExpValidator &);
|
QETRegExpValidator(const QETRegExpValidator &);
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
QValidator::State validate(QString &, int &) const override;
|
QValidator::State validate(QString &, int &) const override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void validationFailed() const;
|
void validationFailed() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 "qfilenameedit.h"
|
#include "qfilenameedit.h"
|
||||||
#include "qetregexpvalidator.h"
|
#include "qetregexpvalidator.h"
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QToolTip>
|
#include <QToolTip>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +36,7 @@ QFileNameEdit::QFileNameEdit(QWidget *parent) : QLineEdit(parent) {
|
|||||||
*/
|
*/
|
||||||
QFileNameEdit::QFileNameEdit(const QString &contents, QWidget *parent) : QLineEdit(parent) {
|
QFileNameEdit::QFileNameEdit(const QString &contents, QWidget *parent) : QLineEdit(parent) {
|
||||||
init();
|
init();
|
||||||
if (!contents.isEmpty() && regexp_.exactMatch(contents)) {
|
if (!contents.isEmpty() && regexp_==QRegularExpression(contents)) {
|
||||||
setText(contents);
|
setText(contents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ bool QFileNameEdit::isEmpty()
|
|||||||
*/
|
*/
|
||||||
bool QFileNameEdit::isValid()
|
bool QFileNameEdit::isValid()
|
||||||
{
|
{
|
||||||
return(regexp_.exactMatch(text()));
|
return(regexp_==QRegularExpression(text()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,7 +69,7 @@ bool QFileNameEdit::isValid()
|
|||||||
*/
|
*/
|
||||||
void QFileNameEdit::init()
|
void QFileNameEdit::init()
|
||||||
{
|
{
|
||||||
regexp_ = QRegExp("^[0-9a-z_\\-\\.]+$", Qt::CaseSensitive);
|
regexp_ = QRegularExpression("^[0-9a-z_\\-\\.]+$");
|
||||||
validator_ = new QETRegExpValidator(regexp_, this);
|
validator_ = new QETRegExpValidator(regexp_, this);
|
||||||
setValidator(validator_);
|
setValidator(validator_);
|
||||||
tooltip_text_ = QString(
|
tooltip_text_ = QString(
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 Q_FILENAME_EDIT_H
|
#ifndef Q_FILENAME_EDIT_H
|
||||||
#define Q_FILENAME_EDIT_H
|
#define Q_FILENAME_EDIT_H
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QRegExp>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QRegularExpression>
|
||||||
class QETRegExpValidator;
|
class QETRegExpValidator;
|
||||||
/**
|
/**
|
||||||
This class represents a textfield dedicated to input a portable filename (not
|
This class represents a textfield dedicated to input a portable filename (not
|
||||||
@@ -31,7 +31,7 @@ class QETRegExpValidator;
|
|||||||
*/
|
*/
|
||||||
class QFileNameEdit : public QLineEdit {
|
class QFileNameEdit : public QLineEdit {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
QFileNameEdit(QWidget * = nullptr);
|
QFileNameEdit(QWidget * = nullptr);
|
||||||
@@ -39,22 +39,22 @@ class QFileNameEdit : public QLineEdit {
|
|||||||
~QFileNameEdit() override;
|
~QFileNameEdit() override;
|
||||||
private:
|
private:
|
||||||
QFileNameEdit(const QFileNameEdit &);
|
QFileNameEdit(const QFileNameEdit &);
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
bool isEmpty();
|
bool isEmpty();
|
||||||
bool isValid();
|
bool isValid();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void displayToolTip();
|
void displayToolTip();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void validationFailed();
|
void validationFailed();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
QRegExp regexp_;
|
QRegularExpression regexp_;
|
||||||
QETRegExpValidator *validator_;
|
QETRegExpValidator *validator_;
|
||||||
QString tooltip_text_;
|
QString tooltip_text_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -40,7 +40,7 @@ QETTitleBlockTemplateEditor::QETTitleBlockTemplateEditor(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
setWindowIcon(QET::Icons::QETLogo);
|
setWindowIcon(QET::Icons::QETLogo);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
initWidgets();
|
initWidgets();
|
||||||
initActions();
|
initActions();
|
||||||
initMenus();
|
initMenus();
|
||||||
@@ -74,7 +74,7 @@ bool QETTitleBlockTemplateEditor::isEditing(const QString &filepath)
|
|||||||
} else {
|
} else {
|
||||||
current_filepath = QETApp::realPath(location_.toString());
|
current_filepath = QETApp::realPath(location_.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return(
|
return(
|
||||||
QET::compareCanonicalFilePaths(
|
QET::compareCanonicalFilePaths(
|
||||||
current_filepath,
|
current_filepath,
|
||||||
@@ -166,7 +166,7 @@ void QETTitleBlockTemplateEditor::duplicateCurrentLocation()
|
|||||||
{
|
{
|
||||||
// this method does not work for templates edited from the filesystem
|
// this method does not work for templates edited from the filesystem
|
||||||
if (opened_from_file_) return;
|
if (opened_from_file_) return;
|
||||||
|
|
||||||
QString proposed_name;
|
QString proposed_name;
|
||||||
if (location_.name().isEmpty()) {
|
if (location_.name().isEmpty()) {
|
||||||
proposed_name = tr("nouveau_modele",
|
proposed_name = tr("nouveau_modele",
|
||||||
@@ -174,7 +174,7 @@ void QETTitleBlockTemplateEditor::duplicateCurrentLocation()
|
|||||||
} else {
|
} else {
|
||||||
proposed_name = QString("%1_copy").arg(location_.name());
|
proposed_name = QString("%1_copy").arg(location_.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool accepted = false;
|
bool accepted = false;
|
||||||
QString new_template_name = QInputDialog::getText(
|
QString new_template_name = QInputDialog::getText(
|
||||||
this,
|
this,
|
||||||
@@ -212,7 +212,7 @@ bool QETTitleBlockTemplateEditor::edit(
|
|||||||
/// TODO The TBT does not exist, manage error
|
/// TODO The TBT does not exist, manage error
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
opened_from_file_ = false;
|
opened_from_file_ = false;
|
||||||
location_ = location;
|
location_ = location;
|
||||||
setReadOnly(location.isReadOnly());
|
setReadOnly(location.isReadOnly());
|
||||||
@@ -231,7 +231,7 @@ bool QETTitleBlockTemplateEditor::edit(
|
|||||||
{
|
{
|
||||||
// we require a project we will rattach templates to
|
// we require a project we will rattach templates to
|
||||||
if (!project) return(false);
|
if (!project) return(false);
|
||||||
|
|
||||||
// the template name may be empty to create a new one
|
// the template name may be empty to create a new one
|
||||||
const TitleBlockTemplate *tb_template_orig;
|
const TitleBlockTemplate *tb_template_orig;
|
||||||
if (template_name.isEmpty())
|
if (template_name.isEmpty())
|
||||||
@@ -244,12 +244,12 @@ bool QETTitleBlockTemplateEditor::edit(
|
|||||||
{
|
{
|
||||||
tb_template_orig = project->embeddedTitleBlockTemplatesCollection()->getTemplate(template_name);
|
tb_template_orig = project->embeddedTitleBlockTemplatesCollection()->getTemplate(template_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tb_template_orig) {
|
if (!tb_template_orig) {
|
||||||
/// TODO The TBT does not exist, manage error
|
/// TODO The TBT does not exist, manage error
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
opened_from_file_ = false;
|
opened_from_file_ = false;
|
||||||
location_.setParentCollection(project -> embeddedTitleBlockTemplatesCollection());
|
location_.setParentCollection(project -> embeddedTitleBlockTemplatesCollection());
|
||||||
location_.setName(template_name);
|
location_.setName(template_name);
|
||||||
@@ -270,13 +270,13 @@ bool QETTitleBlockTemplateEditor::edit(const QString &file_path)
|
|||||||
/// TODO the file opening failed, warn the user?
|
/// TODO the file opening failed, warn the user?
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool editing = edit(tbt);
|
bool editing = edit(tbt);
|
||||||
if (!editing) {
|
if (!editing) {
|
||||||
/// TODO the file editing failed, warn the user?
|
/// TODO the file editing failed, warn the user?
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QFileInfo file_path_info(file_path);
|
QFileInfo file_path_info(file_path);
|
||||||
filepath_ = file_path;
|
filepath_ = file_path;
|
||||||
opened_from_file_ = true;
|
opened_from_file_ = true;
|
||||||
@@ -318,20 +318,20 @@ void QETTitleBlockTemplateEditor::editLogos()
|
|||||||
if (!logo_manager_) {
|
if (!logo_manager_) {
|
||||||
initLogoManager();
|
initLogoManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
logo_manager_ -> layout() -> setContentsMargins(0, 0, 0, 0);
|
logo_manager_ -> layout() -> setContentsMargins(0, 0, 0, 0);
|
||||||
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close);
|
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||||
|
|
||||||
QVBoxLayout *vlayout0 = new QVBoxLayout();
|
QVBoxLayout *vlayout0 = new QVBoxLayout();
|
||||||
vlayout0 -> addWidget(logo_manager_);
|
vlayout0 -> addWidget(logo_manager_);
|
||||||
vlayout0 -> addWidget(buttons);
|
vlayout0 -> addWidget(buttons);
|
||||||
|
|
||||||
QDialog d(this);
|
QDialog d(this);
|
||||||
d.setWindowTitle(logo_manager_ -> windowTitle());
|
d.setWindowTitle(logo_manager_ -> windowTitle());
|
||||||
d.setLayout(vlayout0);
|
d.setLayout(vlayout0);
|
||||||
connect(buttons, SIGNAL(rejected()), &d, SLOT(reject()));
|
connect(buttons, SIGNAL(rejected()), &d, SLOT(reject()));
|
||||||
d.exec();
|
d.exec();
|
||||||
|
|
||||||
// prevent the logo manager from being deleted along with the dialog
|
// prevent the logo manager from being deleted along with the dialog
|
||||||
logo_manager_ -> setParent(this);
|
logo_manager_ -> setParent(this);
|
||||||
}
|
}
|
||||||
@@ -374,10 +374,10 @@ void QETTitleBlockTemplateEditor::initActions()
|
|||||||
add_col_ = new QAction(QET::Icons::EditTableInsertColumnRight, tr("Ajouter une &colonne", "menu entry"), this);
|
add_col_ = new QAction(QET::Icons::EditTableInsertColumnRight, tr("Ajouter une &colonne", "menu entry"), this);
|
||||||
merge_cells_ = new QAction(QET::Icons::EditTableCellMerge, tr("&Fusionner les cellules", "menu entry"), this);
|
merge_cells_ = new QAction(QET::Icons::EditTableCellMerge, tr("&Fusionner les cellules", "menu entry"), this);
|
||||||
split_cell_ = new QAction(QET::Icons::EditTableCellSplit, tr("&Séparer les cellules", "menu entry"), this);
|
split_cell_ = new QAction(QET::Icons::EditTableCellSplit, tr("&Séparer les cellules", "menu entry"), this);
|
||||||
|
|
||||||
undo_ -> setIcon(QET::Icons::EditUndo);
|
undo_ -> setIcon(QET::Icons::EditUndo);
|
||||||
redo_ -> setIcon(QET::Icons::EditRedo);
|
redo_ -> setIcon(QET::Icons::EditRedo);
|
||||||
|
|
||||||
new_ -> setShortcut(QKeySequence::New);
|
new_ -> setShortcut(QKeySequence::New);
|
||||||
open_ -> setShortcut(QKeySequence::Open);
|
open_ -> setShortcut(QKeySequence::Open);
|
||||||
open_from_file_ -> setShortcut(tr("Ctrl+Shift+O", "shortcut to open a template from a file"));
|
open_from_file_ -> setShortcut(tr("Ctrl+Shift+O", "shortcut to open a template from a file"));
|
||||||
@@ -397,7 +397,7 @@ void QETTitleBlockTemplateEditor::initActions()
|
|||||||
zoom_out_ -> setShortcut(QKeySequence::ZoomOut);
|
zoom_out_ -> setShortcut(QKeySequence::ZoomOut);
|
||||||
zoom_fit_ -> setShortcut(QKeySequence(tr("Ctrl+9", "shortcut to enable fit zoom")));
|
zoom_fit_ -> setShortcut(QKeySequence(tr("Ctrl+9", "shortcut to enable fit zoom")));
|
||||||
zoom_reset_ -> setShortcut(QKeySequence(tr("Ctrl+0", "shortcut to reset zoom")));
|
zoom_reset_ -> setShortcut(QKeySequence(tr("Ctrl+0", "shortcut to reset zoom")));
|
||||||
|
|
||||||
connect(new_, SIGNAL(triggered()), this, SLOT(newTemplate()));
|
connect(new_, SIGNAL(triggered()), this, SLOT(newTemplate()));
|
||||||
connect(open_, SIGNAL(triggered()), this, SLOT(open()));
|
connect(open_, SIGNAL(triggered()), this, SLOT(open()));
|
||||||
connect(open_from_file_, SIGNAL(triggered()), this, SLOT(openFromFile()));
|
connect(open_from_file_, SIGNAL(triggered()), this, SLOT(openFromFile()));
|
||||||
@@ -428,7 +428,7 @@ void QETTitleBlockTemplateEditor::initMenus()
|
|||||||
file_menu_ = new QMenu(tr("&Fichier", "menu title"), this);
|
file_menu_ = new QMenu(tr("&Fichier", "menu title"), this);
|
||||||
edit_menu_ = new QMenu(tr("&Édition", "menu title"), this);
|
edit_menu_ = new QMenu(tr("&Édition", "menu title"), this);
|
||||||
display_menu_ = new QMenu(tr("Afficha&ge", "menu title"), this);
|
display_menu_ = new QMenu(tr("Afficha&ge", "menu title"), this);
|
||||||
|
|
||||||
file_menu_ -> addAction(new_);
|
file_menu_ -> addAction(new_);
|
||||||
file_menu_ -> addAction(open_);
|
file_menu_ -> addAction(open_);
|
||||||
file_menu_ -> addAction(open_from_file_);
|
file_menu_ -> addAction(open_from_file_);
|
||||||
@@ -437,7 +437,7 @@ void QETTitleBlockTemplateEditor::initMenus()
|
|||||||
file_menu_ -> addAction(save_as_file_);
|
file_menu_ -> addAction(save_as_file_);
|
||||||
file_menu_ -> addSeparator();
|
file_menu_ -> addSeparator();
|
||||||
file_menu_ -> addAction(quit_);
|
file_menu_ -> addAction(quit_);
|
||||||
|
|
||||||
edit_menu_ -> addAction(undo_);
|
edit_menu_ -> addAction(undo_);
|
||||||
edit_menu_ -> addAction(redo_);
|
edit_menu_ -> addAction(redo_);
|
||||||
edit_menu_ -> addSeparator();
|
edit_menu_ -> addSeparator();
|
||||||
@@ -456,7 +456,7 @@ void QETTitleBlockTemplateEditor::initMenus()
|
|||||||
display_menu_ -> addAction(zoom_out_);
|
display_menu_ -> addAction(zoom_out_);
|
||||||
display_menu_ -> addAction(zoom_fit_);
|
display_menu_ -> addAction(zoom_fit_);
|
||||||
display_menu_ -> addAction(zoom_reset_);
|
display_menu_ -> addAction(zoom_reset_);
|
||||||
|
|
||||||
insertMenu(settings_menu_, file_menu_);
|
insertMenu(settings_menu_, file_menu_);
|
||||||
insertMenu(settings_menu_, edit_menu_);
|
insertMenu(settings_menu_, edit_menu_);
|
||||||
insertMenu(settings_menu_, display_menu_);
|
insertMenu(settings_menu_, display_menu_);
|
||||||
@@ -474,7 +474,7 @@ void QETTitleBlockTemplateEditor::initToolbars()
|
|||||||
main_toolbar -> addAction(save_);
|
main_toolbar -> addAction(save_);
|
||||||
main_toolbar -> addAction(save_as_);
|
main_toolbar -> addAction(save_as_);
|
||||||
addToolBar(Qt::TopToolBarArea, main_toolbar);
|
addToolBar(Qt::TopToolBarArea, main_toolbar);
|
||||||
|
|
||||||
QToolBar *edit_toolbar = new QToolBar(tr("Édition", "toolbar title"), this);
|
QToolBar *edit_toolbar = new QToolBar(tr("Édition", "toolbar title"), this);
|
||||||
edit_toolbar -> setObjectName("tbt_edit_toolbar");
|
edit_toolbar -> setObjectName("tbt_edit_toolbar");
|
||||||
edit_toolbar -> addAction(undo_);
|
edit_toolbar -> addAction(undo_);
|
||||||
@@ -483,7 +483,7 @@ void QETTitleBlockTemplateEditor::initToolbars()
|
|||||||
edit_toolbar -> addAction(merge_cells_);
|
edit_toolbar -> addAction(merge_cells_);
|
||||||
edit_toolbar -> addAction(split_cell_);
|
edit_toolbar -> addAction(split_cell_);
|
||||||
addToolBar(Qt::TopToolBarArea, edit_toolbar);
|
addToolBar(Qt::TopToolBarArea, edit_toolbar);
|
||||||
|
|
||||||
QToolBar *display_toolbar = new QToolBar(tr("Affichage", "toolbar title"), this);
|
QToolBar *display_toolbar = new QToolBar(tr("Affichage", "toolbar title"), this);
|
||||||
display_toolbar -> setObjectName("tbt_display_toolbar");
|
display_toolbar -> setObjectName("tbt_display_toolbar");
|
||||||
display_toolbar -> addAction(zoom_in_);
|
display_toolbar -> addAction(zoom_in_);
|
||||||
@@ -499,19 +499,22 @@ void QETTitleBlockTemplateEditor::initToolbars()
|
|||||||
void QETTitleBlockTemplateEditor::initWidgets()
|
void QETTitleBlockTemplateEditor::initWidgets()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
// undo list on the right
|
// undo list on the right
|
||||||
undo_stack_ = new QUndoStack(this);
|
undo_stack_ = new QUndoStack(this);
|
||||||
undo_view_ = new QUndoView(undo_stack_);
|
undo_view_ = new QUndoView(undo_stack_);
|
||||||
undo_view_ -> setEmptyLabel(tr("Aucune modification", "label displayed in the undo list when empty"));
|
undo_view_ -> setEmptyLabel(tr("Aucune modification", "label displayed in the undo list when empty"));
|
||||||
|
|
||||||
undo_dock_widget_ = new QDockWidget(tr("Annulations", "dock title"));
|
undo_dock_widget_ = new QDockWidget(tr("Annulations", "dock title"));
|
||||||
undo_dock_widget_ -> setObjectName("tbt_undo_dock");
|
undo_dock_widget_ -> setObjectName("tbt_undo_dock");
|
||||||
undo_dock_widget_ -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
undo_dock_widget_ -> setFeatures(
|
||||||
|
QDockWidget::DockWidgetClosable
|
||||||
|
|QDockWidget::DockWidgetMovable
|
||||||
|
|QDockWidget::DockWidgetFloatable);
|
||||||
undo_dock_widget_ -> setWidget(undo_view_);
|
undo_dock_widget_ -> setWidget(undo_view_);
|
||||||
undo_dock_widget_ -> setMinimumWidth(290);
|
undo_dock_widget_ -> setMinimumWidth(290);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, undo_dock_widget_);
|
addDockWidget(Qt::RightDockWidgetArea, undo_dock_widget_);
|
||||||
|
|
||||||
// WYSIWYG editor as central widget
|
// WYSIWYG editor as central widget
|
||||||
template_edition_area_scene_ = new QGraphicsScene(this);
|
template_edition_area_scene_ = new QGraphicsScene(this);
|
||||||
template_edition_area_view_ = new TitleBlockTemplateView(template_edition_area_scene_);
|
template_edition_area_view_ = new TitleBlockTemplateView(template_edition_area_scene_);
|
||||||
@@ -521,18 +524,21 @@ void QETTitleBlockTemplateEditor::initWidgets()
|
|||||||
template_edition_area_view_ -> setPreviewWidth(conf_preview_width);
|
template_edition_area_view_ -> setPreviewWidth(conf_preview_width);
|
||||||
}
|
}
|
||||||
setCentralWidget(template_edition_area_view_);
|
setCentralWidget(template_edition_area_view_);
|
||||||
|
|
||||||
// cell edition widget at the bottom
|
// cell edition widget at the bottom
|
||||||
template_cell_editor_widget_ = new TitleBlockTemplateCellWidget(tb_template_);
|
template_cell_editor_widget_ = new TitleBlockTemplateCellWidget(tb_template_);
|
||||||
template_cell_editor_dock_widget_ = new QDockWidget(tr("Propriétés de la cellule", "dock title"), this);
|
template_cell_editor_dock_widget_ = new QDockWidget(tr("Propriétés de la cellule", "dock title"), this);
|
||||||
template_cell_editor_dock_widget_ -> setObjectName("tbt_celleditor_dock");
|
template_cell_editor_dock_widget_ -> setObjectName("tbt_celleditor_dock");
|
||||||
template_cell_editor_dock_widget_ -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
template_cell_editor_dock_widget_ -> setFeatures(
|
||||||
|
QDockWidget::DockWidgetClosable
|
||||||
|
|QDockWidget::DockWidgetMovable
|
||||||
|
|QDockWidget::DockWidgetFloatable);
|
||||||
template_cell_editor_dock_widget_ -> setWidget(template_cell_editor_widget_);
|
template_cell_editor_dock_widget_ -> setWidget(template_cell_editor_widget_);
|
||||||
template_cell_editor_dock_widget_ -> setMinimumWidth(180);
|
template_cell_editor_dock_widget_ -> setMinimumWidth(180);
|
||||||
template_cell_editor_dock_widget_ -> setMinimumHeight(250);
|
template_cell_editor_dock_widget_ -> setMinimumHeight(250);
|
||||||
addDockWidget(Qt::BottomDockWidgetArea, template_cell_editor_dock_widget_);
|
addDockWidget(Qt::BottomDockWidgetArea, template_cell_editor_dock_widget_);
|
||||||
template_cell_editor_widget_ -> setVisible(false);
|
template_cell_editor_widget_ -> setVisible(false);
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
template_edition_area_view_,
|
template_edition_area_view_,
|
||||||
SIGNAL(selectedCellsChanged(QList<TitleBlockCell *>)),
|
SIGNAL(selectedCellsChanged(QList<TitleBlockCell *>)),
|
||||||
@@ -592,7 +598,7 @@ QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const
|
|||||||
} else {
|
} else {
|
||||||
titleblock_title = location_.name();
|
titleblock_title = location_.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if a (file)name has been added, also add a "[Changed]" tag if needed
|
// if a (file)name has been added, also add a "[Changed]" tag if needed
|
||||||
if (!titleblock_title.isEmpty()) {
|
if (!titleblock_title.isEmpty()) {
|
||||||
QString tag;
|
QString tag;
|
||||||
@@ -609,7 +615,7 @@ QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const
|
|||||||
)
|
)
|
||||||
).arg(titleblock_title).arg(tag);
|
).arg(titleblock_title).arg(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(titleblock_title);
|
return(titleblock_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -620,11 +626,11 @@ QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const
|
|||||||
void QETTitleBlockTemplateEditor::readSettings()
|
void QETTitleBlockTemplateEditor::readSettings()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
// window size and position
|
// window size and position
|
||||||
QVariant geometry = settings.value("titleblocktemplateeditor/geometry");
|
QVariant geometry = settings.value("titleblocktemplateeditor/geometry");
|
||||||
if (geometry.isValid()) restoreGeometry(geometry.toByteArray());
|
if (geometry.isValid()) restoreGeometry(geometry.toByteArray());
|
||||||
|
|
||||||
// window state (toolbars, docks...)
|
// window state (toolbars, docks...)
|
||||||
QVariant state = settings.value("titleblocktemplateeditor/state");
|
QVariant state = settings.value("titleblocktemplateeditor/state");
|
||||||
if (state.isValid()) restoreState(state.toByteArray());
|
if (state.isValid()) restoreState(state.toByteArray());
|
||||||
@@ -698,10 +704,10 @@ void QETTitleBlockTemplateEditor::updateEditorTitle()
|
|||||||
"titleblock template editor: base window title"
|
"titleblock template editor: base window title"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// get the currently edited template (file)name
|
// get the currently edited template (file)name
|
||||||
QString titleblock_title = currentlyEditedTitle();
|
QString titleblock_title = currentlyEditedTitle();
|
||||||
|
|
||||||
// generate the final window title
|
// generate the final window title
|
||||||
QString title;
|
QString title;
|
||||||
if (titleblock_title.isEmpty()) {
|
if (titleblock_title.isEmpty()) {
|
||||||
@@ -724,7 +730,7 @@ void QETTitleBlockTemplateEditor::updateEditorTitle()
|
|||||||
void QETTitleBlockTemplateEditor::updateActions()
|
void QETTitleBlockTemplateEditor::updateActions()
|
||||||
{
|
{
|
||||||
save_ -> setEnabled(!read_only_);
|
save_ -> setEnabled(!read_only_);
|
||||||
|
|
||||||
bool can_merge = true;
|
bool can_merge = true;
|
||||||
bool can_split = true;
|
bool can_split = true;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -748,15 +754,15 @@ void QETTitleBlockTemplateEditor::updateActions()
|
|||||||
bool QETTitleBlockTemplateEditor::saveAs(const TitleBlockTemplateLocation &location) {
|
bool QETTitleBlockTemplateEditor::saveAs(const TitleBlockTemplateLocation &location) {
|
||||||
TitleBlockTemplatesCollection *collection = location.parentCollection();
|
TitleBlockTemplatesCollection *collection = location.parentCollection();
|
||||||
if (!collection) return(false);
|
if (!collection) return(false);
|
||||||
|
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomElement elmt = doc.createElement("root");
|
QDomElement elmt = doc.createElement("root");
|
||||||
tb_template_ -> saveToXmlElement(elmt);
|
tb_template_ -> saveToXmlElement(elmt);
|
||||||
elmt.setAttribute("name", location.name());
|
elmt.setAttribute("name", location.name());
|
||||||
doc.appendChild(elmt);
|
doc.appendChild(elmt);
|
||||||
|
|
||||||
collection -> setTemplateXmlDescription(location.name(), elmt);
|
collection -> setTemplateXmlDescription(location.name(), elmt);
|
||||||
|
|
||||||
opened_from_file_ = false;
|
opened_from_file_ = false;
|
||||||
location_ = location;
|
location_ = location;
|
||||||
undo_stack_ -> setClean();
|
undo_stack_ -> setClean();
|
||||||
@@ -772,7 +778,7 @@ bool QETTitleBlockTemplateEditor::saveAs(const TitleBlockTemplateLocation &locat
|
|||||||
bool QETTitleBlockTemplateEditor::saveAs(const QString &filepath) {
|
bool QETTitleBlockTemplateEditor::saveAs(const QString &filepath) {
|
||||||
bool saving = tb_template_ -> saveToXmlFile(filepath);
|
bool saving = tb_template_ -> saveToXmlFile(filepath);
|
||||||
if (!saving) return(false);
|
if (!saving) return(false);
|
||||||
|
|
||||||
opened_from_file_ = true;
|
opened_from_file_ = true;
|
||||||
filepath_ = filepath;
|
filepath_ = filepath;
|
||||||
undo_stack_ -> setClean();
|
undo_stack_ -> setClean();
|
||||||
@@ -805,7 +811,7 @@ void QETTitleBlockTemplateEditor::openFromFile()
|
|||||||
QString initial_dir = filepath_.isEmpty()
|
QString initial_dir = filepath_.isEmpty()
|
||||||
? QETApp::customTitleBlockTemplatesDir()
|
? QETApp::customTitleBlockTemplatesDir()
|
||||||
: QDir(filepath_).absolutePath();
|
: QDir(filepath_).absolutePath();
|
||||||
|
|
||||||
// ask the user to choose a filepath
|
// ask the user to choose a filepath
|
||||||
QString user_filepath = QFileDialog::getOpenFileName(
|
QString user_filepath = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
@@ -819,8 +825,8 @@ void QETTitleBlockTemplateEditor::openFromFile()
|
|||||||
" - %1 is the .titleblock extension"
|
" - %1 is the .titleblock extension"
|
||||||
).arg(QString(TITLEBLOCKS_FILE_EXTENSION))
|
).arg(QString(TITLEBLOCKS_FILE_EXTENSION))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
if (!user_filepath.isEmpty()) QETApp::instance() -> openTitleBlockTemplate(user_filepath);
|
if (!user_filepath.isEmpty()) QETApp::instance() -> openTitleBlockTemplate(user_filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -871,7 +877,7 @@ bool QETTitleBlockTemplateEditor::saveAsFile()
|
|||||||
QString initial_dir = filepath_.isEmpty()
|
QString initial_dir = filepath_.isEmpty()
|
||||||
? QETApp::customTitleBlockTemplatesDir()
|
? QETApp::customTitleBlockTemplatesDir()
|
||||||
: QDir(filepath_).absolutePath();
|
: QDir(filepath_).absolutePath();
|
||||||
|
|
||||||
// ask the user to choose a target file
|
// ask the user to choose a target file
|
||||||
QString filepath = QFileDialog::getSaveFileName(
|
QString filepath = QFileDialog::getSaveFileName(
|
||||||
this,
|
this,
|
||||||
@@ -882,16 +888,16 @@ bool QETTitleBlockTemplateEditor::saveAsFile()
|
|||||||
"filetypes allowed when saving a title block template file - %1 is the .titleblock extension"
|
"filetypes allowed when saving a title block template file - %1 is the .titleblock extension"
|
||||||
).arg(QString(TITLEBLOCKS_FILE_EXTENSION))
|
).arg(QString(TITLEBLOCKS_FILE_EXTENSION))
|
||||||
);
|
);
|
||||||
|
|
||||||
// if no name was entered, return false
|
// if no name was entered, return false
|
||||||
if (filepath.isEmpty()) return(false);
|
if (filepath.isEmpty()) return(false);
|
||||||
|
|
||||||
// if the name does not end with ".titleblock", add it
|
// if the name does not end with ".titleblock", add it
|
||||||
if (!filepath.endsWith(".titleblock", Qt::CaseInsensitive)) filepath += ".titleblock";
|
if (!filepath.endsWith(".titleblock", Qt::CaseInsensitive)) filepath += ".titleblock";
|
||||||
|
|
||||||
// attempts to save the file
|
// attempts to save the file
|
||||||
bool saving = saveAs(filepath);
|
bool saving = saveAs(filepath);
|
||||||
|
|
||||||
// retourne un booleen representatif de la reussite de l'enregistrement
|
// retourne un booleen representatif de la reussite de l'enregistrement
|
||||||
return(saving);
|
return(saving);
|
||||||
}
|
}
|
||||||
@@ -932,18 +938,18 @@ TitleBlockTemplateLocation QETTitleBlockTemplateEditor::getTitleBlockTemplateLoc
|
|||||||
}
|
}
|
||||||
QDialogButtonBox *buttons = new QDialogButtonBox(
|
QDialogButtonBox *buttons = new QDialogButtonBox(
|
||||||
QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
QVBoxLayout *dialog_layout = new QVBoxLayout();
|
QVBoxLayout *dialog_layout = new QVBoxLayout();
|
||||||
dialog_layout -> addWidget(widget);
|
dialog_layout -> addWidget(widget);
|
||||||
dialog_layout -> addWidget(buttons);
|
dialog_layout -> addWidget(buttons);
|
||||||
|
|
||||||
QDialog dialog;
|
QDialog dialog;
|
||||||
dialog.setWindowTitle(title);
|
dialog.setWindowTitle(title);
|
||||||
dialog.setLayout(dialog_layout);
|
dialog.setLayout(dialog_layout);
|
||||||
|
|
||||||
connect(buttons, SIGNAL(accepted()), &dialog, SLOT(accept()));
|
connect(buttons, SIGNAL(accepted()), &dialog, SLOT(accept()));
|
||||||
connect(buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
|
connect(buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
return(widget -> location());
|
return(widget -> location());
|
||||||
}
|
}
|
||||||
@@ -978,7 +984,7 @@ void QETTitleBlockTemplateEditor::savePreviewWidthToApplicationSettings(
|
|||||||
void QETTitleBlockTemplateEditor::editTemplateInformation()
|
void QETTitleBlockTemplateEditor::editTemplateInformation()
|
||||||
{
|
{
|
||||||
if (!tb_template_) return;
|
if (!tb_template_) return;
|
||||||
|
|
||||||
QDialog dialog_author(this);
|
QDialog dialog_author(this);
|
||||||
dialog_author.setModal(true);
|
dialog_author.setModal(true);
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
@@ -987,20 +993,20 @@ void QETTitleBlockTemplateEditor::editTemplateInformation()
|
|||||||
dialog_author.setMinimumSize(400, 260);
|
dialog_author.setMinimumSize(400, 260);
|
||||||
dialog_author.setWindowTitle(tr("Éditer les informations complémentaires", "window title"));
|
dialog_author.setWindowTitle(tr("Éditer les informations complémentaires", "window title"));
|
||||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_author);
|
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_author);
|
||||||
|
|
||||||
// explanation label
|
// explanation label
|
||||||
QLabel *information_label = new QLabel(tr("Vous pouvez utiliser ce champ libre pour mentionner les auteurs du cartouche, sa licence, ou tout autre renseignement que vous jugerez utile."));
|
QLabel *information_label = new QLabel(tr("Vous pouvez utiliser ce champ libre pour mentionner les auteurs du cartouche, sa licence, ou tout autre renseignement que vous jugerez utile."));
|
||||||
information_label -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
|
information_label -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
|
||||||
information_label -> setWordWrap(true);
|
information_label -> setWordWrap(true);
|
||||||
dialog_layout -> addWidget(information_label);
|
dialog_layout -> addWidget(information_label);
|
||||||
|
|
||||||
// add a QTextEdit to the dialog
|
// add a QTextEdit to the dialog
|
||||||
QTextEdit *text_field = new QTextEdit();
|
QTextEdit *text_field = new QTextEdit();
|
||||||
text_field -> setAcceptRichText(false);
|
text_field -> setAcceptRichText(false);
|
||||||
text_field -> setPlainText(tb_template_ -> information());
|
text_field -> setPlainText(tb_template_ -> information());
|
||||||
text_field -> setReadOnly(read_only_);
|
text_field -> setReadOnly(read_only_);
|
||||||
dialog_layout -> addWidget(text_field);
|
dialog_layout -> addWidget(text_field);
|
||||||
|
|
||||||
// add two buttons to the dialog
|
// add two buttons to the dialog
|
||||||
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(
|
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(
|
||||||
read_only_
|
read_only_
|
||||||
@@ -1012,7 +1018,7 @@ void QETTitleBlockTemplateEditor::editTemplateInformation()
|
|||||||
&dialog_author, SLOT(accept()));
|
&dialog_author, SLOT(accept()));
|
||||||
connect(dialog_buttons, SIGNAL(rejected()),
|
connect(dialog_buttons, SIGNAL(rejected()),
|
||||||
&dialog_author, SLOT(reject()));
|
&dialog_author, SLOT(reject()));
|
||||||
|
|
||||||
// run the dialog
|
// run the dialog
|
||||||
if (dialog_author.exec() == QDialog::Accepted && !read_only_) {
|
if (dialog_author.exec() == QDialog::Accepted && !read_only_) {
|
||||||
QString new_info = text_field -> toPlainText().remove(QChar(13)); // CR-less text
|
QString new_info = text_field -> toPlainText().remove(QChar(13)); // CR-less text
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
#include "templatescollection.h"
|
#include "templatescollection.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
// make this class usable with QVariant
|
// make this class usable with QVariant
|
||||||
int TitleBlockTemplateLocation::MetaTypeId = qRegisterMetaType<TitleBlockTemplateLocation>("TitleBlockTemplateLocation");
|
int TitleBlockTemplateLocation::MetaTypeId = qRegisterMetaType<TitleBlockTemplateLocation>("TitleBlockTemplateLocation");
|
||||||
|
|
||||||
@@ -97,10 +99,10 @@ bool TitleBlockTemplateLocation::isValid() const
|
|||||||
*/
|
*/
|
||||||
void TitleBlockTemplateLocation::fromString(const QString &loc_str) {
|
void TitleBlockTemplateLocation::fromString(const QString &loc_str) {
|
||||||
collection_ = QETApp::titleBlockTemplatesCollection(QUrl(loc_str).scheme());
|
collection_ = QETApp::titleBlockTemplatesCollection(QUrl(loc_str).scheme());
|
||||||
|
|
||||||
QRegExp name_from_url("^[^:]*:\\/\\/(.*)$");
|
QRegularExpression name_from_url("^[^:]*:\\/\\/(.*)$");
|
||||||
if (name_from_url.exactMatch(loc_str)) {
|
if (name_from_url==QRegularExpression(loc_str)) {
|
||||||
name_ = name_from_url.capturedTexts().at(1);
|
name_ = name_from_url.namedCaptureGroups().at(1);
|
||||||
} else {
|
} else {
|
||||||
name_ = QString();
|
name_ = QString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -20,6 +20,8 @@
|
|||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "qetproject.h"
|
#include "qetproject.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructor
|
Constructor
|
||||||
@param parent Parent QObject
|
@param parent Parent QObject
|
||||||
@@ -136,7 +138,7 @@ TitleBlockTemplatesProjectCollection::~TitleBlockTemplatesProjectCollection()
|
|||||||
QString TitleBlockTemplatesProjectCollection::title() const
|
QString TitleBlockTemplatesProjectCollection::title() const
|
||||||
{
|
{
|
||||||
if (!title_.isEmpty()) return(title_);
|
if (!title_.isEmpty()) return(title_);
|
||||||
|
|
||||||
// if the title attribute is empty, we generate a suitable one using the
|
// if the title attribute is empty, we generate a suitable one using the
|
||||||
// parent project
|
// parent project
|
||||||
QString final_title;
|
QString final_title;
|
||||||
@@ -204,12 +206,12 @@ TitleBlockTemplate *TitleBlockTemplatesProjectCollection::getTemplate(const QStr
|
|||||||
if (titleblock_templates_.contains(template_name)) {
|
if (titleblock_templates_.contains(template_name)) {
|
||||||
return(titleblock_templates_[template_name]);
|
return(titleblock_templates_[template_name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No? Do we even know of it?
|
// No? Do we even know of it?
|
||||||
if (!titleblock_templates_xml_.contains(template_name)) {
|
if (!titleblock_templates_xml_.contains(template_name)) {
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, we have its XML description, we have to generate a TitleBlockTemplate object
|
// Ok, we have its XML description, we have to generate a TitleBlockTemplate object
|
||||||
TitleBlockTemplate *titleblock_template = new TitleBlockTemplate(this);
|
TitleBlockTemplate *titleblock_template = new TitleBlockTemplate(this);
|
||||||
if (titleblock_template -> loadFromXmlElement(titleblock_templates_xml_[template_name])) {
|
if (titleblock_template -> loadFromXmlElement(titleblock_templates_xml_[template_name])) {
|
||||||
@@ -248,16 +250,16 @@ bool TitleBlockTemplatesProjectCollection::setTemplateXmlDescription(const QStri
|
|||||||
if (xml_elmt.tagName() != "titleblocktemplate") {
|
if (xml_elmt.tagName() != "titleblocktemplate") {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we *require* a project (at least for the moment...)
|
// we *require* a project (at least for the moment...)
|
||||||
if (!project_) return(false);
|
if (!project_) return(false);
|
||||||
|
|
||||||
// we import the provided XML element in the project document
|
// we import the provided XML element in the project document
|
||||||
QDomElement import = xml_document_.importNode(xml_elmt, true).toElement();
|
QDomElement import = xml_document_.importNode(xml_elmt, true).toElement();
|
||||||
|
|
||||||
// ensure the name stored in the XML description remains consistent with the provided template name
|
// ensure the name stored in the XML description remains consistent with the provided template name
|
||||||
import.setAttribute("name", template_name);
|
import.setAttribute("name", template_name);
|
||||||
|
|
||||||
// we either replace the previous description
|
// we either replace the previous description
|
||||||
if (titleblock_templates_xml_.contains(template_name)) {
|
if (titleblock_templates_xml_.contains(template_name)) {
|
||||||
QDomElement old_description = titleblock_templates_xml_[template_name];
|
QDomElement old_description = titleblock_templates_xml_[template_name];
|
||||||
@@ -266,12 +268,12 @@ bool TitleBlockTemplatesProjectCollection::setTemplateXmlDescription(const QStri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
titleblock_templates_xml_.insert(template_name, import);
|
titleblock_templates_xml_.insert(template_name, import);
|
||||||
|
|
||||||
if (titleblock_templates_.contains(template_name)) {
|
if (titleblock_templates_.contains(template_name)) {
|
||||||
titleblock_templates_[template_name] -> loadFromXmlElement(titleblock_templates_xml_[template_name]);
|
titleblock_templates_[template_name] -> loadFromXmlElement(titleblock_templates_xml_[template_name]);
|
||||||
}
|
}
|
||||||
emit(changed(this, template_name));
|
emit(changed(this, template_name));
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,11 +284,11 @@ bool TitleBlockTemplatesProjectCollection::setTemplateXmlDescription(const QStri
|
|||||||
*/
|
*/
|
||||||
void TitleBlockTemplatesProjectCollection::removeTemplate(const QString &template_name) {
|
void TitleBlockTemplatesProjectCollection::removeTemplate(const QString &template_name) {
|
||||||
emit(aboutToRemove(this, template_name));
|
emit(aboutToRemove(this, template_name));
|
||||||
|
|
||||||
// remove the template itself
|
// remove the template itself
|
||||||
titleblock_templates_xml_.remove(template_name);
|
titleblock_templates_xml_.remove(template_name);
|
||||||
titleblock_templates_.remove(template_name);
|
titleblock_templates_.remove(template_name);
|
||||||
|
|
||||||
// warn the rest of the world that the list of templates embedded within this project has changed
|
// warn the rest of the world that the list of templates embedded within this project has changed
|
||||||
emit(changed(this, template_name));
|
emit(changed(this, template_name));
|
||||||
}
|
}
|
||||||
@@ -339,10 +341,10 @@ void TitleBlockTemplatesProjectCollection::fromXml(const QDomElement &xml_elemen
|
|||||||
// each titleblock template must have a name
|
// each titleblock template must have a name
|
||||||
if (!e.hasAttribute("name")) continue;
|
if (!e.hasAttribute("name")) continue;
|
||||||
QString titleblock_template_name = e.attribute("name");
|
QString titleblock_template_name = e.attribute("name");
|
||||||
|
|
||||||
// if several templates have the same name, we keep the first one encountered
|
// if several templates have the same name, we keep the first one encountered
|
||||||
if (titleblock_templates_xml_.contains(titleblock_template_name)) continue;
|
if (titleblock_templates_xml_.contains(titleblock_template_name)) continue;
|
||||||
|
|
||||||
// we simply store the XML element describing the titleblock template,
|
// we simply store the XML element describing the titleblock template,
|
||||||
// without any further analysis for the moment
|
// without any further analysis for the moment
|
||||||
titleblock_templates_xml_.insert(titleblock_template_name, e);
|
titleblock_templates_xml_.insert(titleblock_template_name, e);
|
||||||
@@ -355,7 +357,7 @@ void TitleBlockTemplatesProjectCollection::fromXml(const QDomElement &xml_elemen
|
|||||||
void TitleBlockTemplatesProjectCollection::deleteUnusedTitleBlocKTemplates()
|
void TitleBlockTemplatesProjectCollection::deleteUnusedTitleBlocKTemplates()
|
||||||
{
|
{
|
||||||
if (!project_) return;
|
if (!project_) return;
|
||||||
|
|
||||||
foreach (QString template_name, templates()) {
|
foreach (QString template_name, templates()) {
|
||||||
if (!project_ -> usesTitleBlockTemplate(location(template_name))) {
|
if (!project_ -> usesTitleBlockTemplate(location(template_name))) {
|
||||||
removeTemplate(template_name);
|
removeTemplate(template_name);
|
||||||
@@ -408,7 +410,7 @@ QString TitleBlockTemplatesFilesCollection::path(const QString &template_name) c
|
|||||||
QStringList TitleBlockTemplatesFilesCollection::templates()
|
QStringList TitleBlockTemplatesFilesCollection::templates()
|
||||||
{
|
{
|
||||||
QStringList templates_names;
|
QStringList templates_names;
|
||||||
QRegExp replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
|
QRegularExpression replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
|
||||||
foreach(QString name, dir_.entryList()) {
|
foreach(QString name, dir_.entryList()) {
|
||||||
templates_names << name.replace(replace_regexp, "");
|
templates_names << name.replace(replace_regexp, "");
|
||||||
}
|
}
|
||||||
@@ -421,10 +423,10 @@ QStringList TitleBlockTemplatesFilesCollection::templates()
|
|||||||
*/
|
*/
|
||||||
TitleBlockTemplate *TitleBlockTemplatesFilesCollection::getTemplate(const QString &template_name) {
|
TitleBlockTemplate *TitleBlockTemplatesFilesCollection::getTemplate(const QString &template_name) {
|
||||||
if (!templates().contains(template_name)) return(nullptr);
|
if (!templates().contains(template_name)) return(nullptr);
|
||||||
|
|
||||||
TitleBlockTemplate *tbtemplate = new TitleBlockTemplate();
|
TitleBlockTemplate *tbtemplate = new TitleBlockTemplate();
|
||||||
QString tbt_file_path = path(template_name);
|
QString tbt_file_path = path(template_name);
|
||||||
|
|
||||||
bool loading = tbtemplate -> loadFromXmlFile(tbt_file_path);
|
bool loading = tbtemplate -> loadFromXmlFile(tbt_file_path);
|
||||||
if (!loading) {
|
if (!loading) {
|
||||||
delete tbtemplate;
|
delete tbtemplate;
|
||||||
@@ -439,17 +441,17 @@ TitleBlockTemplate *TitleBlockTemplatesFilesCollection::getTemplate(const QStrin
|
|||||||
*/
|
*/
|
||||||
QDomElement TitleBlockTemplatesFilesCollection::getTemplateXmlDescription(const QString &template_name) {
|
QDomElement TitleBlockTemplatesFilesCollection::getTemplateXmlDescription(const QString &template_name) {
|
||||||
QString xml_file_path = path(template_name);
|
QString xml_file_path = path(template_name);
|
||||||
|
|
||||||
QFileInfo xml_file_info(xml_file_path);
|
QFileInfo xml_file_info(xml_file_path);
|
||||||
if (!xml_file_info.exists() || !xml_file_info.isReadable()) {
|
if (!xml_file_info.exists() || !xml_file_info.isReadable()) {
|
||||||
return(QDomElement());
|
return(QDomElement());
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile xml_file(xml_file_path);
|
QFile xml_file(xml_file_path);
|
||||||
if (!xml_file.open(QIODevice::ReadOnly)) {
|
if (!xml_file.open(QIODevice::ReadOnly)) {
|
||||||
return(QDomElement());
|
return(QDomElement());
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomDocument *xml_document = new QDomDocument();
|
QDomDocument *xml_document = new QDomDocument();
|
||||||
bool xml_parsing = xml_document -> setContent(&xml_file);
|
bool xml_parsing = xml_document -> setContent(&xml_file);
|
||||||
if (!xml_parsing) {
|
if (!xml_parsing) {
|
||||||
@@ -466,16 +468,16 @@ QDomElement TitleBlockTemplatesFilesCollection::getTemplateXmlDescription(const
|
|||||||
*/
|
*/
|
||||||
bool TitleBlockTemplatesFilesCollection::setTemplateXmlDescription(const QString &template_name, const QDomElement &xml_element) {
|
bool TitleBlockTemplatesFilesCollection::setTemplateXmlDescription(const QString &template_name, const QDomElement &xml_element) {
|
||||||
if (template_name.isEmpty()) return(false);
|
if (template_name.isEmpty()) return(false);
|
||||||
|
|
||||||
// prevent the watcher from emitting signals while we open and write to file
|
// prevent the watcher from emitting signals while we open and write to file
|
||||||
blockSignals(true);
|
blockSignals(true);
|
||||||
|
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
doc.appendChild(doc.importNode(xml_element, true));
|
doc.appendChild(doc.importNode(xml_element, true));
|
||||||
|
|
||||||
bool writing = QET::writeXmlFile(doc, path(template_name));
|
bool writing = QET::writeXmlFile(doc, path(template_name));
|
||||||
if (!writing) return(false);
|
if (!writing) return(false);
|
||||||
|
|
||||||
// emit a single signal for the change
|
// emit a single signal for the change
|
||||||
blockSignals(false);
|
blockSignals(false);
|
||||||
emit(changed(this, template_name));
|
emit(changed(this, template_name));
|
||||||
@@ -489,9 +491,9 @@ void TitleBlockTemplatesFilesCollection::removeTemplate(const QString &template_
|
|||||||
emit(aboutToRemove(this, template_name));
|
emit(aboutToRemove(this, template_name));
|
||||||
// prevent the watcher from emitting signals while we open and write to file
|
// prevent the watcher from emitting signals while we open and write to file
|
||||||
blockSignals(true);
|
blockSignals(true);
|
||||||
|
|
||||||
dir_.remove(toFileName(template_name));
|
dir_.remove(toFileName(template_name));
|
||||||
|
|
||||||
// emit a single signal for the removal
|
// emit a single signal for the removal
|
||||||
blockSignals(false);
|
blockSignals(false);
|
||||||
emit(changed(this, template_name));
|
emit(changed(this, template_name));
|
||||||
@@ -500,7 +502,7 @@ void TitleBlockTemplatesFilesCollection::removeTemplate(const QString &template_
|
|||||||
/**
|
/**
|
||||||
@param template_name Name of a template supposed to be contained within
|
@param template_name Name of a template supposed to be contained within
|
||||||
this collection.
|
this collection.
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
TitleBlockTemplateLocation TitleBlockTemplatesFilesCollection::location(const QString &template_name) {
|
TitleBlockTemplateLocation TitleBlockTemplatesFilesCollection::location(const QString &template_name) {
|
||||||
return(TitleBlockTemplateLocation(template_name, this));
|
return(TitleBlockTemplateLocation(template_name, this));
|
||||||
@@ -544,7 +546,7 @@ bool TitleBlockTemplatesFilesCollection::isReadOnly(const QString &template_name
|
|||||||
@return the template name for \a file_name
|
@return the template name for \a file_name
|
||||||
*/
|
*/
|
||||||
QString TitleBlockTemplatesFilesCollection::toTemplateName(const QString &file_name) {
|
QString TitleBlockTemplatesFilesCollection::toTemplateName(const QString &file_name) {
|
||||||
static QRegExp replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
|
static QRegularExpression replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
|
||||||
QString template_name(file_name);
|
QString template_name(file_name);
|
||||||
return(template_name.replace(replace_regexp, ""));
|
return(template_name.replace(replace_regexp, ""));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -23,6 +23,8 @@
|
|||||||
// uncomment the line below to get more debug information
|
// uncomment the line below to get more debug information
|
||||||
//#define TITLEBLOCK_TEMPLATE_DEBUG
|
//#define TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QRegularExpressionMatch>
|
||||||
/**
|
/**
|
||||||
@brief TitleBlockTemplate::TitleBlockTemplate
|
@brief TitleBlockTemplate::TitleBlockTemplate
|
||||||
Constructor
|
Constructor
|
||||||
@@ -97,7 +99,7 @@ bool TitleBlockTemplate::loadFromXmlFile(const QString &filepath) {
|
|||||||
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
qDebug() << Q_FUNC_INFO << filepath << "opened";
|
qDebug() << Q_FUNC_INFO << filepath << "opened";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// parse its content as XML
|
// parse its content as XML
|
||||||
QDomDocument xml_doc;
|
QDomDocument xml_doc;
|
||||||
bool xml_parsing = xml_doc.setContent(&template_file);
|
bool xml_parsing = xml_doc.setContent(&template_file);
|
||||||
@@ -124,11 +126,11 @@ bool TitleBlockTemplate::loadFromXmlElement(const QDomElement &xml_element) {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
name_ = xml_element.attribute("name");
|
name_ = xml_element.attribute("name");
|
||||||
|
|
||||||
loadInformation(xml_element);
|
loadInformation(xml_element);
|
||||||
loadLogos(xml_element, true);
|
loadLogos(xml_element, true);
|
||||||
loadGrid(xml_element);
|
loadGrid(xml_element);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,14 +143,14 @@ bool TitleBlockTemplate::loadFromXmlElement(const QDomElement &xml_element) {
|
|||||||
*/
|
*/
|
||||||
bool TitleBlockTemplate::saveToXmlFile(const QString &filepath) {
|
bool TitleBlockTemplate::saveToXmlFile(const QString &filepath) {
|
||||||
if (filepath.isEmpty()) return(false);
|
if (filepath.isEmpty()) return(false);
|
||||||
|
|
||||||
// generate the XML document
|
// generate the XML document
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomElement e = doc.createElement("root");
|
QDomElement e = doc.createElement("root");
|
||||||
bool saving = saveToXmlElement(e);
|
bool saving = saveToXmlElement(e);
|
||||||
if (!saving) return(false);
|
if (!saving) return(false);
|
||||||
doc.appendChild(e);
|
doc.appendChild(e);
|
||||||
|
|
||||||
return(QET::writeXmlFile(doc, filepath));
|
return(QET::writeXmlFile(doc, filepath));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +165,7 @@ bool TitleBlockTemplate::saveToXmlElement(QDomElement &xml_element) const
|
|||||||
{
|
{
|
||||||
// we are supposed to have at least a name
|
// we are supposed to have at least a name
|
||||||
if (name_.isEmpty()) return(false);
|
if (name_.isEmpty()) return(false);
|
||||||
|
|
||||||
xml_element.setTagName("titleblocktemplate");
|
xml_element.setTagName("titleblocktemplate");
|
||||||
xml_element.setAttribute("name", name_);
|
xml_element.setAttribute("name", name_);
|
||||||
saveInformation(xml_element);
|
saveInformation(xml_element);
|
||||||
@@ -195,7 +197,7 @@ TitleBlockTemplate *TitleBlockTemplate::clone() const
|
|||||||
TitleBlockTemplate *copy = new TitleBlockTemplate();
|
TitleBlockTemplate *copy = new TitleBlockTemplate();
|
||||||
copy -> name_ = name_;
|
copy -> name_ = name_;
|
||||||
copy -> information_ = information_;
|
copy -> information_ = information_;
|
||||||
|
|
||||||
// this does not really duplicates pixmaps,
|
// this does not really duplicates pixmaps,
|
||||||
// only the objects that hold a key to the implicitly shared pixmaps
|
// only the objects that hold a key to the implicitly shared pixmaps
|
||||||
foreach (QString logo_key, bitmap_logos_.keys()) {
|
foreach (QString logo_key, bitmap_logos_.keys()) {
|
||||||
@@ -209,20 +211,20 @@ TitleBlockTemplate *TitleBlockTemplate::clone() const
|
|||||||
<< copy -> bitmap_logos_[logo_key] -> cacheKey();
|
<< copy -> bitmap_logos_[logo_key] -> cacheKey();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// we have to create new QSvgRenderer objects from the data
|
// we have to create new QSvgRenderer objects from the data
|
||||||
// (no copy constructor)
|
// (no copy constructor)
|
||||||
foreach (QString logo_key, vector_logos_.keys()) {
|
foreach (QString logo_key, vector_logos_.keys()) {
|
||||||
copy -> vector_logos_[logo_key] =
|
copy -> vector_logos_[logo_key] =
|
||||||
new QSvgRenderer(data_logos_[logo_key]);
|
new QSvgRenderer(data_logos_[logo_key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
copy -> data_logos_ = data_logos_;
|
copy -> data_logos_ = data_logos_;
|
||||||
copy -> storage_logos_ = storage_logos_;
|
copy -> storage_logos_ = storage_logos_;
|
||||||
copy -> type_logos_ = type_logos_;
|
copy -> type_logos_ = type_logos_;
|
||||||
copy -> rows_heights_ = rows_heights_;
|
copy -> rows_heights_ = rows_heights_;
|
||||||
copy -> columns_width_ = columns_width_;
|
copy -> columns_width_ = columns_width_;
|
||||||
|
|
||||||
// copy cells basically
|
// copy cells basically
|
||||||
copy -> cells_ = cells_;
|
copy -> cells_ = cells_;
|
||||||
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
|
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
|
||||||
@@ -230,7 +232,7 @@ TitleBlockTemplate *TitleBlockTemplate::clone() const
|
|||||||
copy -> cells_[i][j] = copy -> createCell(cells_[i][j]);
|
copy -> cells_[i][j] = copy -> createCell(cells_[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure the copy has no spanner_cell attribute pointing to a cell
|
// ensure the copy has no spanner_cell attribute pointing to a cell
|
||||||
// from the original object
|
// from the original object
|
||||||
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
|
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
|
||||||
@@ -247,7 +249,7 @@ TitleBlockTemplate *TitleBlockTemplate::clone() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(copy);
|
return(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,15 +280,15 @@ bool TitleBlockTemplate::loadLogos(const QDomElement &xml_element, bool reset) {
|
|||||||
if (reset) {
|
if (reset) {
|
||||||
qDeleteAll(vector_logos_.begin(), vector_logos_.end());
|
qDeleteAll(vector_logos_.begin(), vector_logos_.end());
|
||||||
vector_logos_.clear();
|
vector_logos_.clear();
|
||||||
|
|
||||||
// Note:
|
// Note:
|
||||||
// QPixmap are only a key to access the implicitly shared pixmap
|
// QPixmap are only a key to access the implicitly shared pixmap
|
||||||
bitmap_logos_.clear();
|
bitmap_logos_.clear();
|
||||||
|
|
||||||
data_logos_.clear();
|
data_logos_.clear();
|
||||||
storage_logos_.clear();
|
storage_logos_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// we look for //logos/logo elements
|
// we look for //logos/logo elements
|
||||||
for (QDomNode n = xml_element.firstChild() ;
|
for (QDomNode n = xml_element.firstChild() ;
|
||||||
!n.isNull() ;
|
!n.isNull() ;
|
||||||
@@ -302,7 +304,7 @@ bool TitleBlockTemplate::loadLogos(const QDomElement &xml_element, bool reset) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,7 +323,7 @@ bool TitleBlockTemplate::loadLogo(const QDomElement &xml_element) {
|
|||||||
QString logo_name = xml_element.attribute("name");
|
QString logo_name = xml_element.attribute("name");
|
||||||
QString logo_type = xml_element.attribute("type", "png");
|
QString logo_type = xml_element.attribute("type", "png");
|
||||||
QString logo_storage = xml_element.attribute("storage", "base64");
|
QString logo_storage = xml_element.attribute("storage", "base64");
|
||||||
|
|
||||||
// Both QSvgRenderer and QPixmap read their data from a QByteArray, so
|
// Both QSvgRenderer and QPixmap read their data from a QByteArray, so
|
||||||
// we convert the available data to that format.
|
// we convert the available data to that format.
|
||||||
QByteArray logo_data;
|
QByteArray logo_data;
|
||||||
@@ -342,7 +344,7 @@ bool TitleBlockTemplate::loadLogo(const QDomElement &xml_element) {
|
|||||||
qDebug() << Q_FUNC_INFO << logo_name << logo_type << logo_storage;
|
qDebug() << Q_FUNC_INFO << logo_name << logo_type << logo_storage;
|
||||||
#endif
|
#endif
|
||||||
addLogo(logo_name, &logo_data, logo_type, logo_storage);
|
addLogo(logo_name, &logo_data, logo_type, logo_storage);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,12 +364,12 @@ bool TitleBlockTemplate::loadGrid(const QDomElement &xml_element) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!grid_element.hasAttribute("rows")
|
if (!grid_element.hasAttribute("rows")
|
||||||
|| !grid_element.hasAttribute("cols")) {
|
|| !grid_element.hasAttribute("cols")) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
parseRows(grid_element.attribute("rows"));
|
parseRows(grid_element.attribute("rows"));
|
||||||
parseColumns(grid_element.attribute("cols"));
|
parseColumns(grid_element.attribute("cols"));
|
||||||
initCells();
|
initCells();
|
||||||
@@ -386,7 +388,9 @@ bool TitleBlockTemplate::loadGrid(const QDomElement &xml_element) {
|
|||||||
void TitleBlockTemplate::parseRows(const QString &rows_string) {
|
void TitleBlockTemplate::parseRows(const QString &rows_string) {
|
||||||
rows_heights_.clear();
|
rows_heights_.clear();
|
||||||
// parse the rows attribute: we expect a serie of absolute heights
|
// parse the rows attribute: we expect a serie of absolute heights
|
||||||
QRegExp row_size_format("^([0-9]+)(?:px)?$", Qt::CaseInsensitive);
|
QRegularExpression row_size_format
|
||||||
|
("^([0-9]+)(?:px)?$",
|
||||||
|
QRegularExpression::CaseInsensitiveOption);
|
||||||
bool conv_ok;
|
bool conv_ok;
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||||
@@ -398,10 +402,11 @@ void TitleBlockTemplate::parseRows(const QString &rows_string) {
|
|||||||
rows_string.split(QChar(';'), Qt::SkipEmptyParts);
|
rows_string.split(QChar(';'), Qt::SkipEmptyParts);
|
||||||
#endif
|
#endif
|
||||||
foreach (QString rows_description, rows_descriptions) {
|
foreach (QString rows_description, rows_descriptions) {
|
||||||
if (row_size_format.exactMatch(rows_description)) {
|
QRegularExpressionMatch match;
|
||||||
|
match = row_size_format.match(rows_description);
|
||||||
|
if (match.hasMatch()) {
|
||||||
int row_size =
|
int row_size =
|
||||||
row_size_format.capturedTexts().at(1).toInt(
|
match.captured(1).toInt(&conv_ok);
|
||||||
&conv_ok);
|
|
||||||
if (conv_ok)
|
if (conv_ok)
|
||||||
rows_heights_ << row_size;
|
rows_heights_ << row_size;
|
||||||
}
|
}
|
||||||
@@ -420,8 +425,12 @@ void TitleBlockTemplate::parseRows(const QString &rows_string) {
|
|||||||
void TitleBlockTemplate::parseColumns(const QString &cols_string) {
|
void TitleBlockTemplate::parseColumns(const QString &cols_string) {
|
||||||
columns_width_.clear();
|
columns_width_.clear();
|
||||||
// parse the cols attribute: we expect a serie of absolute or relative widths
|
// parse the cols attribute: we expect a serie of absolute or relative widths
|
||||||
QRegExp abs_col_size_format("^([0-9]+)(?:px)?$", Qt::CaseInsensitive);
|
QRegularExpression abs_col_size_format,rel_col_size_format;
|
||||||
QRegExp rel_col_size_format("^([rt])([0-9]+)%$", Qt::CaseInsensitive);
|
abs_col_size_format.setPattern("^([0-9]+)(?:px)?$");
|
||||||
|
abs_col_size_format.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||||
|
//QRegExp rel_col_size_format("^([rt])([0-9]+)%$", Qt::CaseInsensitive);
|
||||||
|
rel_col_size_format.setPattern("^([rt])([0-9]+)%$");
|
||||||
|
rel_col_size_format.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||||
bool conv_ok;
|
bool conv_ok;
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||||
@@ -433,18 +442,18 @@ void TitleBlockTemplate::parseColumns(const QString &cols_string) {
|
|||||||
cols_string.split(QChar(';'), Qt::SkipEmptyParts);
|
cols_string.split(QChar(';'), Qt::SkipEmptyParts);
|
||||||
#endif
|
#endif
|
||||||
foreach (QString cols_description, cols_descriptions) {
|
foreach (QString cols_description, cols_descriptions) {
|
||||||
if (abs_col_size_format.exactMatch(cols_description)) {
|
QRegularExpressionMatch match_abc,match_rel;
|
||||||
int col_size = abs_col_size_format.capturedTexts().at(1).toInt(&conv_ok);
|
match_abc = abs_col_size_format.match(cols_description);
|
||||||
|
match_rel = rel_col_size_format.match(cols_description);
|
||||||
|
if (match_abc.hasMatch()) {
|
||||||
|
int col_size = match_abc.captured(1).toInt(&conv_ok);
|
||||||
if (conv_ok)
|
if (conv_ok)
|
||||||
columns_width_ << TitleBlockDimension(
|
columns_width_ << TitleBlockDimension(
|
||||||
col_size,
|
col_size,
|
||||||
QET::Absolute);
|
QET::Absolute);
|
||||||
} else if (rel_col_size_format.exactMatch(cols_description)) {
|
} else if (match_rel.hasMatch()) {
|
||||||
int col_size =
|
int col_size = match_rel.captured(2).toInt(&conv_ok);
|
||||||
rel_col_size_format.capturedTexts().at(2).toInt(
|
QET::TitleBlockColumnLength col_type = match_rel.captured(1)
|
||||||
&conv_ok);
|
|
||||||
QET::TitleBlockColumnLength col_type =
|
|
||||||
rel_col_size_format.capturedTexts().at(1)
|
|
||||||
== "t"
|
== "t"
|
||||||
? QET::RelativeToTotalLength
|
? QET::RelativeToTotalLength
|
||||||
: QET::RelativeToRemainingLength;
|
: QET::RelativeToRemainingLength;
|
||||||
@@ -508,7 +517,7 @@ void TitleBlockTemplate::saveInformation(QDomElement &xml_element) const
|
|||||||
{
|
{
|
||||||
QDomNode information_text_node =
|
QDomNode information_text_node =
|
||||||
xml_element.ownerDocument().createTextNode(information());
|
xml_element.ownerDocument().createTextNode(information());
|
||||||
|
|
||||||
QDomElement information_element =
|
QDomElement information_element =
|
||||||
xml_element.ownerDocument().createElement("information");
|
xml_element.ownerDocument().createElement("information");
|
||||||
information_element.appendChild(information_text_node);
|
information_element.appendChild(information_text_node);
|
||||||
@@ -544,11 +553,11 @@ void TitleBlockTemplate::saveLogo(const QString &logo_name,
|
|||||||
QDomElement &xml_element) const
|
QDomElement &xml_element) const
|
||||||
{
|
{
|
||||||
if (!type_logos_.contains(logo_name)) return;
|
if (!type_logos_.contains(logo_name)) return;
|
||||||
|
|
||||||
xml_element.setAttribute("name", logo_name);
|
xml_element.setAttribute("name", logo_name);
|
||||||
xml_element.setAttribute("type", type_logos_[logo_name]);
|
xml_element.setAttribute("type", type_logos_[logo_name]);
|
||||||
xml_element.setAttribute("storage", storage_logos_[logo_name]);
|
xml_element.setAttribute("storage", storage_logos_[logo_name]);
|
||||||
|
|
||||||
if (storage_logos_[logo_name] == "xml"
|
if (storage_logos_[logo_name] == "xml"
|
||||||
&& type_logos_[logo_name] == "svg") {
|
&& type_logos_[logo_name] == "svg") {
|
||||||
QDomDocument svg_logo;
|
QDomDocument svg_logo;
|
||||||
@@ -575,7 +584,7 @@ void TitleBlockTemplate::saveGrid(QDomElement &xml_element) const
|
|||||||
{
|
{
|
||||||
QDomElement grid_element =
|
QDomElement grid_element =
|
||||||
xml_element.ownerDocument().createElement("grid");
|
xml_element.ownerDocument().createElement("grid");
|
||||||
|
|
||||||
QString rows_attr, cols_attr;
|
QString rows_attr, cols_attr;
|
||||||
foreach(int row_height, rows_heights_)
|
foreach(int row_height, rows_heights_)
|
||||||
rows_attr += QString("%1;").arg(row_height);
|
rows_attr += QString("%1;").arg(row_height);
|
||||||
@@ -583,9 +592,9 @@ void TitleBlockTemplate::saveGrid(QDomElement &xml_element) const
|
|||||||
cols_attr += col_width.toShortString();
|
cols_attr += col_width.toShortString();
|
||||||
grid_element.setAttribute("rows", rows_attr);
|
grid_element.setAttribute("rows", rows_attr);
|
||||||
grid_element.setAttribute("cols", cols_attr);
|
grid_element.setAttribute("cols", cols_attr);
|
||||||
|
|
||||||
saveCells(grid_element);
|
saveCells(grid_element);
|
||||||
|
|
||||||
xml_element.appendChild(grid_element);
|
xml_element.appendChild(grid_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -625,12 +634,12 @@ void TitleBlockTemplate::saveCell(TitleBlockCell *cell,
|
|||||||
if (cell -> spanner_cell) return;
|
if (cell -> spanner_cell) return;
|
||||||
if (!save_empty && cell -> cell_type == TitleBlockCell::EmptyCell)
|
if (!save_empty && cell -> cell_type == TitleBlockCell::EmptyCell)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
QDomElement cell_elmt =
|
QDomElement cell_elmt =
|
||||||
xml_element.ownerDocument().createElement("cell");
|
xml_element.ownerDocument().createElement("cell");
|
||||||
xml_element.appendChild(cell_elmt);
|
xml_element.appendChild(cell_elmt);
|
||||||
|
|
||||||
// save information dependent from this template
|
// save information dependent from this template
|
||||||
cell_elmt.setAttribute("row", cell -> num_row);
|
cell_elmt.setAttribute("row", cell -> num_row);
|
||||||
cell_elmt.setAttribute("col", cell -> num_col);
|
cell_elmt.setAttribute("col", cell -> num_col);
|
||||||
@@ -638,7 +647,7 @@ void TitleBlockTemplate::saveCell(TitleBlockCell *cell,
|
|||||||
cell -> row_span);
|
cell -> row_span);
|
||||||
if (cell -> col_span) cell_elmt.setAttribute("colspan",
|
if (cell -> col_span) cell_elmt.setAttribute("colspan",
|
||||||
cell -> col_span);
|
cell -> col_span);
|
||||||
|
|
||||||
// save other information
|
// save other information
|
||||||
cell -> saveContentToXml(cell_elmt);
|
cell -> saveContentToXml(cell_elmt);
|
||||||
}
|
}
|
||||||
@@ -659,15 +668,15 @@ bool TitleBlockTemplate::checkCell(const QDomElement &xml_element,
|
|||||||
TitleBlockCell **titleblock_cell_ptr) {
|
TitleBlockCell **titleblock_cell_ptr) {
|
||||||
int col_count = columns_width_.count(),
|
int col_count = columns_width_.count(),
|
||||||
row_count = rows_heights_.count();
|
row_count = rows_heights_.count();
|
||||||
|
|
||||||
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
qDebug() << Q_FUNC_INFO << "begin" << row_count << col_count;
|
qDebug() << Q_FUNC_INFO << "begin" << row_count << col_count;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int row_num, col_num, row_span, col_span;
|
int row_num, col_num, row_span, col_span;
|
||||||
row_num = col_num = -1;
|
row_num = col_num = -1;
|
||||||
row_span = col_span = 0;
|
row_span = col_span = 0;
|
||||||
|
|
||||||
// parse the row and col attributes
|
// parse the row and col attributes
|
||||||
if (!QET::attributeIsAnInteger(xml_element, "row", &row_num)
|
if (!QET::attributeIsAnInteger(xml_element, "row", &row_num)
|
||||||
|| row_num < 0
|
|| row_num < 0
|
||||||
@@ -679,7 +688,7 @@ bool TitleBlockTemplate::checkCell(const QDomElement &xml_element,
|
|||||||
|| col_num >= col_count) {
|
|| col_num >= col_count) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check whether the target cell can be used or not
|
// check whether the target cell can be used or not
|
||||||
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
|
||||||
qDebug() << Q_FUNC_INFO << "cell access" << col_num << row_num;
|
qDebug() << Q_FUNC_INFO << "cell access" << col_num << row_num;
|
||||||
@@ -692,20 +701,20 @@ bool TitleBlockTemplate::checkCell(const QDomElement &xml_element,
|
|||||||
// ensure the num_row and num_col attributes are alright
|
// ensure the num_row and num_col attributes are alright
|
||||||
cell_ptr -> num_row = row_num;
|
cell_ptr -> num_row = row_num;
|
||||||
cell_ptr -> num_col = col_num;
|
cell_ptr -> num_col = col_num;
|
||||||
|
|
||||||
// parse the rowspan and colspan attributes
|
// parse the rowspan and colspan attributes
|
||||||
if (QET::attributeIsAnInteger(xml_element, "rowspan", &row_span)
|
if (QET::attributeIsAnInteger(xml_element, "rowspan", &row_span)
|
||||||
&& row_span > 0) {
|
&& row_span > 0) {
|
||||||
cell_ptr -> row_span = row_span;
|
cell_ptr -> row_span = row_span;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QET::attributeIsAnInteger(xml_element, "colspan", &col_span)
|
if (QET::attributeIsAnInteger(xml_element, "colspan", &col_span)
|
||||||
&& col_span > 0) {
|
&& col_span > 0) {
|
||||||
cell_ptr -> col_span = col_span;
|
cell_ptr -> col_span = col_span;
|
||||||
}
|
}
|
||||||
// these attributes are stored "as is" -- whether they can be applied
|
// these attributes are stored "as is" -- whether they can be applied
|
||||||
// directly or must be restricted will be checked later
|
// directly or must be restricted will be checked later
|
||||||
|
|
||||||
if (titleblock_cell_ptr) *titleblock_cell_ptr = cell_ptr;
|
if (titleblock_cell_ptr) *titleblock_cell_ptr = cell_ptr;
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@@ -719,7 +728,7 @@ bool TitleBlockTemplate::checkCell(const QDomElement &xml_element,
|
|||||||
void TitleBlockTemplate::initCells()
|
void TitleBlockTemplate::initCells()
|
||||||
{
|
{
|
||||||
if (columns_width_.count() < 1 || rows_heights_.count() < 1) return;
|
if (columns_width_.count() < 1 || rows_heights_.count() < 1) return;
|
||||||
|
|
||||||
cells_.clear();
|
cells_.clear();
|
||||||
qDeleteAll(registered_cells_);
|
qDeleteAll(registered_cells_);
|
||||||
registered_cells_.clear();
|
registered_cells_.clear();
|
||||||
@@ -838,12 +847,12 @@ int TitleBlockTemplate::rowsCount() const
|
|||||||
QList<int> TitleBlockTemplate::columnsWidth(int total_width) const
|
QList<int> TitleBlockTemplate::columnsWidth(int total_width) const
|
||||||
{
|
{
|
||||||
if (total_width < 0) return(QList<int>());
|
if (total_width < 0) return(QList<int>());
|
||||||
|
|
||||||
// we first iter to determine the absolute and total-width-related widths
|
// we first iter to determine the absolute and total-width-related widths
|
||||||
QVector<int> final_widths(columns_width_.count());
|
QVector<int> final_widths(columns_width_.count());
|
||||||
int abs_widths_sum = 0, rel_widths_sum = 0;
|
int abs_widths_sum = 0, rel_widths_sum = 0;
|
||||||
QList<int> relative_columns;
|
QList<int> relative_columns;
|
||||||
|
|
||||||
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
||||||
TitleBlockDimension icd = columns_width_.at(i);
|
TitleBlockDimension icd = columns_width_.at(i);
|
||||||
if (icd.type == QET::Absolute) {
|
if (icd.type == QET::Absolute) {
|
||||||
@@ -856,10 +865,10 @@ QList<int> TitleBlockTemplate::columnsWidth(int total_width) const
|
|||||||
final_widths[i] = abs_value;
|
final_widths[i] = abs_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can now deduce the remaining width
|
// we can now deduce the remaining width
|
||||||
int remaining_width = total_width - abs_widths_sum;
|
int remaining_width = total_width - abs_widths_sum;
|
||||||
|
|
||||||
// we do a second iteration to build the final widths list
|
// we do a second iteration to build the final widths list
|
||||||
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
||||||
TitleBlockDimension icd = columns_width_.at(i);
|
TitleBlockDimension icd = columns_width_.at(i);
|
||||||
@@ -870,14 +879,14 @@ QList<int> TitleBlockTemplate::columnsWidth(int total_width) const
|
|||||||
rel_widths_sum += final_widths[i];
|
rel_widths_sum += final_widths[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Have we computed widths from percentage for relative columns?
|
// Have we computed widths from percentage for relative columns?
|
||||||
if (relative_columns.count()) {
|
if (relative_columns.count()) {
|
||||||
// Due to the rounding process,
|
// Due to the rounding process,
|
||||||
// we may get a slight difference between the
|
// we may get a slight difference between the
|
||||||
// sum of the columns widths and the total width.
|
// sum of the columns widths and the total width.
|
||||||
int difference = total_width - abs_widths_sum - rel_widths_sum;
|
int difference = total_width - abs_widths_sum - rel_widths_sum;
|
||||||
|
|
||||||
if (difference) {
|
if (difference) {
|
||||||
// We consider we should not attempt to compensate
|
// We consider we should not attempt to compensate
|
||||||
// this difference if it is under
|
// this difference if it is under
|
||||||
@@ -886,7 +895,7 @@ QList<int> TitleBlockTemplate::columnsWidth(int total_width) const
|
|||||||
// columns can "bring" up to 0.5px of difference).
|
// columns can "bring" up to 0.5px of difference).
|
||||||
qreal max_acceptable_difference =
|
qreal max_acceptable_difference =
|
||||||
relative_columns.count() * 0.5;
|
relative_columns.count() * 0.5;
|
||||||
|
|
||||||
int share = difference > 0 ? 1 : -1;
|
int share = difference > 0 ? 1 : -1;
|
||||||
if (qAbs(difference) <= max_acceptable_difference) {
|
if (qAbs(difference) <= max_acceptable_difference) {
|
||||||
while (difference) {
|
while (difference) {
|
||||||
@@ -914,32 +923,32 @@ QList<int> TitleBlockTemplate::rowsHeights() const
|
|||||||
/**
|
/**
|
||||||
@brief TitleBlockTemplate::columnTypeCount
|
@brief TitleBlockTemplate::columnTypeCount
|
||||||
@param type : a column type
|
@param type : a column type
|
||||||
@return the count of \a type columns
|
@return the count of \a type columns
|
||||||
*/
|
*/
|
||||||
int TitleBlockTemplate::columnTypeCount(QET::TitleBlockColumnLength type) {
|
int TitleBlockTemplate::columnTypeCount(QET::TitleBlockColumnLength type) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
||||||
if (columns_width_.at(i).type == type) ++ count;
|
if (columns_width_.at(i).type == type) ++ count;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(count);
|
return(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief TitleBlockTemplate::columnTypeTotal
|
@brief TitleBlockTemplate::columnTypeTotal
|
||||||
@param type : a column type
|
@param type : a column type
|
||||||
@return the sum of values attached to \a type columns
|
@return the sum of values attached to \a type columns
|
||||||
*/
|
*/
|
||||||
int TitleBlockTemplate::columnTypeTotal(QET::TitleBlockColumnLength type) {
|
int TitleBlockTemplate::columnTypeTotal(QET::TitleBlockColumnLength type) {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
||||||
if (columns_width_.at(i).type == type) {
|
if (columns_width_.at(i).type == type) {
|
||||||
total += columns_width_.at(i).value;
|
total += columns_width_.at(i).value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(total);
|
return(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -951,7 +960,7 @@ int TitleBlockTemplate::minimumWidth()
|
|||||||
// Abbreviations: ABS: absolute, RTT: relative to total, RTR:
|
// Abbreviations: ABS: absolute, RTT: relative to total, RTR:
|
||||||
// relative to remaining,
|
// relative to remaining,
|
||||||
// TOT: total diagram/TBT width (variable).
|
// TOT: total diagram/TBT width (variable).
|
||||||
|
|
||||||
// Minimum size may be enforced by ABS and RTT widths:
|
// Minimum size may be enforced by ABS and RTT widths:
|
||||||
// TOT >= ((sum(REL)/100)*TOT)+sum(ABS)
|
// TOT >= ((sum(REL)/100)*TOT)+sum(ABS)
|
||||||
// => (1 - (sum(REL)/100))TOT >= sum(ABS)
|
// => (1 - (sum(REL)/100))TOT >= sum(ABS)
|
||||||
@@ -1050,7 +1059,7 @@ bool TitleBlockTemplate::insertRow(int dimension,
|
|||||||
const QList<TitleBlockCell *> &row,
|
const QList<TitleBlockCell *> &row,
|
||||||
int i) {
|
int i) {
|
||||||
int index = (i == -1) ? rows_heights_.count() : i;
|
int index = (i == -1) ? rows_heights_.count() : i;
|
||||||
|
|
||||||
for (int j = 0 ; j < columns_width_.count() ; ++ j) {
|
for (int j = 0 ; j < columns_width_.count() ; ++ j) {
|
||||||
cells_[j].insert(index, row[j]);
|
cells_[j].insert(index, row[j]);
|
||||||
}
|
}
|
||||||
@@ -1166,7 +1175,7 @@ TitleBlockCell *TitleBlockTemplate::cell(int row, int col) const
|
|||||||
{
|
{
|
||||||
if (row >= rows_heights_.count()) return(nullptr);
|
if (row >= rows_heights_.count()) return(nullptr);
|
||||||
if (col >= columns_width_.count()) return(nullptr);
|
if (col >= columns_width_.count()) return(nullptr);
|
||||||
|
|
||||||
return(cells_[col][row]);
|
return(cells_[col][row]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1198,7 +1207,7 @@ QSet<TitleBlockCell *> TitleBlockTemplate::spannedCells(
|
|||||||
? given_cell -> col_span
|
? given_cell -> col_span
|
||||||
: given_cell -> applied_col_span;
|
: given_cell -> applied_col_span;
|
||||||
if (!final_row_span && !final_col_span) return(set);
|
if (!final_row_span && !final_col_span) return(set);
|
||||||
|
|
||||||
for (int i = given_cell -> num_col ;
|
for (int i = given_cell -> num_col ;
|
||||||
i <= given_cell -> num_col + final_col_span ;
|
i <= given_cell -> num_col + final_col_span ;
|
||||||
++ i) {
|
++ i) {
|
||||||
@@ -1269,7 +1278,7 @@ bool TitleBlockTemplate::addLogo(const QString &logo_name,
|
|||||||
// we are replacing the logo
|
// we are replacing the logo
|
||||||
removeLogo(logo_name);
|
removeLogo(logo_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can now create our image object from the byte array
|
// we can now create our image object from the byte array
|
||||||
if (logo_type == "svg") {
|
if (logo_type == "svg") {
|
||||||
// SVG format is handled by the QSvgRenderer class
|
// SVG format is handled by the QSvgRenderer class
|
||||||
@@ -1278,7 +1287,7 @@ bool TitleBlockTemplate::addLogo(const QString &logo_name,
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
vector_logos_.insert(logo_name, svg);
|
vector_logos_.insert(logo_name, svg);
|
||||||
|
|
||||||
// we also memorize the way to store them in the final XML output
|
// we also memorize the way to store them in the final XML output
|
||||||
QString final_logo_storage = logo_storage;
|
QString final_logo_storage = logo_storage;
|
||||||
if (logo_storage != "xml" && logo_storage != "base64") {
|
if (logo_storage != "xml" && logo_storage != "base64") {
|
||||||
@@ -1286,7 +1295,7 @@ bool TitleBlockTemplate::addLogo(const QString &logo_name,
|
|||||||
}
|
}
|
||||||
storage_logos_.insert(logo_name, logo_storage);
|
storage_logos_.insert(logo_name, logo_storage);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// bitmap formats are handled by the QPixmap class
|
// bitmap formats are handled by the QPixmap class
|
||||||
QPixmap logo_pixmap;
|
QPixmap logo_pixmap;
|
||||||
logo_pixmap.loadFromData(*logo_data);
|
logo_pixmap.loadFromData(*logo_data);
|
||||||
@@ -1294,15 +1303,15 @@ bool TitleBlockTemplate::addLogo(const QString &logo_name,
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
bitmap_logos_.insert(logo_name, logo_pixmap);
|
bitmap_logos_.insert(logo_name, logo_pixmap);
|
||||||
|
|
||||||
// bitmap logos can only be stored using a base64 encoding
|
// bitmap logos can only be stored using a base64 encoding
|
||||||
storage_logos_.insert(logo_name, "base64");
|
storage_logos_.insert(logo_name, "base64");
|
||||||
}
|
}
|
||||||
|
|
||||||
// we systematically store the raw data
|
// we systematically store the raw data
|
||||||
data_logos_.insert(logo_name, *logo_data);
|
data_logos_.insert(logo_name, *logo_data);
|
||||||
type_logos_.insert(logo_name, logo_type);
|
type_logos_.insert(logo_name, logo_type);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1320,15 +1329,15 @@ bool TitleBlockTemplate::addLogoFromFile(const QString &filepath,
|
|||||||
QFileInfo filepath_info(filepath);
|
QFileInfo filepath_info(filepath);
|
||||||
QString filename = name.isEmpty() ? filepath_info.fileName() : name;
|
QString filename = name.isEmpty() ? filepath_info.fileName() : name;
|
||||||
QString filetype = filepath_info.suffix();
|
QString filetype = filepath_info.suffix();
|
||||||
|
|
||||||
// we read the provided logo
|
// we read the provided logo
|
||||||
QFile logo_file(filepath);
|
QFile logo_file(filepath);
|
||||||
if (!logo_file.open(QIODevice::ReadOnly)) return(false);
|
if (!logo_file.open(QIODevice::ReadOnly)) return(false);
|
||||||
QByteArray file_content = logo_file.readAll();
|
QByteArray file_content = logo_file.readAll();
|
||||||
|
|
||||||
// first, we try to add it as an SVG image
|
// first, we try to add it as an SVG image
|
||||||
if (addLogo(filename, &file_content, "svg", "xml")) return(true);
|
if (addLogo(filename, &file_content, "svg", "xml")) return(true);
|
||||||
|
|
||||||
// we then try to add it as a bitmap image
|
// we then try to add it as a bitmap image
|
||||||
return addLogo(filename,
|
return addLogo(filename,
|
||||||
&file_content,
|
&file_content,
|
||||||
@@ -1349,12 +1358,12 @@ bool TitleBlockTemplate::saveLogoToFile(const QString &logo_name,
|
|||||||
if (!data_logos_.contains(logo_name)) {
|
if (!data_logos_.contains(logo_name)) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile target_file(filepath);
|
QFile target_file(filepath);
|
||||||
if (!target_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
if (!target_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
target_file.write(data_logos_[logo_name]);
|
target_file.write(data_logos_[logo_name]);
|
||||||
target_file.close();
|
target_file.close();
|
||||||
return(true);
|
return(true);
|
||||||
@@ -1395,7 +1404,7 @@ bool TitleBlockTemplate::renameLogo(const QString &logo_name,
|
|||||||
|| data_logos_.contains(new_name)) {
|
|| data_logos_.contains(new_name)) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO check existing cells using this logo.
|
/// TODO check existing cells using this logo.
|
||||||
if (vector_logos_.contains(logo_name)) {
|
if (vector_logos_.contains(logo_name)) {
|
||||||
vector_logos_.insert(new_name, vector_logos_.take(logo_name));
|
vector_logos_.insert(new_name, vector_logos_.take(logo_name));
|
||||||
@@ -1493,16 +1502,16 @@ void TitleBlockTemplate::render(QPainter &painter,
|
|||||||
{
|
{
|
||||||
QList<int> widths = columnsWidth(titleblock_width);
|
QList<int> widths = columnsWidth(titleblock_width);
|
||||||
int titleblock_height = height();
|
int titleblock_height = height();
|
||||||
|
|
||||||
painter.save();
|
painter.save();
|
||||||
//Setup the QPainter
|
//Setup the QPainter
|
||||||
QPen pen(Qt::black);
|
QPen pen(Qt::black);
|
||||||
pen.setCosmetic(true);
|
pen.setCosmetic(true);
|
||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
|
|
||||||
// draw the titleblock border
|
// draw the titleblock border
|
||||||
painter.drawRect(QRect(0, 0, titleblock_width, titleblock_height));
|
painter.drawRect(QRect(0, 0, titleblock_width, titleblock_height));
|
||||||
|
|
||||||
// run through each individual cell
|
// run through each individual cell
|
||||||
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
|
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
|
||||||
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
|
||||||
@@ -1510,13 +1519,13 @@ void TitleBlockTemplate::render(QPainter &painter,
|
|||||||
|| cells_[i][j] -> cell_type
|
|| cells_[i][j] -> cell_type
|
||||||
== TitleBlockCell::EmptyCell)
|
== TitleBlockCell::EmptyCell)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// calculate the border rect of the current cell
|
// calculate the border rect of the current cell
|
||||||
int x = lengthRange(0, cells_[i][j] -> num_col, widths);
|
int x = lengthRange(0, cells_[i][j] -> num_col, widths);
|
||||||
int y = lengthRange(0,
|
int y = lengthRange(0,
|
||||||
cells_[i][j] -> num_row,
|
cells_[i][j] -> num_row,
|
||||||
rows_heights_);
|
rows_heights_);
|
||||||
|
|
||||||
int row_span = 0, col_span = 0;
|
int row_span = 0, col_span = 0;
|
||||||
if (cells_[i][j] -> span_state
|
if (cells_[i][j] -> span_state
|
||||||
!= TitleBlockCell::Disabled) {
|
!= TitleBlockCell::Disabled) {
|
||||||
@@ -1530,7 +1539,7 @@ void TitleBlockTemplate::render(QPainter &painter,
|
|||||||
cells_[i][j] -> num_row + 1 + row_span,
|
cells_[i][j] -> num_row + 1 + row_span,
|
||||||
rows_heights_);
|
rows_heights_);
|
||||||
QRect cell_rect(x, y, w, h);
|
QRect cell_rect(x, y, w, h);
|
||||||
|
|
||||||
renderCell(painter, *cells_[i][j],
|
renderCell(painter, *cells_[i][j],
|
||||||
diagram_context,
|
diagram_context,
|
||||||
cell_rect);
|
cell_rect);
|
||||||
@@ -1647,7 +1656,7 @@ void TitleBlockTemplate::renderCell(QPainter &painter,
|
|||||||
pen.setColor(Qt::black);
|
pen.setColor(Qt::black);
|
||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
painter.drawRect(cell_rect);
|
painter.drawRect(cell_rect);
|
||||||
|
|
||||||
painter.save();
|
painter.save();
|
||||||
// render the inner content of the current cell
|
// render the inner content of the current cell
|
||||||
if (cell.type() == TitleBlockCell::LogoCell) {
|
if (cell.type() == TitleBlockCell::LogoCell) {
|
||||||
@@ -1672,7 +1681,7 @@ void TitleBlockTemplate::renderCell(QPainter &painter,
|
|||||||
renderTextCell(painter, final_text, cell, cell_rect);
|
renderTextCell(painter, final_text, cell, cell_rect);
|
||||||
}
|
}
|
||||||
painter.restore();
|
painter.restore();
|
||||||
|
|
||||||
// draw again the border rect of the current cell, without the brush this time
|
// draw again the border rect of the current cell, without the brush this time
|
||||||
painter.setBrush(Qt::NoBrush);
|
painter.setBrush(Qt::NoBrush);
|
||||||
painter.drawRect(cell_rect);
|
painter.drawRect(cell_rect);
|
||||||
@@ -1695,9 +1704,9 @@ QString TitleBlockTemplate::finalTextForCell(
|
|||||||
{
|
{
|
||||||
QString cell_text = cell.value.name();
|
QString cell_text = cell.value.name();
|
||||||
QString cell_label = cell.label.name();
|
QString cell_label = cell.label.name();
|
||||||
|
|
||||||
cell_text = interpreteVariables(cell_text, diagram_context);
|
cell_text = interpreteVariables(cell_text, diagram_context);
|
||||||
|
|
||||||
if (cell.display_label && !cell.label.isEmpty()) {
|
if (cell.display_label && !cell.label.isEmpty()) {
|
||||||
cell_label = interpreteVariables(cell_label, diagram_context);
|
cell_label = interpreteVariables(cell_label, diagram_context);
|
||||||
cell_text = QString(tr(" %1 : %2", "titleblock content - please let the blank space at the beginning")).arg(cell_label).arg(cell_text);
|
cell_text = QString(tr(" %1 : %2", "titleblock content - please let the blank space at the beginning")).arg(cell_label).arg(cell_text);
|
||||||
@@ -1749,7 +1758,7 @@ QStringList TitleBlockTemplate::listOfVariables()
|
|||||||
#pragma message("@TODO not works on all cases...")
|
#pragma message("@TODO not works on all cases...")
|
||||||
// TODO: not works on all cases...
|
// TODO: not works on all cases...
|
||||||
list << cells_[i][j] -> value.name().replace("%","");
|
list << cells_[i][j] -> value.name().replace("%","");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug() << list;
|
qDebug() << list;
|
||||||
return list;
|
return list;
|
||||||
@@ -1778,25 +1787,25 @@ void TitleBlockTemplate::renderTextCell(QPainter &painter,
|
|||||||
if (text.isEmpty()) return;
|
if (text.isEmpty()) return;
|
||||||
QFont text_font = TitleBlockTemplate::fontForCell(cell);
|
QFont text_font = TitleBlockTemplate::fontForCell(cell);
|
||||||
painter.setFont(text_font);
|
painter.setFont(text_font);
|
||||||
|
|
||||||
if (cell.hadjust) {
|
if (cell.hadjust) {
|
||||||
QFontMetricsF font_metrics(text_font);
|
QFontMetricsF font_metrics(text_font);
|
||||||
QRectF font_rect = font_metrics.boundingRect(
|
QRectF font_rect = font_metrics.boundingRect(
|
||||||
QRect(-10000, -10000, 10000, 10000),
|
QRect(-10000, -10000, 10000, 10000),
|
||||||
cell.alignment,
|
cell.alignment,
|
||||||
text);
|
text);
|
||||||
|
|
||||||
if (font_rect.width() > cell_rect.width()) {
|
if (font_rect.width() > cell_rect.width()) {
|
||||||
qreal ratio = qreal(cell_rect.width())
|
qreal ratio = qreal(cell_rect.width())
|
||||||
/ qreal(font_rect.width());
|
/ qreal(font_rect.width());
|
||||||
painter.save();
|
painter.save();
|
||||||
|
|
||||||
painter.translate(cell_rect.topLeft());
|
painter.translate(cell_rect.topLeft());
|
||||||
qreal vertical_adjustment =
|
qreal vertical_adjustment =
|
||||||
cell_rect.height() * (1 - ratio) / 2.0;
|
cell_rect.height() * (1 - ratio) / 2.0;
|
||||||
painter.translate(0.0, vertical_adjustment);
|
painter.translate(0.0, vertical_adjustment);
|
||||||
painter.scale(ratio, ratio);
|
painter.scale(ratio, ratio);
|
||||||
|
|
||||||
QRectF new_world_cell_rect(cell_rect);
|
QRectF new_world_cell_rect(cell_rect);
|
||||||
new_world_cell_rect.moveTo(0, 0.0);
|
new_world_cell_rect.moveTo(0, 0.0);
|
||||||
new_world_cell_rect.setWidth(new_world_cell_rect.width()
|
new_world_cell_rect.setWidth(new_world_cell_rect.width()
|
||||||
@@ -1804,12 +1813,12 @@ void TitleBlockTemplate::renderTextCell(QPainter &painter,
|
|||||||
painter.drawText(new_world_cell_rect,
|
painter.drawText(new_world_cell_rect,
|
||||||
cell.alignment,
|
cell.alignment,
|
||||||
text);
|
text);
|
||||||
|
|
||||||
painter.restore();
|
painter.restore();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Still here? Let's draw the text normally
|
// Still here? Let's draw the text normally
|
||||||
painter.drawText(cell_rect, cell.alignment, text);
|
painter.drawText(cell_rect, cell.alignment, text);
|
||||||
}
|
}
|
||||||
@@ -1825,14 +1834,15 @@ void TitleBlockTemplate::renderTextCell(QPainter &painter,
|
|||||||
@param h
|
@param h
|
||||||
@param color
|
@param color
|
||||||
*/
|
*/
|
||||||
void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
|
void TitleBlockTemplate::renderTextCellDxf(
|
||||||
const QString &text,
|
QString &file_path,
|
||||||
const TitleBlockCell &cell,
|
const QString &text,
|
||||||
qreal x,
|
const TitleBlockCell &cell,
|
||||||
qreal y,
|
qreal x,
|
||||||
qreal w,
|
qreal y,
|
||||||
qreal h,
|
qreal w,
|
||||||
int color) const
|
qreal h,
|
||||||
|
int color) const
|
||||||
{
|
{
|
||||||
if (text.isEmpty()) return;
|
if (text.isEmpty()) return;
|
||||||
QFont text_font = TitleBlockTemplate::fontForCell(cell);
|
QFont text_font = TitleBlockTemplate::fontForCell(cell);
|
||||||
@@ -1841,61 +1851,73 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
|
|||||||
textHeight = text_font.pixelSize();
|
textHeight = text_font.pixelSize();
|
||||||
|
|
||||||
qreal x2 = x + w;
|
qreal x2 = x + w;
|
||||||
qreal y1 = y;
|
qreal y1 = y;
|
||||||
|
|
||||||
int vAlign = 0;
|
int vAlign = 0;
|
||||||
int hAlign = 0;
|
int hAlign = 0;
|
||||||
|
|
||||||
x2 = x; // default
|
x2 = x; // default
|
||||||
|
|
||||||
if ( cell.alignment & Qt::AlignTop ) {
|
if ( cell.alignment & Qt::AlignTop )
|
||||||
vAlign = 3;
|
{
|
||||||
y1 = y + h - (textHeight*Createdxf::yScale / 8);
|
vAlign = 3;
|
||||||
} else if ( cell.alignment & Qt::AlignVCenter ) {
|
y1 = y + h - (textHeight*Createdxf::yScale / 8);
|
||||||
vAlign = 2;
|
}
|
||||||
y1 = y + h/2;
|
else if ( cell.alignment & Qt::AlignVCenter )
|
||||||
} else if ( cell.alignment & Qt::AlignBottom ) {
|
{
|
||||||
y1 = y + (textHeight*Createdxf::yScale / 8);
|
vAlign = 2;
|
||||||
}
|
y1 = y + h/2;
|
||||||
|
}
|
||||||
|
else if ( cell.alignment & Qt::AlignBottom )
|
||||||
|
{
|
||||||
|
y1 = y + (textHeight*Createdxf::yScale / 8);
|
||||||
|
}
|
||||||
|
|
||||||
if ( cell.alignment & Qt::AlignRight ) {
|
if ( cell.alignment & Qt::AlignRight )
|
||||||
|
{
|
||||||
hAlign = 2;
|
hAlign = 2;
|
||||||
x2 = x + w;
|
x2 = x + w;
|
||||||
} else if ( cell.alignment & Qt::AlignHCenter ) {
|
}
|
||||||
|
else if ( cell.alignment & Qt::AlignHCenter )
|
||||||
|
{
|
||||||
hAlign = 1;
|
hAlign = 1;
|
||||||
x2 = x + w/2;
|
x2 = x + w/2;
|
||||||
} else if (cell.alignment & Qt::AlignJustify ) {
|
}
|
||||||
|
else if (cell.alignment & Qt::AlignJustify )
|
||||||
|
{
|
||||||
hAlign = 5;
|
hAlign = 5;
|
||||||
vAlign = 0;
|
vAlign = 0;
|
||||||
x2 = x + w;
|
x2 = x + w;
|
||||||
y1 = y + textHeight*Createdxf::yScale / 8;
|
y1 = y + textHeight*Createdxf::yScale / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
//painter.setFont(text_font);
|
//painter.setFont(text_font);
|
||||||
qreal ratio = 1.0;
|
qreal ratio = 1.0;
|
||||||
|
|
||||||
if (cell.hadjust) {
|
if (cell.hadjust)
|
||||||
// Scale font width to fit string in cell width w
|
{
|
||||||
// As DXF font aspect ratio is implementation dependent we add a fudge-factor based on tests with AutoCAD
|
// Scale font width to fit string in cell width w
|
||||||
int len = text.length() * textHeight * Createdxf::xScale * 1.2;
|
// As DXF font aspect ratio is implementation dependent we add a fudge-factor based on tests with AutoCAD
|
||||||
|
int len = text.length() * textHeight * Createdxf::xScale * 1.2;
|
||||||
|
|
||||||
if(len > w)
|
if(len > w)
|
||||||
ratio = (w/len);
|
ratio = (w/len);
|
||||||
}
|
}
|
||||||
|
|
||||||
// x offset value below currently set heuristically based on appearance...
|
// x offset value below currently set heuristically based on appearance...
|
||||||
Createdxf::drawTextAligned(file_path,
|
Createdxf::drawTextAligned(
|
||||||
text,
|
file_path,
|
||||||
x - 2*Createdxf::xScale,
|
text,
|
||||||
y1,
|
x - 2*Createdxf::xScale,
|
||||||
textHeight*Createdxf::yScale,
|
y1,
|
||||||
0,
|
textHeight*Createdxf::yScale,
|
||||||
0,
|
0,
|
||||||
hAlign,
|
0,
|
||||||
vAlign,
|
hAlign,
|
||||||
x2,
|
vAlign,
|
||||||
ratio,
|
x2,
|
||||||
color);
|
ratio,
|
||||||
|
color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1965,11 +1987,11 @@ void TitleBlockTemplate::applyCellSpans()
|
|||||||
*/
|
*/
|
||||||
bool TitleBlockTemplate::checkCellSpan(TitleBlockCell *cell) {
|
bool TitleBlockTemplate::checkCellSpan(TitleBlockCell *cell) {
|
||||||
if (!cell) return(false);
|
if (!cell) return(false);
|
||||||
|
|
||||||
cell -> span_state = TitleBlockCell::Enabled;
|
cell -> span_state = TitleBlockCell::Enabled;
|
||||||
cell -> applied_row_span = cell -> row_span;
|
cell -> applied_row_span = cell -> row_span;
|
||||||
cell -> applied_col_span = cell -> col_span;
|
cell -> applied_col_span = cell -> col_span;
|
||||||
|
|
||||||
// ensure the cell can span as far as required
|
// ensure the cell can span as far as required
|
||||||
if (cell -> num_col + cell -> col_span >= columnsCount()) {
|
if (cell -> num_col + cell -> col_span >= columnsCount()) {
|
||||||
cell -> applied_col_span = columnsCount() - 1 - cell -> num_col;
|
cell -> applied_col_span = columnsCount() - 1 - cell -> num_col;
|
||||||
@@ -1979,7 +2001,7 @@ bool TitleBlockTemplate::checkCellSpan(TitleBlockCell *cell) {
|
|||||||
cell -> applied_row_span = rowsCount() - 1 - cell -> num_row;
|
cell -> applied_row_span = rowsCount() - 1 - cell -> num_row;
|
||||||
cell -> span_state = TitleBlockCell::Restricted;
|
cell -> span_state = TitleBlockCell::Restricted;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure cells that will be spanned are either empty or free
|
// ensure cells that will be spanned are either empty or free
|
||||||
for (int i = cell -> num_col ;
|
for (int i = cell -> num_col ;
|
||||||
i <= cell -> num_col + cell -> applied_col_span ;
|
i <= cell -> num_col + cell -> applied_col_span ;
|
||||||
@@ -2006,7 +2028,7 @@ bool TitleBlockTemplate::checkCellSpan(TitleBlockCell *cell) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2019,10 +2041,11 @@ bool TitleBlockTemplate::checkCellSpan(TitleBlockCell *cell) {
|
|||||||
@param cell :
|
@param cell :
|
||||||
Potentially spanning cell
|
Potentially spanning cell
|
||||||
*/
|
*/
|
||||||
void TitleBlockTemplate::applyCellSpan(TitleBlockCell *cell) {
|
void TitleBlockTemplate::applyCellSpan(TitleBlockCell *cell)
|
||||||
|
{
|
||||||
if (!cell || (!cell -> row_span && !cell -> col_span)) return;
|
if (!cell || (!cell -> row_span && !cell -> col_span)) return;
|
||||||
if (cell -> span_state == TitleBlockCell::Disabled) return;
|
if (cell -> span_state == TitleBlockCell::Disabled) return;
|
||||||
|
|
||||||
// goes through every spanned cell
|
// goes through every spanned cell
|
||||||
for (int i = cell -> num_col ;
|
for (int i = cell -> num_col ;
|
||||||
i <= cell -> num_col + cell -> applied_col_span ;
|
i <= cell -> num_col + cell -> applied_col_span ;
|
||||||
@@ -2093,7 +2116,7 @@ int TitleBlockTemplate::lengthRange(
|
|||||||
#endif
|
#endif
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int length = 0;
|
int length = 0;
|
||||||
for (int i = start ; i < end ; ++i) {
|
for (int i = start ; i < end ; ++i) {
|
||||||
length += lengths_list[i];
|
length += lengths_list[i];
|
||||||
|
|||||||
@@ -1,23 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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 "diagramcontextwidget.h"
|
#include "diagramcontextwidget.h"
|
||||||
#include "ui_diagramcontextwidget.h"
|
#include "ui_diagramcontextwidget.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
DiagramContextWidget::DiagramContextWidget(QWidget *parent) :
|
DiagramContextWidget::DiagramContextWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::DiagramContextWidget)
|
ui(new Ui::DiagramContextWidget)
|
||||||
@@ -38,7 +40,7 @@ DiagramContextWidget::~DiagramContextWidget()
|
|||||||
DiagramContext DiagramContextWidget::context() const
|
DiagramContext DiagramContextWidget::context() const
|
||||||
{
|
{
|
||||||
DiagramContext context;
|
DiagramContext context;
|
||||||
|
|
||||||
for (int i = 0 ; i < ui->m_table-> rowCount() ; ++ i)
|
for (int i = 0 ; i < ui->m_table-> rowCount() ; ++ i)
|
||||||
{
|
{
|
||||||
QTableWidgetItem *qtwi_name = ui->m_table-> item(i, 0);
|
QTableWidgetItem *qtwi_name = ui->m_table-> item(i, 0);
|
||||||
@@ -46,16 +48,16 @@ DiagramContext DiagramContextWidget::context() const
|
|||||||
if (!qtwi_name || !qtwi_value) {
|
if (!qtwi_name || !qtwi_value) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString key = qtwi_name -> text();
|
QString key = qtwi_name -> text();
|
||||||
if (key.isEmpty()) {
|
if (key.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString value = qtwi_value -> text();
|
QString value = qtwi_value -> text();
|
||||||
context.addValue(key, value);
|
context.addValue(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(context);
|
return(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +69,7 @@ DiagramContext DiagramContextWidget::context() const
|
|||||||
void DiagramContextWidget::setContext (const DiagramContext &context)
|
void DiagramContextWidget::setContext (const DiagramContext &context)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (QString key : context.keys(DiagramContext::Alphabetical))
|
for (QString key : context.keys(DiagramContext::Alphabetical))
|
||||||
{
|
{
|
||||||
@@ -75,7 +77,7 @@ void DiagramContextWidget::setContext (const DiagramContext &context)
|
|||||||
ui->m_table->setItem(i, 1, new QTableWidgetItem(context[key].toString()));
|
ui->m_table->setItem(i, 1, new QTableWidgetItem(context[key].toString()));
|
||||||
++ i;
|
++ i;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkTableRows();
|
checkTableRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +95,7 @@ int DiagramContextWidget::nameLessRowsCount() const
|
|||||||
++ name_less_rows_count;
|
++ name_less_rows_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(name_less_rows_count);
|
return(name_less_rows_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +109,7 @@ void DiagramContextWidget::clear()
|
|||||||
for (int i = 1 ; i < ui->m_table->rowCount() ; ++ i) {
|
for (int i = 1 ; i < ui->m_table->rowCount() ; ++ i) {
|
||||||
ui->m_table->removeRow(i);
|
ui->m_table->removeRow(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshFormatLabel();
|
refreshFormatLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,10 +120,10 @@ void DiagramContextWidget::clear()
|
|||||||
*/
|
*/
|
||||||
int DiagramContextWidget::highlightNonAcceptableKeys()
|
int DiagramContextWidget::highlightNonAcceptableKeys()
|
||||||
{
|
{
|
||||||
static QRegExp re(DiagramContext::validKeyRegExp());
|
static QRegularExpression re(DiagramContext::validKeyRegExp());
|
||||||
|
|
||||||
QBrush fg_brush = ui->m_table->palette().brush(QPalette::WindowText);
|
QBrush fg_brush = ui->m_table->palette().brush(QPalette::WindowText);
|
||||||
|
|
||||||
int invalid_keys = 0;
|
int invalid_keys = 0;
|
||||||
for (int i = 0 ; i < ui->m_table->rowCount() ; ++ i)
|
for (int i = 0 ; i < ui->m_table->rowCount() ; ++ i)
|
||||||
{
|
{
|
||||||
@@ -129,11 +131,11 @@ int DiagramContextWidget::highlightNonAcceptableKeys()
|
|||||||
if (!qtwi_name) {
|
if (!qtwi_name) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool highlight = false;
|
bool highlight = false;
|
||||||
if (!qtwi_name -> text().isEmpty())
|
if (!qtwi_name -> text().isEmpty())
|
||||||
{
|
{
|
||||||
if (!re.exactMatch(qtwi_name -> text()))
|
if (re!=QRegularExpression(qtwi_name -> text()))
|
||||||
{
|
{
|
||||||
highlight = true;
|
highlight = true;
|
||||||
++ invalid_keys;
|
++ invalid_keys;
|
||||||
@@ -141,7 +143,7 @@ int DiagramContextWidget::highlightNonAcceptableKeys()
|
|||||||
}
|
}
|
||||||
qtwi_name -> setForeground(highlight ? Qt::red : fg_brush);
|
qtwi_name -> setForeground(highlight ? Qt::red : fg_brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(invalid_keys);
|
return(invalid_keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +158,7 @@ void DiagramContextWidget::refreshFormatLabel()
|
|||||||
"Les noms ne peuvent contenir que des lettres minuscules, des "
|
"Les noms ne peuvent contenir que des lettres minuscules, des "
|
||||||
"chiffres et des tirets."
|
"chiffres et des tirets."
|
||||||
);
|
);
|
||||||
|
|
||||||
if (highlightNonAcceptableKeys()) {
|
if (highlightNonAcceptableKeys()) {
|
||||||
format_text = QString("<span style=\"color: red;\">%1</span>").arg(format_text);
|
format_text = QString("<span style=\"color: red;\">%1</span>").arg(format_text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#define DYNAMICELEMENTTEXTMODEL_H
|
#define DYNAMICELEMENTTEXTMODEL_H
|
||||||
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#include <qstyleditemdelegate.h>
|
#include <qstyleditemdelegate.h>
|
||||||
#include "dynamicelementtextitem.h"
|
#include "dynamicelementtextitem.h"
|
||||||
|
|
||||||
@@ -35,7 +37,7 @@ class Element;
|
|||||||
class DynamicElementTextModel : public QStandardItemModel
|
class DynamicElementTextModel : public QStandardItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ValueType {
|
enum ValueType {
|
||||||
textFrom =1,
|
textFrom =1,
|
||||||
@@ -58,10 +60,10 @@ class DynamicElementTextModel : public QStandardItemModel
|
|||||||
grpHoldBottom,
|
grpHoldBottom,
|
||||||
grpFrame
|
grpFrame
|
||||||
};
|
};
|
||||||
|
|
||||||
DynamicElementTextModel(Element *element, QObject *parent = nullptr);
|
DynamicElementTextModel(Element *element, QObject *parent = nullptr);
|
||||||
~DynamicElementTextModel() override;
|
~DynamicElementTextModel() override;
|
||||||
|
|
||||||
bool indexIsInGroup(const QModelIndex &index) const;
|
bool indexIsInGroup(const QModelIndex &index) const;
|
||||||
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
|
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
|
||||||
DynamicElementTextItem *textFromItem(QStandardItem *item) const;
|
DynamicElementTextItem *textFromItem(QStandardItem *item) const;
|
||||||
@@ -72,13 +74,13 @@ class DynamicElementTextModel : public QStandardItemModel
|
|||||||
QUndoCommand *undoForEditedGroup(
|
QUndoCommand *undoForEditedGroup(
|
||||||
ElementTextItemGroup *group,
|
ElementTextItemGroup *group,
|
||||||
QUndoCommand *parent_undo = nullptr) const;
|
QUndoCommand *parent_undo = nullptr) const;
|
||||||
|
|
||||||
ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const;
|
ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const;
|
||||||
ElementTextItemGroup *groupFromItem(QStandardItem *item) const;
|
ElementTextItemGroup *groupFromItem(QStandardItem *item) const;
|
||||||
QModelIndex indexFromGroup(ElementTextItemGroup *group) const;
|
QModelIndex indexFromGroup(ElementTextItemGroup *group) const;
|
||||||
bool indexIsText(const QModelIndex &index) const;
|
bool indexIsText(const QModelIndex &index) const;
|
||||||
bool indexIsGroup(const QModelIndex &index) const;
|
bool indexIsGroup(const QModelIndex &index) const;
|
||||||
|
|
||||||
bool canDropMimeData(
|
bool canDropMimeData(
|
||||||
const QMimeData *data,
|
const QMimeData *data,
|
||||||
Qt::DropAction action,
|
Qt::DropAction action,
|
||||||
@@ -93,10 +95,10 @@ class DynamicElementTextModel : public QStandardItemModel
|
|||||||
const QModelIndex &parent) override;
|
const QModelIndex &parent) override;
|
||||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||||
QStringList mimeTypes() const override;
|
QStringList mimeTypes() const override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataChanged();
|
void dataChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QStandardItem *> itemsForText(DynamicElementTextItem *deti);
|
QList<QStandardItem *> itemsForText(DynamicElementTextItem *deti);
|
||||||
void addText(DynamicElementTextItem *deti);
|
void addText(DynamicElementTextItem *deti);
|
||||||
@@ -119,7 +121,7 @@ class DynamicElementTextModel : public QStandardItemModel
|
|||||||
DynamicElementTextModel::ValueType type);
|
DynamicElementTextModel::ValueType type);
|
||||||
void updateDataFromGroup(ElementTextItemGroup *group,
|
void updateDataFromGroup(ElementTextItemGroup *group,
|
||||||
DynamicElementTextModel::ValueType type);
|
DynamicElementTextModel::ValueType type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<Element> m_element;
|
QPointer<Element> m_element;
|
||||||
QHash <DynamicElementTextItem *, QStandardItem *> m_texts_list;
|
QHash <DynamicElementTextItem *, QStandardItem *> m_texts_list;
|
||||||
@@ -134,10 +136,10 @@ class DynamicElementTextModel : public QStandardItemModel
|
|||||||
class DynamicTextItemDelegate : public QStyledItemDelegate
|
class DynamicTextItemDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
|
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
QWidget *createEditor(
|
QWidget *createEditor(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
const QStyleOptionViewItem &option,
|
const QStyleOptionViewItem &option,
|
||||||
@@ -146,10 +148,10 @@ class DynamicTextItemDelegate : public QStyledItemDelegate
|
|||||||
QWidget *editor,
|
QWidget *editor,
|
||||||
QAbstractItemModel *model,
|
QAbstractItemModel *model,
|
||||||
const QModelIndex &index) const override;
|
const QModelIndex &index) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *object, QEvent *event) override;
|
bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList availableInfo(DynamicElementTextItem *deti) const;
|
QStringList availableInfo(DynamicElementTextItem *deti) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
#ifndef LINKSINGLEELEMENTWIDGET_H
|
#ifndef LINKSINGLEELEMENTWIDGET_H
|
||||||
#define LINKSINGLEELEMENTWIDGET_H
|
#define LINKSINGLEELEMENTWIDGET_H
|
||||||
|
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
#include "abstractelementpropertieseditorwidget.h"
|
#include "abstractelementpropertieseditorwidget.h"
|
||||||
|
|
||||||
@@ -73,30 +75,30 @@ class LinkSingleElementWidget : public AbstractElementPropertiesEditorWidget
|
|||||||
void hideButtons();
|
void hideButtons();
|
||||||
void showButtons();
|
void showButtons();
|
||||||
void headerCustomContextMenuRequested(const QPoint &pos);
|
void headerCustomContextMenuRequested(const QPoint &pos);
|
||||||
|
|
||||||
void on_m_unlink_pb_clicked();
|
void on_m_unlink_pb_clicked();
|
||||||
void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||||
void on_m_tree_widget_customContextMenuRequested(const QPoint &pos);
|
void on_m_tree_widget_customContextMenuRequested(const QPoint &pos);
|
||||||
void on_m_show_linked_pb_clicked();
|
void on_m_show_linked_pb_clicked();
|
||||||
void on_m_show_this_pb_clicked();
|
void on_m_show_this_pb_clicked();
|
||||||
|
|
||||||
void on_m_search_field_textEdited(const QString &arg1);
|
void on_m_search_field_textEdited(const QString &arg1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::LinkSingleElementWidget *ui;
|
Ui::LinkSingleElementWidget *ui;
|
||||||
|
|
||||||
bool m_unlink = false;
|
bool m_unlink = false;
|
||||||
Element::kind m_filter;
|
Element::kind m_filter;
|
||||||
|
|
||||||
QHash <QTreeWidgetItem*, Element*> m_qtwi_elmt_hash;
|
QHash <QTreeWidgetItem*, Element*> m_qtwi_elmt_hash;
|
||||||
QHash <QTreeWidgetItem*, QStringList> m_qtwi_strl_hash;
|
QHash <QTreeWidgetItem*, QStringList> m_qtwi_strl_hash;
|
||||||
|
|
||||||
QTreeWidgetItem *m_qtwi_at_context_menu = nullptr,
|
QTreeWidgetItem *m_qtwi_at_context_menu = nullptr,
|
||||||
*m_pending_qtwi = nullptr;
|
*m_pending_qtwi = nullptr;
|
||||||
|
|
||||||
Element *m_showed_element = nullptr,
|
Element *m_showed_element = nullptr,
|
||||||
*m_element_to_link = nullptr;
|
*m_element_to_link = nullptr;
|
||||||
|
|
||||||
QMenu *m_context_menu;
|
QMenu *m_context_menu;
|
||||||
QAction *m_link_action,
|
QAction *m_link_action,
|
||||||
*m_show_qtwi,
|
*m_show_qtwi,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
#include "abstractelementpropertieseditorwidget.h"
|
#include "abstractelementpropertieseditorwidget.h"
|
||||||
|
|
||||||
class Element;
|
class Element;
|
||||||
|
|||||||
@@ -15,13 +15,16 @@
|
|||||||
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 <QSettings>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#include "multipastedialog.h"
|
#include "multipastedialog.h"
|
||||||
#include "ui_multipastedialog.h"
|
#include "ui_multipastedialog.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
#include "conductorautonumerotation.h"
|
#include "conductorautonumerotation.h"
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
MultiPasteDialog::MultiPasteDialog(Diagram *diagram, QWidget *parent) :
|
MultiPasteDialog::MultiPasteDialog(Diagram *diagram, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
@@ -29,16 +32,16 @@ MultiPasteDialog::MultiPasteDialog(Diagram *diagram, QWidget *parent) :
|
|||||||
m_diagram(diagram)
|
m_diagram(diagram)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
connect(ui->m_x_sb, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
|
connect(ui->m_x_sb, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
|
||||||
connect(ui->m_y_sb, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
|
connect(ui->m_y_sb, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
|
||||||
connect(ui->m_copy_count, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
|
connect(ui->m_copy_count, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
|
||||||
|
|
||||||
QRectF br;
|
QRectF br;
|
||||||
for (QGraphicsItem *item : m_diagram->selectedItems())
|
for (QGraphicsItem *item : m_diagram->selectedItems())
|
||||||
br = br.united(item->mapToScene(item->boundingRect()).boundingRect());
|
br = br.united(item->mapToScene(item->boundingRect()).boundingRect());
|
||||||
m_origin = br.topLeft();
|
m_origin = br.topLeft();
|
||||||
|
|
||||||
m_document = m_diagram->toXml(false);
|
m_document = m_diagram->toXml(false);
|
||||||
updatePreview();
|
updatePreview();
|
||||||
}
|
}
|
||||||
@@ -56,7 +59,7 @@ MultiPasteDialog::~MultiPasteDialog()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,20 +76,20 @@ void MultiPasteDialog::updatePreview()
|
|||||||
}
|
}
|
||||||
m_pasted_content.clear();
|
m_pasted_content.clear();
|
||||||
m_pasted_content_list.clear();
|
m_pasted_content_list.clear();
|
||||||
|
|
||||||
QPointF offset(ui->m_x_sb->value(), ui->m_y_sb->value());
|
QPointF offset(ui->m_x_sb->value(), ui->m_y_sb->value());
|
||||||
QPointF pos = m_origin+offset;
|
QPointF pos = m_origin+offset;
|
||||||
|
|
||||||
for(int i=0 ; i<ui->m_copy_count->value() ; i++)
|
for(int i=0 ; i<ui->m_copy_count->value() ; i++)
|
||||||
{
|
{
|
||||||
DiagramContent dc;
|
DiagramContent dc;
|
||||||
m_diagram->fromXml(m_document, pos, false, &dc);
|
m_diagram->fromXml(m_document, pos, false, &dc);
|
||||||
|
|
||||||
m_pasted_content += dc;
|
m_pasted_content += dc;
|
||||||
m_pasted_content_list << dc;
|
m_pasted_content_list << dc;
|
||||||
pos += offset;
|
pos += offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_pasted_content.count())
|
if(m_pasted_content.count())
|
||||||
m_diagram->adjustSceneRect();
|
m_diagram->adjustSceneRect();
|
||||||
}
|
}
|
||||||
@@ -96,7 +99,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
|||||||
if(m_pasted_content.count())
|
if(m_pasted_content.count())
|
||||||
{
|
{
|
||||||
m_diagram->undoStack().beginMacro(tr("Multi-collage"));
|
m_diagram->undoStack().beginMacro(tr("Multi-collage"));
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
bool erase_label = settings.value("diagramcommands/erase-label-on-copy", true).toBool();
|
bool erase_label = settings.value("diagramcommands/erase-label-on-copy", true).toBool();
|
||||||
//Ensure when 'auto_num' is checked, the settings 'save_label' is to true.
|
//Ensure when 'auto_num' is checked, the settings 'save_label' is to true.
|
||||||
@@ -105,18 +108,18 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
|||||||
//and so the auto_num below do nothing (there is not a formula to compare)
|
//and so the auto_num below do nothing (there is not a formula to compare)
|
||||||
if(ui->m_auto_num_cb->isChecked())
|
if(ui->m_auto_num_cb->isChecked())
|
||||||
settings.setValue("diagramcommands/erase-label-on-copy", false);
|
settings.setValue("diagramcommands/erase-label-on-copy", false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_diagram->clearSelection();
|
m_diagram->clearSelection();
|
||||||
m_diagram->undoStack().push(new PasteDiagramCommand(m_diagram, m_pasted_content));
|
m_diagram->undoStack().push(new PasteDiagramCommand(m_diagram, m_pasted_content));
|
||||||
|
|
||||||
for(DiagramContent dc : m_pasted_content_list)
|
for(DiagramContent dc : m_pasted_content_list)
|
||||||
{
|
{
|
||||||
QList<Element *> pasted_elements = dc.m_elements;
|
QList<Element *> pasted_elements = dc.m_elements;
|
||||||
//Sort the list element by there pos (top -> bottom)
|
//Sort the list element by there pos (top -> bottom)
|
||||||
std::sort(pasted_elements.begin(), pasted_elements.end(), [](Element *a, Element *b){return (a->pos().y() < b->pos().y());});
|
std::sort(pasted_elements.begin(), pasted_elements.end(), [](Element *a, Element *b){return (a->pos().y() < b->pos().y());});
|
||||||
|
|
||||||
//Auto-connection
|
//Auto-connection
|
||||||
if(ui->m_auto_connection_cb->isChecked())
|
if(ui->m_auto_connection_cb->isChecked())
|
||||||
{
|
{
|
||||||
@@ -125,10 +128,10 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
|||||||
while (!elmt->AlignedFreeTerminals().isEmpty())
|
while (!elmt->AlignedFreeTerminals().isEmpty())
|
||||||
{
|
{
|
||||||
QPair <Terminal *, Terminal *> pair = elmt->AlignedFreeTerminals().takeFirst();
|
QPair <Terminal *, Terminal *> pair = elmt->AlignedFreeTerminals().takeFirst();
|
||||||
|
|
||||||
Conductor *conductor = new Conductor(pair.first, pair.second);
|
Conductor *conductor = new Conductor(pair.first, pair.second);
|
||||||
m_diagram->undoStack().push(new AddItemCommand<Conductor *>(conductor, m_diagram, QPointF()));
|
m_diagram->undoStack().push(new AddItemCommand<Conductor *>(conductor, m_diagram, QPointF()));
|
||||||
|
|
||||||
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
|
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
|
||||||
ConductorAutoNumerotation can (conductor, m_diagram);
|
ConductorAutoNumerotation can (conductor, m_diagram);
|
||||||
can.numerate();
|
can.numerate();
|
||||||
@@ -138,7 +141,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set up the label of element
|
//Set up the label of element
|
||||||
//Instead of use the current autonum of project,
|
//Instead of use the current autonum of project,
|
||||||
//we try to fetch the same formula of the pasted element, in the several autonum of the project
|
//we try to fetch the same formula of the pasted element, in the several autonum of the project
|
||||||
@@ -152,7 +155,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
|||||||
{
|
{
|
||||||
QHash <QString, NumerotationContext> autonums = m_diagram->project()->elementAutoNum();
|
QHash <QString, NumerotationContext> autonums = m_diagram->project()->elementAutoNum();
|
||||||
QHashIterator<QString, NumerotationContext> hash_iterator(autonums);
|
QHashIterator<QString, NumerotationContext> hash_iterator(autonums);
|
||||||
|
|
||||||
while(hash_iterator.hasNext())
|
while(hash_iterator.hasNext())
|
||||||
{
|
{
|
||||||
hash_iterator.next();
|
hash_iterator.next();
|
||||||
@@ -167,7 +170,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
|||||||
}
|
}
|
||||||
//Like elements, we compare formula of pasted conductor with the autonums available in the project.
|
//Like elements, we compare formula of pasted conductor with the autonums available in the project.
|
||||||
if(ui->m_auto_num_cond_cb->isChecked())
|
if(ui->m_auto_num_cond_cb->isChecked())
|
||||||
{
|
{
|
||||||
//This list is to ensure we not numerate twice the same conductor
|
//This list is to ensure we not numerate twice the same conductor
|
||||||
QList<Conductor *> numerated;
|
QList<Conductor *> numerated;
|
||||||
//Start with the element at top
|
//Start with the element at top
|
||||||
@@ -184,7 +187,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
|||||||
{
|
{
|
||||||
QHash <QString, NumerotationContext> autonums = m_diagram->project()->conductorAutoNum();
|
QHash <QString, NumerotationContext> autonums = m_diagram->project()->conductorAutoNum();
|
||||||
QHashIterator <QString, NumerotationContext> hash_iterator(autonums);
|
QHashIterator <QString, NumerotationContext> hash_iterator(autonums);
|
||||||
|
|
||||||
while (hash_iterator.hasNext())
|
while (hash_iterator.hasNext())
|
||||||
{
|
{
|
||||||
hash_iterator.next();
|
hash_iterator.next();
|
||||||
@@ -205,7 +208,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_diagram->adjustSceneRect();
|
m_diagram->adjustSceneRect();
|
||||||
m_accept = true;
|
m_accept = true;
|
||||||
settings.setValue("diagramcommands/erase-label-on-copy", erase_label);
|
settings.setValue("diagramcommands/erase-label-on-copy", erase_label);
|
||||||
|
|||||||
@@ -15,11 +15,14 @@
|
|||||||
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 <QRadioButton>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#include "potentialselectordialog.h"
|
#include "potentialselectordialog.h"
|
||||||
#include "ui_potentialselectordialog.h"
|
#include "ui_potentialselectordialog.h"
|
||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include <QRadioButton>
|
|
||||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
@@ -191,14 +194,14 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList<ConductorPro
|
|||||||
} else if (list.size() == 1) {
|
} else if (list.size() == 1) {
|
||||||
return list.first();
|
return list.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog dialog(widget);
|
QDialog dialog(widget);
|
||||||
QVBoxLayout layout(widget);
|
QVBoxLayout layout(widget);
|
||||||
dialog.setLayout(&layout);
|
dialog.setLayout(&layout);
|
||||||
QLabel label(tr("Veuillez choisir un potentiel électrique de la liste \n"
|
QLabel label(tr("Veuillez choisir un potentiel électrique de la liste \n"
|
||||||
"à utiliser pour le nouveau potentiel"));
|
"à utiliser pour le nouveau potentiel"));
|
||||||
layout.addWidget(&label);
|
layout.addWidget(&label);
|
||||||
|
|
||||||
QHash <QRadioButton *, ConductorProperties> H;
|
QHash <QRadioButton *, ConductorProperties> H;
|
||||||
for (ConductorProperties cp : list)
|
for (ConductorProperties cp : list)
|
||||||
{
|
{
|
||||||
@@ -213,7 +216,7 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList<ConductorPro
|
|||||||
text.append(tr("\nCouleur du conducteur : %1").arg(cp.m_wire_color));
|
text.append(tr("\nCouleur du conducteur : %1").arg(cp.m_wire_color));
|
||||||
if(!cp.m_wire_section.isEmpty())
|
if(!cp.m_wire_section.isEmpty())
|
||||||
text.append(tr("\nSection du conducteur : %1").arg(cp.m_wire_section));
|
text.append(tr("\nSection du conducteur : %1").arg(cp.m_wire_section));
|
||||||
|
|
||||||
QRadioButton *b = new QRadioButton(text, &dialog);
|
QRadioButton *b = new QRadioButton(text, &dialog);
|
||||||
layout.addWidget(b);
|
layout.addWidget(b);
|
||||||
H.insert(b, cp);
|
H.insert(b, cp);
|
||||||
@@ -221,14 +224,14 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList<ConductorPro
|
|||||||
QDialogButtonBox *button_box = new QDialogButtonBox(QDialogButtonBox::Ok, &dialog);
|
QDialogButtonBox *button_box = new QDialogButtonBox(QDialogButtonBox::Ok, &dialog);
|
||||||
layout.addWidget(button_box);
|
layout.addWidget(button_box);
|
||||||
connect(button_box, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
connect(button_box, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
||||||
|
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
for (QRadioButton *b : H.keys()) {
|
for (QRadioButton *b : H.keys()) {
|
||||||
if(b->isChecked()) {
|
if(b->isChecked()) {
|
||||||
return H.value(b);
|
return H.value(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ConductorProperties();
|
return ConductorProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +293,7 @@ void PotentialSelectorDialog::buildWidget()
|
|||||||
QString text1(tr("%n conducteurs composent le potentiel suivant :",
|
QString text1(tr("%n conducteurs composent le potentiel suivant :",
|
||||||
"",
|
"",
|
||||||
m_potential_selector->m_conductor_number_1));
|
m_potential_selector->m_conductor_number_1));
|
||||||
|
|
||||||
ConductorProperties cp1;
|
ConductorProperties cp1;
|
||||||
if(!m_potential_selector->m_properties_list_1.isEmpty())
|
if(!m_potential_selector->m_properties_list_1.isEmpty())
|
||||||
cp1 = m_potential_selector->m_properties_list_1.first();;
|
cp1 = m_potential_selector->m_properties_list_1.first();;
|
||||||
@@ -308,14 +311,14 @@ void PotentialSelectorDialog::buildWidget()
|
|||||||
if(!cp1.m_wire_section.isEmpty())
|
if(!cp1.m_wire_section.isEmpty())
|
||||||
text1.append(tr("\nSection du conducteur : %1")
|
text1.append(tr("\nSection du conducteur : %1")
|
||||||
.arg(cp1.m_wire_section));
|
.arg(cp1.m_wire_section));
|
||||||
|
|
||||||
QString text2(tr("%n conducteurs composent le potentiel suivant :",
|
QString text2(tr("%n conducteurs composent le potentiel suivant :",
|
||||||
"",
|
"",
|
||||||
m_potential_selector->m_conductor_number_2));
|
m_potential_selector->m_conductor_number_2));
|
||||||
ConductorProperties cp2;
|
ConductorProperties cp2;
|
||||||
if(!m_potential_selector->m_properties_list_2.isEmpty())
|
if(!m_potential_selector->m_properties_list_2.isEmpty())
|
||||||
cp2 = m_potential_selector->m_properties_list_2.first();
|
cp2 = m_potential_selector->m_properties_list_2.first();
|
||||||
|
|
||||||
if(!cp2.text.isEmpty())
|
if(!cp2.text.isEmpty())
|
||||||
text2.append(tr("\nNuméro : %1").arg(cp2.text));
|
text2.append(tr("\nNuméro : %1").arg(cp2.text));
|
||||||
if(!cp2.m_function.isEmpty())
|
if(!cp2.m_function.isEmpty())
|
||||||
@@ -329,7 +332,7 @@ void PotentialSelectorDialog::buildWidget()
|
|||||||
if(!cp2.m_wire_section.isEmpty())
|
if(!cp2.m_wire_section.isEmpty())
|
||||||
text2.append(tr("\nSection du conducteur : %1")
|
text2.append(tr("\nSection du conducteur : %1")
|
||||||
.arg(cp2.m_wire_section));
|
.arg(cp2.m_wire_section));
|
||||||
|
|
||||||
QRadioButton *rb1 = new QRadioButton(text1, this);
|
QRadioButton *rb1 = new QRadioButton(text1, this);
|
||||||
QRadioButton *rb2 = new QRadioButton(text2, this);
|
QRadioButton *rb2 = new QRadioButton(text2, this);
|
||||||
|
|
||||||
@@ -429,7 +432,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
|||||||
new_value,
|
new_value,
|
||||||
undo);
|
undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if formula of the new potential
|
//Check if formula of the new potential
|
||||||
// have incompatible variable with folio report
|
// have incompatible variable with folio report
|
||||||
QRegularExpression rx ("%sequf_|%seqtf_|%seqhf_|%id|%F|%M|%LM");
|
QRegularExpression rx ("%sequf_|%seqtf_|%seqhf_|%id|%F|%M|%LM");
|
||||||
@@ -445,7 +448,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
|||||||
<< "%F"
|
<< "%F"
|
||||||
<< "%M"
|
<< "%M"
|
||||||
<< "%LM";
|
<< "%LM";
|
||||||
|
|
||||||
QString text(tr("La formule du nouveau potentiel contient des variables incompatibles avec les reports de folio.\n"
|
QString text(tr("La formule du nouveau potentiel contient des variables incompatibles avec les reports de folio.\n"
|
||||||
"Veuillez saisir une formule compatible pour ce potentiel.\n"
|
"Veuillez saisir une formule compatible pour ce potentiel.\n"
|
||||||
"Les variables suivantes sont incompatibles :\n"
|
"Les variables suivantes sont incompatibles :\n"
|
||||||
@@ -455,7 +458,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
|||||||
fag.setText(text);
|
fag.setText(text);
|
||||||
fag.setFormula(cp.m_formula);
|
fag.setFormula(cp.m_formula);
|
||||||
fag.exec();
|
fag.exec();
|
||||||
|
|
||||||
QString new_formula = fag.formula();
|
QString new_formula = fag.formula();
|
||||||
QSet <Conductor *> c_list = m_report->conductors().first()->relatedPotentialConductors();
|
QSet <Conductor *> c_list = m_report->conductors().first()->relatedPotentialConductors();
|
||||||
c_list.insert(m_report->conductors().first());
|
c_list.insert(m_report->conductors().first());
|
||||||
@@ -471,7 +474,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
|||||||
new_value,
|
new_value,
|
||||||
undo);
|
undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
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 <QHash>
|
||||||
|
|
||||||
#include "shapegraphicsitempropertieswidget.h"
|
#include "shapegraphicsitempropertieswidget.h"
|
||||||
#include "ui_shapegraphicsitempropertieswidget.h"
|
#include "ui_shapegraphicsitempropertieswidget.h"
|
||||||
#include "qetshapeitem.h"
|
#include "qetshapeitem.h"
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
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 "xrefpropertieswidget.h"
|
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <QHash>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
|
||||||
|
#include "xrefpropertieswidget.h"
|
||||||
#include "ui_xrefpropertieswidget.h"
|
#include "ui_xrefpropertieswidget.h"
|
||||||
#include "qdebug.h"
|
#include "qdebug.h"
|
||||||
#include <QMetaEnum>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief XRefPropertiesWidget::XRefPropertiesWidget
|
@brief XRefPropertiesWidget::XRefPropertiesWidget
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#define XREFPROPERTIESWIDGET_H
|
#define XREFPROPERTIESWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#include "properties/xrefproperties.h"
|
#include "properties/xrefproperties.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <QUndoCommand>
|
#include <QUndoCommand>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
class Element;
|
class Element;
|
||||||
class DynamicElementTextItem;
|
class DynamicElementTextItem;
|
||||||
@@ -37,10 +38,10 @@ class AddElementTextCommand : public QUndoCommand
|
|||||||
DynamicElementTextItem *deti,
|
DynamicElementTextItem *deti,
|
||||||
QUndoCommand *parent = nullptr);
|
QUndoCommand *parent = nullptr);
|
||||||
~AddElementTextCommand() override;
|
~AddElementTextCommand() override;
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Element *m_element = nullptr;
|
Element *m_element = nullptr;
|
||||||
DynamicElementTextItem *m_text = nullptr;
|
DynamicElementTextItem *m_text = nullptr;
|
||||||
@@ -64,10 +65,10 @@ class AddTextsGroupCommand : public QUndoCommand
|
|||||||
QList<DynamicElementTextItem *> texts_list,
|
QList<DynamicElementTextItem *> texts_list,
|
||||||
QUndoCommand *parent = nullptr);
|
QUndoCommand *parent = nullptr);
|
||||||
~AddTextsGroupCommand() override;
|
~AddTextsGroupCommand() override;
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<Element> m_element;
|
QPointer<Element> m_element;
|
||||||
QPointer<ElementTextItemGroup> m_group;
|
QPointer<ElementTextItemGroup> m_group;
|
||||||
@@ -88,10 +89,10 @@ class RemoveTextsGroupCommand : public QUndoCommand
|
|||||||
ElementTextItemGroup *group,
|
ElementTextItemGroup *group,
|
||||||
QUndoCommand *parent = nullptr);
|
QUndoCommand *parent = nullptr);
|
||||||
~RemoveTextsGroupCommand() override;
|
~RemoveTextsGroupCommand() override;
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<Element> m_element;
|
QPointer<Element> m_element;
|
||||||
QPointer<ElementTextItemGroup> m_group;
|
QPointer<ElementTextItemGroup> m_group;
|
||||||
@@ -108,10 +109,10 @@ class AddTextToGroupCommand : public QUndoCommand
|
|||||||
ElementTextItemGroup *group,
|
ElementTextItemGroup *group,
|
||||||
QUndoCommand *parent = nullptr);
|
QUndoCommand *parent = nullptr);
|
||||||
~AddTextToGroupCommand() override;
|
~AddTextToGroupCommand() override;
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<DynamicElementTextItem> m_text;
|
QPointer<DynamicElementTextItem> m_text;
|
||||||
QPointer<ElementTextItemGroup> m_group;
|
QPointer<ElementTextItemGroup> m_group;
|
||||||
@@ -128,10 +129,10 @@ class RemoveTextFromGroupCommand : public QUndoCommand
|
|||||||
ElementTextItemGroup *group,
|
ElementTextItemGroup *group,
|
||||||
QUndoCommand *parent = nullptr);
|
QUndoCommand *parent = nullptr);
|
||||||
~RemoveTextFromGroupCommand() override;
|
~RemoveTextFromGroupCommand() override;
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<DynamicElementTextItem> m_text;
|
QPointer<DynamicElementTextItem> m_text;
|
||||||
QPointer<ElementTextItemGroup> m_group;
|
QPointer<ElementTextItemGroup> m_group;
|
||||||
@@ -148,12 +149,12 @@ class AlignmentTextsGroupCommand : public QUndoCommand
|
|||||||
Qt::Alignment new_alignment,
|
Qt::Alignment new_alignment,
|
||||||
QUndoCommand *parent = nullptr);
|
QUndoCommand *parent = nullptr);
|
||||||
~AlignmentTextsGroupCommand() override;
|
~AlignmentTextsGroupCommand() override;
|
||||||
|
|
||||||
int id() const override{return 6;}
|
int id() const override{return 6;}
|
||||||
bool mergeWith(const QUndoCommand *other) override;
|
bool mergeWith(const QUndoCommand *other) override;
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<ElementTextItemGroup> m_group;
|
QPointer<ElementTextItemGroup> m_group;
|
||||||
Qt::Alignment m_previous_alignment,
|
Qt::Alignment m_previous_alignment,
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
#define DELETEQGRAPHICSITEMCOMMAND_H
|
#define DELETEQGRAPHICSITEMCOMMAND_H
|
||||||
|
|
||||||
#include <QUndoCommand>
|
#include <QUndoCommand>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#include "diagramcontent.h"
|
#include "diagramcontent.h"
|
||||||
|
|
||||||
class Diagram;
|
class Diagram;
|
||||||
@@ -32,17 +34,17 @@ class DeleteQGraphicsItemCommand : public QUndoCommand
|
|||||||
public:
|
public:
|
||||||
DeleteQGraphicsItemCommand(Diagram *diagram, const DiagramContent &content, QUndoCommand * parent = nullptr);
|
DeleteQGraphicsItemCommand(Diagram *diagram, const DiagramContent &content, QUndoCommand * parent = nullptr);
|
||||||
~DeleteQGraphicsItemCommand() override;
|
~DeleteQGraphicsItemCommand() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DeleteQGraphicsItemCommand(const DeleteQGraphicsItemCommand &);
|
DeleteQGraphicsItemCommand(const DeleteQGraphicsItemCommand &);
|
||||||
|
|
||||||
void setPotentialsOfRemovedElements();
|
void setPotentialsOfRemovedElements();
|
||||||
Terminal *terminalInSamePotential(Terminal *terminal, Conductor *conductor_to_exclude);
|
Terminal *terminalInSamePotential(Terminal *terminal, Conductor *conductor_to_exclude);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
DiagramContent m_removed_contents;
|
DiagramContent m_removed_contents;
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 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/>.
|
||||||
*/
|
*/
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QUndoCommand>
|
#include <QUndoCommand>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class ConductorTextItem;
|
class ConductorTextItem;
|
||||||
@@ -35,16 +36,16 @@ class RotateSelectionCommand : public QUndoCommand
|
|||||||
RotateSelectionCommand(Diagram *diagram, qreal angle=90, QUndoCommand *parent=nullptr);
|
RotateSelectionCommand(Diagram *diagram, qreal angle=90, QUndoCommand *parent=nullptr);
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
bool isValid();
|
bool isValid();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Diagram *m_diagram =nullptr;
|
Diagram *m_diagram =nullptr;
|
||||||
|
|
||||||
QList<QPointer<ConductorTextItem>> m_cond_text;
|
QList<QPointer<ConductorTextItem>> m_cond_text;
|
||||||
QHash<ConductorTextItem *, bool> m_rotate_by_user;
|
QHash<ConductorTextItem *, bool> m_rotate_by_user;
|
||||||
QList<QPropertyUndoCommand*> m_undo;
|
QList<QPropertyUndoCommand*> m_undo;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ROTATESELECTIONCOMMAND_H
|
#endif // ROTATESELECTIONCOMMAND_H
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QUndoCommand>
|
#include <QUndoCommand>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
class ConductorTextItem;
|
class ConductorTextItem;
|
||||||
class Diagram;
|
class Diagram;
|
||||||
@@ -34,14 +35,14 @@ class RotateTextsCommand : public QUndoCommand
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RotateTextsCommand(Diagram *diagram, QUndoCommand *parent=nullptr);
|
RotateTextsCommand(Diagram *diagram, QUndoCommand *parent=nullptr);
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void openDialog();
|
void openDialog();
|
||||||
void setupAnimation(QObject *target, const QByteArray &propertyName, const QVariant& start, const QVariant& end);
|
void setupAnimation(QObject *target, const QByteArray &propertyName, const QVariant& start, const QVariant& end);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<Diagram> m_diagram;
|
QPointer<Diagram> m_diagram;
|
||||||
QHash<ConductorTextItem *, bool> m_cond_texts;
|
QHash<ConductorTextItem *, bool> m_cond_texts;
|
||||||
|
|||||||
Reference in New Issue
Block a user