mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-05-03 03:49:59 +02:00
Compare commits
46 Commits
0.9.0
...
7e5d41b474
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e5d41b474 | ||
|
|
f0ec416a91 | ||
|
|
f6ba47277d | ||
|
|
74b55f3bf5 | ||
|
|
a121fbe530 | ||
|
|
a2ae8255ac | ||
|
|
d711d8fb4a | ||
|
|
3a6b4807db | ||
|
|
d699faf501 | ||
|
|
95e401a266 | ||
|
|
2c1b840f9c | ||
|
|
2d89d70682 | ||
|
|
7747223dfa | ||
|
|
ae5e188866 | ||
|
|
4ca0bbf682 | ||
|
|
258bfd7957 | ||
|
|
b422d9c6c5 | ||
|
|
12b7c7c47c | ||
|
|
8ca1e0487e | ||
|
|
48f9ef7632 | ||
|
|
752fe032e7 | ||
|
|
45b8cb34f3 | ||
|
|
470e4a059b | ||
|
|
d3223c8ca4 | ||
|
|
b1f6b1823a | ||
|
|
1e2bdc203b | ||
|
|
f75f6d3f3f | ||
|
|
f07e4319d3 | ||
|
|
d5f0a7932a | ||
|
|
4da7f6cd13 | ||
|
|
c6739b5bec | ||
|
|
cc7e185d59 | ||
|
|
60ceab8a32 | ||
|
|
539e0a7a49 | ||
|
|
f54bea713e | ||
|
|
f41b5a4ed4 | ||
|
|
1f99a40f1b | ||
|
|
d23a5bbdc7 | ||
|
|
81640015e5 | ||
|
|
a18cd2461f | ||
|
|
aca3b8ad1e | ||
|
|
9e1ef8c42f | ||
|
|
7fede2277f | ||
|
|
21de926367 | ||
|
|
ff80453f2c | ||
|
|
d9a0b03e23 |
51
ChangeLog
51
ChangeLog
@@ -1,3 +1,54 @@
|
|||||||
|
====== ChangeLog from 0.8 to 0.9 ======
|
||||||
|
|
||||||
|
|
||||||
|
*Diagram editor :
|
||||||
|
Improved QElectroTech speed (launch qet, open project, function)
|
||||||
|
A drop-down list has been added to the toolbar to change the size of the resize handles.
|
||||||
|
|
||||||
|
|
||||||
|
*Element Editor:
|
||||||
|
The "keep visual rotation" property of element texts is editable from the element editor.
|
||||||
|
Thanks to the work of antonioaja it is now possible to import a dxf directly from the element editor in a completely transparent way for the user.
|
||||||
|
In the background QElectroTech uses the dxf2elmt software. https://qelectrotech.org/forum/viewtopic.php?id=2265 https://github.com/antonioaja/dxf2elmt
|
||||||
|
Improved responsiveness when multiple shapes are selected or deleted, especially when working on a large converted DXF element.
|
||||||
|
https://qelectrotech.org/forum/viewtopic.php?pid=16612#p16612
|
||||||
|
|
||||||
|
*Other:
|
||||||
|
Add a "side project" tab in the "about" window.
|
||||||
|
In the general QElectroTech configuration, a drop down list allows to choose the scaling method for hdpi screens.
|
||||||
|
Allow open polygons (i.e. polylines) when saving in dxf format.
|
||||||
|
https://qelectrotech.org/forum/viewtopic.php?pid=16611#p16611
|
||||||
|
|
||||||
|
Added 'Other' option for slave device contact type.
|
||||||
|
https://github.com/qelectrotech/qelectrotech-source-mirror/pull/222
|
||||||
|
https://qelectrotech.org/forum/viewtopic.php?id=2264
|
||||||
|
|
||||||
|
*Logs:
|
||||||
|
|
||||||
|
Added a QElapsedTimer to calculate the time used to reload the item collection.
|
||||||
|
Improved QElapsedTimer to calculate the time used to reload the item collection in seconds instead of ms.
|
||||||
|
Added Linux pc.gpu.RAM information, but requires mesa-utils dependency on the Linux OS.
|
||||||
|
Added information about mounted disk volumes.
|
||||||
|
Added CPU architecture for which Qt was compiled in the aboutqetdialog widget and in the logs.
|
||||||
|
Added MSVC support to MachineInfo.
|
||||||
|
Added RAM information on Windows of available RAM.
|
||||||
|
Added QElectroTech version to the log file.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* Elements collection :
|
||||||
|
Improve collection 8274 elements in 1097 categories (i.e. 9371 files).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* macOS :
|
||||||
|
Fix sqlite3 database export on macOS, now I use macports with Digikam scripts instead off Homebrew Package Manager.
|
||||||
|
See: https://invent.kde.org/graphics/digikam/-/tree/master/project/bundles/macports
|
||||||
|
|
||||||
|
|
||||||
|
*Bug fix:
|
||||||
|
see: https://git.tuxfamily.org/qet/qet.git/log/?h=0.8.1
|
||||||
|
|
||||||
====== ChangeLog from 0.7 to 0.8 ======
|
====== ChangeLog from 0.7 to 0.8 ======
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ DiagramImageItem + 1007
|
|||||||
QetShapItem + 1008
|
QetShapItem + 1008
|
||||||
crossRefItem + 1009
|
crossRefItem + 1009
|
||||||
DynamiqueElementTextItem + 1010
|
DynamiqueElementTextItem + 1010
|
||||||
|
TerminalStripItem +1011
|
||||||
ElementPrimitiveDecorator + 2200
|
ElementPrimitiveDecorator + 2200
|
||||||
|
|
||||||
###ELEMENT EDITOR###
|
###ELEMENT EDITOR###
|
||||||
|
|||||||
@@ -126,7 +126,9 @@ INCLUDEPATH += sources/ui
|
|||||||
# sources/print
|
# sources/print
|
||||||
|
|
||||||
# Fichiers sources
|
# Fichiers sources
|
||||||
HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) \
|
HEADERS += $$files(sources/*.h) \
|
||||||
|
$$files(sources/project/*.h) \
|
||||||
|
$$files(sources/ui/*.h) \
|
||||||
$$files(sources/editor/*.h) \
|
$$files(sources/editor/*.h) \
|
||||||
$$files(sources/titleblock/*.h) \
|
$$files(sources/titleblock/*.h) \
|
||||||
$$files(sources/richtext/*.h) \
|
$$files(sources/richtext/*.h) \
|
||||||
@@ -159,11 +161,17 @@ HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) \
|
|||||||
$$files(sources/print/*.h) \
|
$$files(sources/print/*.h) \
|
||||||
$$files(sources/TerminalStrip/*.h) \
|
$$files(sources/TerminalStrip/*.h) \
|
||||||
$$files(sources/TerminalStrip/ui/*.h) \
|
$$files(sources/TerminalStrip/ui/*.h) \
|
||||||
|
$$files(sources/TerminalStrip/ui/ConfigPage/*h) \
|
||||||
$$files(sources/TerminalStrip/UndoCommand/*.h) \
|
$$files(sources/TerminalStrip/UndoCommand/*.h) \
|
||||||
$$files(sources/dxf/*.h)
|
$$files(sources/TerminalStrip/GraphicsItem/*.h) \
|
||||||
|
$$files(sources/TerminalStrip/GraphicsItem/properties/*.h) \
|
||||||
|
$$files(sources/xml/*.h) \
|
||||||
|
$$files(sources/dxf/*.h) \
|
||||||
|
$$files(sources/svg/*.h)
|
||||||
|
|
||||||
SOURCES += $$files(sources/*.cpp) \
|
SOURCES += $$files(sources/*.cpp) \
|
||||||
$$files(sources/editor/*.cpp) \
|
$$files(sources/editor/*.cpp) \
|
||||||
|
$$files(sources/project/*.cpp) \
|
||||||
$$files(sources/titleblock/*.cpp) \
|
$$files(sources/titleblock/*.cpp) \
|
||||||
$$files(sources/richtext/*.cpp) \
|
$$files(sources/richtext/*.cpp) \
|
||||||
$$files(sources/ui/*.cpp) \
|
$$files(sources/ui/*.cpp) \
|
||||||
@@ -196,8 +204,13 @@ SOURCES += $$files(sources/*.cpp) \
|
|||||||
$$files(sources/print/*.cpp) \
|
$$files(sources/print/*.cpp) \
|
||||||
$$files(sources/TerminalStrip/*.cpp) \
|
$$files(sources/TerminalStrip/*.cpp) \
|
||||||
$$files(sources/TerminalStrip/ui/*.cpp) \
|
$$files(sources/TerminalStrip/ui/*.cpp) \
|
||||||
|
$$files(sources/TerminalStrip/ui/ConfigPage/*cpp) \
|
||||||
$$files(sources/TerminalStrip/UndoCommand/*.cpp) \
|
$$files(sources/TerminalStrip/UndoCommand/*.cpp) \
|
||||||
$$files(sources/dxf/*.cpp)
|
$$files(sources/TerminalStrip/GraphicsItem/*.cpp) \
|
||||||
|
$$files(sources/TerminalStrip/GraphicsItem/properties/*.cpp) \
|
||||||
|
$$files(sources/xml/*.cpp) \
|
||||||
|
$$files(sources/dxf/*.cpp) \
|
||||||
|
$$files(sources/svg/*.cpp)
|
||||||
|
|
||||||
# Needed for use promote QTreeWidget in terminalstripeditor.ui
|
# Needed for use promote QTreeWidget in terminalstripeditor.ui
|
||||||
INCLUDEPATH += sources/TerminalStrip/ui
|
INCLUDEPATH += sources/TerminalStrip/ui
|
||||||
@@ -227,7 +240,8 @@ FORMS += $$files(sources/richtext/*.ui) \
|
|||||||
$$files(sources/dataBase/ui/*.ui) \
|
$$files(sources/dataBase/ui/*.ui) \
|
||||||
$$files(sources/factory/ui/*.ui) \
|
$$files(sources/factory/ui/*.ui) \
|
||||||
$$files(sources/print/*.ui) \
|
$$files(sources/print/*.ui) \
|
||||||
$$files(sources/TerminalStrip/ui/*.ui)
|
$$files(sources/TerminalStrip/ui/*.ui) \
|
||||||
|
$$files(sources/TerminalStrip/ui/ConfigPage/*.ui)
|
||||||
|
|
||||||
UI_SOURCES_DIR = sources/ui/
|
UI_SOURCES_DIR = sources/ui/
|
||||||
UI_HEADERS_DIR = sources/ui/
|
UI_HEADERS_DIR = sources/ui/
|
||||||
@@ -289,7 +303,7 @@ man.extra = sh man/compress_man_pages.sh
|
|||||||
INSTALLS += target elements tbt lang copyright
|
INSTALLS += target elements tbt lang copyright
|
||||||
# Sous Unix, on installe egalement l'icone, un fichier .desktop, des fichiers mime et les pages de manuel
|
# Sous Unix, on installe egalement l'icone, un fichier .desktop, des fichiers mime et les pages de manuel
|
||||||
unix {
|
unix {
|
||||||
INSTALLS += desktop mime_xml mime_desktop mime_package icons man examples appdata
|
INSTALLS += desktop mime_package icons man examples appdata
|
||||||
}
|
}
|
||||||
|
|
||||||
# Options de compilation communes a Unix et MacOS X
|
# Options de compilation communes a Unix et MacOS X
|
||||||
|
|||||||
@@ -84,6 +84,39 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
|
|||||||
0x006C,
|
0x006C,
|
||||||
0x0065,
|
0x0065,
|
||||||
0x0072};
|
0x0072};
|
||||||
|
const QChar ukrainian_data[20] = {
|
||||||
|
0x0406,
|
||||||
|
0x043c,
|
||||||
|
0x043f,
|
||||||
|
0x043e,
|
||||||
|
0x0440,
|
||||||
|
0x0442,
|
||||||
|
0x043e,
|
||||||
|
0x0432,
|
||||||
|
0x0430,
|
||||||
|
0x043d,
|
||||||
|
0x0456,
|
||||||
|
0x0020,
|
||||||
|
0x0435,
|
||||||
|
0x043b,
|
||||||
|
0x0435,
|
||||||
|
0x043c,
|
||||||
|
0x0435,
|
||||||
|
0x043d,
|
||||||
|
0x0442,
|
||||||
|
0x0438};
|
||||||
|
const QChar japanese_data[10] = {
|
||||||
|
0x30A4,
|
||||||
|
0x30F3,
|
||||||
|
0x30D0,
|
||||||
|
0x30FC,
|
||||||
|
0x30C8,
|
||||||
|
0x3055,
|
||||||
|
0x308C,
|
||||||
|
0x305F,
|
||||||
|
0x8981,
|
||||||
|
0x7D20};
|
||||||
|
|
||||||
names.addName("fr", "Éléments importés");
|
names.addName("fr", "Éléments importés");
|
||||||
names.addName("en", "Imported elements");
|
names.addName("en", "Imported elements");
|
||||||
names.addName("de", "Importierte elemente");
|
names.addName("de", "Importierte elemente");
|
||||||
@@ -100,8 +133,9 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
|
|||||||
names.addName("ro", "Elemente importate");
|
names.addName("ro", "Elemente importate");
|
||||||
names.addName("tr", QString(turkish_data, 12));
|
names.addName("tr", QString(turkish_data, 12));
|
||||||
names.addName("da", "Importerede elementer");
|
names.addName("da", "Importerede elementer");
|
||||||
names.addName("hr", "Uvezeni elementi");
|
|
||||||
names.addName("sl", "Uvoženi elementi");
|
names.addName("sl", "Uvoženi elementi");
|
||||||
|
names.addName("ja", QString(japanese_data, 10));
|
||||||
|
names.addName("uk", QString(ukrainian_data, 20));
|
||||||
#else
|
#else
|
||||||
# if TODO_LIST
|
# if TODO_LIST
|
||||||
# pragma message("@TODO remove code for QT 6 or later")
|
# pragma message("@TODO remove code for QT 6 or later")
|
||||||
@@ -120,8 +154,8 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
|
|||||||
names.addName("ca", "Elements importats");
|
names.addName("ca", "Elements importats");
|
||||||
names.addName("ro", "Elemente importate");
|
names.addName("ro", "Elemente importate");
|
||||||
names.addName("da", "Importerede elementer");
|
names.addName("da", "Importerede elementer");
|
||||||
names.addName("hr", "Uvezeni elementi");
|
|
||||||
names.addName("sl", "Uvoženi elementi");
|
names.addName("sl", "Uvoženi elementi");
|
||||||
|
names.addName("uk", "Імпортовані елементи");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import.appendChild(names.toXml(m_dom_document));
|
import.appendChild(names.toXml(m_dom_document));
|
||||||
|
|||||||
170
sources/TerminalStrip/GraphicsItem/demoterminalstrip.cpp
Normal file
170
sources/TerminalStrip/GraphicsItem/demoterminalstrip.cpp
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "demoterminalstrip.h"
|
||||||
|
|
||||||
|
namespace TerminalStripDrawer
|
||||||
|
{
|
||||||
|
|
||||||
|
/*========= DemoBridge =========*/
|
||||||
|
class DemoBridge : public AbstractBridgeInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DemoBridge(const QUuid &uuid) :
|
||||||
|
m_uuid { uuid } {}
|
||||||
|
|
||||||
|
QUuid uuid() const override {
|
||||||
|
return m_uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const QUuid m_uuid;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DemoRealTerminal : public AbstractRealTerminalInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DemoRealTerminal(const QString &label, const QString &xref, const QUuid &bridge) :
|
||||||
|
m_label { label },
|
||||||
|
m_xref{ xref },
|
||||||
|
m_bridge { bridge }
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString label() const override {
|
||||||
|
return m_label;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isBridged() const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DemoBridge *bridge() const override {
|
||||||
|
return new DemoBridge { m_bridge };
|
||||||
|
}
|
||||||
|
|
||||||
|
QString xref() const override {
|
||||||
|
return m_xref;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_label, m_xref;
|
||||||
|
QUuid m_bridge;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DemoPhysicalTerminal : public AbstractPhysicalTerminalInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DemoPhysicalTerminal(QVector<QSharedPointer<AbstractRealTerminalInterface>> real_terminals) :
|
||||||
|
m_real_terminals { real_terminals}
|
||||||
|
{}
|
||||||
|
|
||||||
|
QVector<QSharedPointer<AbstractRealTerminalInterface>> realTerminals() const override {
|
||||||
|
return m_real_terminals;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<QSharedPointer<AbstractRealTerminalInterface>> m_real_terminals;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*========= DemoTerminalStrip =========*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DemoTerminalStrip::DemoTerminalStrip
|
||||||
|
*/
|
||||||
|
DemoTerminalStrip::DemoTerminalStrip()
|
||||||
|
{
|
||||||
|
build();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<QSharedPointer<AbstractPhysicalTerminalInterface> > DemoTerminalStrip::physicalTerminal() const
|
||||||
|
{
|
||||||
|
return m_physical_terminal;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemoTerminalStrip::build()
|
||||||
|
{
|
||||||
|
QUuid lvl_1 = QUuid::createUuid();
|
||||||
|
QUuid lvl_2 = QUuid::createUuid();
|
||||||
|
QUuid lvl_3 = QUuid::createUuid();
|
||||||
|
QUuid lvl_4 = QUuid::createUuid();
|
||||||
|
|
||||||
|
QVector <QSharedPointer<AbstractRealTerminalInterface>> real_terminals_vector;
|
||||||
|
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("24vdc"),
|
||||||
|
QStringLiteral("1_A1"),
|
||||||
|
lvl_1)};
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("0vdc"),
|
||||||
|
QStringLiteral("1_A2"),
|
||||||
|
lvl_2)};
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("signal"),
|
||||||
|
QStringLiteral("1_A3"),
|
||||||
|
lvl_3)};
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("teach"),
|
||||||
|
QStringLiteral("1_A4"),
|
||||||
|
lvl_4)};
|
||||||
|
m_physical_terminal << QSharedPointer<AbstractPhysicalTerminalInterface> {
|
||||||
|
new DemoPhysicalTerminal {real_terminals_vector}};
|
||||||
|
|
||||||
|
real_terminals_vector.clear();
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("24vdc"),
|
||||||
|
QStringLiteral("2_A1"),
|
||||||
|
lvl_1)};
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("0vdc"),
|
||||||
|
QStringLiteral("2_A2"),
|
||||||
|
lvl_2)};
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("signal"),
|
||||||
|
QStringLiteral("2_A3"),
|
||||||
|
lvl_3)};
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("teach"),
|
||||||
|
QStringLiteral("2_A4"),
|
||||||
|
lvl_4)};
|
||||||
|
m_physical_terminal << QSharedPointer<AbstractPhysicalTerminalInterface> {
|
||||||
|
new DemoPhysicalTerminal {real_terminals_vector}};
|
||||||
|
|
||||||
|
|
||||||
|
real_terminals_vector.clear();
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("24vdc"),
|
||||||
|
QStringLiteral("3_A1"),
|
||||||
|
lvl_1)};
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("0vdc"),
|
||||||
|
QStringLiteral("3_A2"),
|
||||||
|
lvl_2)};
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("signal"),
|
||||||
|
QStringLiteral("3_A3"),
|
||||||
|
lvl_3)};
|
||||||
|
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
|
||||||
|
new DemoRealTerminal( QStringLiteral("teach"),
|
||||||
|
QStringLiteral("3_A4"),
|
||||||
|
lvl_4)};
|
||||||
|
m_physical_terminal << QSharedPointer<AbstractPhysicalTerminalInterface> {
|
||||||
|
new DemoPhysicalTerminal {real_terminals_vector}};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
50
sources/TerminalStrip/GraphicsItem/demoterminalstrip.h
Normal file
50
sources/TerminalStrip/GraphicsItem/demoterminalstrip.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef DEMOTERMINALSTRIP_H
|
||||||
|
#define DEMOTERMINALSTRIP_H
|
||||||
|
|
||||||
|
#include "terminalstripdrawer.h"
|
||||||
|
|
||||||
|
namespace TerminalStripDrawer {
|
||||||
|
|
||||||
|
class DemoTerminalStrip : public AbstractTerminalStripInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DemoTerminalStrip();
|
||||||
|
|
||||||
|
QString installation() const override {
|
||||||
|
return QStringLiteral("=INST");
|
||||||
|
}
|
||||||
|
QString location() const override {
|
||||||
|
return QStringLiteral("+LOC" );
|
||||||
|
}
|
||||||
|
QString name() const override {
|
||||||
|
return QStringLiteral("X1");
|
||||||
|
}
|
||||||
|
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> physicalTerminal() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void build();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> m_physical_terminal;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //End namespace TerminalStripDrawer
|
||||||
|
|
||||||
|
#endif // DEMOTERMINALSTRIP_H
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2022 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "terminalstriplayoutpattern.h"
|
||||||
|
#include "../../../utils/qetutils.h"
|
||||||
|
|
||||||
|
TerminalStripLayoutPattern::TerminalStripLayoutPattern()
|
||||||
|
{
|
||||||
|
m_font.setPixelSize(15);
|
||||||
|
updateHeaderTextOption();
|
||||||
|
updateTerminalsTextOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripLayoutPattern::setHeaderTextAlignment
|
||||||
|
* Set text alignment to @param alignment. If alignment have no
|
||||||
|
* flag this function do nothing
|
||||||
|
* @param alignment
|
||||||
|
*/
|
||||||
|
void TerminalStripLayoutPattern::setHeaderTextAlignment(const Qt::Alignment &alignment)
|
||||||
|
{
|
||||||
|
if (!alignment) return;
|
||||||
|
m_header_text_alignment = alignment;
|
||||||
|
updateHeaderTextOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::Alignment TerminalStripLayoutPattern::headerTextAlignment() const
|
||||||
|
{
|
||||||
|
return m_header_text_alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextOption TerminalStripLayoutPattern::headerTextOption() const {
|
||||||
|
return m_header_text_option;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFont TerminalStripLayoutPattern::font() const {
|
||||||
|
return m_font;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripLayoutPattern::setFont(const QFont &font) {
|
||||||
|
m_font = font;
|
||||||
|
QETUtils::pixelSizedFont(m_font);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripLayoutPattern::setTerminalsTextAlignment
|
||||||
|
* Set text alignment to @param alignment. If alignment have no
|
||||||
|
* flag this function do nothing
|
||||||
|
* @param alignment
|
||||||
|
*/
|
||||||
|
void TerminalStripLayoutPattern::setTerminalsTextAlignment(const Qt::Alignment &alignment)
|
||||||
|
{
|
||||||
|
if (!alignment) return;
|
||||||
|
m_terminals_text_alignment = alignment;
|
||||||
|
updateTerminalsTextOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::Alignment TerminalStripLayoutPattern::terminalsTextAlignment() const
|
||||||
|
{
|
||||||
|
return m_terminals_text_alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextOption TerminalStripLayoutPattern::terminalsTextOption() const
|
||||||
|
{
|
||||||
|
return m_terminals_text_option;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripLayoutPattern::setXrefTextAlignment
|
||||||
|
* Set text alignment to @param alignment. If alignment have no
|
||||||
|
* flag this function do nothing
|
||||||
|
* @param alignment
|
||||||
|
*/
|
||||||
|
void TerminalStripLayoutPattern::setXrefTextAlignment(const Qt::Alignment &alignment)
|
||||||
|
{
|
||||||
|
if (!alignment) return;
|
||||||
|
m_xref_text_alignment = alignment;
|
||||||
|
updateTerminalsTextOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::Alignment TerminalStripLayoutPattern::xrefTextAlignment() const
|
||||||
|
{
|
||||||
|
return m_xref_text_alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextOption TerminalStripLayoutPattern::xrefTextOption() const
|
||||||
|
{
|
||||||
|
return m_xref_text_option;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripLayoutPattern::updateHeaderTextOption()
|
||||||
|
{
|
||||||
|
m_header_text_option.setAlignment(m_header_text_alignment);
|
||||||
|
m_header_text_option.setWrapMode(QTextOption::WordWrap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripLayoutPattern::updateTerminalsTextOption()
|
||||||
|
{
|
||||||
|
m_terminals_text_option.setAlignment(m_terminals_text_alignment);
|
||||||
|
m_terminals_text_option.setWrapMode(QTextOption::WordWrap);
|
||||||
|
|
||||||
|
m_xref_text_option.setAlignment(m_xref_text_alignment);
|
||||||
|
m_xref_text_option.setWrapMode(QTextOption::WordWrap);
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2022 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef TERMINALSTRIPLAYOUTPATTERN_H
|
||||||
|
#define TERMINALSTRIPLAYOUTPATTERN_H
|
||||||
|
|
||||||
|
#include <QFont>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QSize>
|
||||||
|
#include <QTextOption>
|
||||||
|
#include <QUuid>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The TerminalStripLayoutPattern class
|
||||||
|
* A class with all values used to define how a terminal strip must be drawn.
|
||||||
|
* Most of the value are public, some values are private and have getter / setter
|
||||||
|
* because when these values change we need to compute the change.
|
||||||
|
*
|
||||||
|
* The values with name '_y_offset' mean offset is relating to the top
|
||||||
|
* of the QGraphicsItem used to display the terminal strip.
|
||||||
|
*
|
||||||
|
* The terminal strip can display up to 4 terminal level,
|
||||||
|
* the value used for multilevel terminal are stored in several QVector (m_terminal_y_offset, m_terminal_height, m_bridge_point_y_offset).
|
||||||
|
* The order of the values are from the most back terminal to the front terminal.
|
||||||
|
*/
|
||||||
|
class TerminalStripLayoutPattern
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TerminalStripLayoutPattern();
|
||||||
|
|
||||||
|
//Header of terminal strip
|
||||||
|
QRectF m_header_rect{0,30,50,130};
|
||||||
|
Qt::Orientation m_header_text_orientation{Qt::Horizontal};
|
||||||
|
void setHeaderTextAlignment(const Qt::Alignment &alignment);
|
||||||
|
Qt::Alignment headerTextAlignment() const;
|
||||||
|
QTextOption headerTextOption() const;
|
||||||
|
|
||||||
|
//Spacer between the header and the terminals
|
||||||
|
QRectF m_spacer_rect{0, 50, 10, 90};
|
||||||
|
|
||||||
|
//Font
|
||||||
|
QFont font() const;
|
||||||
|
void setFont (const QFont &font);
|
||||||
|
|
||||||
|
//Terminals
|
||||||
|
QVector<QRectF> m_terminal_rect
|
||||||
|
{
|
||||||
|
QRectF{0, 0, 20, 190},
|
||||||
|
QRectF{0, 10, 20, 170},
|
||||||
|
QRectF{0, 20, 20, 150},
|
||||||
|
QRectF{0, 30, 20, 130}
|
||||||
|
};
|
||||||
|
|
||||||
|
//Terminal text
|
||||||
|
void setTerminalsTextAlignment(const Qt::Alignment &alignment);
|
||||||
|
Qt::Alignment terminalsTextAlignment() const;
|
||||||
|
QTextOption terminalsTextOption() const;
|
||||||
|
qreal m_terminals_text_height{50};
|
||||||
|
qreal m_terminals_text_y{35};
|
||||||
|
Qt::Orientation m_terminals_text_orientation {Qt::Vertical};
|
||||||
|
|
||||||
|
//Xref text
|
||||||
|
void setXrefTextAlignment(const Qt::Alignment &alignment);
|
||||||
|
Qt::Alignment xrefTextAlignment() const;
|
||||||
|
QTextOption xrefTextOption() const;
|
||||||
|
qreal m_xref_text_height{60};
|
||||||
|
qreal m_xref_text_y{95};
|
||||||
|
Qt::Orientation m_xref_text_orientation {Qt::Vertical};
|
||||||
|
|
||||||
|
qreal m_bridge_point_d{5};
|
||||||
|
QVector<qreal> m_bridge_point_y_offset{50,70,90,110};
|
||||||
|
|
||||||
|
QUuid m_uuid{QUuid::createUuid()};
|
||||||
|
QString m_name;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateHeaderTextOption();
|
||||||
|
void updateTerminalsTextOption();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QFont m_font;
|
||||||
|
Qt::Alignment m_header_text_alignment{Qt::AlignCenter};
|
||||||
|
QTextOption m_header_text_option;
|
||||||
|
|
||||||
|
Qt::Alignment
|
||||||
|
m_terminals_text_alignment {Qt::AlignRight | Qt::AlignVCenter},
|
||||||
|
m_xref_text_alignment {Qt::AlignLeft | Qt::AlignVCenter};
|
||||||
|
QTextOption
|
||||||
|
m_terminals_text_option{QTextOption()},
|
||||||
|
m_xref_text_option{QTextOption()};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TERMINALSTRIPLAYOUTPATTERN_H
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "terminalstriplayoutshandler.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
TerminalStripLayoutsHandler::TerminalStripLayoutsHandler()
|
||||||
|
{
|
||||||
|
|
||||||
|
m_default_layout = QSharedPointer<TerminalStripLayoutPattern>::create();
|
||||||
|
m_default_layout->m_name = QObject::tr("Disposition par défaut");
|
||||||
|
}
|
||||||
|
|
||||||
|
QSharedPointer<TerminalStripLayoutPattern> TerminalStripLayoutsHandler::defaultLayout()
|
||||||
|
{
|
||||||
|
return m_default_layout;
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef TERMINALSTRIPLAYOUTSHANDLER_H
|
||||||
|
#define TERMINALSTRIPLAYOUTSHANDLER_H
|
||||||
|
|
||||||
|
#include <QSet>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include "terminalstriplayoutpattern.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The TerminalStripLayoutsHandler class
|
||||||
|
* Manage and provide TerminalStripLayoutPattern
|
||||||
|
*/
|
||||||
|
class TerminalStripLayoutsHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TerminalStripLayoutsHandler();
|
||||||
|
QSharedPointer<TerminalStripLayoutPattern> defaultLayout();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSet<QSharedPointer<TerminalStripLayoutPattern>> m_layout_set;
|
||||||
|
QSharedPointer<TerminalStripLayoutPattern> m_default_layout;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TERMINALSTRIPLAYOUTSHANDLER_H
|
||||||
388
sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp
Normal file
388
sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp
Normal file
@@ -0,0 +1,388 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "terminalstripdrawer.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
namespace TerminalStripDrawer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripDrawer::TerminalStripDrawer
|
||||||
|
* @param strip
|
||||||
|
* @param pattern
|
||||||
|
*/
|
||||||
|
TerminalStripDrawer::TerminalStripDrawer(QSharedPointer<AbstractTerminalStripInterface> strip,
|
||||||
|
QSharedPointer<TerminalStripLayoutPattern> layout) :
|
||||||
|
m_strip { strip },
|
||||||
|
m_pattern { layout }
|
||||||
|
{}
|
||||||
|
|
||||||
|
void TerminalStripDrawer::setStrip(QSharedPointer<AbstractTerminalStripInterface> strip)
|
||||||
|
{
|
||||||
|
m_strip = strip;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripDrawer::paint
|
||||||
|
* @param painter
|
||||||
|
*/
|
||||||
|
void TerminalStripDrawer::paint(QPainter *painter)
|
||||||
|
{
|
||||||
|
if (m_strip && m_pattern)
|
||||||
|
{
|
||||||
|
m_united_xref_text_rect = QRectF();
|
||||||
|
//To draw text, QPainter need a Qrect. Instead of create an instance
|
||||||
|
//for each text, we re-use the same instance of QRect.
|
||||||
|
QRect text_rect;
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
auto pen_{painter->pen()};
|
||||||
|
pen_.setColor(Qt::black);
|
||||||
|
pen_.setWidth(1);
|
||||||
|
|
||||||
|
auto brush_ = painter->brush();
|
||||||
|
brush_.setColor(Qt::white);
|
||||||
|
|
||||||
|
painter->setFont(m_pattern->font());
|
||||||
|
|
||||||
|
painter->setPen(pen_);
|
||||||
|
painter->setBrush(brush_);
|
||||||
|
|
||||||
|
if (m_preview_draw)
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
painter->setPen(Qt::blue);
|
||||||
|
painter->drawRect(boundingRect());
|
||||||
|
painter->drawLine(QPointF{boundingRect().left(), boundingRect().center().y()},
|
||||||
|
QPointF{boundingRect().right(), boundingRect().center().y()});
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Draw header
|
||||||
|
painter->drawRect(m_pattern->m_header_rect);
|
||||||
|
|
||||||
|
//Draw the header text
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
if (m_pattern->m_header_text_orientation == Qt::Horizontal)
|
||||||
|
{
|
||||||
|
text_rect.setRect(0,m_pattern->m_header_rect.y(),m_pattern->m_header_rect.width(),m_pattern->m_header_rect.height());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
painter->translate(m_pattern->m_header_rect.bottomLeft());
|
||||||
|
painter->rotate(270);
|
||||||
|
text_rect.setRect(0,0,m_pattern->m_header_rect.height(),m_pattern->m_header_rect.width());
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto text_{m_strip->installation() + " " + m_strip->location() + " " + m_strip->name()};
|
||||||
|
painter->drawText(text_rect, text_, m_pattern->headerTextOption());
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
//Move painter pos to next drawing
|
||||||
|
painter->translate(m_pattern->m_header_rect.width(),0);
|
||||||
|
qreal x_offset{m_pattern->m_header_rect.width()};
|
||||||
|
|
||||||
|
//Draw spacer
|
||||||
|
painter->drawRect(m_pattern->m_spacer_rect);
|
||||||
|
//Move painter pos to next drawing
|
||||||
|
painter->translate(m_pattern->m_spacer_rect.width(),0);
|
||||||
|
x_offset += m_pattern->m_spacer_rect.width();
|
||||||
|
|
||||||
|
|
||||||
|
//Draw terminals
|
||||||
|
const auto terminals_text_orientation{m_pattern->m_terminals_text_orientation};
|
||||||
|
const auto terminals_text_option{m_pattern->terminalsTextOption()};
|
||||||
|
const auto terminals_text_height{m_pattern->m_terminals_text_height};
|
||||||
|
const auto terminals_text_y{m_pattern->m_terminals_text_y};
|
||||||
|
QRectF terminal_rect;
|
||||||
|
|
||||||
|
const auto xref_text_orientation{m_pattern->m_xref_text_orientation};
|
||||||
|
const auto xref_text_option{m_pattern->xrefTextOption()};
|
||||||
|
const auto xref_text_height{m_pattern->m_xref_text_height};
|
||||||
|
const auto xref_text_y{m_pattern->m_xref_text_y};
|
||||||
|
QRectF xref_rect;
|
||||||
|
|
||||||
|
QHash<QUuid, QVector<QPointF>> bridges_anchor_points;
|
||||||
|
|
||||||
|
m_hovered_xref = hoverTerminal{};
|
||||||
|
int physical_index = 0;
|
||||||
|
//Loop over physical terminals
|
||||||
|
for (const auto &physical_t : m_strip->physicalTerminal())
|
||||||
|
{
|
||||||
|
//Get the good offset according to how many level have the current physical terminal
|
||||||
|
const QVector<QSharedPointer<AbstractRealTerminalInterface>> real_terminal_vector{physical_t->realTerminals()};
|
||||||
|
const auto real_t_count{real_terminal_vector.size()};
|
||||||
|
const auto offset_{4 - real_t_count};
|
||||||
|
|
||||||
|
//Loop over real terminals
|
||||||
|
for (auto i=0 ; i<real_t_count ; ++i)
|
||||||
|
{
|
||||||
|
const auto index_ = offset_ + i;
|
||||||
|
if (index_ >= 4) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
terminal_rect = m_pattern->m_terminal_rect[index_];
|
||||||
|
//Draw terminal rect
|
||||||
|
painter->drawRect(terminal_rect);
|
||||||
|
//Draw a stronger line if the current terminal have level
|
||||||
|
//and the current level is the first
|
||||||
|
if (real_t_count > 1 && i == 0)
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
pen_ = painter->pen();
|
||||||
|
pen_.setWidth(4);
|
||||||
|
pen_.setCapStyle(Qt::FlatCap);
|
||||||
|
painter->setPen(pen_);
|
||||||
|
const auto p1 { terminal_rect.topLeft() };
|
||||||
|
//We can't use terminal_rect.bottomLeft for p2 because
|
||||||
|
//the returned value deviate from the true value
|
||||||
|
//(see Qt documentation about QRect)
|
||||||
|
const QPointF p2 { p1.x(), p1.y() + terminal_rect.height() };
|
||||||
|
painter->drawLine(p1, p2);
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_preview_draw)
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
painter->setPen(Qt::yellow);
|
||||||
|
painter->drawLine(QPointF{terminal_rect.x(), terminal_rect.y() + terminal_rect.height()/2},
|
||||||
|
QPointF{terminal_rect.width(), terminal_rect.y() + terminal_rect.height()/2});
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Draw text
|
||||||
|
painter->save();
|
||||||
|
text_rect.setRect(0, terminals_text_y, terminal_rect.width(), terminals_text_height);
|
||||||
|
if (terminals_text_orientation == Qt::Vertical)
|
||||||
|
{
|
||||||
|
painter->translate(text_rect.bottomLeft());
|
||||||
|
painter->rotate(270);
|
||||||
|
text_rect.setRect(0, 0, text_rect.height(), text_rect.width());
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto shared_real_terminal{real_terminal_vector[i]};
|
||||||
|
painter->drawText(text_rect,
|
||||||
|
shared_real_terminal ? shared_real_terminal->label() : QLatin1String(),
|
||||||
|
terminals_text_option);
|
||||||
|
|
||||||
|
if (m_preview_draw)
|
||||||
|
{
|
||||||
|
painter->setPen(Qt::blue);
|
||||||
|
painter->drawRect(text_rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
//Draw xref
|
||||||
|
xref_rect.setRect(0, xref_text_y, terminal_rect.width(), xref_text_height);
|
||||||
|
painter->save();
|
||||||
|
if (xref_text_orientation == Qt::Vertical)
|
||||||
|
{
|
||||||
|
painter->translate(xref_rect.bottomLeft());
|
||||||
|
painter->rotate(270);
|
||||||
|
xref_rect.setRect(0, 0, xref_rect.height(), xref_rect.width());
|
||||||
|
}
|
||||||
|
|
||||||
|
QTransform transform;
|
||||||
|
transform.translate(x_offset, 0);
|
||||||
|
|
||||||
|
if (xref_text_orientation == Qt::Vertical)
|
||||||
|
{
|
||||||
|
transform.translate(0, xref_text_y + xref_text_height);
|
||||||
|
transform.rotate(270);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto xref_string = shared_real_terminal->xref();
|
||||||
|
|
||||||
|
const auto mapped_xref_text_rect = transform.mapRect(painter->boundingRect(xref_rect, xref_string, xref_text_option));
|
||||||
|
if (m_united_xref_text_rect.isNull()) {
|
||||||
|
m_united_xref_text_rect = mapped_xref_text_rect;
|
||||||
|
} else {
|
||||||
|
m_united_xref_text_rect = m_united_xref_text_rect.united(mapped_xref_text_rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
//if mouse hover the xref text, draw it in blue to advise user the xref is clickable.
|
||||||
|
if (!m_mouse_hover_pos.isNull() && mapped_xref_text_rect.contains(m_mouse_hover_pos)) {
|
||||||
|
painter->setPen(Qt::blue);
|
||||||
|
m_hovered_xref.physical = physical_index;
|
||||||
|
m_hovered_xref.real = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->drawText(xref_rect, xref_string, xref_text_option);
|
||||||
|
|
||||||
|
if (m_preview_draw)
|
||||||
|
{
|
||||||
|
painter->setPen(Qt::blue);
|
||||||
|
painter->drawRect(xref_rect);
|
||||||
|
}
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
//Add bridge anchor
|
||||||
|
if (shared_real_terminal->isBridged())
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
if (QScopedPointer<AbstractBridgeInterface> bridge_ {
|
||||||
|
shared_real_terminal->bridge() })
|
||||||
|
{
|
||||||
|
const auto x_anchor{terminal_rect.width()/2};
|
||||||
|
const auto y_anchor {m_pattern->m_bridge_point_y_offset[index_]};
|
||||||
|
const auto radius_anchor{m_pattern->m_bridge_point_d/2};
|
||||||
|
|
||||||
|
painter->setBrush(Qt::SolidPattern);
|
||||||
|
painter->drawEllipse(QPointF(x_anchor, y_anchor),
|
||||||
|
radius_anchor, radius_anchor);
|
||||||
|
|
||||||
|
auto anchor_points{bridges_anchor_points.value(bridge_->uuid())};
|
||||||
|
anchor_points.append(QPointF(x_offset + x_anchor, y_anchor));
|
||||||
|
bridges_anchor_points.insert(bridge_->uuid(), anchor_points);
|
||||||
|
}
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Move painter pos to next drawing
|
||||||
|
painter->translate(terminal_rect.width(),0);
|
||||||
|
x_offset += terminal_rect.width();
|
||||||
|
}
|
||||||
|
physical_index++;
|
||||||
|
}
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
//Draw the bridges
|
||||||
|
for (const auto &points_ : qAsConst(bridges_anchor_points))
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
auto pen_{painter->pen()};
|
||||||
|
pen_.setWidth(2);
|
||||||
|
painter->setPen(pen_);
|
||||||
|
painter->drawPolyline(QPolygonF{points_});
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF TerminalStripDrawer::boundingRect() const
|
||||||
|
{
|
||||||
|
return QRectF{0, 0, width(), height()};;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripDrawer::setLayout(QSharedPointer<TerminalStripLayoutPattern> layout)
|
||||||
|
{
|
||||||
|
m_pattern = layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TerminalStripDrawer::haveLayout() const
|
||||||
|
{
|
||||||
|
return !m_pattern.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripDrawer::setPreviewDraw(bool draw) {
|
||||||
|
m_preview_draw = draw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripDrawer::setMouseHoverPos(const QPointF &pos)
|
||||||
|
{
|
||||||
|
m_last_mouse_pos_in_xrefs_rect = m_united_xref_text_rect.contains(m_mouse_hover_pos);
|
||||||
|
m_mouse_hover_pos = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripDrawer::mouseHoverXref
|
||||||
|
* @return True if the mouse position (given through the function setMouseHoverPos)
|
||||||
|
* hover the rect of a xref.
|
||||||
|
*/
|
||||||
|
bool TerminalStripDrawer::mouseHoverXref() const {
|
||||||
|
return m_united_xref_text_rect.contains(m_mouse_hover_pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TerminalStripDrawer::needUpdate()
|
||||||
|
{
|
||||||
|
if (mouseHoverXref()) {
|
||||||
|
return true;
|
||||||
|
} else if (m_last_mouse_pos_in_xrefs_rect) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripDrawer::hoveredXref
|
||||||
|
* @return the current terminal hovered by the mouse
|
||||||
|
* in the xref bounding rectangle
|
||||||
|
*/
|
||||||
|
hoverTerminal TerminalStripDrawer::hoveredXref() const
|
||||||
|
{
|
||||||
|
return m_hovered_xref;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal TerminalStripDrawer::height() const
|
||||||
|
{
|
||||||
|
if (m_pattern)
|
||||||
|
{
|
||||||
|
auto height_{m_pattern->m_header_rect.y() + m_pattern->m_header_rect.height()};
|
||||||
|
|
||||||
|
height_ = std::max(height_, m_pattern->m_spacer_rect.y() + m_pattern->m_spacer_rect.height());
|
||||||
|
|
||||||
|
for (const auto &rect : m_pattern->m_terminal_rect) {
|
||||||
|
height_ = std::max(height_, rect.y() + rect.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
return height_;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal TerminalStripDrawer::width() const
|
||||||
|
{
|
||||||
|
if (m_pattern)
|
||||||
|
{
|
||||||
|
qreal width_{m_pattern->m_header_rect.width() + m_pattern->m_spacer_rect.width()};
|
||||||
|
|
||||||
|
if (m_strip)
|
||||||
|
{
|
||||||
|
//Loop over physical terminals
|
||||||
|
for (const auto &physical_t : m_strip->physicalTerminal())
|
||||||
|
{
|
||||||
|
//Get the good offset according to how many level have the current physical terminal
|
||||||
|
const QVector<QSharedPointer<AbstractRealTerminalInterface>> real_terminal_vector{physical_t->realTerminals()};
|
||||||
|
const auto real_t_count{real_terminal_vector.size()};
|
||||||
|
const auto offset_{4 - real_t_count};
|
||||||
|
|
||||||
|
//Loop over real terminals
|
||||||
|
for (auto i=0 ; i<real_t_count ; ++i)
|
||||||
|
{
|
||||||
|
const auto index_ = offset_ + i;
|
||||||
|
if (index_ >= 4) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
width_ += m_pattern->m_terminal_rect[index_].width();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return width_;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} //End namespace TerminalStripDrawer
|
||||||
114
sources/TerminalStrip/GraphicsItem/terminalstripdrawer.h
Normal file
114
sources/TerminalStrip/GraphicsItem/terminalstripdrawer.h
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef TERMINALSTRIPDRAWER_H
|
||||||
|
#define TERMINALSTRIPDRAWER_H
|
||||||
|
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
|
#include "properties/terminalstriplayoutpattern.h"
|
||||||
|
|
||||||
|
class QPainter;
|
||||||
|
class TerminalStrip;
|
||||||
|
|
||||||
|
namespace TerminalStripDrawer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief The hoverTerminal struct
|
||||||
|
* Just a little struct use to know what is the physical and real terminal
|
||||||
|
* when the mouse hover the Xref string of a terminal.
|
||||||
|
* If mouse don't hover a Xref the value is set to -1;
|
||||||
|
*/
|
||||||
|
struct hoverTerminal{
|
||||||
|
int physical{-1};
|
||||||
|
int real{-1};
|
||||||
|
};
|
||||||
|
|
||||||
|
class AbstractBridgeInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AbstractBridgeInterface() {}
|
||||||
|
virtual ~AbstractBridgeInterface() {}
|
||||||
|
virtual QUuid uuid() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AbstractRealTerminalInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AbstractRealTerminalInterface() {}
|
||||||
|
virtual ~AbstractRealTerminalInterface() {}
|
||||||
|
virtual QString label() const = 0;
|
||||||
|
virtual bool isBridged() const = 0;
|
||||||
|
virtual AbstractBridgeInterface* bridge() const = 0;
|
||||||
|
virtual QString xref() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AbstractPhysicalTerminalInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AbstractPhysicalTerminalInterface() {}
|
||||||
|
virtual ~AbstractPhysicalTerminalInterface() {}
|
||||||
|
virtual QVector<QSharedPointer<AbstractRealTerminalInterface>> realTerminals() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AbstractTerminalStripInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AbstractTerminalStripInterface() {}
|
||||||
|
virtual ~AbstractTerminalStripInterface() {}
|
||||||
|
virtual QString installation() const = 0;
|
||||||
|
virtual QString location() const = 0;
|
||||||
|
virtual QString name() const = 0;
|
||||||
|
virtual QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> physicalTerminal() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TerminalStripDrawer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TerminalStripDrawer(QSharedPointer<AbstractTerminalStripInterface> strip = QSharedPointer<AbstractTerminalStripInterface> { nullptr },
|
||||||
|
QSharedPointer<TerminalStripLayoutPattern> layout = QSharedPointer<TerminalStripLayoutPattern>());
|
||||||
|
|
||||||
|
void setStrip(QSharedPointer<AbstractTerminalStripInterface> strip);
|
||||||
|
void paint(QPainter *painter);
|
||||||
|
QRectF boundingRect() const;
|
||||||
|
|
||||||
|
void setLayout(QSharedPointer<TerminalStripLayoutPattern> layout);
|
||||||
|
bool haveLayout() const;
|
||||||
|
|
||||||
|
void setPreviewDraw(bool draw = true);
|
||||||
|
|
||||||
|
void setMouseHoverPos(const QPointF &pos);
|
||||||
|
bool mouseHoverXref() const;
|
||||||
|
bool needUpdate();
|
||||||
|
hoverTerminal hoveredXref() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
qreal height() const;
|
||||||
|
qreal width() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSharedPointer <AbstractTerminalStripInterface> m_strip;
|
||||||
|
QSharedPointer<TerminalStripLayoutPattern> m_pattern;
|
||||||
|
bool m_preview_draw { false };
|
||||||
|
QPointF m_mouse_hover_pos;
|
||||||
|
QRectF m_united_xref_text_rect;
|
||||||
|
bool m_last_mouse_pos_in_xrefs_rect{false};
|
||||||
|
hoverTerminal m_hovered_xref;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TERMINALSTRIPDRAWER_H
|
||||||
174
sources/TerminalStrip/GraphicsItem/terminalstripitem.cpp
Normal file
174
sources/TerminalStrip/GraphicsItem/terminalstripitem.cpp
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2022 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "terminalstripitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "../diagram.h"
|
||||||
|
#include "../../project/projectpropertieshandler.h"
|
||||||
|
#include "../../qetgraphicsitem/qgraphicsitemutility.h"
|
||||||
|
#include "../terminalstrip.h"
|
||||||
|
#include "../physicalterminal.h"
|
||||||
|
#include "../realterminal.h"
|
||||||
|
#include "../ui/terminalstripeditorwindow.h"
|
||||||
|
#include "trueterminalstrip.h"
|
||||||
|
|
||||||
|
TerminalStripItem::TerminalStripItem(QPointer<TerminalStrip> strip,
|
||||||
|
QGraphicsItem *parent) :
|
||||||
|
QetGraphicsItem { parent },
|
||||||
|
m_strip { strip },
|
||||||
|
m_drawer { QSharedPointer<TerminalStripDrawer::TrueTerminalStrip> {
|
||||||
|
new TerminalStripDrawer::TrueTerminalStrip { strip }}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
setDefaultLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminalStripItem::TerminalStripItem(QGraphicsItem *parent) :
|
||||||
|
QetGraphicsItem { parent }
|
||||||
|
{
|
||||||
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripItem::setTerminalStrip(TerminalStrip *strip)
|
||||||
|
{
|
||||||
|
m_strip = strip;
|
||||||
|
m_drawer.setStrip(QSharedPointer<TerminalStripDrawer::TrueTerminalStrip> {
|
||||||
|
new TerminalStripDrawer::TrueTerminalStrip { strip }});
|
||||||
|
m_pending_strip_uuid = QUuid();
|
||||||
|
|
||||||
|
if (!m_drawer.haveLayout()) {
|
||||||
|
setDefaultLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripItem::terminalStrip
|
||||||
|
* @return The strip drawed by this item
|
||||||
|
*/
|
||||||
|
QPointer<TerminalStrip> TerminalStripItem::terminalStrip() const {
|
||||||
|
return m_strip;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option)
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
|
m_drawer.paint(painter);
|
||||||
|
|
||||||
|
if (isSelected() || isHovered())
|
||||||
|
{
|
||||||
|
QGIUtility::drawBoundingRectSelection(this, painter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF TerminalStripItem::boundingRect() const
|
||||||
|
{
|
||||||
|
auto br_ = m_drawer.boundingRect();
|
||||||
|
br_.adjust(-5,-5,5,5);
|
||||||
|
|
||||||
|
return br_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripItem::name
|
||||||
|
* @return usual name of this item
|
||||||
|
*/
|
||||||
|
QString TerminalStripItem::name() const {
|
||||||
|
return tr("plan de bornes");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
QetGraphicsItem::hoverMoveEvent(event);
|
||||||
|
m_drawer.setMouseHoverPos(hoverMousePos());
|
||||||
|
if (m_drawer.needUpdate()) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
QetGraphicsItem::hoverLeaveEvent(event);
|
||||||
|
m_drawer.setMouseHoverPos(QPointF{});
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED (event);
|
||||||
|
|
||||||
|
const auto hovered = m_drawer.hoveredXref();
|
||||||
|
|
||||||
|
if (m_strip) {
|
||||||
|
if (hovered.physical >= 0 &&
|
||||||
|
hovered.real >= 0)
|
||||||
|
{
|
||||||
|
if (const auto physical_terminal = m_strip->physicalTerminal(hovered.physical);
|
||||||
|
!physical_terminal.isNull())
|
||||||
|
{
|
||||||
|
if (const auto real_terminal = physical_terminal->realTerminal(hovered.real);
|
||||||
|
!real_terminal.isNull() &&
|
||||||
|
real_terminal->isElement())
|
||||||
|
{
|
||||||
|
if (QPointer<Element> element = real_terminal->element();
|
||||||
|
!element.isNull())
|
||||||
|
{
|
||||||
|
//Unselect and ungrab mouse to prevent unwanted
|
||||||
|
//move when element is in the same scene of this.
|
||||||
|
setSelected(false);
|
||||||
|
ungrabMouse();
|
||||||
|
QetGraphicsItem::showItem(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
TerminalStripEditorWindow::edit(m_strip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripItem::refreshPending()
|
||||||
|
{
|
||||||
|
if (!m_pending_strip_uuid.isNull()
|
||||||
|
&& diagram()
|
||||||
|
&& diagram()->project())
|
||||||
|
{
|
||||||
|
for (const auto &strip_ : diagram()->project()->terminalStrip()) {
|
||||||
|
if (strip_->uuid() == m_pending_strip_uuid) {
|
||||||
|
setTerminalStrip(strip_);
|
||||||
|
m_pending_strip_uuid = QUuid();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripItem::setLayout(QSharedPointer<TerminalStripLayoutPattern> layout)
|
||||||
|
{
|
||||||
|
m_drawer.setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripItem::setDefaultLayout()
|
||||||
|
{
|
||||||
|
if (m_strip && m_strip->project()) {
|
||||||
|
m_drawer.setLayout(m_strip->project()->projectPropertiesHandler().terminalStripLayoutHandler().defaultLayout());
|
||||||
|
}
|
||||||
|
}
|
||||||
64
sources/TerminalStrip/GraphicsItem/terminalstripitem.h
Normal file
64
sources/TerminalStrip/GraphicsItem/terminalstripitem.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2022 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef TERMINALSTRIPITEM_H
|
||||||
|
#define TERMINALSTRIPITEM_H
|
||||||
|
|
||||||
|
#include <QGraphicsObject>
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
|
#include "terminalstripdrawer.h"
|
||||||
|
#include "../../qetgraphicsitem/qetgraphicsitem.h"
|
||||||
|
|
||||||
|
class TerminalStrip;
|
||||||
|
|
||||||
|
class TerminalStripItem : public QetGraphicsItem
|
||||||
|
{
|
||||||
|
friend class TerminalStripItemXml;
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TerminalStripItem(QPointer<TerminalStrip> strip, QGraphicsItem *parent = nullptr);
|
||||||
|
TerminalStripItem(QGraphicsItem *parent = nullptr);
|
||||||
|
|
||||||
|
void setTerminalStrip(TerminalStrip *strip);
|
||||||
|
QPointer<TerminalStrip> terminalStrip() const;
|
||||||
|
|
||||||
|
enum {Type = UserType + 1011};
|
||||||
|
int type() const override {return Type;}
|
||||||
|
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
QRectF boundingRect() const override;
|
||||||
|
QString name() const override;
|
||||||
|
|
||||||
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
|
void refreshPending();
|
||||||
|
void setLayout(QSharedPointer<TerminalStripLayoutPattern> layout);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setDefaultLayout();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<TerminalStrip> m_strip;
|
||||||
|
TerminalStripDrawer::TerminalStripDrawer m_drawer;
|
||||||
|
QUuid m_pending_strip_uuid;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TERMINALSTRIPITEM_H
|
||||||
143
sources/TerminalStrip/GraphicsItem/trueterminalstrip.cpp
Normal file
143
sources/TerminalStrip/GraphicsItem/trueterminalstrip.cpp
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "trueterminalstrip.h"
|
||||||
|
#include "../physicalterminal.h"
|
||||||
|
#include "../realterminal.h"
|
||||||
|
#include "../terminalstrip.h"
|
||||||
|
#include "../terminalstripbridge.h"
|
||||||
|
#include "../../autoNum/assignvariables.h"
|
||||||
|
|
||||||
|
#include "terminalstripdrawer.h"
|
||||||
|
|
||||||
|
namespace TerminalStripDrawer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief TrueTerminalStrip::TrueTerminalStrip
|
||||||
|
* Constructor, this class don't take ownership of @a strip
|
||||||
|
* @param strip
|
||||||
|
*/
|
||||||
|
TrueTerminalStrip::TrueTerminalStrip(TerminalStrip *strip) :
|
||||||
|
m_strip { strip }
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
QString TrueTerminalStrip::installation() const
|
||||||
|
{
|
||||||
|
if (m_strip) {
|
||||||
|
return m_strip->installation();
|
||||||
|
} else {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TrueTerminalStrip::location() const
|
||||||
|
{
|
||||||
|
if (m_strip) {
|
||||||
|
return m_strip->location();
|
||||||
|
} else {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TrueTerminalStrip::name() const
|
||||||
|
{
|
||||||
|
if (m_strip) {
|
||||||
|
return m_strip->name();
|
||||||
|
} else {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> TrueTerminalStrip::physicalTerminal() const
|
||||||
|
{
|
||||||
|
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> vector_;
|
||||||
|
if (m_strip) {
|
||||||
|
for (const auto &phy : m_strip->physicalTerminal()) {
|
||||||
|
vector_.append(QSharedPointer<AbstractPhysicalTerminalInterface>{ new TruePhysicalTerminal(phy) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return vector_;
|
||||||
|
}
|
||||||
|
|
||||||
|
TruePhysicalTerminal::TruePhysicalTerminal(QSharedPointer<PhysicalTerminal> physical) :
|
||||||
|
m_physical { physical }
|
||||||
|
{}
|
||||||
|
|
||||||
|
QVector<QSharedPointer<AbstractRealTerminalInterface>> TruePhysicalTerminal::realTerminals() const
|
||||||
|
{
|
||||||
|
QVector<QSharedPointer<AbstractRealTerminalInterface>> vector_;
|
||||||
|
if (m_physical) {
|
||||||
|
for (const auto &real_ : m_physical->realTerminals()) {
|
||||||
|
vector_.append(QSharedPointer<AbstractRealTerminalInterface> { new TrueRealTerminal{ real_ }});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return vector_;
|
||||||
|
}
|
||||||
|
|
||||||
|
TrueRealTerminal::TrueRealTerminal(QSharedPointer<RealTerminal> real) :
|
||||||
|
m_real { real }
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString TrueRealTerminal::label() const
|
||||||
|
{
|
||||||
|
if (m_real) {
|
||||||
|
return m_real->label();
|
||||||
|
} else {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TrueRealTerminal::isBridged() const
|
||||||
|
{
|
||||||
|
if (m_real) {
|
||||||
|
return m_real->isBridged();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return a raw pointer, the pointer is not managed by this class
|
||||||
|
AbstractBridgeInterface* TrueRealTerminal::bridge() const
|
||||||
|
{
|
||||||
|
return new TrueBridge(m_real->bridge());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TrueRealTerminal::xref() const
|
||||||
|
{
|
||||||
|
if (m_real && m_real->isElement()) {
|
||||||
|
return autonum::AssignVariables::genericXref(m_real->element());
|
||||||
|
} else {
|
||||||
|
return QString{};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TrueBridge::TrueBridge(QSharedPointer<TerminalStripBridge> bridge) :
|
||||||
|
m_bridge { bridge }
|
||||||
|
{}
|
||||||
|
|
||||||
|
QUuid TrueBridge::uuid() const
|
||||||
|
{
|
||||||
|
if (m_bridge) {
|
||||||
|
return m_bridge->uuid();
|
||||||
|
} else {
|
||||||
|
return QUuid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
78
sources/TerminalStrip/GraphicsItem/trueterminalstrip.h
Normal file
78
sources/TerminalStrip/GraphicsItem/trueterminalstrip.h
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef TRUETERMINALSTRIP_H
|
||||||
|
#define TRUETERMINALSTRIP_H
|
||||||
|
|
||||||
|
#include "terminalstripdrawer.h"
|
||||||
|
|
||||||
|
class TerminalStrip;
|
||||||
|
class PhysicalTerminal;
|
||||||
|
class RealTerminal;
|
||||||
|
class TerminalStripBridge;
|
||||||
|
|
||||||
|
namespace TerminalStripDrawer
|
||||||
|
{
|
||||||
|
class TrueTerminalStrip : public AbstractTerminalStripInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TrueTerminalStrip(TerminalStrip *strip);
|
||||||
|
|
||||||
|
QString installation() const override;
|
||||||
|
QString location() const override;
|
||||||
|
QString name() const override;
|
||||||
|
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> physicalTerminal() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<TerminalStrip> m_strip;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TruePhysicalTerminal : public AbstractPhysicalTerminalInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TruePhysicalTerminal(QSharedPointer<PhysicalTerminal> physical);
|
||||||
|
QVector<QSharedPointer<AbstractRealTerminalInterface>> realTerminals() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSharedPointer<PhysicalTerminal> m_physical;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TrueRealTerminal : public AbstractRealTerminalInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TrueRealTerminal(QSharedPointer<RealTerminal> real);
|
||||||
|
QString label() const override;
|
||||||
|
bool isBridged() const override;
|
||||||
|
AbstractBridgeInterface* bridge() const override;
|
||||||
|
QString xref() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSharedPointer<RealTerminal> m_real;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TrueBridge : public AbstractBridgeInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TrueBridge(QSharedPointer<TerminalStripBridge> bridge);
|
||||||
|
QUuid uuid() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSharedPointer<TerminalStripBridge> m_bridge;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TRUETERMINALSTRIP_H
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "bridgeterminalscommand.h"
|
#include "bridgeterminalscommand.h"
|
||||||
|
#include "../terminalstripbridge.h"
|
||||||
|
|
||||||
BridgeTerminalsCommand::BridgeTerminalsCommand(TerminalStrip *strip,
|
BridgeTerminalsCommand::BridgeTerminalsCommand(TerminalStrip *strip,
|
||||||
QVector<QSharedPointer<RealTerminal>> real_terminal,
|
QVector<QSharedPointer<RealTerminal>> real_terminal,
|
||||||
@@ -57,8 +58,18 @@ UnBridgeTerminalsCommand::UnBridgeTerminalsCommand(TerminalStrip *strip,
|
|||||||
|
|
||||||
if (strip->canUnBridge(real_terminal))
|
if (strip->canUnBridge(real_terminal))
|
||||||
{
|
{
|
||||||
m_terminals = real_terminal;
|
|
||||||
m_bridge = strip->isBridged(real_terminal.first());
|
m_bridge = strip->isBridged(real_terminal.first());
|
||||||
|
|
||||||
|
//If bridge have one more terminals than @real_terminal
|
||||||
|
//that mean every terminals of the bridge must be unbridged by this undo command,
|
||||||
|
//else the single terminal who's not umbridged by this undo command
|
||||||
|
//continue to have a bridge (to nothing) and this nowhere bridge is visible
|
||||||
|
//in the terminal strip graphic item and terminal strip editor dialog.
|
||||||
|
if (m_bridge->realTerminals().size() == real_terminal.size() + 1) {
|
||||||
|
m_terminals = m_bridge->realTerminals();
|
||||||
|
} else {
|
||||||
|
m_terminals = real_terminal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -189,6 +189,20 @@ QVector<QSharedPointer<RealTerminal>> PhysicalTerminal::realTerminals() const {
|
|||||||
return m_real_terminal;
|
return m_real_terminal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PhysicalTerminal::realTerminal
|
||||||
|
* @param pos
|
||||||
|
* @return the real terminal at position pos.
|
||||||
|
* Note that the returned QSharedPointer can be null
|
||||||
|
*/
|
||||||
|
QSharedPointer<RealTerminal> PhysicalTerminal::realTerminal(int pos) const
|
||||||
|
{
|
||||||
|
if (pos < m_real_terminal.size()) {
|
||||||
|
return m_real_terminal.at(pos);
|
||||||
|
}
|
||||||
|
else return QSharedPointer<RealTerminal>{};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief uuid
|
* @brief uuid
|
||||||
* @return the uuid of this physical terminal
|
* @return the uuid of this physical terminal
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ class PhysicalTerminal
|
|||||||
int levelCount() const;
|
int levelCount() const;
|
||||||
int levelOf(const QSharedPointer<RealTerminal> &terminal) const;
|
int levelOf(const QSharedPointer<RealTerminal> &terminal) const;
|
||||||
QVector<QSharedPointer<RealTerminal>> realTerminals() const;
|
QVector<QSharedPointer<RealTerminal>> realTerminals() const;
|
||||||
|
QSharedPointer<RealTerminal> realTerminal(int pos) const;
|
||||||
QUuid uuid() const;
|
QUuid uuid() const;
|
||||||
int pos() const;
|
int pos() const;
|
||||||
int realTerminalCount() const;
|
int realTerminalCount() const;
|
||||||
|
|||||||
@@ -975,8 +975,9 @@ QDomElement TerminalStrip::toXml(QDomDocument &parent_document)
|
|||||||
|
|
||||||
root_elmt.appendChild(m_data.toXml(parent_document));
|
root_elmt.appendChild(m_data.toXml(parent_document));
|
||||||
|
|
||||||
//Undrawn terminals
|
//Undrawed terminals
|
||||||
auto xml_layout = parent_document.createElement("layout");
|
auto xml_layout = parent_document.createElement(QStringLiteral("layout"));
|
||||||
|
|
||||||
for (auto &phy_t : m_physical_terminals) {
|
for (auto &phy_t : m_physical_terminals) {
|
||||||
xml_layout.appendChild(phy_t->toXml(parent_document));
|
xml_layout.appendChild(phy_t->toXml(parent_document));
|
||||||
}
|
}
|
||||||
@@ -1036,9 +1037,11 @@ bool TerminalStrip::fromXml(QDomElement &xml_element)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!real_t_vector.isEmpty()) {
|
||||||
auto raw_ptr = new PhysicalTerminal(this, real_t_vector);
|
auto raw_ptr = new PhysicalTerminal(this, real_t_vector);
|
||||||
m_physical_terminals.append(raw_ptr->sharedRef());
|
m_physical_terminals.append(raw_ptr->sharedRef());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,14 @@ void TerminalStripBridge::fromXml(const QDomElement &dom_element)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripBridge::uuid
|
||||||
|
* @return The uuid of this terminal
|
||||||
|
*/
|
||||||
|
QUuid TerminalStripBridge::uuid() const noexcept {
|
||||||
|
return m_uuid;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TerminalStripBridge::addTerminals
|
* @brief TerminalStripBridge::addTerminals
|
||||||
* @param real_terminals
|
* @param real_terminals
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class TerminalStripBridge
|
|||||||
static QString xmlTagName() {return QStringLiteral("terminal_strip_bridge");}
|
static QString xmlTagName() {return QStringLiteral("terminal_strip_bridge");}
|
||||||
QDomElement toXml(QDomDocument &parent_document) const;
|
QDomElement toXml(QDomDocument &parent_document) const;
|
||||||
void fromXml(const QDomElement &dom_element);
|
void fromXml(const QDomElement &dom_element);
|
||||||
|
QUuid uuid() const noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool addTerminals(const QVector<QSharedPointer<RealTerminal>> &real_terminals);
|
bool addTerminals(const QVector<QSharedPointer<RealTerminal>> &real_terminals);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ QDomElement TerminalStripData::toXml(QDomDocument &xml_document) const
|
|||||||
|
|
||||||
root_elmt.setAttribute(QStringLiteral("uuid"), m_uuid.toString());
|
root_elmt.setAttribute(QStringLiteral("uuid"), m_uuid.toString());
|
||||||
|
|
||||||
auto info_elmt = xml_document.createElement("informations");
|
auto info_elmt = xml_document.createElement(QStringLiteral("informations"));
|
||||||
root_elmt.appendChild(info_elmt);
|
root_elmt.appendChild(info_elmt);
|
||||||
|
|
||||||
if (!m_installation.isEmpty()) {
|
if (!m_installation.isEmpty()) {
|
||||||
@@ -65,23 +65,23 @@ bool TerminalStripData::fromXml(const QDomElement &xml_element)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
m_uuid = QUuid::fromString(xml_element.attribute(QLatin1String("uuid")));
|
m_uuid = QUuid::fromString(xml_element.attribute(QStringLiteral("uuid")));
|
||||||
#else
|
#else
|
||||||
m_uuid = QUuid(xml_element.attribute(QStringLiteral("uuid")));
|
m_uuid = QUuid(xml_element.attribute(QStringLiteral("uuid")));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (auto &xml_info :
|
for (auto &xml_info :
|
||||||
QETXML::findInDomElement(xml_element.firstChildElement("informations"),
|
QETXML::findInDomElement(xml_element.firstChildElement(QStringLiteral("informations")),
|
||||||
QStringLiteral("information")))
|
QStringLiteral("information")))
|
||||||
{
|
{
|
||||||
auto name = xml_info.attribute("name");
|
auto name = xml_info.attribute(QStringLiteral("name"));
|
||||||
auto value = xml_info.text();
|
auto value = xml_info.text();
|
||||||
|
|
||||||
if (name == QStringLiteral("installation")) { m_installation = value;}
|
if (name == QLatin1String("installation")) { m_installation = value;}
|
||||||
else if (name == QStringLiteral("location")) {m_location = value;}
|
else if (name == QLatin1String("location")) {m_location = value;}
|
||||||
else if (name == QStringLiteral("name")) {m_name = value;}
|
else if (name == QLatin1String("name")) {m_name = value;}
|
||||||
else if (name == QStringLiteral("comment")) {m_comment = value;}
|
else if (name == QLatin1String("comment")) {m_comment = value;}
|
||||||
else if (name == QStringLiteral("description")) {m_description = value;}
|
else if (name == QLatin1String("description")) {m_description = value;}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -101,7 +101,7 @@ TerminalStripData &TerminalStripData::operator=(const TerminalStripData &other)
|
|||||||
|
|
||||||
QDomElement TerminalStripData::infoToXml(QDomDocument &xml_doc, const QString &name, const QString &value)
|
QDomElement TerminalStripData::infoToXml(QDomDocument &xml_doc, const QString &name, const QString &value)
|
||||||
{
|
{
|
||||||
auto xml_elmt = xml_doc.createElement("information");
|
auto xml_elmt = xml_doc.createElement(QStringLiteral("information"));
|
||||||
xml_elmt.setAttribute(QStringLiteral("name"), name);
|
xml_elmt.setAttribute(QStringLiteral("name"), name);
|
||||||
xml_elmt.appendChild(xml_doc.createTextNode(value));
|
xml_elmt.appendChild(xml_doc.createTextNode(value));
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "terminalstripprojectconfigpage.h"
|
||||||
|
#include "../../../qeticons.h"
|
||||||
|
#include "../terminalstriplayouteditor.h"
|
||||||
|
#include "../../../qetproject.h"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
TerminalStripProjectConfigPage::TerminalStripProjectConfigPage(QETProject *project,
|
||||||
|
QWidget *parent) :
|
||||||
|
ProjectConfigPage { project, parent }
|
||||||
|
{
|
||||||
|
initWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TerminalStripProjectConfigPage::title() const {
|
||||||
|
return tr("Plan de bornes");
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon TerminalStripProjectConfigPage::icon() const {
|
||||||
|
return QET::Icons::TerminalStrip;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripProjectConfigPage::initWidgets()
|
||||||
|
{
|
||||||
|
m_layout_editor = new TerminalStripLayoutEditor{ project()->projectPropertiesHandler().terminalStripLayoutHandler().defaultLayout(),
|
||||||
|
this };
|
||||||
|
|
||||||
|
auto v_layout = new QVBoxLayout { this };
|
||||||
|
v_layout->addWidget(m_layout_editor);
|
||||||
|
setLayout(v_layout);
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef TERMINALSTRIPPROJECTCONFIGPAGE_H
|
||||||
|
#define TERMINALSTRIPPROJECTCONFIGPAGE_H
|
||||||
|
|
||||||
|
#include "../../../ui/configpage/projectconfigpages.h"
|
||||||
|
|
||||||
|
class TerminalStripLayoutEditor;
|
||||||
|
|
||||||
|
class TerminalStripProjectConfigPage : public ProjectConfigPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TerminalStripProjectConfigPage(QETProject *project, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
QString title() const override;
|
||||||
|
QIcon icon() const override;
|
||||||
|
|
||||||
|
void applyProjectConf() override {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void initWidgets() override;
|
||||||
|
void initLayout() override{}
|
||||||
|
void readValuesFromProject() override {}
|
||||||
|
void adjustReadOnly() override {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
TerminalStripLayoutEditor *m_layout_editor { nullptr };
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TERMINALSTRIPPROJECTCONFIGPAGE_H
|
||||||
88
sources/TerminalStrip/ui/addterminalstripitemdialog.cpp
Normal file
88
sources/TerminalStrip/ui/addterminalstripitemdialog.cpp
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2022 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "addterminalstripitemdialog.h"
|
||||||
|
#include "ui_addterminalstripitemdialog.h"
|
||||||
|
|
||||||
|
#include "../../undocommand/addgraphicsobjectcommand.h"
|
||||||
|
#include "../terminalstrip.h"
|
||||||
|
#include "../GraphicsItem/terminalstripitem.h"
|
||||||
|
#include "../../diagram.h"
|
||||||
|
|
||||||
|
void AddTerminalStripItemDialog::openDialog(Diagram *diagram, QWidget *parent)
|
||||||
|
{
|
||||||
|
AddTerminalStripItemDialog d(diagram->project(), parent);
|
||||||
|
if (d.exec())
|
||||||
|
{
|
||||||
|
const auto strip_{d.selectedTerminalStrip()};
|
||||||
|
if (strip_)
|
||||||
|
{
|
||||||
|
auto item_ = new TerminalStripItem(strip_);
|
||||||
|
diagram->addItem(item_);
|
||||||
|
item_->setPos(50, 50);
|
||||||
|
|
||||||
|
diagram->project()->undoStack()->push(new AddGraphicsObjectCommand(item_, diagram, QPointF{50, 50}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AddTerminalStripItemDialog::AddTerminalStripItemDialog(QETProject *project, QWidget *parent) :
|
||||||
|
QDialog{parent},
|
||||||
|
m_project{project},
|
||||||
|
ui{new Ui::AddTerminalStripItemDialog}
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
fillComboBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
AddTerminalStripItemDialog::~AddTerminalStripItemDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief AddTerminalStripItemDialog::selectedTerminalStrip
|
||||||
|
* @return The selected terminal strip or nullptr if no one is selected
|
||||||
|
* or error encounted.
|
||||||
|
*/
|
||||||
|
TerminalStrip *AddTerminalStripItemDialog::selectedTerminalStrip() const
|
||||||
|
{
|
||||||
|
if (m_project)
|
||||||
|
{
|
||||||
|
const QUuid uuid_{ui->m_terminal_strip_cb->currentData().toUuid()};
|
||||||
|
for (auto &&strip_ : m_project->terminalStrip())
|
||||||
|
{
|
||||||
|
if (strip_->uuid() == uuid_) {
|
||||||
|
return strip_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddTerminalStripItemDialog::fillComboBox()
|
||||||
|
{
|
||||||
|
if (m_project)
|
||||||
|
{
|
||||||
|
for (auto &&strip_ : m_project->terminalStrip())
|
||||||
|
{
|
||||||
|
const auto text{strip_->installation() + " " + strip_->location() + " " + strip_->name()};
|
||||||
|
ui->m_terminal_strip_cb->addItem(text, strip_->uuid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
51
sources/TerminalStrip/ui/addterminalstripitemdialog.h
Normal file
51
sources/TerminalStrip/ui/addterminalstripitemdialog.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2022 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef ADDTERMINALSTRIPITEMDIALOG_H
|
||||||
|
#define ADDTERMINALSTRIPITEMDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
|
class Diagram;
|
||||||
|
class QETDiagramEditor;
|
||||||
|
class QETProject;
|
||||||
|
class TerminalStrip;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class AddTerminalStripItemDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AddTerminalStripItemDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void openDialog(Diagram *diagram, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit AddTerminalStripItemDialog(QETProject *project, QWidget *parent = nullptr);
|
||||||
|
~AddTerminalStripItemDialog();
|
||||||
|
TerminalStrip *selectedTerminalStrip() const;
|
||||||
|
void fillComboBox();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<QETProject> m_project;
|
||||||
|
Ui::AddTerminalStripItemDialog *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ADDTERMINALSTRIPITEMDIALOG_H
|
||||||
87
sources/TerminalStrip/ui/addterminalstripitemdialog.ui
Normal file
87
sources/TerminalStrip/ui/addterminalstripitemdialog.ui
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AddTerminalStripItemDialog</class>
|
||||||
|
<widget class="QDialog" name="AddTerminalStripItemDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>326</width>
|
||||||
|
<height>100</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ajouter le plan de bornes suivant :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="m_terminal_strip_cb"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>AddTerminalStripItemDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>AddTerminalStripItemDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
@@ -42,6 +42,10 @@ FreeTerminalEditor::FreeTerminalEditor(QETProject *project, QWidget *parent) :
|
|||||||
ui->m_table_view->setModel(m_model);
|
ui->m_table_view->setModel(m_model);
|
||||||
ui->m_table_view->setCurrentIndex(m_model->index(0,0));
|
ui->m_table_view->setCurrentIndex(m_model->index(0,0));
|
||||||
|
|
||||||
|
if (m_project) {
|
||||||
|
connect(m_project, &QObject::destroyed, this, &FreeTerminalEditor::reload);
|
||||||
|
}
|
||||||
|
|
||||||
//Disabled the move if the table is currently edited (yellow cell)
|
//Disabled the move if the table is currently edited (yellow cell)
|
||||||
connect(m_model, &FreeTerminalModel::dataChanged, this, [=] {
|
connect(m_model, &FreeTerminalModel::dataChanged, this, [=] {
|
||||||
this->setDisabledMove();
|
this->setDisabledMove();
|
||||||
@@ -135,6 +139,31 @@ void FreeTerminalEditor::apply()
|
|||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FreeTerminalEditor::setProject
|
||||||
|
* Set @project as project handled by this editor.
|
||||||
|
* If a previous project was setted, everything is clear.
|
||||||
|
* This function track the destruction of the project,
|
||||||
|
* that mean if the project pointer is deleted
|
||||||
|
* no need to call this function with a nullptr,
|
||||||
|
* everything is made inside this class.
|
||||||
|
* @param project
|
||||||
|
*/
|
||||||
|
void FreeTerminalEditor::setProject(QETProject *project)
|
||||||
|
{
|
||||||
|
if(m_project) {
|
||||||
|
disconnect(m_project, &QObject::destroyed, this, &FreeTerminalEditor::reload);
|
||||||
|
}
|
||||||
|
m_project = project;
|
||||||
|
if (m_model) {
|
||||||
|
m_model->setProject(project);
|
||||||
|
}
|
||||||
|
if (m_project) {
|
||||||
|
connect(m_project, &QObject::destroyed, this, &FreeTerminalEditor::reload);
|
||||||
|
}
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
|
||||||
void FreeTerminalEditor::on_m_type_cb_activated(int index)
|
void FreeTerminalEditor::on_m_type_cb_activated(int index)
|
||||||
{
|
{
|
||||||
if (m_model)
|
if (m_model)
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
#define FREETERMINALEDITOR_H
|
#define FREETERMINALEDITOR_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include "../../qetproject.h"
|
||||||
|
|
||||||
class QETProject;
|
|
||||||
class RealTerminal;
|
class RealTerminal;
|
||||||
class FreeTerminalModel;
|
class FreeTerminalModel;
|
||||||
class QTableView;
|
class QTableView;
|
||||||
@@ -40,6 +40,8 @@ class FreeTerminalEditor : public QWidget
|
|||||||
void reload();
|
void reload();
|
||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
|
void setProject(QETProject *project);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_type_cb_activated(int index);
|
void on_m_type_cb_activated(int index);
|
||||||
void on_m_function_cb_activated(int index);
|
void on_m_function_cb_activated(int index);
|
||||||
@@ -52,7 +54,7 @@ class FreeTerminalEditor : public QWidget
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FreeTerminalEditor *ui;
|
Ui::FreeTerminalEditor *ui;
|
||||||
QETProject *m_project = nullptr;
|
QPointer <QETProject> m_project;
|
||||||
FreeTerminalModel *m_model = nullptr;
|
FreeTerminalModel *m_model {nullptr};
|
||||||
};
|
};
|
||||||
#endif // FREETERMINALEDITOR_H
|
#endif // FREETERMINALEDITOR_H
|
||||||
|
|||||||
@@ -56,10 +56,30 @@ FreeTerminalModel::Column FreeTerminalModel::columnTypeForIndex(const QModelInde
|
|||||||
* @param parent
|
* @param parent
|
||||||
*/
|
*/
|
||||||
FreeTerminalModel::FreeTerminalModel(QETProject *project, QObject *parent) :
|
FreeTerminalModel::FreeTerminalModel(QETProject *project, QObject *parent) :
|
||||||
QAbstractTableModel(parent),
|
QAbstractTableModel(parent) {
|
||||||
m_project(project)
|
setProject(project);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FreeTerminalModel::setProject
|
||||||
|
* Set @project as project handled by this model.
|
||||||
|
* If a previous project was setted, everything is clear.
|
||||||
|
* This function track the destruction of the project,
|
||||||
|
* that mean if the project pointer is deleted
|
||||||
|
* no need to call this function with a nullptr,
|
||||||
|
* everything is made inside this class.
|
||||||
|
* @param project
|
||||||
|
*/
|
||||||
|
void FreeTerminalModel::setProject(QETProject *project)
|
||||||
{
|
{
|
||||||
fillTerminalVector();
|
if(m_project) {
|
||||||
|
disconnect(m_project, &QObject::destroyed, this, &FreeTerminalModel::clear);
|
||||||
|
}
|
||||||
|
m_project = project;
|
||||||
|
if (m_project) {
|
||||||
|
connect(m_project, &QObject::destroyed, this, &FreeTerminalModel::clear);
|
||||||
|
}
|
||||||
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -305,6 +325,7 @@ QVector<QSharedPointer<RealTerminal> > FreeTerminalModel::realTerminalForIndex(c
|
|||||||
*/
|
*/
|
||||||
void FreeTerminalModel::fillTerminalVector()
|
void FreeTerminalModel::fillTerminalVector()
|
||||||
{
|
{
|
||||||
|
if (m_project) {
|
||||||
ElementProvider provider_(m_project);
|
ElementProvider provider_(m_project);
|
||||||
auto free_terminal_vector = provider_.freeTerminal();
|
auto free_terminal_vector = provider_.freeTerminal();
|
||||||
|
|
||||||
@@ -320,6 +341,7 @@ void FreeTerminalModel::fillTerminalVector()
|
|||||||
m_real_t_data.append(modelRealTerminalData::data(terminal_->realTerminal()));
|
m_real_t_data.append(modelRealTerminalData::data(terminal_->realTerminal()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
* A little delegate for add a combobox to edit type and function
|
* A little delegate for add a combobox to edit type and function
|
||||||
@@ -333,7 +355,7 @@ QWidget *FreeTerminalModelDelegate::createEditor(QWidget *parent, const QStyleOp
|
|||||||
{
|
{
|
||||||
if (index.column() == TYPE_CELL) {
|
if (index.column() == TYPE_CELL) {
|
||||||
auto qcb = new QComboBox(parent);
|
auto qcb = new QComboBox(parent);
|
||||||
qcb->setObjectName(QLatin1String("terminal_type"));
|
qcb->setObjectName(QStringLiteral("terminal_type"));
|
||||||
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTGeneric), ElementData::TTGeneric);
|
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTGeneric), ElementData::TTGeneric);
|
||||||
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTFuse), ElementData::TTFuse);
|
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTFuse), ElementData::TTFuse);
|
||||||
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTSectional), ElementData::TTSectional);
|
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTSectional), ElementData::TTSectional);
|
||||||
@@ -344,7 +366,7 @@ QWidget *FreeTerminalModelDelegate::createEditor(QWidget *parent, const QStyleOp
|
|||||||
}
|
}
|
||||||
if (index.column() == FUNCTION_CELL) {
|
if (index.column() == FUNCTION_CELL) {
|
||||||
auto qcb = new QComboBox(parent);
|
auto qcb = new QComboBox(parent);
|
||||||
qcb->setObjectName(QLatin1String("terminal_function"));
|
qcb->setObjectName(QStringLiteral("terminal_function"));
|
||||||
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFGeneric), ElementData::TFGeneric);
|
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFGeneric), ElementData::TFGeneric);
|
||||||
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFPhase), ElementData::TFPhase);
|
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFPhase), ElementData::TFPhase);
|
||||||
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFNeutral), ElementData::TFNeutral);
|
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFNeutral), ElementData::TFNeutral);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class FreeTerminalModel : public QAbstractTableModel
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FreeTerminalModel(QETProject *project, QObject *parent = nullptr);
|
explicit FreeTerminalModel(QETProject *project, QObject *parent = nullptr);
|
||||||
|
void setProject(QETProject *project);
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent) const override;
|
int rowCount(const QModelIndex &parent) const override;
|
||||||
int columnCount(const QModelIndex &parent) const override;
|
int columnCount(const QModelIndex &parent) const override;
|
||||||
|
|||||||
@@ -84,6 +84,12 @@ TerminalStripEditor::~TerminalStripEditor() {
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TerminalStripEditor::setProject(QETProject *project)
|
||||||
|
{
|
||||||
|
m_project = project;
|
||||||
|
setCurrentStrip(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TerminalStripEditor::setCurrentStrip
|
* @brief TerminalStripEditor::setCurrentStrip
|
||||||
* Set the current terminal strip edited to \p strip_
|
* Set the current terminal strip edited to \p strip_
|
||||||
@@ -98,27 +104,15 @@ void TerminalStripEditor::setCurrentStrip(TerminalStrip *strip_)
|
|||||||
if (m_current_strip) {
|
if (m_current_strip) {
|
||||||
disconnect(m_current_strip, &TerminalStrip::orderChanged, this, &TerminalStripEditor::reload);
|
disconnect(m_current_strip, &TerminalStrip::orderChanged, this, &TerminalStripEditor::reload);
|
||||||
disconnect(m_current_strip, &TerminalStrip::bridgeChanged, this, &TerminalStripEditor::reload);
|
disconnect(m_current_strip, &TerminalStrip::bridgeChanged, this, &TerminalStripEditor::reload);
|
||||||
|
disconnect(m_current_strip, &QObject::destroyed, this, &TerminalStripEditor::clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->m_move_to_cb->clear();
|
ui->m_move_to_cb->clear();
|
||||||
|
|
||||||
if (!strip_)
|
if (!strip_) {
|
||||||
{
|
clear();
|
||||||
ui->m_installation_le ->clear();
|
|
||||||
ui->m_location_le ->clear();
|
|
||||||
ui->m_name_le ->clear();
|
|
||||||
ui->m_comment_le ->clear();
|
|
||||||
ui->m_description_te ->clear();
|
|
||||||
m_current_strip = nullptr;
|
|
||||||
|
|
||||||
ui->m_table_widget->setModel(nullptr);
|
|
||||||
if (m_model) {
|
|
||||||
m_model->deleteLater();
|
|
||||||
m_model = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->m_installation_le ->setText(strip_->installation());
|
ui->m_installation_le ->setText(strip_->installation());
|
||||||
ui->m_location_le ->setText(strip_->location());
|
ui->m_location_le ->setText(strip_->location());
|
||||||
ui->m_name_le ->setText(strip_->name());
|
ui->m_name_le ->setText(strip_->name());
|
||||||
@@ -159,6 +153,7 @@ void TerminalStripEditor::setCurrentStrip(TerminalStrip *strip_)
|
|||||||
|
|
||||||
connect(m_current_strip, &TerminalStrip::orderChanged, this, &TerminalStripEditor::reload);
|
connect(m_current_strip, &TerminalStrip::orderChanged, this, &TerminalStripEditor::reload);
|
||||||
connect(m_current_strip, &TerminalStrip::bridgeChanged, this, &TerminalStripEditor::reload);
|
connect(m_current_strip, &TerminalStrip::bridgeChanged, this, &TerminalStripEditor::reload);
|
||||||
|
connect(m_current_strip, &QObject::destroyed, this, &TerminalStripEditor::clear);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,6 +175,7 @@ void TerminalStripEditor::reload()
|
|||||||
if (m_model)
|
if (m_model)
|
||||||
{
|
{
|
||||||
m_model->reload();
|
m_model->reload();
|
||||||
|
spanMultiLevelTerminals();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,6 +225,22 @@ void TerminalStripEditor::apply()
|
|||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TerminalStripEditor::clear()
|
||||||
|
{
|
||||||
|
ui->m_installation_le ->clear();
|
||||||
|
ui->m_location_le ->clear();
|
||||||
|
ui->m_name_le ->clear();
|
||||||
|
ui->m_comment_le ->clear();
|
||||||
|
ui->m_description_te ->clear();
|
||||||
|
m_current_strip.clear();
|
||||||
|
|
||||||
|
ui->m_table_widget->setModel(nullptr);
|
||||||
|
if (m_model) {
|
||||||
|
m_model->deleteLater();
|
||||||
|
m_model = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TerminalStripEditor::spanMultiLevelTerminals
|
* @brief TerminalStripEditor::spanMultiLevelTerminals
|
||||||
* Span row of m_table_widget for multi-level terminal
|
* Span row of m_table_widget for multi-level terminal
|
||||||
|
|||||||
@@ -41,11 +41,13 @@ class TerminalStripEditor : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit TerminalStripEditor(QETProject *project, QWidget *parent = nullptr);
|
explicit TerminalStripEditor(QETProject *project, QWidget *parent = nullptr);
|
||||||
~TerminalStripEditor() override;
|
~TerminalStripEditor() override;
|
||||||
|
void setProject(QETProject *project);
|
||||||
void setCurrentStrip(TerminalStrip *strip_);
|
void setCurrentStrip(TerminalStrip *strip_);
|
||||||
void reload();
|
void reload();
|
||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void clear();
|
||||||
void spanMultiLevelTerminals();
|
void spanMultiLevelTerminals();
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
QSize setUpBridgeCellWidth();
|
QSize setUpBridgeCellWidth();
|
||||||
@@ -67,8 +69,8 @@ class TerminalStripEditor : public QWidget
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::TerminalStripEditor *ui;
|
Ui::TerminalStripEditor *ui;
|
||||||
QETProject *m_project {nullptr};
|
QPointer<QETProject> m_project;
|
||||||
TerminalStrip *m_current_strip {nullptr};
|
QPointer<TerminalStrip> m_current_strip;
|
||||||
TerminalStripModel *m_model {nullptr};
|
TerminalStripModel *m_model {nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include "../UndoCommand/addterminalstripcommand.h"
|
#include "../UndoCommand/addterminalstripcommand.h"
|
||||||
#include "freeterminaleditor.h"
|
#include "freeterminaleditor.h"
|
||||||
|
#include "../../qetapp.h"
|
||||||
|
#include "../../qetdiagrameditor.h"
|
||||||
#include "../../qetproject.h"
|
#include "../../qetproject.h"
|
||||||
#include "../realterminal.h"
|
#include "../realterminal.h"
|
||||||
#include "../terminalstrip.h"
|
#include "../terminalstrip.h"
|
||||||
@@ -27,6 +29,8 @@
|
|||||||
#include "terminalstripeditorwindow.h"
|
#include "terminalstripeditorwindow.h"
|
||||||
#include "terminalstriptreedockwidget.h"
|
#include "terminalstriptreedockwidget.h"
|
||||||
|
|
||||||
|
QPointer<TerminalStripEditorWindow> TerminalStripEditorWindow::window_;
|
||||||
|
|
||||||
static const int EMPTY_PAGE = 0;
|
static const int EMPTY_PAGE = 0;
|
||||||
static const int FREE_TERMINAL_PAGE = 1;
|
static const int FREE_TERMINAL_PAGE = 1;
|
||||||
static const int TERMINAL_STRIP_PAGE = 2;
|
static const int TERMINAL_STRIP_PAGE = 2;
|
||||||
@@ -35,12 +39,27 @@ static const int TERMINAL_STRIP_PAGE = 2;
|
|||||||
* @param project
|
* @param project
|
||||||
* @param parent
|
* @param parent
|
||||||
*/
|
*/
|
||||||
|
void TerminalStripEditorWindow::edit(TerminalStrip *strip)
|
||||||
|
{
|
||||||
|
if (const auto project_ = strip->project())
|
||||||
|
{
|
||||||
|
auto editor_ = TerminalStripEditorWindow::instance(project_, QETApp::diagramEditor(project_));
|
||||||
|
editor_->setCurrentStrip(strip);
|
||||||
|
editor_->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TerminalStripEditorWindow::TerminalStripEditorWindow(QETProject *project, QWidget *parent) :
|
TerminalStripEditorWindow::TerminalStripEditorWindow(QETProject *project, QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::TerminalStripEditorWindow),
|
ui(new Ui::TerminalStripEditorWindow),
|
||||||
m_project(project)
|
m_project(project)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
if (auto diagram_editor = QETApp::diagramEditor(project)) {
|
||||||
|
ui->m_tool_bar->addSeparator();
|
||||||
|
ui->m_tool_bar->addAction(diagram_editor->undo);
|
||||||
|
ui->m_tool_bar->addAction(diagram_editor->redo);
|
||||||
|
}
|
||||||
ui->m_remove_terminal->setDisabled(true);
|
ui->m_remove_terminal->setDisabled(true);
|
||||||
addTreeDockWidget();
|
addTreeDockWidget();
|
||||||
|
|
||||||
@@ -62,6 +81,22 @@ TerminalStripEditorWindow::~TerminalStripEditorWindow()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripEditorWindow::setProject
|
||||||
|
* @param project
|
||||||
|
*/
|
||||||
|
void TerminalStripEditorWindow::setProject(QETProject *project)
|
||||||
|
{
|
||||||
|
m_project = project;
|
||||||
|
m_tree_dock->setProject(project);
|
||||||
|
m_free_terminal_editor->setProject(project);
|
||||||
|
m_terminal_strip_editor->setProject(project);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripEditorWindow::setCurrentStrip(TerminalStrip *strip) {
|
||||||
|
m_tree_dock->setSelectedStrip(strip);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TerminalStripEditorWindow::addTreeDockWidget
|
* @brief TerminalStripEditorWindow::addTreeDockWidget
|
||||||
*/
|
*/
|
||||||
@@ -182,4 +217,3 @@ void TerminalStripEditorWindow::on_m_button_box_clicked(QAbstractButton *button)
|
|||||||
void TerminalStripEditorWindow::on_m_stacked_widget_currentChanged(int arg1) {
|
void TerminalStripEditorWindow::on_m_stacked_widget_currentChanged(int arg1) {
|
||||||
ui->m_button_box->setHidden(arg1 == EMPTY_PAGE);
|
ui->m_button_box->setHidden(arg1 == EMPTY_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#define TERMINALSTRIPEDITORWINDOW_H
|
#define TERMINALSTRIPEDITORWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
class QETProject;
|
class QETProject;
|
||||||
class TerminalStripTreeDockWidget;
|
class TerminalStripTreeDockWidget;
|
||||||
@@ -35,16 +37,50 @@ class TerminalStripEditorWindow : public QMainWindow
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
//We need to use a QPointer instead of a raw pointer because when window_
|
||||||
|
//have got a parent widget, the parent widget can delete the window_
|
||||||
|
//instance in her destrucor and then window_ become a dangling pointer.
|
||||||
|
static QPointer<TerminalStripEditorWindow> window_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TerminalStripEditorWindow* instance(QETProject *project, QWidget *parent = nullptr) {
|
||||||
|
static QMutex mutex_;
|
||||||
|
if (!window_) {
|
||||||
|
mutex_.lock();
|
||||||
|
if (!window_)
|
||||||
|
window_ = new TerminalStripEditorWindow{project, parent};
|
||||||
|
mutex_.unlock();
|
||||||
|
} else {
|
||||||
|
window_->setProject(project);
|
||||||
|
}
|
||||||
|
return window_;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dropInstance () {
|
||||||
|
static QMutex mutex;
|
||||||
|
if (window_) {
|
||||||
|
mutex.lock();
|
||||||
|
window_->deleteLater();
|
||||||
|
window_.clear();
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void edit(TerminalStrip *strip);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TerminalStripEditorWindow(QETProject *project, QWidget *parent = nullptr);
|
explicit TerminalStripEditorWindow(QETProject *project, QWidget *parent = nullptr);
|
||||||
~TerminalStripEditorWindow();
|
~TerminalStripEditorWindow();
|
||||||
|
|
||||||
|
void setProject(QETProject *project);
|
||||||
|
void setCurrentStrip(TerminalStrip *strip);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_add_terminal_strip_triggered();
|
void on_m_add_terminal_strip_triggered();
|
||||||
void on_m_remove_terminal_triggered();
|
void on_m_remove_terminal_triggered();
|
||||||
void on_m_reload_triggered();
|
void on_m_reload_triggered();
|
||||||
void on_m_button_box_clicked(QAbstractButton *button);
|
void on_m_button_box_clicked(QAbstractButton *button);
|
||||||
|
|
||||||
void on_m_stacked_widget_currentChanged(int arg1);
|
void on_m_stacked_widget_currentChanged(int arg1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -54,7 +90,7 @@ class TerminalStripEditorWindow : public QMainWindow
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::TerminalStripEditorWindow *ui{nullptr};
|
Ui::TerminalStripEditorWindow *ui{nullptr};
|
||||||
QETProject *m_project {nullptr};
|
QPointer <QETProject> m_project;
|
||||||
TerminalStripTreeDockWidget *m_tree_dock{nullptr};
|
TerminalStripTreeDockWidget *m_tree_dock{nullptr};
|
||||||
FreeTerminalEditor *m_free_terminal_editor {nullptr};
|
FreeTerminalEditor *m_free_terminal_editor {nullptr};
|
||||||
TerminalStripEditor *m_terminal_strip_editor {nullptr};
|
TerminalStripEditor *m_terminal_strip_editor {nullptr};
|
||||||
|
|||||||
@@ -33,12 +33,12 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1364</width>
|
<width>1364</width>
|
||||||
<height>21</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
<widget class="QToolBar" name="toolBar">
|
<widget class="QToolBar" name="m_tool_bar">
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>toolBar</string>
|
<string>toolBar</string>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
270
sources/TerminalStrip/ui/terminalstriplayouteditor.cpp
Normal file
270
sources/TerminalStrip/ui/terminalstriplayouteditor.cpp
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <QFontDialog>
|
||||||
|
|
||||||
|
#include "terminalstriplayouteditor.h"
|
||||||
|
#include "ui_terminalstriplayouteditor.h"
|
||||||
|
#include "../GraphicsItem/properties/terminalstriplayoutpattern.h"
|
||||||
|
|
||||||
|
TerminalStripLayoutEditor::TerminalStripLayoutEditor(QSharedPointer<TerminalStripLayoutPattern> layout,
|
||||||
|
QWidget *parent) :
|
||||||
|
QWidget{ parent },
|
||||||
|
ui{ new Ui::TerminalStripLayoutEditor },
|
||||||
|
m_layout{ layout }
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->m_graphics_view->setScene(new QGraphicsScene{ this });
|
||||||
|
ui->m_graphics_view->scene()->addItem(&m_preview_strip_item);
|
||||||
|
updateUi();
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminalStripLayoutEditor::~TerminalStripLayoutEditor()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripLayoutEditor::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
|
QWidget::resizeEvent(event);
|
||||||
|
updatePreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripLayoutEditor::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
QWidget::showEvent(event);
|
||||||
|
updatePreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripLayoutEditor::valueEdited()
|
||||||
|
{
|
||||||
|
if (!m_layout || m_ui_updating) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_layout.data()->m_header_rect.setRect(0,
|
||||||
|
ui->m_y_header_sb->value(),
|
||||||
|
ui->m_width_header_sb->value(),
|
||||||
|
ui->m_height_header_sb->value());
|
||||||
|
|
||||||
|
m_layout.data()->m_spacer_rect.setRect(0,
|
||||||
|
ui->m_y_spacer_sb->value(),
|
||||||
|
ui->m_width_spacer_sb->value(),
|
||||||
|
ui->m_height_spacer_sb->value());
|
||||||
|
|
||||||
|
m_layout.data()->m_terminal_rect[0].setRect(0,
|
||||||
|
ui->m_y_terminal_0_sb->value(),
|
||||||
|
ui->m_width_terminal_0_sb->value(),
|
||||||
|
ui->m_height_terminal_0_sb->value());
|
||||||
|
|
||||||
|
m_layout.data()->m_terminal_rect[1].setRect(0,
|
||||||
|
ui->m_y_terminal_1_sb->value(),
|
||||||
|
ui->m_width_terminal_1_sb->value(),
|
||||||
|
ui->m_height_terminal_1_sb->value());
|
||||||
|
|
||||||
|
m_layout.data()->m_terminal_rect[2].setRect(0,
|
||||||
|
ui->m_y_terminal_2_sb->value(),
|
||||||
|
ui->m_width_terminal_2_sb->value(),
|
||||||
|
ui->m_height_terminal_2_sb->value());
|
||||||
|
|
||||||
|
m_layout.data()->m_terminal_rect[3].setRect(0,
|
||||||
|
ui->m_y_terminal_3_sb->value(),
|
||||||
|
ui->m_width_terminal_3_sb->value(),
|
||||||
|
ui->m_height_terminal_3_sb->value());
|
||||||
|
|
||||||
|
m_layout.data()->m_bridge_point_y_offset[0] = ui->m_bridge_point_0_sb->value();
|
||||||
|
m_layout.data()->m_bridge_point_y_offset[1] = ui->m_bridge_point_1_sb->value();
|
||||||
|
m_layout.data()->m_bridge_point_y_offset[2] = ui->m_bridge_point_2_sb->value();
|
||||||
|
m_layout.data()->m_bridge_point_y_offset[3] = ui->m_bridge_point_3_sb->value();
|
||||||
|
|
||||||
|
auto font_ = ui->m_font_cb->currentFont();
|
||||||
|
font_.setPixelSize(ui->m_font_size_sb->value());
|
||||||
|
m_layout->setFont(font_);
|
||||||
|
|
||||||
|
m_layout.data()->m_header_text_orientation = ui->m_header_text_orientation_cb->currentIndex() == 0 ?
|
||||||
|
Qt::Horizontal :
|
||||||
|
Qt::Vertical;
|
||||||
|
|
||||||
|
switch (ui->m_header_text_alignment_cb->currentIndex()) {
|
||||||
|
case 0:
|
||||||
|
m_layout.data()->setHeaderTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); break;
|
||||||
|
case 1:
|
||||||
|
m_layout.data()->setHeaderTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); break;
|
||||||
|
default:
|
||||||
|
m_layout.data()->setHeaderTextAlignment(Qt::AlignRight | Qt::AlignVCenter); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Terminal text
|
||||||
|
m_layout.data()->m_terminals_text_orientation = ui->m_terminal_text_orientation_cb->currentIndex() == 0 ?
|
||||||
|
Qt::Horizontal :
|
||||||
|
Qt::Vertical;
|
||||||
|
|
||||||
|
switch (ui->m_terminal_text_alignment_cb->currentIndex()) {
|
||||||
|
case 0:
|
||||||
|
m_layout.data()->setTerminalsTextAlignment(Qt::Alignment {Qt::AlignLeft | Qt::AlignVCenter});
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
m_layout.data()->setTerminalsTextAlignment(Qt::Alignment { Qt::AlignHCenter | Qt::AlignVCenter});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
m_layout.data()->setTerminalsTextAlignment(Qt::Alignment { Qt::AlignRight | Qt::AlignVCenter});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_layout.data()->m_terminals_text_y = ui->m_terminal_text_y_sb->value();
|
||||||
|
m_layout.data()->m_terminals_text_height = ui->m_terminal_text_height_sb->value();
|
||||||
|
|
||||||
|
//Xref text
|
||||||
|
m_layout.data()->m_xref_text_orientation = ui->m_xref_orientation_cb->currentIndex() == 0 ?
|
||||||
|
Qt::Horizontal :
|
||||||
|
Qt::Vertical;
|
||||||
|
|
||||||
|
switch (ui->m_xref_alignment_cb->currentIndex()) {
|
||||||
|
case 0:
|
||||||
|
m_layout.data()->setXrefTextAlignment(Qt::Alignment {Qt::AlignLeft | Qt::AlignVCenter});
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
m_layout.data()->setXrefTextAlignment(Qt::Alignment { Qt::AlignHCenter | Qt::AlignVCenter});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
m_layout.data()->setXrefTextAlignment(Qt::Alignment { Qt::AlignRight | Qt::AlignVCenter});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_layout.data()->m_xref_text_y = ui->m_xref_y_sb->value();
|
||||||
|
m_layout.data()->m_xref_text_height = ui->m_xref_height_sb->value();
|
||||||
|
|
||||||
|
updateUi();
|
||||||
|
m_preview_strip_item.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripLayoutEditor::updateUi()
|
||||||
|
{
|
||||||
|
if (!m_layout) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto data = m_layout.data();
|
||||||
|
|
||||||
|
m_ui_updating = true;
|
||||||
|
|
||||||
|
ui->m_y_header_sb->setValue(data->m_header_rect.y());
|
||||||
|
ui->m_width_header_sb->setValue(data->m_header_rect.width());
|
||||||
|
ui->m_height_header_sb->setValue(data->m_header_rect.height());
|
||||||
|
|
||||||
|
ui->m_y_spacer_sb->setValue(data->m_spacer_rect.y());
|
||||||
|
ui->m_width_spacer_sb->setValue(data->m_spacer_rect.width());
|
||||||
|
ui->m_height_spacer_sb->setValue(data->m_spacer_rect.height());
|
||||||
|
|
||||||
|
const auto terminal_0 = data->m_terminal_rect[0];
|
||||||
|
ui->m_y_terminal_0_sb->setValue(terminal_0.y());
|
||||||
|
ui->m_height_terminal_0_sb->setValue(terminal_0.height());
|
||||||
|
ui->m_width_terminal_0_sb->setValue(terminal_0.width());
|
||||||
|
|
||||||
|
const auto terminal_1 = data->m_terminal_rect[1];
|
||||||
|
ui->m_y_terminal_1_sb->setValue(terminal_1.y());
|
||||||
|
ui->m_height_terminal_1_sb->setValue(terminal_1.height());
|
||||||
|
ui->m_width_terminal_1_sb->setValue(terminal_1.width());
|
||||||
|
|
||||||
|
const auto terminal_2 = data->m_terminal_rect[2];
|
||||||
|
ui->m_y_terminal_2_sb->setValue(terminal_2.y());
|
||||||
|
ui->m_height_terminal_2_sb->setValue(terminal_2.height());
|
||||||
|
ui->m_width_terminal_2_sb->setValue(terminal_2.width());
|
||||||
|
|
||||||
|
const auto terminal_3 = data->m_terminal_rect[3];
|
||||||
|
ui->m_y_terminal_3_sb->setValue(terminal_3.y());
|
||||||
|
ui->m_height_terminal_3_sb->setValue(terminal_3.height());
|
||||||
|
ui->m_width_terminal_3_sb->setValue(terminal_3.width());
|
||||||
|
|
||||||
|
const auto bridge_point = data->m_bridge_point_y_offset;
|
||||||
|
ui->m_bridge_point_0_sb->setValue(bridge_point[0]);
|
||||||
|
ui->m_bridge_point_1_sb->setValue(bridge_point[1]);
|
||||||
|
ui->m_bridge_point_2_sb->setValue(bridge_point[2]);
|
||||||
|
ui->m_bridge_point_3_sb->setValue(bridge_point[3]);
|
||||||
|
|
||||||
|
const auto font = m_layout->font();
|
||||||
|
ui->m_font_size_sb->setValue(font.pixelSize());
|
||||||
|
ui->m_font_cb->setCurrentFont(font);
|
||||||
|
|
||||||
|
if (data->m_header_text_orientation == Qt::Horizontal) {
|
||||||
|
ui->m_header_text_orientation_cb->setCurrentIndex(0);
|
||||||
|
} else {
|
||||||
|
ui->m_header_text_orientation_cb->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->m_terminals_text_orientation == Qt::Horizontal) {
|
||||||
|
ui->m_terminal_text_orientation_cb->setCurrentIndex(0);
|
||||||
|
} else {
|
||||||
|
ui->m_terminal_text_orientation_cb->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto header_alignment = data->headerTextAlignment();
|
||||||
|
if (header_alignment &Qt::AlignLeft) {
|
||||||
|
ui->m_header_text_alignment_cb->setCurrentIndex(0);
|
||||||
|
} else if (header_alignment &Qt::AlignHCenter) {
|
||||||
|
ui->m_header_text_alignment_cb->setCurrentIndex(1);
|
||||||
|
} else if (header_alignment &Qt::AlignRight) {
|
||||||
|
ui->m_header_text_alignment_cb->setCurrentIndex(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Terminal text
|
||||||
|
const auto terminal_alignment = data->terminalsTextAlignment();
|
||||||
|
if (terminal_alignment &Qt::AlignLeft) {
|
||||||
|
ui->m_terminal_text_alignment_cb->setCurrentIndex(0);
|
||||||
|
} else if (terminal_alignment &Qt::AlignHCenter) {
|
||||||
|
ui->m_terminal_text_alignment_cb->setCurrentIndex(1);
|
||||||
|
} else if (terminal_alignment &Qt::AlignRight) {
|
||||||
|
ui->m_terminal_text_alignment_cb->setCurrentIndex(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->m_terminal_text_y_sb->setValue(data->m_terminals_text_y);
|
||||||
|
ui->m_terminal_text_height_sb->setValue(data->m_terminals_text_height);
|
||||||
|
|
||||||
|
//Xref text
|
||||||
|
if (data->m_xref_text_orientation == Qt::Horizontal) {
|
||||||
|
ui->m_xref_orientation_cb->setCurrentIndex(0);
|
||||||
|
} else {
|
||||||
|
ui->m_xref_orientation_cb->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto xref_alignment = data->xrefTextAlignment();
|
||||||
|
if (xref_alignment &Qt::AlignLeft) {
|
||||||
|
ui->m_xref_alignment_cb->setCurrentIndex(0);
|
||||||
|
} else if (xref_alignment &Qt::AlignHCenter) {
|
||||||
|
ui->m_xref_alignment_cb->setCurrentIndex(1);
|
||||||
|
} else if (xref_alignment &Qt::AlignRight) {
|
||||||
|
ui->m_xref_alignment_cb->setCurrentIndex(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->m_xref_y_sb->setValue(data->m_xref_text_y);
|
||||||
|
ui->m_xref_height_sb->setValue(data->m_xref_text_height);
|
||||||
|
|
||||||
|
m_ui_updating = false;
|
||||||
|
updatePreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripLayoutEditor::updatePreview()
|
||||||
|
{
|
||||||
|
ui->m_graphics_view->fitInView(m_preview_strip_item.boundingRect().adjusted(-5,-5,5,5),
|
||||||
|
Qt::KeepAspectRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerminalStripLayoutEditor::on_m_display_preview_help_clicked(bool checked)
|
||||||
|
{
|
||||||
|
m_preview_strip_item.m_drawer.setPreviewDraw(checked);
|
||||||
|
m_preview_strip_item.update();
|
||||||
|
}
|
||||||
92
sources/TerminalStrip/ui/terminalstriplayouteditor.h
Normal file
92
sources/TerminalStrip/ui/terminalstriplayouteditor.h
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef TERMINALSTRIPLAYOUTEDITOR_H
|
||||||
|
#define TERMINALSTRIPLAYOUTEDITOR_H
|
||||||
|
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "../GraphicsItem/demoterminalstrip.h"
|
||||||
|
#include "../GraphicsItem/terminalstripdrawer.h"
|
||||||
|
|
||||||
|
class TerminalStripLayoutPattern;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class TerminalStripLayoutEditor;
|
||||||
|
}
|
||||||
|
|
||||||
|
class PreviewStripItem : public QGraphicsItem
|
||||||
|
{
|
||||||
|
friend class TerminalStripLayoutEditor;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PreviewStripItem (QSharedPointer<TerminalStripLayoutPattern> layout) :
|
||||||
|
m_drawer {QSharedPointer<TerminalStripDrawer::DemoTerminalStrip>{new TerminalStripDrawer::DemoTerminalStrip},
|
||||||
|
layout}
|
||||||
|
{}
|
||||||
|
|
||||||
|
QRectF boundingRect() const override {
|
||||||
|
return m_drawer.boundingRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paint(QPainter *painter,
|
||||||
|
const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget = nullptr) override
|
||||||
|
{
|
||||||
|
Q_UNUSED (option); Q_UNUSED (widget);
|
||||||
|
m_drawer.paint(painter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
TerminalStripDrawer::TerminalStripDrawer m_drawer;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The TerminalStripLayoutEditor class
|
||||||
|
* Widget used to edit the layout of a terminal strip item
|
||||||
|
*/
|
||||||
|
class TerminalStripLayoutEditor : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit TerminalStripLayoutEditor(QSharedPointer<TerminalStripLayoutPattern> layout,
|
||||||
|
QWidget *parent = nullptr);
|
||||||
|
~TerminalStripLayoutEditor();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
void showEvent(QShowEvent *event) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void valueEdited();
|
||||||
|
void on_m_display_preview_help_clicked(bool checked);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateUi();
|
||||||
|
void updatePreview();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::TerminalStripLayoutEditor *ui;
|
||||||
|
QSharedPointer<TerminalStripLayoutPattern> m_layout;
|
||||||
|
bool m_ui_updating { false } ;
|
||||||
|
PreviewStripItem m_preview_strip_item {m_layout};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TERMINALSTRIPLAYOUTEDITOR_H
|
||||||
1101
sources/TerminalStrip/ui/terminalstriplayouteditor.ui
Normal file
1101
sources/TerminalStrip/ui/terminalstriplayouteditor.ui
Normal file
File diff suppressed because it is too large
Load Diff
@@ -186,7 +186,7 @@ QVariant TerminalStripModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
return mrtd.led_ ? Qt::Checked : Qt::Unchecked;
|
return mrtd.led_ ? Qt::Checked : Qt::Unchecked;
|
||||||
}
|
}
|
||||||
else if (role == Qt::BackgroundRole && index.column() <= CONDUCTOR_CELL )
|
else if (role == Qt::BackgroundRole && index.column() < COLUMN_COUNT )
|
||||||
{
|
{
|
||||||
if (m_modified_cell.contains(mrtd.element_) &&
|
if (m_modified_cell.contains(mrtd.element_) &&
|
||||||
m_modified_cell.value(mrtd.element_).at(index.column()))
|
m_modified_cell.value(mrtd.element_).at(index.column()))
|
||||||
@@ -794,7 +794,7 @@ QWidget *TerminalStripModelDelegate::createEditor(QWidget *parent, const QStyleO
|
|||||||
{
|
{
|
||||||
if (index.column() == TYPE_CELL) {
|
if (index.column() == TYPE_CELL) {
|
||||||
auto qcb = new QComboBox(parent);
|
auto qcb = new QComboBox(parent);
|
||||||
qcb->setObjectName(QLatin1String("terminal_type"));
|
qcb->setObjectName(QStringLiteral("terminal_type"));
|
||||||
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTGeneric), ElementData::TTGeneric);
|
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTGeneric), ElementData::TTGeneric);
|
||||||
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTFuse), ElementData::TTFuse);
|
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTFuse), ElementData::TTFuse);
|
||||||
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTSectional), ElementData::TTSectional);
|
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTSectional), ElementData::TTSectional);
|
||||||
@@ -805,7 +805,7 @@ QWidget *TerminalStripModelDelegate::createEditor(QWidget *parent, const QStyleO
|
|||||||
}
|
}
|
||||||
if (index.column() == FUNCTION_CELL) {
|
if (index.column() == FUNCTION_CELL) {
|
||||||
auto qcb = new QComboBox(parent);
|
auto qcb = new QComboBox(parent);
|
||||||
qcb->setObjectName(QLatin1String("terminal_function"));
|
qcb->setObjectName(QStringLiteral("terminal_function"));
|
||||||
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFGeneric), ElementData::TFGeneric);
|
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFGeneric), ElementData::TFGeneric);
|
||||||
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFPhase), ElementData::TFPhase);
|
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFPhase), ElementData::TFPhase);
|
||||||
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFNeutral), ElementData::TFNeutral);
|
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFNeutral), ElementData::TFNeutral);
|
||||||
|
|||||||
@@ -30,11 +30,10 @@
|
|||||||
|
|
||||||
TerminalStripTreeDockWidget::TerminalStripTreeDockWidget(QETProject *project, QWidget *parent) :
|
TerminalStripTreeDockWidget::TerminalStripTreeDockWidget(QETProject *project, QWidget *parent) :
|
||||||
QDockWidget(parent),
|
QDockWidget(parent),
|
||||||
ui(new Ui::TerminalStripTreeDockWidget),
|
ui(new Ui::TerminalStripTreeDockWidget)
|
||||||
m_project(project)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
buildTree();
|
setProject(project);
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||||
ui->m_tree_view->expandRecursively(ui->m_tree_view->rootIndex());
|
ui->m_tree_view->expandRecursively(ui->m_tree_view->rootIndex());
|
||||||
@@ -48,6 +47,32 @@ TerminalStripTreeDockWidget::~TerminalStripTreeDockWidget()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripTreeDockWidget::setProject
|
||||||
|
* Set @project as project handled by this tree dock.
|
||||||
|
* If a previous project was setted, everything is clear.
|
||||||
|
* This function track the destruction of the project,
|
||||||
|
* that mean if the project pointer is deleted
|
||||||
|
* no need to call this function with a nullptr,
|
||||||
|
* everything is made inside this class.
|
||||||
|
* @param project
|
||||||
|
*/
|
||||||
|
void TerminalStripTreeDockWidget::setProject(QETProject *project)
|
||||||
|
{
|
||||||
|
if(m_project && m_project_destroy_connection) {
|
||||||
|
disconnect(m_project_destroy_connection);
|
||||||
|
}
|
||||||
|
m_project = project;
|
||||||
|
if (m_project) {
|
||||||
|
m_project_destroy_connection = connect(m_project, &QObject::destroyed, [this](){
|
||||||
|
this->m_current_strip.clear();
|
||||||
|
this->reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
m_current_strip.clear();
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TerminalStripTreeDockWidget::reload
|
* @brief TerminalStripTreeDockWidget::reload
|
||||||
*/
|
*/
|
||||||
@@ -205,6 +230,9 @@ void TerminalStripTreeDockWidget::on_m_tree_view_currentItemChanged(QTreeWidgetI
|
|||||||
*/
|
*/
|
||||||
void TerminalStripTreeDockWidget::buildTree()
|
void TerminalStripTreeDockWidget::buildTree()
|
||||||
{
|
{
|
||||||
|
if(!m_project) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto title_ = m_project->title();
|
auto title_ = m_project->title();
|
||||||
if (title_.isEmpty()) {
|
if (title_.isEmpty()) {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class TerminalStripTreeDockWidget : public QDockWidget
|
|||||||
explicit TerminalStripTreeDockWidget(QETProject *project, QWidget *parent = nullptr);
|
explicit TerminalStripTreeDockWidget(QETProject *project, QWidget *parent = nullptr);
|
||||||
~TerminalStripTreeDockWidget();
|
~TerminalStripTreeDockWidget();
|
||||||
|
|
||||||
|
void setProject(QETProject *project = nullptr);
|
||||||
void reload();
|
void reload();
|
||||||
bool currentIsStrip() const;
|
bool currentIsStrip() const;
|
||||||
TerminalStrip* currentStrip() const;
|
TerminalStrip* currentStrip() const;
|
||||||
@@ -74,11 +75,12 @@ class TerminalStripTreeDockWidget : public QDockWidget
|
|||||||
QPointer<QETProject> m_project;
|
QPointer<QETProject> m_project;
|
||||||
QPointer<TerminalStrip> m_current_strip;
|
QPointer<TerminalStrip> m_current_strip;
|
||||||
|
|
||||||
QHash<QTreeWidgetItem *, TerminalStrip *> m_item_strip_H;
|
QHash<QTreeWidgetItem *, QPointer<TerminalStrip>> m_item_strip_H;
|
||||||
QHash<QUuid, QSharedPointer<RealTerminal>> m_uuid_terminal_H;
|
QHash<QUuid, QSharedPointer<RealTerminal>> m_uuid_terminal_H;
|
||||||
QHash<QUuid, QPointer<TerminalStrip>> m_uuid_strip_H;
|
QHash<QUuid, QPointer<TerminalStrip>> m_uuid_strip_H;
|
||||||
QVector<QMetaObject::Connection> m_strip_changed_connection;
|
QVector<QMetaObject::Connection> m_strip_changed_connection;
|
||||||
bool m_current_is_free_terminal{false};
|
bool m_current_is_free_terminal{false};
|
||||||
|
QMetaObject::Connection m_project_destroy_connection;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TERMINALSTRIPTREEDOCKWIDGET_H
|
#endif // TERMINALSTRIPTREEDOCKWIDGET_H
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
|
|
||||||
#include "ElementsCollection/elementcollectionhandler.h"
|
#include "ElementsCollection/elementcollectionhandler.h"
|
||||||
|
#include "TerminalStrip/GraphicsItem/terminalstripitem.h"
|
||||||
|
#include "xml/terminalstripitemxml.h"
|
||||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
#include "diagramcontent.h"
|
#include "diagramcontent.h"
|
||||||
@@ -873,6 +875,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
QVector<DiagramImageItem *> list_images;
|
QVector<DiagramImageItem *> list_images;
|
||||||
QVector<QetShapeItem *> list_shapes;
|
QVector<QetShapeItem *> list_shapes;
|
||||||
QVector<QetGraphicsTableItem *> table_vector;
|
QVector<QetGraphicsTableItem *> table_vector;
|
||||||
|
QVector<TerminalStripItem *> strip_vector;
|
||||||
|
|
||||||
//Ckeck graphics item to "XMLise"
|
//Ckeck graphics item to "XMLise"
|
||||||
for(QGraphicsItem *qgi : items())
|
for(QGraphicsItem *qgi : items())
|
||||||
@@ -921,6 +924,14 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
auto table = static_cast<QetGraphicsTableItem *>(qgi);
|
auto table = static_cast<QetGraphicsTableItem *>(qgi);
|
||||||
if (whole_content || table->isSelected())
|
if (whole_content || table->isSelected())
|
||||||
table_vector << table;
|
table_vector << table;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TerminalStripItem::Type: {
|
||||||
|
const auto strip = static_cast<TerminalStripItem *>(qgi);
|
||||||
|
if (whole_content || strip->isSelected()) {
|
||||||
|
strip_vector << strip;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -979,6 +990,11 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
dom_root.appendChild(tables);
|
dom_root.appendChild(tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strip_vector.isEmpty()) {
|
||||||
|
dom_root.appendChild(TerminalStripItemXml::toXml(strip_vector, document));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return(document);
|
return(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1423,6 +1439,9 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
added_tables << table;
|
added_tables << table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Load terminal strip item
|
||||||
|
QVector<TerminalStripItem *> added_strips { TerminalStripItemXml::fromXml(this, root) };
|
||||||
|
|
||||||
//Translate items if a new position was given in parameter
|
//Translate items if a new position was given in parameter
|
||||||
if (position != QPointF())
|
if (position != QPointF())
|
||||||
{
|
{
|
||||||
@@ -1433,6 +1452,7 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
for (auto text : qAsConst(added_texts )) added_items << text;
|
for (auto text : qAsConst(added_texts )) added_items << text;
|
||||||
for (auto image : qAsConst(added_images )) added_items << image;
|
for (auto image : qAsConst(added_images )) added_items << image;
|
||||||
for (auto table : qAsConst(added_tables )) added_items << table;
|
for (auto table : qAsConst(added_tables )) added_items << table;
|
||||||
|
for (const auto &strip : qAsConst(added_strips)) added_items << strip;
|
||||||
|
|
||||||
//Get the top left corner of the rectangle that contain all added items
|
//Get the top left corner of the rectangle that contain all added items
|
||||||
QRectF items_rect;
|
QRectF items_rect;
|
||||||
@@ -1473,8 +1493,9 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
content_ptr -> m_shapes = QSet<QetShapeItem *>(
|
content_ptr -> m_shapes = QSet<QetShapeItem *>(
|
||||||
added_shapes.begin(),
|
added_shapes.begin(),
|
||||||
added_shapes.end());
|
added_shapes.end());
|
||||||
|
content_ptr->m_terminal_strip.swap(added_strips);
|
||||||
#endif
|
#endif
|
||||||
content_ptr -> m_tables = added_tables;
|
content_ptr->m_tables.swap(added_tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustSceneRect();
|
adjustSceneRect();
|
||||||
@@ -1528,22 +1549,27 @@ void Diagram::folioSequentialsFromXml(const QDomElement &root,
|
|||||||
*/
|
*/
|
||||||
void Diagram::refreshContents()
|
void Diagram::refreshContents()
|
||||||
{
|
{
|
||||||
ElementProvider provider_(this);
|
DiagramContent dc_(this, false);
|
||||||
|
|
||||||
for (Element *elmt : elements())
|
for (auto &elmt : dc_.m_elements) {
|
||||||
{
|
|
||||||
elmt->initLink(project());
|
elmt->initLink(project());
|
||||||
for (DynamicElementTextItem *deti : elmt->dynamicTextItems())
|
for (auto &deti : elmt->dynamicTextItems())
|
||||||
deti->refreshLabelConnection();
|
deti->refreshLabelConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Conductor *conductor : conductors())
|
for (auto &conductor : dc_.conductors()) {
|
||||||
conductor->refreshText();
|
conductor->refreshText();
|
||||||
|
}
|
||||||
|
|
||||||
for (auto table : provider_.table())
|
for (auto &table : qAsConst(dc_.m_tables)) {
|
||||||
table->initLink();
|
table->initLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto &strip :qAsConst(dc_.m_terminal_strip)) {
|
||||||
|
strip->refreshPending();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::addItem
|
@brief Diagram::addItem
|
||||||
Réimplemented from QGraphicsScene::addItem(QGraphicsItem *item)
|
Réimplemented from QGraphicsScene::addItem(QGraphicsItem *item)
|
||||||
|
|||||||
@@ -148,153 +148,6 @@ CutDiagramCommand::~CutDiagramCommand()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@brief MoveElementsCommand::MoveElementsCommand
|
|
||||||
Constructor
|
|
||||||
@param dia diagram
|
|
||||||
@param diagram_content diagram content (contain all items to be moved)
|
|
||||||
@param m movement to applied
|
|
||||||
@param parent parent undo command
|
|
||||||
*/
|
|
||||||
MoveElementsCommand::MoveElementsCommand(
|
|
||||||
Diagram *dia,
|
|
||||||
const DiagramContent &diagram_content,
|
|
||||||
const QPointF &m,
|
|
||||||
QUndoCommand *parent
|
|
||||||
) :
|
|
||||||
QUndoCommand (parent),
|
|
||||||
diagram (dia),
|
|
||||||
content_to_move (diagram_content),
|
|
||||||
movement (m),
|
|
||||||
m_anim_group (nullptr),
|
|
||||||
first_redo (true)
|
|
||||||
{
|
|
||||||
QString moved_content_sentence = content_to_move.sentence(
|
|
||||||
DiagramContent::Elements |
|
|
||||||
DiagramContent::TextFields |
|
|
||||||
DiagramContent::ConductorsToUpdate |
|
|
||||||
DiagramContent::ConductorsToMove |
|
|
||||||
DiagramContent::Images |
|
|
||||||
DiagramContent::Shapes |
|
|
||||||
DiagramContent::ElementTextFields
|
|
||||||
);
|
|
||||||
|
|
||||||
setText(
|
|
||||||
QString(
|
|
||||||
QObject::tr(
|
|
||||||
"déplacer %1",
|
|
||||||
"undo caption - %1 is a sentence listing the moved content"
|
|
||||||
).arg(moved_content_sentence)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief MoveElementsCommand::~MoveElementsCommand
|
|
||||||
Destructor
|
|
||||||
*/
|
|
||||||
MoveElementsCommand::~MoveElementsCommand()
|
|
||||||
{
|
|
||||||
delete m_anim_group;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief MoveElementsCommand::undo
|
|
||||||
*/
|
|
||||||
void MoveElementsCommand::undo()
|
|
||||||
{
|
|
||||||
diagram -> showMe();
|
|
||||||
m_anim_group->setDirection(QAnimationGroup::Forward);
|
|
||||||
m_anim_group->start();
|
|
||||||
QUndoCommand::undo();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief MoveElementsCommand::redo
|
|
||||||
*/
|
|
||||||
void MoveElementsCommand::redo()
|
|
||||||
{
|
|
||||||
diagram -> showMe();
|
|
||||||
if (first_redo) {
|
|
||||||
first_redo = false;
|
|
||||||
move(-movement);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_anim_group->setDirection(QAnimationGroup::Backward);
|
|
||||||
m_anim_group->start();
|
|
||||||
}
|
|
||||||
QUndoCommand::redo();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief MoveElementsCommand::move
|
|
||||||
Move item and conductor to actual_movement
|
|
||||||
@param actual_movement movement to be applied
|
|
||||||
*/
|
|
||||||
void MoveElementsCommand::move(const QPointF &actual_movement)
|
|
||||||
{
|
|
||||||
typedef DiagramContent dc;
|
|
||||||
|
|
||||||
//Move every movable items, except conductor
|
|
||||||
for (QGraphicsItem *qgi : content_to_move.items(dc::Elements
|
|
||||||
| dc::TextFields
|
|
||||||
| dc::Images
|
|
||||||
| dc::Shapes
|
|
||||||
| dc::TextGroup
|
|
||||||
| dc::ElementTextFields
|
|
||||||
| dc::Tables))
|
|
||||||
{
|
|
||||||
//If current item has parent, and parent item is in content_to_move
|
|
||||||
//we don't apply movement to this item, because this item will be moved by is parent.
|
|
||||||
if (qgi->parentItem())
|
|
||||||
if (content_to_move.items().contains(qgi->parentItem()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(qgi->toGraphicsObject())
|
|
||||||
setupAnimation(qgi->toGraphicsObject(), "pos",
|
|
||||||
qgi->pos(), qgi->pos() + actual_movement);
|
|
||||||
else if(qgi->type() == QGraphicsItemGroup::Type)
|
|
||||||
{
|
|
||||||
//ElementTextItemGroup is a QObject but not a QGraphicsObject
|
|
||||||
if(ElementTextItemGroup *etig = dynamic_cast<ElementTextItemGroup *>(qgi))
|
|
||||||
setupAnimation(etig, "pos", etig->pos(),
|
|
||||||
etig->pos() + actual_movement);
|
|
||||||
}
|
|
||||||
else qgi -> setPos(qgi->pos() + actual_movement);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move some conductors
|
|
||||||
for (Conductor *conductor : content_to_move.m_conductors_to_move)
|
|
||||||
setupAnimation(conductor, "pos", conductor->pos(),
|
|
||||||
conductor->pos() + actual_movement);
|
|
||||||
|
|
||||||
// Recalcul the path of other conductor
|
|
||||||
for (Conductor *conductor : content_to_move.m_conductors_to_update)
|
|
||||||
setupAnimation(conductor, "animPath", 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief MoveElementsCommand::setupAnimation
|
|
||||||
Set up the animation for this undo command
|
|
||||||
@param target object to anim
|
|
||||||
@param propertyName property to animate
|
|
||||||
@param start value at start
|
|
||||||
@param end value at end
|
|
||||||
*/
|
|
||||||
void MoveElementsCommand::setupAnimation(QObject *target,
|
|
||||||
const QByteArray &propertyName,
|
|
||||||
const QVariant& start,
|
|
||||||
const QVariant& end) {
|
|
||||||
//create animation group if not yet.
|
|
||||||
if (m_anim_group == nullptr) m_anim_group = new QParallelAnimationGroup();
|
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(target, propertyName);
|
|
||||||
animation->setDuration(300);
|
|
||||||
animation->setStartValue(start);
|
|
||||||
animation->setEndValue(end);
|
|
||||||
animation->setEasingCurve(QEasingCurve::OutQuad);
|
|
||||||
m_anim_group->addAnimation(animation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief MoveConductorsTextsCommand::MoveConductorsTextsCommand
|
@brief MoveConductorsTextsCommand::MoveConductorsTextsCommand
|
||||||
Constructeur
|
Constructeur
|
||||||
|
|||||||
@@ -69,45 +69,6 @@ class CutDiagramCommand : public DeleteQGraphicsItemCommand {
|
|||||||
CutDiagramCommand(const CutDiagramCommand &);
|
CutDiagramCommand(const CutDiagramCommand &);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
@brief The MoveElementsCommand class
|
|
||||||
This command moves some content on a particular diagram.
|
|
||||||
*/
|
|
||||||
class MoveElementsCommand : public QUndoCommand {
|
|
||||||
// constructors, destructor
|
|
||||||
public:
|
|
||||||
MoveElementsCommand(Diagram *, const DiagramContent &,
|
|
||||||
const QPointF &m, QUndoCommand * = nullptr);
|
|
||||||
~MoveElementsCommand() override;
|
|
||||||
private:
|
|
||||||
MoveElementsCommand(const MoveElementsCommand &);
|
|
||||||
|
|
||||||
// methods
|
|
||||||
public:
|
|
||||||
void undo() override;
|
|
||||||
void redo() override;
|
|
||||||
virtual void move(const QPointF &);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setupAnimation (QObject * target,
|
|
||||||
const QByteArray &propertyName,
|
|
||||||
const QVariant& start,
|
|
||||||
const QVariant& end);
|
|
||||||
|
|
||||||
// attributes
|
|
||||||
private:
|
|
||||||
/// diagram the movement takes place on.
|
|
||||||
Diagram *diagram;
|
|
||||||
/// moved content
|
|
||||||
DiagramContent content_to_move;
|
|
||||||
/// applied movement
|
|
||||||
QPointF movement;
|
|
||||||
///animation group
|
|
||||||
QParallelAnimationGroup *m_anim_group;
|
|
||||||
/// prevent the first call to redo()
|
|
||||||
bool first_redo;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The MoveConductorsTextsCommand class
|
@brief The MoveConductorsTextsCommand class
|
||||||
This command moves text items related to conductors
|
This command moves text items related to conductors
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "qetgraphicsitem/independenttextitem.h"
|
#include "qetgraphicsitem/independenttextitem.h"
|
||||||
#include "qetgraphicsitem/qetshapeitem.h"
|
#include "qetgraphicsitem/qetshapeitem.h"
|
||||||
#include "qetgraphicsitem/terminal.h"
|
#include "qetgraphicsitem/terminal.h"
|
||||||
|
#include "TerminalStrip/GraphicsItem/terminalstripitem.h"
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
|
||||||
@@ -54,11 +55,19 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
|
|||||||
item_list = diagram->items();
|
item_list = diagram->items();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto item : item_list)
|
for (const auto &item : qAsConst(item_list))
|
||||||
{
|
{
|
||||||
switch (item->type())
|
switch (item->type())
|
||||||
{
|
{
|
||||||
case Element::Type: { m_elements << qgraphicsitem_cast<Element *>(item); break;}
|
case Element::Type:
|
||||||
|
{
|
||||||
|
auto element = qgraphicsitem_cast<Element *>(item);
|
||||||
|
m_elements << element;
|
||||||
|
if (element->elementData().m_type == ElementData::Terminale) {
|
||||||
|
m_terminal_elements << static_cast<TerminalElement*>(element);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case IndependentTextItem::Type: { m_text_fields << qgraphicsitem_cast<IndependentTextItem *>(item); break;}
|
case IndependentTextItem::Type: { m_text_fields << qgraphicsitem_cast<IndependentTextItem *>(item); break;}
|
||||||
case Conductor::Type:
|
case Conductor::Type:
|
||||||
{
|
{
|
||||||
@@ -88,6 +97,7 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QetGraphicsTableItem::Type: { m_tables << qgraphicsitem_cast<QetGraphicsTableItem *>(item); break;}
|
case QetGraphicsTableItem::Type: { m_tables << qgraphicsitem_cast<QetGraphicsTableItem *>(item); break;}
|
||||||
|
case TerminalStripItem::Type : {m_terminal_strip << qgraphicsitem_cast<TerminalStripItem *>(item); break;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,13 +204,14 @@ bool DiagramContent::hasDeletableItems() const
|
|||||||
{
|
{
|
||||||
for(QGraphicsItem *qgi : m_selected_items)
|
for(QGraphicsItem *qgi : m_selected_items)
|
||||||
{
|
{
|
||||||
if (qgi->type() == Element::Type ||
|
if (qgi->type() == Element::Type
|
||||||
qgi->type() == Conductor::Type ||
|
|| qgi->type() == Conductor::Type
|
||||||
qgi->type() == IndependentTextItem::Type ||
|
|| qgi->type() == IndependentTextItem::Type
|
||||||
qgi->type() == QetShapeItem::Type ||
|
|| qgi->type() == QetShapeItem::Type
|
||||||
qgi->type() == DiagramImageItem::Type ||
|
|| qgi->type() == DiagramImageItem::Type
|
||||||
qgi->type() == DynamicElementTextItem::Type ||
|
|| qgi->type() == DynamicElementTextItem::Type
|
||||||
qgi->type() == QetGraphicsTableItem::Type)
|
|| qgi->type() == QetGraphicsTableItem::Type
|
||||||
|
|| qgi->type() == TerminalStripItem::Type)
|
||||||
return true;
|
return true;
|
||||||
if(qgi->type() == QGraphicsItemGroup::Type)
|
if(qgi->type() == QGraphicsItemGroup::Type)
|
||||||
if(dynamic_cast<ElementTextItemGroup *>(qgi))
|
if(dynamic_cast<ElementTextItemGroup *>(qgi))
|
||||||
@@ -240,6 +251,7 @@ void DiagramContent::clear()
|
|||||||
m_texts_groups.clear();
|
m_texts_groups.clear();
|
||||||
m_selected_items.clear();
|
m_selected_items.clear();
|
||||||
m_tables.clear();
|
m_tables.clear();
|
||||||
|
m_terminal_strip.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -378,7 +390,7 @@ QList<QGraphicsItem *> DiagramContent::items(int filter) const
|
|||||||
{
|
{
|
||||||
QList<QGraphicsItem *> items_list;
|
QList<QGraphicsItem *> items_list;
|
||||||
|
|
||||||
for(QGraphicsItem *qgi : conductors(filter)) items_list << qgi;
|
for(auto &&qgi : conductors(filter)) items_list << qgi;
|
||||||
|
|
||||||
if (filter & Elements) for(auto qgi : m_elements) items_list << qgi;
|
if (filter & Elements) for(auto qgi : m_elements) items_list << qgi;
|
||||||
if (filter & TextFields) for(auto qgi : m_text_fields) items_list << qgi;
|
if (filter & TextFields) for(auto qgi : m_text_fields) items_list << qgi;
|
||||||
@@ -387,9 +399,10 @@ QList<QGraphicsItem *> DiagramContent::items(int filter) const
|
|||||||
if (filter & ElementTextFields) for(auto qgi : m_element_texts) items_list << qgi;
|
if (filter & ElementTextFields) for(auto qgi : m_element_texts) items_list << qgi;
|
||||||
if (filter & TextGroup) for(auto qgi : m_texts_groups) items_list << qgi;
|
if (filter & TextGroup) for(auto qgi : m_texts_groups) items_list << qgi;
|
||||||
if (filter & Tables) for(auto qgi : m_tables) items_list << qgi;
|
if (filter & Tables) for(auto qgi : m_tables) items_list << qgi;
|
||||||
|
if (filter & TerminalStrip) for(const auto qgi : qAsConst(m_terminal_strip)) items_list << qgi;
|
||||||
|
|
||||||
if (filter & SelectedOnly) {
|
if (filter & SelectedOnly) {
|
||||||
for(QGraphicsItem *qgi : items_list) {
|
for(const auto &qgi : qAsConst(items_list)) {
|
||||||
if (!qgi -> isSelected()) items_list.removeOne(qgi);
|
if (!qgi -> isSelected()) items_list.removeOne(qgi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -415,6 +428,7 @@ int DiagramContent::count(int filter) const
|
|||||||
if (filter & ElementTextFields) for(auto deti : m_element_texts) { if (deti -> isSelected()) ++ count; }
|
if (filter & ElementTextFields) for(auto deti : m_element_texts) { if (deti -> isSelected()) ++ count; }
|
||||||
if (filter & TextGroup) for(auto etig : m_texts_groups) { if (etig -> isSelected()) ++ count; }
|
if (filter & TextGroup) for(auto etig : m_texts_groups) { if (etig -> isSelected()) ++ count; }
|
||||||
if (filter & Tables) for(auto table : m_tables) { if (table -> isSelected()) ++ count; }
|
if (filter & Tables) for(auto table : m_tables) { if (table -> isSelected()) ++ count; }
|
||||||
|
if (filter & TerminalStrip) for(const auto &strip : qAsConst(m_terminal_strip)) {if (strip->isSelected()) ++ count;}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (filter & Elements) count += m_elements.count();
|
if (filter & Elements) count += m_elements.count();
|
||||||
@@ -427,6 +441,7 @@ int DiagramContent::count(int filter) const
|
|||||||
if (filter & ElementTextFields) count += m_element_texts.count();
|
if (filter & ElementTextFields) count += m_element_texts.count();
|
||||||
if (filter & TextGroup) count += m_texts_groups.count();
|
if (filter & TextGroup) count += m_texts_groups.count();
|
||||||
if (filter & Tables) count += m_tables.count();
|
if (filter & Tables) count += m_tables.count();
|
||||||
|
if (filter & TerminalStrip) count += m_terminal_strip.count();
|
||||||
}
|
}
|
||||||
return(count);
|
return(count);
|
||||||
}
|
}
|
||||||
@@ -447,7 +462,7 @@ QString DiagramContent::sentence(int filter) const
|
|||||||
int shapes_count = (filter & Shapes) ? m_shapes.count() : 0;
|
int shapes_count = (filter & Shapes) ? m_shapes.count() : 0;
|
||||||
int elmt_text_count = (filter & ElementTextFields) ? m_element_texts.count() : 0;
|
int elmt_text_count = (filter & ElementTextFields) ? m_element_texts.count() : 0;
|
||||||
int tables_count = (filter & Tables) ? m_tables.count() : 0;
|
int tables_count = (filter & Tables) ? m_tables.count() : 0;
|
||||||
|
const int strip_count = (filter & TerminalStrip) ? m_terminal_strip.count() : 0;
|
||||||
return(
|
return(
|
||||||
QET::ElementsAndConductorsSentence(
|
QET::ElementsAndConductorsSentence(
|
||||||
elements_count,
|
elements_count,
|
||||||
@@ -456,7 +471,8 @@ QString DiagramContent::sentence(int filter) const
|
|||||||
images_count,
|
images_count,
|
||||||
shapes_count,
|
shapes_count,
|
||||||
elmt_text_count,
|
elmt_text_count,
|
||||||
tables_count
|
tables_count,
|
||||||
|
strip_count
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "../qetgraphicsitem/terminalelement.h"
|
||||||
|
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
class Conductor;
|
class Conductor;
|
||||||
class Element;
|
class Element;
|
||||||
@@ -32,6 +34,7 @@ class ElementTextItemGroup;
|
|||||||
class Diagram;
|
class Diagram;
|
||||||
class DiagramTextItem;
|
class DiagramTextItem;
|
||||||
class QetGraphicsTableItem;
|
class QetGraphicsTableItem;
|
||||||
|
class TerminalStripItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class provides a container that makes the transmission of diagram content
|
This class provides a container that makes the transmission of diagram content
|
||||||
@@ -62,8 +65,9 @@ class DiagramContent
|
|||||||
Shapes = 128,
|
Shapes = 128,
|
||||||
TextGroup = 256,
|
TextGroup = 256,
|
||||||
Tables = 512,
|
Tables = 512,
|
||||||
All = 1023,
|
TerminalStrip = 1024,
|
||||||
SelectedOnly = 1024
|
All = 2047,
|
||||||
|
SelectedOnly = 2048
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<Element *> m_elements;
|
QList<Element *> m_elements;
|
||||||
@@ -78,6 +82,8 @@ class DiagramContent
|
|||||||
QSet<ElementTextItemGroup *> m_texts_groups;
|
QSet<ElementTextItemGroup *> m_texts_groups;
|
||||||
QList<QGraphicsItem *> m_selected_items;
|
QList<QGraphicsItem *> m_selected_items;
|
||||||
QVector<QetGraphicsTableItem *> m_tables;
|
QVector<QetGraphicsTableItem *> m_tables;
|
||||||
|
QVector<TerminalStripItem *> m_terminal_strip;
|
||||||
|
QVector<QPointer<TerminalElement>> m_terminal_elements;
|
||||||
|
|
||||||
|
|
||||||
QList<DiagramTextItem *> selectedTexts() const;
|
QList<DiagramTextItem *> selectedTexts() const;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include "conductorautonumerotation.h"
|
#include "conductorautonumerotation.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "qetgraphicsitem/conductor.h"
|
#include "qetgraphicsitem/conductor.h"
|
||||||
#include "diagramcommands.h"
|
|
||||||
#include "qetgraphicsitem/conductortextitem.h"
|
#include "qetgraphicsitem/conductortextitem.h"
|
||||||
#include "qetgraphicsitem/diagramimageitem.h"
|
#include "qetgraphicsitem/diagramimageitem.h"
|
||||||
#include "qetgraphicsitem/dynamicelementtextitem.h"
|
#include "qetgraphicsitem/dynamicelementtextitem.h"
|
||||||
@@ -30,6 +29,7 @@
|
|||||||
#include "undocommand/addgraphicsobjectcommand.h"
|
#include "undocommand/addgraphicsobjectcommand.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "qetdiagrameditor.h"
|
#include "qetdiagrameditor.h"
|
||||||
|
#include "undocommand/movegraphicsitemcommand.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ElementsMover::ElementsMover Constructor
|
@brief ElementsMover::ElementsMover Constructor
|
||||||
@@ -176,7 +176,7 @@ void ElementsMover::endMovement()
|
|||||||
|
|
||||||
//Create undo move if there is a movement
|
//Create undo move if there is a movement
|
||||||
if (!m_current_movement.isNull()) {
|
if (!m_current_movement.isNull()) {
|
||||||
QUndoCommand *quc{new MoveElementsCommand(m_diagram, m_moved_content, m_current_movement, undo_object)};
|
QUndoCommand *quc{new MoveGraphicsItemCommand(m_diagram, m_moved_content, m_current_movement, undo_object)};
|
||||||
undo_object->setText(quc->text());
|
undo_object->setText(quc->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,8 @@ void ElementsMover::endMovement()
|
|||||||
typedef DiagramContent dc;
|
typedef DiagramContent dc;
|
||||||
if (m_moved_content.items(dc::TextFields
|
if (m_moved_content.items(dc::TextFields
|
||||||
| dc::Images
|
| dc::Images
|
||||||
| dc::Shapes).isEmpty()
|
| dc::Shapes
|
||||||
|
| dc::TerminalStrip).isEmpty()
|
||||||
&& m_moved_content.items(dc::Elements).size() == 1
|
&& m_moved_content.items(dc::Elements).size() == 1
|
||||||
&& m_diagram->project()->autoConductor())
|
&& m_diagram->project()->autoConductor())
|
||||||
{
|
{
|
||||||
|
|||||||
30
sources/project/projectpropertieshandler.cpp
Normal file
30
sources/project/projectpropertieshandler.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "projectpropertieshandler.h"
|
||||||
|
|
||||||
|
#include "../qetproject.h"
|
||||||
|
|
||||||
|
ProjectPropertiesHandler::ProjectPropertiesHandler(QETProject *project) :
|
||||||
|
m_project(project)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminalStripLayoutsHandler &ProjectPropertiesHandler::terminalStripLayoutHandler()
|
||||||
|
{
|
||||||
|
return m_terminal_strip_layout_handler;
|
||||||
|
}
|
||||||
53
sources/project/projectpropertieshandler.h
Normal file
53
sources/project/projectpropertieshandler.h
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2023 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef PROJECTPROPERTIESHANDLER_H
|
||||||
|
#define PROJECTPROPERTIESHANDLER_H
|
||||||
|
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
|
#include "../TerminalStrip/GraphicsItem/properties/terminalstriplayoutshandler.h"
|
||||||
|
|
||||||
|
class QETProject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The ProjectPropertiesHandler class
|
||||||
|
* A central class who handle, keep and provide all utilities
|
||||||
|
* to easily manage all kind of properties used in a project.
|
||||||
|
*
|
||||||
|
* This is a new class since QElectroTech 0.9
|
||||||
|
* by consequent she is small and you can found a lot of properties (made before qet 0.9)
|
||||||
|
* everywhere in the code.
|
||||||
|
* All new properties should be managed by this class
|
||||||
|
* (of course if it make sense to be managed by this class).
|
||||||
|
* Older properties who are not managed by this class but should be,
|
||||||
|
* will be managed in future.
|
||||||
|
*/
|
||||||
|
class ProjectPropertiesHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProjectPropertiesHandler(QETProject *project);
|
||||||
|
|
||||||
|
TerminalStripLayoutsHandler& terminalStripLayoutHandler();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<QETProject> m_project;
|
||||||
|
|
||||||
|
TerminalStripLayoutsHandler m_terminal_strip_layout_handler;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PROJECTPROPERTIESHANDLER_H
|
||||||
@@ -266,7 +266,8 @@ QString QET::ElementsAndConductorsSentence(
|
|||||||
int images_count,
|
int images_count,
|
||||||
int shapes_count,
|
int shapes_count,
|
||||||
int element_text_count,
|
int element_text_count,
|
||||||
int tables_count)
|
int tables_count,
|
||||||
|
int terminal_strip_count)
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
if (elements_count) {
|
if (elements_count) {
|
||||||
@@ -329,6 +330,14 @@ QString QET::ElementsAndConductorsSentence(
|
|||||||
tables_count);
|
tables_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (terminal_strip_count) {
|
||||||
|
if (!text.isEmpty()) text += ", ";
|
||||||
|
text += QObject::tr(
|
||||||
|
"%n plan de bornes",
|
||||||
|
"part of a sentence listing the content of a diagram",
|
||||||
|
terminal_strip_count);
|
||||||
|
}
|
||||||
|
|
||||||
return(text);
|
return(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ class QActionGroup;
|
|||||||
*/
|
*/
|
||||||
namespace QET {
|
namespace QET {
|
||||||
/// QElectroTech version (as string, used to mark projects and elements XML documents)
|
/// QElectroTech version (as string, used to mark projects and elements XML documents)
|
||||||
const QString version = "0.90";
|
const QString version = "0.100";
|
||||||
/// QElectroTech displayed version
|
/// QElectroTech displayed version
|
||||||
const QString displayedVersion = "0.90-DEV";
|
const QString displayedVersion = "0.100-DEV";
|
||||||
QString license();
|
QString license();
|
||||||
|
|
||||||
//Describe the current state of a graphic item
|
//Describe the current state of a graphic item
|
||||||
@@ -162,7 +162,14 @@ namespace QET {
|
|||||||
bool orthogonalProjection(const QPointF &, const QLineF &, QPointF * = nullptr);
|
bool orthogonalProjection(const QPointF &, const QLineF &, QPointF * = nullptr);
|
||||||
bool attributeIsAnInteger(const QDomElement &, const QString& , int * = nullptr);
|
bool attributeIsAnInteger(const QDomElement &, const QString& , int * = nullptr);
|
||||||
bool attributeIsAReal(const QDomElement &, const QString& , qreal * = nullptr);
|
bool attributeIsAReal(const QDomElement &, const QString& , qreal * = nullptr);
|
||||||
QString ElementsAndConductorsSentence(int elements=0, int conductors=0, int indi_texts=0, int images=0, int shapes=0, int element_text=0, int tables_count=0);
|
QString ElementsAndConductorsSentence(int elements=0,
|
||||||
|
int conductors=0,
|
||||||
|
int indi_texts=0,
|
||||||
|
int images=0,
|
||||||
|
int shapes=0,
|
||||||
|
int element_text=0,
|
||||||
|
int tables_count=0,
|
||||||
|
int terminal_strip_count=0);
|
||||||
QList<QDomElement> findInDomElement(const QDomElement &, const QString &);
|
QList<QDomElement> findInDomElement(const QDomElement &, const QString &);
|
||||||
QList<QDomElement> findInDomElement(const QDomElement &, const QString &, const QString &);
|
QList<QDomElement> findInDomElement(const QDomElement &, const QString &, const QString &);
|
||||||
QList<QChar> forbiddenCharacters();
|
QList<QChar> forbiddenCharacters();
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "ui/aboutqetdialog.h"
|
#include "ui/aboutqetdialog.h"
|
||||||
#include "ui/configpage/generalconfigurationpage.h"
|
#include "ui/configpage/generalconfigurationpage.h"
|
||||||
#include "machine_info.h"
|
#include "machine_info.h"
|
||||||
|
#include "TerminalStrip/ui/terminalstripeditorwindow.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -159,6 +160,7 @@ QETApp::~QETApp()
|
|||||||
ElementFactory::dropInstance();
|
ElementFactory::dropInstance();
|
||||||
ElementPictureFactory::dropInstance();
|
ElementPictureFactory::dropInstance();
|
||||||
MachineInfo::dropInstance();
|
MachineInfo::dropInstance();
|
||||||
|
TerminalStripEditorWindow::dropInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1132,6 +1134,27 @@ QList<QETDiagramEditor *> QETApp::diagramEditors()
|
|||||||
return(QETApp::instance() -> detectWindows<QETDiagramEditor>());
|
return(QETApp::instance() -> detectWindows<QETDiagramEditor>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETApp::diagramEditor
|
||||||
|
* @param project
|
||||||
|
* @return The diagram editor of @a project or nullptr.
|
||||||
|
*/
|
||||||
|
QETDiagramEditor *QETApp::diagramEditor(QETProject *project)
|
||||||
|
{
|
||||||
|
for (const auto &editor : QETApp::instance()->detectWindows<QETDiagramEditor>())
|
||||||
|
{
|
||||||
|
for (const auto &project_view : editor->openedProjects())
|
||||||
|
{
|
||||||
|
if (project_view->project() == project)
|
||||||
|
{
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QETApp::elementEditors
|
@brief QETApp::elementEditors
|
||||||
@return element editors
|
@return element editors
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ class QETApp : public QObject
|
|||||||
static QETDiagramEditor *diagramEditorForFile(const QString &);
|
static QETDiagramEditor *diagramEditorForFile(const QString &);
|
||||||
static QETDiagramEditor *diagramEditorAncestorOf (const QWidget *child);
|
static QETDiagramEditor *diagramEditorAncestorOf (const QWidget *child);
|
||||||
static QList<QETDiagramEditor *> diagramEditors();
|
static QList<QETDiagramEditor *> diagramEditors();
|
||||||
|
static QETDiagramEditor* diagramEditor(QETProject *project);
|
||||||
static QList<QETElementEditor *> elementEditors();
|
static QList<QETElementEditor *> elementEditors();
|
||||||
static QList<QETElementEditor *> elementEditors(QETProject *);
|
static QList<QETElementEditor *> elementEditors(QETProject *);
|
||||||
static QList<QETTitleBlockTemplateEditor *> titleBlockTemplateEditors();
|
static QList<QETTitleBlockTemplateEditor *> titleBlockTemplateEditors();
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "TerminalStrip/ui/terminalstripeditorwindow.h"
|
#include "TerminalStrip/ui/terminalstripeditorwindow.h"
|
||||||
#include "ui/diagrameditorhandlersizewidget.h"
|
#include "ui/diagrameditorhandlersizewidget.h"
|
||||||
|
#include "TerminalStrip/ui/addterminalstripitemdialog.h"
|
||||||
|
|
||||||
#ifdef BUILD_WITHOUT_KF5
|
#ifdef BUILD_WITHOUT_KF5
|
||||||
#else
|
#else
|
||||||
@@ -446,8 +447,7 @@ void QETDiagramEditor::setUpActions()
|
|||||||
{
|
{
|
||||||
if (auto project = this->currentProject())
|
if (auto project = this->currentProject())
|
||||||
{
|
{
|
||||||
auto tsew {new TerminalStripEditorWindow{project, this}};
|
TerminalStripEditorWindow::instance(project, this)->show();
|
||||||
tsew->show();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -664,6 +664,7 @@ void QETDiagramEditor::setUpActions()
|
|||||||
QAction *add_rectangle = m_add_item_actions_group.addAction(QET::Icons::PartRectangle, tr("Ajouter un rectangle"));
|
QAction *add_rectangle = m_add_item_actions_group.addAction(QET::Icons::PartRectangle, tr("Ajouter un rectangle"));
|
||||||
QAction *add_ellipse = m_add_item_actions_group.addAction(QET::Icons::PartEllipse, tr("Ajouter une ellipse"));
|
QAction *add_ellipse = m_add_item_actions_group.addAction(QET::Icons::PartEllipse, tr("Ajouter une ellipse"));
|
||||||
QAction *add_polyline = m_add_item_actions_group.addAction(QET::Icons::PartPolygon, tr("Ajouter une polyligne"));
|
QAction *add_polyline = m_add_item_actions_group.addAction(QET::Icons::PartPolygon, tr("Ajouter une polyligne"));
|
||||||
|
QAction *add_terminal_strip = m_add_item_actions_group.addAction(QET::Icons::TerminalStrip, tr("Ajouter un plan de bornes"));
|
||||||
|
|
||||||
add_text ->setStatusTip(tr("Ajoute un champ de texte sur le folio actuel"));
|
add_text ->setStatusTip(tr("Ajoute un champ de texte sur le folio actuel"));
|
||||||
add_image ->setStatusTip(tr("Ajoute une image sur le folio actuel"));
|
add_image ->setStatusTip(tr("Ajoute une image sur le folio actuel"));
|
||||||
@@ -671,17 +672,22 @@ void QETDiagramEditor::setUpActions()
|
|||||||
add_rectangle->setStatusTip(tr("Ajoute un rectangle sur le folio actuel"));
|
add_rectangle->setStatusTip(tr("Ajoute un rectangle sur le folio actuel"));
|
||||||
add_ellipse ->setStatusTip(tr("Ajoute une ellipse sur le folio actuel"));
|
add_ellipse ->setStatusTip(tr("Ajoute une ellipse sur le folio actuel"));
|
||||||
add_polyline ->setStatusTip(tr("Ajoute une polyligne sur le folio actuel"));
|
add_polyline ->setStatusTip(tr("Ajoute une polyligne sur le folio actuel"));
|
||||||
|
add_terminal_strip->setStatusTip(tr("Ajoute un plan de bornier sur le folio actuel"));
|
||||||
|
|
||||||
add_text ->setData("text");
|
add_text ->setData(QStringLiteral("text"));
|
||||||
add_image ->setData("image");
|
add_image ->setData(QStringLiteral("image"));
|
||||||
add_line ->setData("line");
|
add_line ->setData(QStringLiteral("line"));
|
||||||
add_rectangle->setData("rectangle");
|
add_rectangle->setData(QStringLiteral("rectangle"));
|
||||||
add_ellipse ->setData("ellipse");
|
add_ellipse ->setData(QStringLiteral("ellipse"));
|
||||||
add_polyline ->setData("polyline");
|
add_polyline ->setData(QStringLiteral("polyline"));
|
||||||
|
add_terminal_strip->setData(QStringLiteral("terminal_strip"));
|
||||||
|
|
||||||
|
add_text->setCheckable(true);
|
||||||
|
add_line->setCheckable(true);
|
||||||
|
add_rectangle->setCheckable(true);
|
||||||
|
add_ellipse->setCheckable(true);
|
||||||
|
add_polyline->setCheckable(true);
|
||||||
|
|
||||||
for(QAction *action : m_add_item_actions_group.actions()) {
|
|
||||||
action->setCheckable(true);
|
|
||||||
}
|
|
||||||
connect(&m_add_item_actions_group, &QActionGroup::triggered, this, &QETDiagramEditor::addItemGroupTriggered);
|
connect(&m_add_item_actions_group, &QActionGroup::triggered, this, &QETDiagramEditor::addItemGroupTriggered);
|
||||||
|
|
||||||
//Depth action
|
//Depth action
|
||||||
@@ -1423,14 +1429,23 @@ void QETDiagramEditor::addItemGroupTriggered(QAction *action)
|
|||||||
if (deai->isNull())
|
if (deai->isNull())
|
||||||
{
|
{
|
||||||
delete deai;
|
delete deai;
|
||||||
action->setChecked(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
diagram_event = deai;
|
diagram_event = deai;
|
||||||
}
|
}
|
||||||
else if (value == "text")
|
else if (value == "text")
|
||||||
|
{
|
||||||
diagram_event = new DiagramEventAddText(d);
|
diagram_event = new DiagramEventAddText(d);
|
||||||
|
}
|
||||||
|
else if (value == QLatin1String("terminal_strip"))
|
||||||
|
{
|
||||||
|
const auto diagram_view{currentDiagramView()};
|
||||||
|
if (diagram_view)
|
||||||
|
{
|
||||||
|
AddTerminalStripItemDialog::openDialog(diagram_view->diagram(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (diagram_event)
|
if (diagram_event)
|
||||||
{
|
{
|
||||||
@@ -1455,10 +1470,19 @@ void QETDiagramEditor::selectionGroupTriggered(QAction *action)
|
|||||||
|
|
||||||
if (value == "delete_selection")
|
if (value == "delete_selection")
|
||||||
{
|
{
|
||||||
|
if (DeleteQGraphicsItemCommand::hasNonDeletableTerminal(dc)) {
|
||||||
|
QET::QetMessageBox::information(this,
|
||||||
|
tr("Suppression de borne impossible"),
|
||||||
|
tr("La suppression ne peut être effectué car la selection "
|
||||||
|
"possède une ou plusieurs bornes ponté et/ou appartenant à une borne à niveau multiple.\n"
|
||||||
|
"Déponter et/ou supprimer les niveaux des bornes concerné "
|
||||||
|
"afin de pouvoir les supprimer"));
|
||||||
|
} else {
|
||||||
diagram->clearSelection();
|
diagram->clearSelection();
|
||||||
diagram->undoStack().push(new DeleteQGraphicsItemCommand(diagram, dc));
|
diagram->undoStack().push(new DeleteQGraphicsItemCommand(diagram, dc));
|
||||||
dv->adjustSceneRect();
|
dv->adjustSceneRect();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (value == "rotate_selection")
|
else if (value == "rotate_selection")
|
||||||
{
|
{
|
||||||
RotateSelectionCommand *c = new RotateSelectionCommand(diagram);
|
RotateSelectionCommand *c = new RotateSelectionCommand(diagram);
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ class QETDiagramEditor : public QETMainWindow
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
friend class TerminalStripEditorWindow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QETDiagramEditor(
|
QETDiagramEditor(
|
||||||
const QStringList & = QStringList(),
|
const QStringList & = QStringList(),
|
||||||
|
|||||||
@@ -253,13 +253,13 @@ void CrossRefItem::autoPos()
|
|||||||
{
|
{
|
||||||
//We calcul the position according to the snapTo of the xrefproperties
|
//We calcul the position according to the snapTo of the xrefproperties
|
||||||
if (m_properties.snapTo() == XRefProperties::Bottom)
|
if (m_properties.snapTo() == XRefProperties::Bottom)
|
||||||
centerToBottomDiagram(this,
|
QGIUtility::centerToBottomDiagram(this,
|
||||||
m_element,
|
m_element,
|
||||||
m_properties.offset() <= 40
|
m_properties.offset() <= 40
|
||||||
? 5
|
? 5
|
||||||
: m_properties.offset());
|
: m_properties.offset());
|
||||||
else
|
else
|
||||||
centerToParentBottom(this);
|
QGIUtility::centerToParentBottom(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "elementtextitemgroup.h"
|
#include "elementtextitemgroup.h"
|
||||||
#include "iostream"
|
#include "iostream"
|
||||||
#include "../qetxml.h"
|
#include "../qetxml.h"
|
||||||
|
#include "qgraphicsitemutility.h"
|
||||||
|
|
||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -242,7 +243,7 @@ void Element::paint(
|
|||||||
|
|
||||||
//Draw the selection rectangle
|
//Draw the selection rectangle
|
||||||
if ( isSelected() || m_mouse_over ) {
|
if ( isSelected() || m_mouse_over ) {
|
||||||
drawSelection(painter, options);
|
QGIUtility::drawBoundingRectSelection(this, painter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,34 +341,6 @@ void Element::drawAxes(
|
|||||||
|
|
||||||
/*** Methodes privees ***/
|
/*** Methodes privees ***/
|
||||||
|
|
||||||
/**
|
|
||||||
Dessine le cadre de selection de l'element de maniere systematiquement non antialiasee.
|
|
||||||
@param painter Le QPainter a utiliser pour dessiner les bornes.
|
|
||||||
@param options Les options de style a prendre en compte
|
|
||||||
*/
|
|
||||||
void Element::drawSelection(
|
|
||||||
QPainter *painter,
|
|
||||||
const QStyleOptionGraphicsItem *options)
|
|
||||||
{
|
|
||||||
Q_UNUSED(options)
|
|
||||||
painter -> save();
|
|
||||||
// Annulation des renderhints
|
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
|
||||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
|
||||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
|
||||||
// Dessin du cadre de selection en gris
|
|
||||||
QPen t;
|
|
||||||
t.setColor(Qt::gray);
|
|
||||||
t.setStyle(Qt::DashDotLine);
|
|
||||||
t.setCosmetic(true);
|
|
||||||
painter -> setPen(t);
|
|
||||||
// Le dessin se fait a partir du rectangle delimitant
|
|
||||||
painter -> drawRoundedRect(boundingRect().adjusted(1, 1, -1, -1),
|
|
||||||
10,
|
|
||||||
10);
|
|
||||||
painter -> restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Dessine le cadre de selection de l'element de maniere systematiquement non antialiasee.
|
Dessine le cadre de selection de l'element de maniere systematiquement non antialiasee.
|
||||||
@param painter Le QPainter a utiliser pour dessiner les bornes.
|
@param painter Le QPainter a utiliser pour dessiner les bornes.
|
||||||
|
|||||||
@@ -197,9 +197,6 @@ class Element : public QetGraphicsItem
|
|||||||
void setSize(int, int);
|
void setSize(int, int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawSelection(
|
|
||||||
QPainter *,
|
|
||||||
const QStyleOptionGraphicsItem *);
|
|
||||||
void drawHighlight(
|
void drawHighlight(
|
||||||
QPainter *,
|
QPainter *,
|
||||||
const QStyleOptionGraphicsItem *);
|
const QStyleOptionGraphicsItem *);
|
||||||
|
|||||||
@@ -861,7 +861,7 @@ void ElementTextItemGroup::autoPos()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
qreal r = rotation();
|
qreal r = rotation();
|
||||||
centerToBottomDiagram(this, m_parent_element, offset);
|
QGIUtility::centerToBottomDiagram(this, m_parent_element, offset);
|
||||||
//centerToBottomDiagram change the rotation of this group if needed,
|
//centerToBottomDiagram change the rotation of this group if needed,
|
||||||
//but setRotation is not a virtual function of QGraphicsItem, and the function centerToBottomDiagram
|
//but setRotation is not a virtual function of QGraphicsItem, and the function centerToBottomDiagram
|
||||||
//work with a QGraphicsItem. So we emit the signal if rotation changed
|
//work with a QGraphicsItem. So we emit the signal if rotation changed
|
||||||
|
|||||||
@@ -24,12 +24,31 @@
|
|||||||
Default constructor
|
Default constructor
|
||||||
@param parent : Parent Item
|
@param parent : Parent Item
|
||||||
*/
|
*/
|
||||||
|
void QetGraphicsItem::showItem(QetGraphicsItem *item)
|
||||||
|
{
|
||||||
|
if (item && item->diagram())
|
||||||
|
{
|
||||||
|
item->diagram()->showMe();
|
||||||
|
item->setSelected(true);
|
||||||
|
|
||||||
|
//Zoom to the item
|
||||||
|
for(QGraphicsView *view : item->scene()->views())
|
||||||
|
{
|
||||||
|
QRectF fit = item->sceneBoundingRect();
|
||||||
|
fit.adjust(-200, -200, 200, 200);
|
||||||
|
view->fitInView(fit, Qt::KeepAspectRatioByExpanding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
|
QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
|
||||||
QGraphicsObject(parent),
|
QGraphicsObject(parent),
|
||||||
is_movable_(true),
|
is_movable_(true),
|
||||||
m_first_move(true),
|
m_first_move(true),
|
||||||
snap_to_grid_(true)
|
snap_to_grid_(true)
|
||||||
{}
|
{
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
}
|
||||||
|
|
||||||
QetGraphicsItem::~QetGraphicsItem()
|
QetGraphicsItem::~QetGraphicsItem()
|
||||||
{}
|
{}
|
||||||
@@ -64,6 +83,15 @@ void QetGraphicsItem::setPos(qreal x, qreal y) {
|
|||||||
setPos(QPointF(x, y));
|
setPos(QPointF(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QetGraphicsItem::isHovered() const {
|
||||||
|
return m_hovered;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF QetGraphicsItem::hoverMousePos() const
|
||||||
|
{
|
||||||
|
return m_mouse_hover_pos;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QetGraphicsItem::state
|
@brief QetGraphicsItem::state
|
||||||
@return the current state of this item
|
@return the current state of this item
|
||||||
@@ -155,3 +183,21 @@ void QetGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QetGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
m_hovered = true;
|
||||||
|
QGraphicsObject::hoverEnterEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QetGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
QGraphicsObject::hoverMoveEvent(event);
|
||||||
|
m_mouse_hover_pos = event->pos();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QetGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
m_hovered = false;
|
||||||
|
QGraphicsObject::hoverLeaveEvent(event);
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ class QetGraphicsItem : public QGraphicsObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
public :
|
||||||
|
static void showItem (QetGraphicsItem *item);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//constructor destructor
|
//constructor destructor
|
||||||
QetGraphicsItem(QGraphicsItem *parent = nullptr);
|
QetGraphicsItem(QGraphicsItem *parent = nullptr);
|
||||||
@@ -42,6 +45,9 @@ class QetGraphicsItem : public QGraphicsObject
|
|||||||
{return is_movable_;}
|
{return is_movable_;}
|
||||||
virtual void setMovable (bool movable) { is_movable_ = movable;}
|
virtual void setMovable (bool movable) { is_movable_ = movable;}
|
||||||
|
|
||||||
|
bool isHovered() const;
|
||||||
|
QPointF hoverMousePos() const;
|
||||||
|
|
||||||
virtual void editProperty () {}
|
virtual void editProperty () {}
|
||||||
virtual QString name ()const
|
virtual QString name ()const
|
||||||
{return QString("");}
|
{return QString("");}
|
||||||
@@ -54,6 +60,9 @@ class QetGraphicsItem : public QGraphicsObject
|
|||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool is_movable_;
|
bool is_movable_;
|
||||||
@@ -62,6 +71,10 @@ class QetGraphicsItem : public QGraphicsObject
|
|||||||
QPointF m_mouse_to_origin_movement;
|
QPointF m_mouse_to_origin_movement;
|
||||||
QET::GraphicsItemState m_state = QET:: GIOK;
|
QET::GraphicsItemState m_state = QET:: GIOK;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_hovered{false};
|
||||||
|
QPointF m_mouse_hover_pos;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QETGRAPHICSITEM_H
|
#endif // QETGRAPHICSITEM_H
|
||||||
|
|||||||
@@ -23,6 +23,9 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
|
||||||
|
namespace QGIUtility
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief centerToParentBottom
|
@brief centerToParentBottom
|
||||||
Center the item at the bottom of is parent.
|
Center the item at the bottom of is parent.
|
||||||
@@ -51,10 +54,10 @@ bool centerToParentBottom(QGraphicsItem *item) {
|
|||||||
@param offset
|
@param offset
|
||||||
@return true if element is centered else false (element_to_follow have not diagram)
|
@return true if element is centered else false (element_to_follow have not diagram)
|
||||||
*/
|
*/
|
||||||
#include "elementtextitemgroup.h"
|
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset)
|
||||||
#include "crossrefitem.h"
|
{
|
||||||
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset) {
|
if (! element_to_follow -> diagram())
|
||||||
if (! element_to_follow -> diagram()) {
|
{
|
||||||
qDebug() << "qgraphicsitemutility centerAtBottomDiagram : Element_to_follow have not diagram";
|
qDebug() << "qgraphicsitemutility centerAtBottomDiagram : Element_to_follow have not diagram";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -81,8 +84,25 @@ bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_f
|
|||||||
rot += parent->rotation();
|
rot += parent->rotation();
|
||||||
parent = parent->parentItem();
|
parent = parent->parentItem();
|
||||||
}
|
}
|
||||||
if(rot != 0)
|
if(rot != 0) {
|
||||||
item_to_center->setRotation(item_to_center->rotation() - rot);
|
item_to_center->setRotation(item_to_center->rotation() - rot);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawBoundingRectSelection(QGraphicsItem *item, QPainter *painter)
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
QPen t;
|
||||||
|
t.setColor(Qt::gray);
|
||||||
|
t.setStyle(Qt::DashDotLine);
|
||||||
|
t.setCosmetic(true);
|
||||||
|
|
||||||
|
painter->setPen(t);
|
||||||
|
painter->drawRoundedRect(item->boundingRect(),10,10);
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,18 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef QGRAPHICSITEMUTILITY_H
|
#ifndef QGRAPHICSITEMUTILITY_H
|
||||||
#define QGRAPHICSITEMUTILITY_H
|
#define QGRAPHICSITEMUTILITY_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
class Element;
|
class Element;
|
||||||
|
class QPainter;
|
||||||
|
|
||||||
|
namespace QGIUtility
|
||||||
|
{
|
||||||
bool centerToParentBottom (QGraphicsItem *item);
|
bool centerToParentBottom (QGraphicsItem *item);
|
||||||
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset = 0 );
|
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset = 0 );
|
||||||
|
void drawBoundingRectSelection(QGraphicsItem *item, QPainter *painter);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // QGRAPHICSITEMUTILITY_H
|
#endif // QGRAPHICSITEMUTILITY_H
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min
|
|||||||
QETProject::QETProject(QObject *parent) :
|
QETProject::QETProject(QObject *parent) :
|
||||||
QObject (parent),
|
QObject (parent),
|
||||||
m_titleblocks_collection(this),
|
m_titleblocks_collection(this),
|
||||||
m_data_base(this, this)
|
m_data_base(this, this),
|
||||||
|
m_project_properties_handler{this}
|
||||||
{
|
{
|
||||||
setDefaultTitleBlockProperties(TitleBlockProperties::defaultProperties());
|
setDefaultTitleBlockProperties(TitleBlockProperties::defaultProperties());
|
||||||
|
|
||||||
@@ -59,6 +60,11 @@ QETProject::QETProject(QObject *parent) :
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProjectPropertiesHandler &QETProject::projectPropertiesHandler()
|
||||||
|
{
|
||||||
|
return m_project_properties_handler;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QETProject::QETProject
|
@brief QETProject::QETProject
|
||||||
Construct a project from a .qet file
|
Construct a project from a .qet file
|
||||||
@@ -68,7 +74,8 @@ QETProject::QETProject(QObject *parent) :
|
|||||||
QETProject::QETProject(const QString &path, QObject *parent) :
|
QETProject::QETProject(const QString &path, QObject *parent) :
|
||||||
QObject (parent),
|
QObject (parent),
|
||||||
m_titleblocks_collection(this),
|
m_titleblocks_collection(this),
|
||||||
m_data_base(this, this)
|
m_data_base(this, this),
|
||||||
|
m_project_properties_handler{this}
|
||||||
{
|
{
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
m_state = openFile(&file);
|
m_state = openFile(&file);
|
||||||
@@ -89,7 +96,8 @@ QETProject::QETProject(const QString &path, QObject *parent) :
|
|||||||
QETProject::QETProject(KAutoSaveFile *backup, QObject *parent) :
|
QETProject::QETProject(KAutoSaveFile *backup, QObject *parent) :
|
||||||
QObject (parent),
|
QObject (parent),
|
||||||
m_titleblocks_collection(this),
|
m_titleblocks_collection(this),
|
||||||
m_data_base(this, this)
|
m_data_base(this, this),
|
||||||
|
m_project_properties_handler{this}
|
||||||
{
|
{
|
||||||
m_state = openFile(backup);
|
m_state = openFile(backup);
|
||||||
//Failed to open from the backup, try to open the crashed
|
//Failed to open from the backup, try to open the crashed
|
||||||
@@ -228,6 +236,32 @@ QETProject::ProjectState QETProject::openFile(QFile *file)
|
|||||||
return ProjectState::Ok;
|
return ProjectState::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETProject::refresh
|
||||||
|
* Refresh everything in the project.
|
||||||
|
* This is notably use when open a project from file.
|
||||||
|
*/
|
||||||
|
void QETProject::refresh()
|
||||||
|
{
|
||||||
|
DialogWaiting *dlgWaiting { nullptr };
|
||||||
|
if(DialogWaiting::hasInstance())
|
||||||
|
{
|
||||||
|
dlgWaiting = DialogWaiting::instance();
|
||||||
|
dlgWaiting->setModal(true);
|
||||||
|
dlgWaiting->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(const auto &diagram : diagrams())
|
||||||
|
{
|
||||||
|
if(dlgWaiting)
|
||||||
|
{
|
||||||
|
dlgWaiting->setProgressBar(dlgWaiting->progressBarValue()+1);
|
||||||
|
dlgWaiting->setDetail(diagram->title());
|
||||||
|
}
|
||||||
|
diagram->refreshContents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Cette methode peut etre utilisee pour tester la bonne ouverture d'un projet
|
Cette methode peut etre utilisee pour tester la bonne ouverture d'un projet
|
||||||
@return l'etat du projet
|
@return l'etat du projet
|
||||||
@@ -1388,6 +1422,9 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
//Load the terminal strip
|
//Load the terminal strip
|
||||||
readTerminalStripXml(xml_project);
|
readTerminalStripXml(xml_project);
|
||||||
|
|
||||||
|
//Now that all are loaded we refresh content of the project.
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
|
||||||
m_data_base.blockSignals(false);
|
m_data_base.blockSignals(false);
|
||||||
m_data_base.updateDB();
|
m_data_base.updateDB();
|
||||||
@@ -1461,18 +1498,6 @@ void QETProject::readDiagramsXml(QDomDocument &xml_project)
|
|||||||
"Mise en place des références croisées"
|
"Mise en place des références croisées"
|
||||||
"</p>"));
|
"</p>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data_base.updateDB(); //All diagrams and items are created we need to update the database
|
|
||||||
|
|
||||||
for(const auto &diagram : diagrams())
|
|
||||||
{
|
|
||||||
if(dlgWaiting)
|
|
||||||
{
|
|
||||||
dlgWaiting->setProgressBar(dlgWaiting->progressBarValue()+1);
|
|
||||||
dlgWaiting->setDetail(diagram->title());
|
|
||||||
}
|
|
||||||
diagram->refreshContents();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1775,6 +1800,40 @@ NamesList QETProject::namesListForIntegrationCategory()
|
|||||||
0x03b5,
|
0x03b5,
|
||||||
0x03af,
|
0x03af,
|
||||||
0x03b1};
|
0x03b1};
|
||||||
|
const QChar turkish_data[12] = {
|
||||||
|
0x0130,
|
||||||
|
0x0074,
|
||||||
|
0x0068,
|
||||||
|
0x0061,
|
||||||
|
0x006C,
|
||||||
|
0x0020,
|
||||||
|
0x00F6,
|
||||||
|
0x011F,
|
||||||
|
0x0065,
|
||||||
|
0x006C,
|
||||||
|
0x0065,
|
||||||
|
0x0072};
|
||||||
|
const QChar ukrainian_data[20] = {
|
||||||
|
0x0406,
|
||||||
|
0x043c,
|
||||||
|
0x043f,
|
||||||
|
0x043e,
|
||||||
|
0x0440,
|
||||||
|
0x0442,
|
||||||
|
0x043e,
|
||||||
|
0x0432,
|
||||||
|
0x0430,
|
||||||
|
0x043d,
|
||||||
|
0x0456,
|
||||||
|
0x0020,
|
||||||
|
0x0435,
|
||||||
|
0x043b,
|
||||||
|
0x0435,
|
||||||
|
0x043c,
|
||||||
|
0x0435,
|
||||||
|
0x043d,
|
||||||
|
0x0442,
|
||||||
|
0x0438};
|
||||||
const QChar japanese_data[10] = {
|
const QChar japanese_data[10] = {
|
||||||
0x30A4,
|
0x30A4,
|
||||||
0x30F3,
|
0x30F3,
|
||||||
@@ -1801,7 +1860,11 @@ NamesList QETProject::namesListForIntegrationCategory()
|
|||||||
names.addName("hr", "Uvezeni elementi");
|
names.addName("hr", "Uvezeni elementi");
|
||||||
names.addName("ca", "Elements importats");
|
names.addName("ca", "Elements importats");
|
||||||
names.addName("ro", "Elemente importate");
|
names.addName("ro", "Elemente importate");
|
||||||
|
names.addName("tr", QString(turkish_data, 12));
|
||||||
|
names.addName("da", "Importerede elementer");
|
||||||
|
names.addName("sl", "Uvoženi elementi");
|
||||||
names.addName("ja", QString(japanese_data, 10));
|
names.addName("ja", QString(japanese_data, 10));
|
||||||
|
names.addName("uk", QString(ukrainian_data, 20));
|
||||||
return (names);
|
return (names);
|
||||||
#else
|
#else
|
||||||
# if TODO_LIST
|
# if TODO_LIST
|
||||||
@@ -1821,6 +1884,9 @@ NamesList QETProject::namesListForIntegrationCategory()
|
|||||||
names.addName("hr", "Uvezeni elementi");
|
names.addName("hr", "Uvezeni elementi");
|
||||||
names.addName("ca", "Elements importats");
|
names.addName("ca", "Elements importats");
|
||||||
names.addName("ro", "Elemente importate");
|
names.addName("ro", "Elemente importate");
|
||||||
|
names.addName("da", "Importerede elementer");
|
||||||
|
names.addName("sl", "Uvoženi elementi");
|
||||||
|
names.addName("uk", "Імпортовані елементи");
|
||||||
return (names);
|
return (names);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "ElementsCollection/elementslocation.h"
|
#include "ElementsCollection/elementslocation.h"
|
||||||
#include "NameList/nameslist.h"
|
#include "NameList/nameslist.h"
|
||||||
|
#include "project/projectpropertieshandler.h"
|
||||||
#include "borderproperties.h"
|
#include "borderproperties.h"
|
||||||
#include "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
#include "dataBase/projectdatabase.h"
|
#include "dataBase/projectdatabase.h"
|
||||||
@@ -27,10 +28,12 @@
|
|||||||
#include "properties/xrefproperties.h"
|
#include "properties/xrefproperties.h"
|
||||||
#include "titleblock/templatescollection.h"
|
#include "titleblock/templatescollection.h"
|
||||||
#include "titleblockproperties.h"
|
#include "titleblockproperties.h"
|
||||||
|
|
||||||
#ifdef BUILD_WITHOUT_KF5
|
#ifdef BUILD_WITHOUT_KF5
|
||||||
#else
|
#else
|
||||||
# include <KAutoSaveFile>
|
# include <KAutoSaveFile>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
class Diagram;
|
class Diagram;
|
||||||
@@ -86,6 +89,7 @@ class QETProject : public QObject
|
|||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
|
ProjectPropertiesHandler& projectPropertiesHandler();
|
||||||
projectDataBase *dataBase();
|
projectDataBase *dataBase();
|
||||||
QUuid uuid() const;
|
QUuid uuid() const;
|
||||||
ProjectState state() const;
|
ProjectState state() const;
|
||||||
@@ -234,6 +238,7 @@ class QETProject : public QObject
|
|||||||
void writeBackup();
|
void writeBackup();
|
||||||
void init();
|
void init();
|
||||||
ProjectState openFile(QFile *file);
|
ProjectState openFile(QFile *file);
|
||||||
|
void refresh();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
@@ -290,6 +295,8 @@ class QETProject : public QObject
|
|||||||
QUuid m_uuid = QUuid::createUuid();
|
QUuid m_uuid = QUuid::createUuid();
|
||||||
projectDataBase m_data_base;
|
projectDataBase m_data_base;
|
||||||
QVector<TerminalStrip *> m_terminal_strip_vector;
|
QVector<TerminalStrip *> m_terminal_strip_vector;
|
||||||
|
|
||||||
|
ProjectPropertiesHandler m_project_properties_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QETProject *)
|
Q_DECLARE_METATYPE(QETProject *)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
#include <QGraphicsItem>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -920,4 +921,125 @@ bool validXmlProperty(const QDomElement& e) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief qGraphicsItemPosToXml
|
||||||
|
* Save the pos of a QGraphicsItem into an xml element.
|
||||||
|
* The tag name of the xml element is pos and there is 3 attributes:
|
||||||
|
* x, y, z.
|
||||||
|
* @param item
|
||||||
|
* @param document
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QDomElement qGraphicsItemPosToXml(QGraphicsItem *item, QDomDocument &document)
|
||||||
|
{
|
||||||
|
auto dom_pos = document.createElement(QStringLiteral("pos"));
|
||||||
|
dom_pos.setAttribute(QStringLiteral("x"), QString::number(item->pos().x()));
|
||||||
|
dom_pos.setAttribute(QStringLiteral("y"), QString::number(item->pos().y()));
|
||||||
|
dom_pos.setAttribute(QStringLiteral("z"), QString::number(item->zValue()));
|
||||||
|
|
||||||
|
return dom_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool qGraphicsItemPosFromXml(QGraphicsItem *item, const QDomElement &xml_elmt)
|
||||||
|
{
|
||||||
|
if (xml_elmt.tagName() == QLatin1String("pos"))
|
||||||
|
{
|
||||||
|
item->setX(xml_elmt.attribute(QStringLiteral("x"), QStringLiteral("0")).toDouble());
|
||||||
|
item->setY(xml_elmt.attribute(QStringLiteral("y"), QStringLiteral("0")).toDouble());
|
||||||
|
item->setZValue(xml_elmt.attribute(QStringLiteral("z"), QStringLiteral("0")).toInt());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief orientationToAttribute
|
||||||
|
* Write the Qt::orientation has an attribute of @param element.
|
||||||
|
* Attribute name is 'orientation' value is 'horizontal' or 'vertical'
|
||||||
|
* @param orientation
|
||||||
|
* @param element
|
||||||
|
*/
|
||||||
|
void orientationToAttribute(const Qt::Orientation &orientation, QDomElement &element)
|
||||||
|
{
|
||||||
|
element.setAttribute(QStringLiteral("orientation"),
|
||||||
|
orientation == Qt::Horizontal ? QStringLiteral("Horizontal") :
|
||||||
|
QStringLiteral("Vertical"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief orientationFromAttribute
|
||||||
|
* @param element
|
||||||
|
* @param def_value
|
||||||
|
* @return the Qt::Orientation read in @param element. If an error occur
|
||||||
|
* the returned orientation is @param def_value.
|
||||||
|
*/
|
||||||
|
Qt::Orientation orientationFromAttribute(const QDomElement &element, Qt::Orientation def_value)
|
||||||
|
{
|
||||||
|
if (element.hasAttribute(QStringLiteral("orientation"))) {
|
||||||
|
const auto str {element.attribute(QStringLiteral("orientation"))};
|
||||||
|
if (str == QLatin1String("Horizontal"))
|
||||||
|
return Qt::Horizontal;
|
||||||
|
else if (str == QLatin1String("Vertical"))
|
||||||
|
return Qt::Vertical;
|
||||||
|
}
|
||||||
|
//Error occur during reading, we return the default value
|
||||||
|
return def_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void alignmentToAttribute(const Qt::Alignment &alignment, QDomElement &element)
|
||||||
|
{
|
||||||
|
QStringList al;
|
||||||
|
if (alignment &Qt::AlignLeft)
|
||||||
|
al.append(QStringLiteral("Left"));
|
||||||
|
if (alignment &Qt::AlignRight)
|
||||||
|
al.append(QStringLiteral("Right"));
|
||||||
|
if (alignment &Qt::AlignHCenter)
|
||||||
|
al.append(QStringLiteral("HCenter"));
|
||||||
|
if (alignment &Qt::AlignJustify)
|
||||||
|
al.append(QStringLiteral("Justify"));
|
||||||
|
if (alignment &Qt::AlignTop)
|
||||||
|
al.append(QStringLiteral("Top"));
|
||||||
|
if (alignment &Qt::AlignBottom)
|
||||||
|
al.append(QStringLiteral("Bottom"));
|
||||||
|
if (alignment &Qt::AlignBottom)
|
||||||
|
al.append(QStringLiteral("VCenter"));
|
||||||
|
if (alignment &Qt::AlignBaseline)
|
||||||
|
al.append(QStringLiteral("Baseline"));
|
||||||
|
|
||||||
|
element.setAttribute(QStringLiteral("alignment"),al.join(QStringLiteral(" ")));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief alignmentFromAttribute
|
||||||
|
* @param element
|
||||||
|
* @return The alignment read in @param element. If an error
|
||||||
|
* occured the return Qt::alignment contain no set flag.
|
||||||
|
*/
|
||||||
|
Qt::Alignment alignmentFromAttribute(const QDomElement &element)
|
||||||
|
{
|
||||||
|
Qt::Alignment al;
|
||||||
|
if (element.hasAttribute(QStringLiteral("alignment"))) {
|
||||||
|
const auto alignment {element.attribute(QStringLiteral("alignment"))};
|
||||||
|
if(alignment.contains(QStringLiteral("Left")))
|
||||||
|
al = al | Qt::AlignLeft;
|
||||||
|
if(alignment.contains(QStringLiteral("Right")))
|
||||||
|
al = al | Qt::AlignRight;
|
||||||
|
if(alignment.contains(QStringLiteral("HCenter")))
|
||||||
|
al = al | Qt::AlignHCenter;
|
||||||
|
if(alignment.contains(QStringLiteral("Justify")))
|
||||||
|
al = al | Qt::AlignJustify;
|
||||||
|
if(alignment.contains(QStringLiteral("Top")))
|
||||||
|
al = al | Qt::AlignTop;
|
||||||
|
if(alignment.contains(QStringLiteral("Bottom")))
|
||||||
|
al = al | Qt::AlignBottom;
|
||||||
|
if(alignment.contains(QStringLiteral("VCenter")))
|
||||||
|
al = al | Qt::AlignVCenter;
|
||||||
|
if(alignment.contains(QStringLiteral("Baseline")))
|
||||||
|
al = al | Qt::AlignBaseline;
|
||||||
|
}
|
||||||
|
|
||||||
|
return al;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class QDomDocument;
|
|||||||
class QDir;
|
class QDir;
|
||||||
class QFile;
|
class QFile;
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
|
class QGraphicsItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*This namespace contain some function to use xml with QET.
|
*This namespace contain some function to use xml with QET.
|
||||||
@@ -89,6 +90,16 @@ namespace QETXML
|
|||||||
|
|
||||||
QVector<QDomElement> findInDomElement(const QDomElement &dom_elmt,
|
QVector<QDomElement> findInDomElement(const QDomElement &dom_elmt,
|
||||||
const QString &tag_name);
|
const QString &tag_name);
|
||||||
|
|
||||||
|
QDomElement qGraphicsItemPosToXml(QGraphicsItem *item, QDomDocument &document);
|
||||||
|
bool qGraphicsItemPosFromXml(QGraphicsItem *item, const QDomElement &xml_elmt);
|
||||||
|
|
||||||
|
void orientationToAttribute(const Qt::Orientation &orientation, QDomElement &element);
|
||||||
|
Qt::Orientation orientationFromAttribute(const QDomElement &element, Qt::Orientation def_value = Qt::Vertical);
|
||||||
|
|
||||||
|
void alignmentToAttribute(const Qt::Alignment &alignment, QDomElement &element);
|
||||||
|
Qt::Alignment alignmentFromAttribute (const QDomElement &element);
|
||||||
|
|
||||||
QString boolToString(bool value);
|
QString boolToString(bool value);
|
||||||
bool boolFromString(const QString &value,
|
bool boolFromString(const QString &value,
|
||||||
bool default_value = true,
|
bool default_value = true,
|
||||||
|
|||||||
151
sources/svg/qetsvg.cpp
Normal file
151
sources/svg/qetsvg.cpp
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2025 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qetsvg.h"
|
||||||
|
|
||||||
|
#include <QDomDocument>
|
||||||
|
#include <QRect>
|
||||||
|
#include <../qet.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETSVG::rectToElmt
|
||||||
|
* Write a QRect as a svg rect element.
|
||||||
|
* @param rect
|
||||||
|
* @param parent_document
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QDomElement QETSVG::rectToElmt(const QRectF &rect, QDomDocument &parent_document)
|
||||||
|
{
|
||||||
|
auto dom_element = parent_document.createElement(QStringLiteral("rect"));
|
||||||
|
if (!rect.isNull()) {
|
||||||
|
dom_element.setAttribute(QStringLiteral("x"), rect.x());
|
||||||
|
yToAttribute(rect.y(), dom_element);
|
||||||
|
dom_element.setAttribute(QStringLiteral("width"), rect.width());
|
||||||
|
heightToAttribute(rect.height(), dom_element);
|
||||||
|
}
|
||||||
|
return dom_element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETSVG::rectFromElmt
|
||||||
|
* @param xml_element : xml_element of an svg rect.
|
||||||
|
* The tag name must be 'rect' if not, the returned QRect is null.
|
||||||
|
* @return a svg rect to QRect
|
||||||
|
*/
|
||||||
|
QRectF QETSVG::rectFromElmt(const QDomElement &xml_element)
|
||||||
|
{
|
||||||
|
QRectF rect_;
|
||||||
|
if (xml_element.tagName() == QLatin1String("rect")) {
|
||||||
|
rect_.setRect(xml_element.attribute(QStringLiteral("x"), QStringLiteral("0")).toDouble(),
|
||||||
|
yFromAttribute(xml_element, 0),
|
||||||
|
xml_element.attribute(QStringLiteral("width"), QStringLiteral("10")).toDouble(),
|
||||||
|
heightFromAttribute(xml_element, 10));
|
||||||
|
}
|
||||||
|
return rect_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETSVG::yToAttribute
|
||||||
|
* @param y
|
||||||
|
* @param xml_element
|
||||||
|
*/
|
||||||
|
void QETSVG::yToAttribute(const qreal &y, QDomElement &xml_element) {
|
||||||
|
xml_element.setAttribute(QStringLiteral("y"), QString::number(y));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETSVG::yFromAttribute
|
||||||
|
* @param xml_element
|
||||||
|
* @param def_value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
qreal QETSVG::yFromAttribute(const QDomElement &xml_element, const qreal &def_value) {
|
||||||
|
qreal value_;
|
||||||
|
if (QET::attributeIsAReal(xml_element, QStringLiteral("y"), &value_)) {
|
||||||
|
return value_;
|
||||||
|
}
|
||||||
|
return def_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETSVG::heightToAttribute
|
||||||
|
* @param height
|
||||||
|
* @param xml_element
|
||||||
|
*/
|
||||||
|
void QETSVG::heightToAttribute(const qreal &height, QDomElement &xml_element) {
|
||||||
|
xml_element.setAttribute(QStringLiteral("height"), QString::number(height));
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal QETSVG::heightFromAttribute(const QDomElement &xml_element, const qreal &def_value) {
|
||||||
|
qreal value_;
|
||||||
|
if (QET::attributeIsAReal(xml_element, QStringLiteral("height"), &value_)) {
|
||||||
|
return value_;
|
||||||
|
}
|
||||||
|
return def_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QETSVG::rToAttribute(const qreal &r, QDomElement &xml_element) {
|
||||||
|
xml_element.setAttribute(QStringLiteral("r"), QString::number(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal QETSVG::rFromAttribute(const QDomElement &xml_element, const qreal &def_value) {
|
||||||
|
qreal value_;
|
||||||
|
if (QET::attributeIsAReal(xml_element, QStringLiteral("r"), &value_)) {
|
||||||
|
return value_;
|
||||||
|
}
|
||||||
|
return def_value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void QETSVG::pointsToAttribute(const QVector<QPointF> &points, QDomElement &xml_element)
|
||||||
|
{
|
||||||
|
QStringList strl_;
|
||||||
|
for (const auto &point : points) {
|
||||||
|
strl_.append(QString::number(point.x()) +
|
||||||
|
QString(",") +
|
||||||
|
QString::number(point.y()));
|
||||||
|
}
|
||||||
|
|
||||||
|
xml_element.setAttribute(QStringLiteral("points"), strl_.join(" "));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETSVG::pointsFromAttribute
|
||||||
|
* @param xml_element
|
||||||
|
* @return a vector of points stored in attribute 'points' of @xml_element.
|
||||||
|
* The returned vector can be empty.
|
||||||
|
*/
|
||||||
|
QVector<QPointF> QETSVG::pointsFromAttribute(const QDomElement &xml_element)
|
||||||
|
{
|
||||||
|
QVector<QPointF> vector_;
|
||||||
|
if (const auto string_points = xml_element.attribute(QStringLiteral("points")).split(QStringLiteral(" ")) ;
|
||||||
|
!string_points.isEmpty()) {
|
||||||
|
bool x_ok, y_ok; for (const auto &point : string_points) {
|
||||||
|
const auto string_x_y = point.split(QStringLiteral(","));
|
||||||
|
if (string_x_y.size() == 2) {
|
||||||
|
const auto x = string_x_y[0].toDouble(&x_ok);
|
||||||
|
const auto y = string_x_y[1].toDouble(&y_ok);
|
||||||
|
if (x_ok && y_ok) {
|
||||||
|
vector_.append(QPointF{x,y});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return vector_;
|
||||||
|
}
|
||||||
51
sources/svg/qetsvg.h
Normal file
51
sources/svg/qetsvg.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2025 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef QETSVG_H
|
||||||
|
#define QETSVG_H
|
||||||
|
|
||||||
|
#include <QDomElement>
|
||||||
|
|
||||||
|
class QDomDocument;
|
||||||
|
class QPointF;
|
||||||
|
class QRectF;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @namespace QETSVG
|
||||||
|
* @brief the QETSVG namespace provide function read and write svg.
|
||||||
|
* Some function work on xml element (ex rect) and some other
|
||||||
|
* work on attribute of an element (ex x)
|
||||||
|
*/
|
||||||
|
namespace QETSVG
|
||||||
|
{
|
||||||
|
QDomElement rectToElmt(const QRectF &rect, QDomDocument &parent_document);
|
||||||
|
QRectF rectFromElmt(const QDomElement &xml_element);
|
||||||
|
|
||||||
|
void yToAttribute(const qreal &y, QDomElement &xml_element);
|
||||||
|
qreal yFromAttribute(const QDomElement &xml_element, const qreal &def_value=0);
|
||||||
|
|
||||||
|
void heightToAttribute(const qreal &height, QDomElement &xml_element);
|
||||||
|
qreal heightFromAttribute(const QDomElement &xml_element, const qreal &def_value=10);
|
||||||
|
|
||||||
|
void rToAttribute(const qreal &r, QDomElement &xml_element);
|
||||||
|
qreal rFromAttribute(const QDomElement &xml_element, const qreal &def_value=1);
|
||||||
|
|
||||||
|
void pointsToAttribute(const QVector<QPointF> &points, QDomElement &xml_element);
|
||||||
|
QVector<QPointF> pointsFromAttribute (const QDomElement &xml_element);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // QETSVG_H
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "../configdialog.h"
|
#include "../configdialog.h"
|
||||||
#include "configpage/configpages.h"
|
#include "configpage/configpages.h"
|
||||||
#include "configpage/projectconfigpages.h"
|
#include "configpage/projectconfigpages.h"
|
||||||
|
#include "../TerminalStrip/ui/ConfigPage/terminalstripprojectconfigpage.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
@@ -29,14 +30,20 @@
|
|||||||
@param project : project to edit properties
|
@param project : project to edit properties
|
||||||
@param parent : parent widget of this dialog
|
@param parent : parent widget of this dialog
|
||||||
*/
|
*/
|
||||||
ProjectPropertiesDialog::ProjectPropertiesDialog(QETProject *project, QWidget *parent) {
|
ProjectPropertiesDialog::ProjectPropertiesDialog(QETProject *project, QWidget *parent)
|
||||||
NewDiagramPage *newDiagramPage = new NewDiagramPage(project,parent,this);
|
{
|
||||||
ProjectAutoNumConfigPage *projectAutoNumConfigPage = new ProjectAutoNumConfigPage (project);
|
|
||||||
m_properties_dialog = new ConfigDialog (parent);
|
m_properties_dialog = new ConfigDialog (parent);
|
||||||
m_properties_dialog -> setWindowTitle(QObject::tr("Propriétés du projet", "window title"));
|
m_properties_dialog -> setWindowTitle(QObject::tr("Propriétés du projet", "window title"));
|
||||||
m_properties_dialog -> addPage(new ProjectMainConfigPage(project));
|
m_properties_dialog -> addPage(new ProjectMainConfigPage(project));
|
||||||
|
|
||||||
|
NewDiagramPage *newDiagramPage = new NewDiagramPage(project,parent,this);
|
||||||
m_properties_dialog -> addPage(newDiagramPage);
|
m_properties_dialog -> addPage(newDiagramPage);
|
||||||
|
|
||||||
|
ProjectAutoNumConfigPage *projectAutoNumConfigPage = new ProjectAutoNumConfigPage (project);
|
||||||
m_properties_dialog -> addPage(projectAutoNumConfigPage);
|
m_properties_dialog -> addPage(projectAutoNumConfigPage);
|
||||||
|
|
||||||
|
m_properties_dialog->addPage(new TerminalStripProjectConfigPage { project, parent });
|
||||||
|
|
||||||
connect(projectAutoNumConfigPage,SIGNAL(setAutoNum(QString)),newDiagramPage,SLOT(setFolioAutonum(QString)));
|
connect(projectAutoNumConfigPage,SIGNAL(setAutoNum(QString)),newDiagramPage,SLOT(setFolioAutonum(QString)));
|
||||||
connect(projectAutoNumConfigPage,SIGNAL(saveCurrentTbp()),newDiagramPage,SLOT(saveCurrentTbp()));
|
connect(projectAutoNumConfigPage,SIGNAL(saveCurrentTbp()),newDiagramPage,SLOT(saveCurrentTbp()));
|
||||||
connect(projectAutoNumConfigPage,SIGNAL(loadSavedTbp()),newDiagramPage,SLOT(loadSavedTbp()));
|
connect(projectAutoNumConfigPage,SIGNAL(loadSavedTbp()),newDiagramPage,SLOT(loadSavedTbp()));
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ class ProjectPropertiesDialog : public QObject {
|
|||||||
enum Page {
|
enum Page {
|
||||||
Main = 0,
|
Main = 0,
|
||||||
Diagram = 1,
|
Diagram = 1,
|
||||||
Autonum = 2
|
Autonum = 2,
|
||||||
|
TerminalStrip = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectPropertiesDialog(QETProject *project, QWidget *parent = nullptr);
|
ProjectPropertiesDialog(QETProject *project, QWidget *parent = nullptr);
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
#include "../qetgraphicsitem/elementtextitemgroup.h"
|
#include "../qetgraphicsitem/elementtextitemgroup.h"
|
||||||
#include "../qetgraphicsitem/terminal.h"
|
#include "../qetgraphicsitem/terminal.h"
|
||||||
#include "addelementtextcommand.h"
|
#include "addelementtextcommand.h"
|
||||||
|
#include "../TerminalStrip/realterminal.h"
|
||||||
|
#include "../TerminalStrip/physicalterminal.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand
|
@brief DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand
|
||||||
@@ -115,6 +117,36 @@ DeleteQGraphicsItemCommand::~DeleteQGraphicsItemCommand()
|
|||||||
m_diagram->qgiManager().release(m_removed_contents.items(DiagramContent::All));
|
m_diagram->qgiManager().release(m_removed_contents.items(DiagramContent::All));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DeleteQGraphicsItemCommand::hasNonDeletableTerminal
|
||||||
|
* Return true if @content have terminal element which can't be deleted.
|
||||||
|
* The reason why a terminal can't be deleted is because they have bridge
|
||||||
|
* or belong to a physical terminal with more than one level.
|
||||||
|
* @param diagram
|
||||||
|
* @param content
|
||||||
|
* @param dialog
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool DeleteQGraphicsItemCommand::hasNonDeletableTerminal(const DiagramContent &content)
|
||||||
|
{
|
||||||
|
if (!content.m_terminal_elements.isEmpty())
|
||||||
|
{
|
||||||
|
for (const auto &terminal : content.m_terminal_elements)
|
||||||
|
{
|
||||||
|
if (!terminal.isNull())
|
||||||
|
{
|
||||||
|
if (terminal->parentTerminalStrip()
|
||||||
|
&& (terminal->realTerminal()->isBridged()
|
||||||
|
|| terminal->realTerminal()->physicalTerminal()->levelCount() != 1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements
|
@brief DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements
|
||||||
This function creates new conductors (if needed) for conserve the electrical potentials
|
This function creates new conductors (if needed) for conserve the electrical potentials
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ 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;
|
||||||
|
static bool hasNonDeletableTerminal(const DiagramContent &content);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|||||||
175
sources/undocommand/movegraphicsitemcommand.cpp
Normal file
175
sources/undocommand/movegraphicsitemcommand.cpp
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2022 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <QGraphicsItemGroup>
|
||||||
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
|
#include "movegraphicsitemcommand.h"
|
||||||
|
|
||||||
|
#include "../qetgraphicsitem/conductor.h"
|
||||||
|
#include "../qetgraphicsitem/elementtextitemgroup.h"
|
||||||
|
|
||||||
|
#include "../diagram.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MoveGraphicsItemCommand::MoveGraphicsItemCommand
|
||||||
|
* @param diagram : Diagram where the movement occur
|
||||||
|
* @param content : content aka QGraphicsItem to move
|
||||||
|
* @param movement : the movement to apply
|
||||||
|
* @param parent : parent undo command
|
||||||
|
*/
|
||||||
|
MoveGraphicsItemCommand::MoveGraphicsItemCommand(Diagram *diagram,
|
||||||
|
const DiagramContent &content,
|
||||||
|
const QPointF &movement,
|
||||||
|
QUndoCommand *parent) :
|
||||||
|
QUndoCommand{parent},
|
||||||
|
m_diagram{diagram},
|
||||||
|
m_content{content},
|
||||||
|
m_movement{movement}
|
||||||
|
{
|
||||||
|
const auto moved_content_sentence = m_content.sentence(DiagramContent::Elements
|
||||||
|
| DiagramContent::TextFields
|
||||||
|
| DiagramContent::ConductorsToUpdate
|
||||||
|
| DiagramContent::ConductorsToMove
|
||||||
|
| DiagramContent::Images
|
||||||
|
| DiagramContent::Shapes
|
||||||
|
| DiagramContent::ElementTextFields
|
||||||
|
| DiagramContent::TerminalStrip);
|
||||||
|
|
||||||
|
setText(QString(QObject::tr("déplacer %1",
|
||||||
|
"undo caption - %1 is a sentence listing the moved content").arg(moved_content_sentence)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MoveGraphicsItemCommand::undo
|
||||||
|
* Reimplemented from QUndoCommand::undo()
|
||||||
|
*/
|
||||||
|
void MoveGraphicsItemCommand::undo()
|
||||||
|
{
|
||||||
|
if (m_diagram)
|
||||||
|
{
|
||||||
|
m_diagram->showMe();
|
||||||
|
m_anim_group.setDirection(QAnimationGroup::Forward);
|
||||||
|
m_anim_group.start();
|
||||||
|
}
|
||||||
|
QUndoCommand::undo();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MoveGraphicsItemCommand::redo
|
||||||
|
* Reimplemented from QUndoCommand::redo()
|
||||||
|
*/
|
||||||
|
void MoveGraphicsItemCommand::redo()
|
||||||
|
{
|
||||||
|
if (m_diagram)
|
||||||
|
{
|
||||||
|
m_diagram->showMe();
|
||||||
|
if (m_first_redo)
|
||||||
|
{
|
||||||
|
m_first_redo = false;
|
||||||
|
move(-m_movement);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_anim_group.setDirection(QAnimationGroup::Backward);
|
||||||
|
m_anim_group.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QUndoCommand::redo();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MoveGraphicsItemCommand::move
|
||||||
|
* Apply @a movement to items of m_content
|
||||||
|
* @param movement
|
||||||
|
*/
|
||||||
|
void MoveGraphicsItemCommand::move(const QPointF &movement)
|
||||||
|
{
|
||||||
|
for (auto &&qgi : m_content.items(DiagramContent::Elements
|
||||||
|
| DiagramContent::TextFields
|
||||||
|
| DiagramContent::Images
|
||||||
|
| DiagramContent::Shapes
|
||||||
|
| DiagramContent::TextGroup
|
||||||
|
| DiagramContent::ElementTextFields
|
||||||
|
| DiagramContent::Tables
|
||||||
|
| DiagramContent::TerminalStrip))
|
||||||
|
{
|
||||||
|
//If item have a parent and the parent is in m_content,
|
||||||
|
//we don't apply movement because this item will be moved by his parent
|
||||||
|
if (const auto parent_ = qgi->parentItem()) {
|
||||||
|
if (m_content.items().contains(parent_)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const auto graphics_object = qgi->toGraphicsObject()) {
|
||||||
|
setupAnimation(graphics_object,
|
||||||
|
"pos",
|
||||||
|
graphics_object->pos(),
|
||||||
|
graphics_object->pos() + movement);
|
||||||
|
}
|
||||||
|
else if (qgi->type() == QGraphicsItemGroup::Type)
|
||||||
|
{
|
||||||
|
//ElementTextItemGroup is a QObject not a QGraphicsObject
|
||||||
|
if (ElementTextItemGroup *etig = dynamic_cast<ElementTextItemGroup *>(qgi)) {
|
||||||
|
setupAnimation(etig,
|
||||||
|
"pos",
|
||||||
|
etig->pos(),
|
||||||
|
etig->pos() + movement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qgi->setPos(qgi->pos() + movement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Move some conductors
|
||||||
|
for (const auto &conductor : qAsConst(m_content.m_conductors_to_move)) {
|
||||||
|
setupAnimation(conductor,
|
||||||
|
"pos",
|
||||||
|
conductor->pos(),
|
||||||
|
conductor->pos() + movement);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Recalcul the path of other conductors
|
||||||
|
for (const auto &conductor : qAsConst(m_content.m_conductors_to_update)) {
|
||||||
|
setupAnimation(conductor, "animPath", 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MoveGraphicsItemCommand::setupAnimation
|
||||||
|
* Create the animation used for the movement.
|
||||||
|
* @see QPropertyAnimation.
|
||||||
|
* @param target
|
||||||
|
* @param property_name
|
||||||
|
* @param start
|
||||||
|
* @param end
|
||||||
|
*/
|
||||||
|
void MoveGraphicsItemCommand::setupAnimation(QObject *target,
|
||||||
|
const QByteArray &property_name,
|
||||||
|
const QVariant &start,
|
||||||
|
const QVariant &end)
|
||||||
|
{
|
||||||
|
QPropertyAnimation *animation{new QPropertyAnimation(target, property_name)};
|
||||||
|
animation->setDuration(300);
|
||||||
|
animation->setStartValue(start);
|
||||||
|
animation->setEndValue(end);
|
||||||
|
animation->setEasingCurve(QEasingCurve::OutQuad);
|
||||||
|
m_anim_group.addAnimation(animation);
|
||||||
|
}
|
||||||
65
sources/undocommand/movegraphicsitemcommand.h
Normal file
65
sources/undocommand/movegraphicsitemcommand.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2022 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef MOVEGRAPHICSITEMCOMMAND_H
|
||||||
|
#define MOVEGRAPHICSITEMCOMMAND_H
|
||||||
|
|
||||||
|
#include <QUndoCommand>
|
||||||
|
#include <QParallelAnimationGroup>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
|
#include "../diagramcontent.h"
|
||||||
|
|
||||||
|
class Diagram;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The MoveGraphicsItemCommand class
|
||||||
|
* An undo command used for move item(s) in a diagram
|
||||||
|
*/
|
||||||
|
class MoveGraphicsItemCommand : public QUndoCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MoveGraphicsItemCommand(Diagram *diagram,
|
||||||
|
const DiagramContent &content,
|
||||||
|
const QPointF &movement,
|
||||||
|
QUndoCommand *parent = nullptr);
|
||||||
|
|
||||||
|
~MoveGraphicsItemCommand() {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MoveGraphicsItemCommand(const MoveGraphicsItemCommand &);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void undo() override;
|
||||||
|
void redo() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void move(const QPointF &movement);
|
||||||
|
void setupAnimation(QObject *target,
|
||||||
|
const QByteArray &property_name,
|
||||||
|
const QVariant &start,
|
||||||
|
const QVariant &end);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<Diagram> m_diagram;
|
||||||
|
DiagramContent m_content;
|
||||||
|
const QPointF m_movement;
|
||||||
|
QParallelAnimationGroup m_anim_group;
|
||||||
|
bool m_first_redo{true};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOVEGRAPHICSITEMCOMMAND_H
|
||||||
@@ -132,3 +132,21 @@ bool QETUtils::sortBeginIntString(const QString &str_a, const QString &str_b)
|
|||||||
return str_a<str_b;
|
return str_a<str_b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETUtils::pixelSizedFont
|
||||||
|
* Set the font size to pixelSize instead of pointSize (if needed).
|
||||||
|
* The font used to draw diagram must be pixel sized instead of point sized (default by Qt)
|
||||||
|
* then no matter the screen dpi used, the text in diagram keep the same size.
|
||||||
|
* For more information see @link https://qelectrotech.org/forum/viewtopic.php?pid=6267#p6267 @endlink
|
||||||
|
* @param font
|
||||||
|
*/
|
||||||
|
void QETUtils::pixelSizedFont(QFont &font)
|
||||||
|
{
|
||||||
|
if (font.pixelSize() > -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto px = font.pointSizeF()/72 * QFontMetrics{font}.fontDpi();
|
||||||
|
font.setPixelSize(qRound(px));
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace QETUtils
|
|||||||
QString marginsToString(const QMargins &margins);
|
QString marginsToString(const QMargins &margins);
|
||||||
QMargins marginsFromString(const QString &string);
|
QMargins marginsFromString(const QString &string);
|
||||||
qreal graphicsHandlerSize(QGraphicsItem *item);
|
qreal graphicsHandlerSize(QGraphicsItem *item);
|
||||||
|
void pixelSizedFont (QFont &font);
|
||||||
|
|
||||||
bool sortBeginIntString(const QString &str_a, const QString &str_b);
|
bool sortBeginIntString(const QString &str_a, const QString &str_b);
|
||||||
|
|
||||||
|
|||||||
140
sources/xml/terminalstripitemxml.cpp
Normal file
140
sources/xml/terminalstripitemxml.cpp
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2022 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "terminalstripitemxml.h"
|
||||||
|
|
||||||
|
#include "../diagram.h"
|
||||||
|
#include "../qetproject.h"
|
||||||
|
#include "../qetxml.h"
|
||||||
|
#include "../TerminalStrip/GraphicsItem/terminalstripitem.h"
|
||||||
|
#include "../TerminalStrip/terminalstrip.h"
|
||||||
|
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
|
const QString STRIP_ITEM_TAG_NAME { QStringLiteral("terminal_strip_item") };
|
||||||
|
const QString STRIP_ITEMS_TAG_NAME { QStringLiteral("terminal_strip_items") };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripItemXml::toXml
|
||||||
|
* Save the vector of @a items as child of an xml element with tag "terminal_strip_tems"
|
||||||
|
* @param items : items to save in xml
|
||||||
|
* @param document : parent document used to create the QDomElement returned by this function.
|
||||||
|
* @return QDomElement where are saved @a items.
|
||||||
|
*/
|
||||||
|
QDomElement TerminalStripItemXml::toXml(const QVector<TerminalStripItem *> &items, QDomDocument &document)
|
||||||
|
{
|
||||||
|
auto dom_element = document.createElement(STRIP_ITEMS_TAG_NAME);
|
||||||
|
for (const auto &item : items)
|
||||||
|
{
|
||||||
|
const auto child_ = toXml(item, document);
|
||||||
|
if (!child_.isNull()) {
|
||||||
|
dom_element.appendChild(child_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dom_element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripItemXml::fromXml
|
||||||
|
* Load items stored in @a xml_elmt into @a diagram
|
||||||
|
* @a xml_elmt must have a child element with tag name "terminal_strip_tems"
|
||||||
|
* @param diagram
|
||||||
|
* @param xml_elmt
|
||||||
|
* @return a vector of added terminal strip item
|
||||||
|
*/
|
||||||
|
QVector<TerminalStripItem *> TerminalStripItemXml::fromXml(Diagram *diagram, const QDomElement &xml_elmt)
|
||||||
|
{
|
||||||
|
QVector<TerminalStripItem *> returned_vector;
|
||||||
|
|
||||||
|
for (const auto &dom_elmt : QETXML::subChild(xml_elmt,
|
||||||
|
STRIP_ITEMS_TAG_NAME,
|
||||||
|
STRIP_ITEM_TAG_NAME))
|
||||||
|
{
|
||||||
|
auto strip_item = new TerminalStripItem();
|
||||||
|
diagram->addItem(strip_item);
|
||||||
|
returned_vector << strip_item;
|
||||||
|
|
||||||
|
TerminalStripItemXml::fromXml(strip_item, diagram->project(), dom_elmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return returned_vector;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripItemXml::toXml
|
||||||
|
* Save @a item to an xml element with tag "terminal_strip_item"
|
||||||
|
* @param item : item to save in xml
|
||||||
|
* @param document : parent document used to create the QDomElement returned by this function.
|
||||||
|
* @return QDomElement where are saved @a item, note that the returned QDomElement can be null.
|
||||||
|
*/
|
||||||
|
QDomElement TerminalStripItemXml::toXml(TerminalStripItem *item, QDomDocument &document)
|
||||||
|
{
|
||||||
|
if (item->terminalStrip())
|
||||||
|
{
|
||||||
|
//Terminal strip item dom element
|
||||||
|
auto dom_element = document.createElement(STRIP_ITEM_TAG_NAME);
|
||||||
|
|
||||||
|
auto dom_strip = document.createElement(QStringLiteral("terminal_strip"));
|
||||||
|
dom_strip.setAttribute(QStringLiteral("uuid"), item->terminalStrip()->uuid().toString());
|
||||||
|
dom_element.appendChild(dom_strip);
|
||||||
|
|
||||||
|
dom_element.appendChild(QETXML::qGraphicsItemPosToXml(item, document));
|
||||||
|
|
||||||
|
return dom_element;
|
||||||
|
} else {
|
||||||
|
return QDomElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripItemXml::fromXml
|
||||||
|
* Restor the state of a terminal strip item from @a xml_elmt.
|
||||||
|
* The @a xml_elmt tag name must be "terminal_strip_item"
|
||||||
|
* @param item
|
||||||
|
* @param project
|
||||||
|
* @param xml_elmt
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool TerminalStripItemXml::fromXml(TerminalStripItem *item, QETProject *project, const QDomElement &xml_elmt)
|
||||||
|
{
|
||||||
|
if (xml_elmt.tagName() == STRIP_ITEM_TAG_NAME)
|
||||||
|
{
|
||||||
|
bool a{false};
|
||||||
|
|
||||||
|
const auto ts = xml_elmt.firstChildElement(QStringLiteral("terminal_strip"));
|
||||||
|
if (!ts.isNull())
|
||||||
|
{
|
||||||
|
const QUuid uuid_(ts.attribute(QStringLiteral("uuid")));
|
||||||
|
item->m_pending_strip_uuid = uuid_;
|
||||||
|
|
||||||
|
for (const auto &ts : project->terminalStrip()) {
|
||||||
|
if (ts->uuid() == uuid_) {
|
||||||
|
item->setTerminalStrip(ts);
|
||||||
|
a = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool b{QETXML::qGraphicsItemPosFromXml(item,
|
||||||
|
xml_elmt.firstChildElement(QStringLiteral("pos")))};
|
||||||
|
|
||||||
|
return (a && b);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
37
sources/xml/terminalstripitemxml.h
Normal file
37
sources/xml/terminalstripitemxml.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2022 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef TERMINALSTRIPITEMXML_H
|
||||||
|
#define TERMINALSTRIPITEMXML_H
|
||||||
|
|
||||||
|
#include <QDomElement>
|
||||||
|
|
||||||
|
class TerminalStripItem;
|
||||||
|
class QETProject;
|
||||||
|
class Diagram;
|
||||||
|
|
||||||
|
class TerminalStripItemXml
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static QDomElement toXml(const QVector<TerminalStripItem *> &items, QDomDocument &document);
|
||||||
|
static QVector<TerminalStripItem *> fromXml(Diagram *diagram, const QDomElement &xml_elmt);
|
||||||
|
|
||||||
|
static QDomElement toXml(TerminalStripItem *item, QDomDocument &document);
|
||||||
|
static bool fromXml(TerminalStripItem *item, QETProject *project, const QDomElement &xml_elmt);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TERMINALSTRIPITEMXML_H
|
||||||
206
sources/xml/terminalstriplayoutpatternxml.cpp
Normal file
206
sources/xml/terminalstriplayoutpatternxml.cpp
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2025 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "terminalstriplayoutpatternxml.h"
|
||||||
|
|
||||||
|
#include "../TerminalStrip/GraphicsItem/properties/terminalstriplayoutpattern.h"
|
||||||
|
#include "../qetxml.h"
|
||||||
|
#include "../svg/qetsvg.h"
|
||||||
|
|
||||||
|
const QString LAYOUT_PATTERN_TAG_NAME { QStringLiteral("terminal_strip_layout_pattern") };
|
||||||
|
const QString LAYOUTS_PATTERN_TAG_NAME { QStringLiteral("terminal_strip_layouts_pattern") };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripLayoutPatternXml::toXml
|
||||||
|
* Save a vector of @class TerminalStripLayoutPattern into main xml element
|
||||||
|
* with tagg name 'terminal_strip_layouts_pattern' who itself embedded each single @class TerminalStripLayoutPattern
|
||||||
|
* into a xml element with tag name 'terminal_strip_layout_pattern' (layout without 'S' at the end)
|
||||||
|
* @param patterns
|
||||||
|
* @param document
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QDomElement TerminalStripLayoutPatternXml::toXml(const QVector<QSharedPointer<TerminalStripLayoutPattern> > &patterns,
|
||||||
|
QDomDocument &document)
|
||||||
|
{
|
||||||
|
auto dom_element = document.createElement(LAYOUTS_PATTERN_TAG_NAME);
|
||||||
|
for (const auto &pattern : patterns)
|
||||||
|
{
|
||||||
|
const auto child_ = toXml(pattern, document);
|
||||||
|
if (!child_.isNull()) {
|
||||||
|
dom_element.appendChild(child_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dom_element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripLayoutPatternXml::fromXml
|
||||||
|
* Load a vector of @class TerminalStripLayoutPattern from a main xml element
|
||||||
|
* with tagg name 'terminal_strip_layouts_pattern' who itself have several child
|
||||||
|
* with tag name 'terminal_strip_layout_pattern' (layout without 'S' at the end) for every
|
||||||
|
* @class TerminalStripLayoutPattern to load
|
||||||
|
* @param element
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QVector<QSharedPointer<TerminalStripLayoutPattern> > TerminalStripLayoutPatternXml::fromXml(const QDomElement &element)
|
||||||
|
{
|
||||||
|
QVector <QSharedPointer<TerminalStripLayoutPattern>> returned_vector;
|
||||||
|
|
||||||
|
for (const auto &dom_elmt : QETXML::subChild(element,
|
||||||
|
LAYOUTS_PATTERN_TAG_NAME,
|
||||||
|
LAYOUT_PATTERN_TAG_NAME))
|
||||||
|
{
|
||||||
|
auto layout_pattern = QSharedPointer<TerminalStripLayoutPattern>::create();
|
||||||
|
fromXml(layout_pattern, dom_elmt);
|
||||||
|
|
||||||
|
returned_vector << layout_pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
return returned_vector;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripLayoutPatternXml::toXml
|
||||||
|
* Save a @class TerminalStripLayoutPattern to a xml element with tag name terminal_strip_layout_pattern
|
||||||
|
* @param pattern
|
||||||
|
* @param document
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QDomElement TerminalStripLayoutPatternXml::toXml(const QSharedPointer<TerminalStripLayoutPattern> &pattern, QDomDocument &document)
|
||||||
|
{
|
||||||
|
auto pattern_xml = document.createElement(LAYOUT_PATTERN_TAG_NAME);
|
||||||
|
if (!pattern.isNull()) {
|
||||||
|
//Write strip pattern attributes
|
||||||
|
pattern_xml.setAttribute(QStringLiteral("name"), pattern->m_name);
|
||||||
|
pattern_xml.setAttribute(QStringLiteral("uuid"), pattern->m_uuid.toString());
|
||||||
|
|
||||||
|
//Write header properties
|
||||||
|
auto header_xml = document.createElement(QStringLiteral("header"));
|
||||||
|
header_xml.appendChild(QETSVG::rectToElmt(pattern->m_header_rect, document));
|
||||||
|
|
||||||
|
auto header_text_xml = document.createElement(QStringLiteral("text"));
|
||||||
|
QETXML::orientationToAttribute(pattern->m_header_text_orientation, header_text_xml);
|
||||||
|
QETXML::alignmentToAttribute(pattern->headerTextAlignment(),header_text_xml);
|
||||||
|
|
||||||
|
//Write spacer properties
|
||||||
|
auto spacer_xml = document.createElement(QStringLiteral("spacer"));
|
||||||
|
spacer_xml.appendChild(QETSVG::rectToElmt(pattern->m_spacer_rect, document));
|
||||||
|
|
||||||
|
pattern_xml.appendChild(header_xml).appendChild(header_text_xml);
|
||||||
|
pattern_xml.appendChild(spacer_xml);
|
||||||
|
|
||||||
|
//Write terminals properties
|
||||||
|
auto terminals_xml = document.createElement(QStringLiteral("terminals"));
|
||||||
|
for (const auto &rect : pattern->m_terminal_rect) {
|
||||||
|
terminals_xml.appendChild(QETSVG::rectToElmt(rect, document));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto terminals_text_xml = document.createElement(QStringLiteral("text"));
|
||||||
|
QETXML::orientationToAttribute(pattern->m_terminals_text_orientation, terminals_text_xml);
|
||||||
|
QETXML::alignmentToAttribute(pattern->terminalsTextAlignment(),terminals_text_xml);
|
||||||
|
QETSVG::yToAttribute(pattern->m_terminals_text_y, terminals_text_xml);
|
||||||
|
QETSVG::heightToAttribute(pattern->m_terminals_text_height, terminals_text_xml);
|
||||||
|
terminals_xml.appendChild(terminals_text_xml);
|
||||||
|
|
||||||
|
auto xref_text_xml = document.createElement(QStringLiteral("xref"));
|
||||||
|
QETXML::orientationToAttribute(pattern->m_xref_text_orientation, xref_text_xml);
|
||||||
|
QETXML::alignmentToAttribute(pattern->xrefTextAlignment(),xref_text_xml);
|
||||||
|
QETSVG::yToAttribute(pattern->m_xref_text_y, xref_text_xml);
|
||||||
|
QETSVG::heightToAttribute(pattern->m_xref_text_height, xref_text_xml);
|
||||||
|
terminals_xml.appendChild(xref_text_xml);
|
||||||
|
|
||||||
|
auto bridge_xml = document.createElement(QStringLiteral("bridges"));
|
||||||
|
QETSVG::rToAttribute(pattern->m_bridge_point_d/2, bridge_xml);
|
||||||
|
QVector<QPointF> points_vector;
|
||||||
|
for (const auto &y : pattern->m_bridge_point_y_offset) {
|
||||||
|
points_vector.append(QPointF{0,y});
|
||||||
|
}
|
||||||
|
QETSVG::pointsToAttribute(points_vector, bridge_xml);
|
||||||
|
terminals_xml.appendChild(bridge_xml);
|
||||||
|
|
||||||
|
pattern_xml.appendChild(terminals_xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pattern_xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripLayoutPatternXml::fromXml
|
||||||
|
* LOad a @class TerminalStripLayoutPattern from a xml element with tag name terminal_strip_layout_pattern
|
||||||
|
* @param layout
|
||||||
|
* @param element
|
||||||
|
*/
|
||||||
|
void TerminalStripLayoutPatternXml::fromXml(QSharedPointer<TerminalStripLayoutPattern> &layout, const QDomElement &element)
|
||||||
|
{
|
||||||
|
if (element.tagName() != LAYOUT_PATTERN_TAG_NAME) return;
|
||||||
|
layout->m_name = element.attribute(QStringLiteral("name"), layout->m_name);
|
||||||
|
layout->m_uuid.fromString(element.attribute(QStringLiteral("uuid"), layout->m_uuid.toString()));
|
||||||
|
|
||||||
|
const auto header_xml = element.firstChildElement(QStringLiteral("header"));
|
||||||
|
if (!header_xml.isNull() && header_xml.hasAttribute(QStringLiteral("rect"))) {
|
||||||
|
layout->m_header_rect = QETSVG::rectFromElmt(header_xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const auto header_text_xml = header_xml.firstChildElement(QStringLiteral("text"));
|
||||||
|
!header_text_xml.isNull()) {
|
||||||
|
layout->m_header_text_orientation = QETXML::orientationFromAttribute(header_text_xml, layout->m_header_text_orientation);
|
||||||
|
layout->setHeaderTextAlignment(QETXML::alignmentFromAttribute(header_text_xml));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto spacer_xml = element.firstChildElement(QStringLiteral("spacer"));
|
||||||
|
if (const auto rect = QETSVG::rectFromElmt(spacer_xml);
|
||||||
|
!rect.isNull()) {
|
||||||
|
layout->m_spacer_rect = rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const auto terminals_xml = element.firstChildElement(QStringLiteral("terminals"));
|
||||||
|
!terminals_xml.isNull()) {
|
||||||
|
layout->m_terminal_rect.clear();
|
||||||
|
for (const auto &terminal_rect_xml : QETXML::directChild(terminals_xml, QStringLiteral("rect"))) {
|
||||||
|
layout->m_terminal_rect.append(QETSVG::rectFromElmt(terminal_rect_xml)) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const auto terminals_text_xml = terminals_xml.firstChildElement(QStringLiteral("text"));
|
||||||
|
!terminals_text_xml.isNull()) {
|
||||||
|
layout->m_terminals_text_orientation = QETXML::orientationFromAttribute(terminals_text_xml, layout->m_terminals_text_orientation);
|
||||||
|
layout->setTerminalsTextAlignment(QETXML::alignmentFromAttribute(terminals_text_xml));
|
||||||
|
layout->m_terminals_text_y = QETSVG::yFromAttribute(terminals_text_xml);
|
||||||
|
layout->m_terminals_text_height = QETSVG::heightFromAttribute(terminals_text_xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const auto xref_text_xml = terminals_xml.firstChildElement(QStringLiteral("xref"));
|
||||||
|
!xref_text_xml.isNull()) {
|
||||||
|
layout->m_xref_text_orientation = QETXML::orientationFromAttribute(xref_text_xml, layout->m_xref_text_orientation);
|
||||||
|
layout->setXrefTextAlignment(QETXML::alignmentFromAttribute(xref_text_xml));
|
||||||
|
layout->m_xref_text_y = QETSVG::yFromAttribute(xref_text_xml);
|
||||||
|
layout->m_xref_text_height = QETSVG::heightFromAttribute(xref_text_xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const auto bridge_xml = terminals_xml.firstChildElement(QStringLiteral("bridges"));
|
||||||
|
!bridge_xml.isNull()) {
|
||||||
|
layout->m_bridge_point_d = QETSVG::rFromAttribute(bridge_xml, 2.5)*2;
|
||||||
|
if (const auto points = QETSVG::pointsFromAttribute(bridge_xml);
|
||||||
|
points.size() == 4) {
|
||||||
|
layout->m_bridge_point_y_offset[0]= points[0].y();
|
||||||
|
layout->m_bridge_point_y_offset[1]= points[1].y();
|
||||||
|
layout->m_bridge_point_y_offset[2]= points[2].y();
|
||||||
|
layout->m_bridge_point_y_offset[3]= points[3].y();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
41
sources/xml/terminalstriplayoutpatternxml.h
Normal file
41
sources/xml/terminalstriplayoutpatternxml.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2025 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef TERMINALSTRIPLAYOUTPATTERNXML_H
|
||||||
|
#define TERMINALSTRIPLAYOUTPATTERNXML_H
|
||||||
|
|
||||||
|
#include <QDomElement>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
class TerminalStripLayoutPattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The TerminalStripLayoutPatternXml class
|
||||||
|
* A class with static function used to save/restor a
|
||||||
|
* @class TerminalStripLayoutPattern to xml
|
||||||
|
*/
|
||||||
|
class TerminalStripLayoutPatternXml
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static QDomElement toXml(const QVector<QSharedPointer<TerminalStripLayoutPattern>> &patterns, QDomDocument &document);
|
||||||
|
static QVector<QSharedPointer<TerminalStripLayoutPattern>> fromXml(const QDomElement &element);
|
||||||
|
|
||||||
|
static QDomElement toXml (const QSharedPointer<TerminalStripLayoutPattern> &pattern, QDomDocument &document);
|
||||||
|
static void fromXml(QSharedPointer<TerminalStripLayoutPattern> &layout, const QDomElement &element);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TERMINALSTRIPLAYOUTPATTERNXML_H
|
||||||
Reference in New Issue
Block a user