mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-05-02 11:29:59 +02:00
Compare commits
47 Commits
0.9-dev-20
...
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 | ||
|
|
9afef79629 | ||
|
|
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 ======
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ DiagramImageItem + 1007
|
||||
QetShapItem + 1008
|
||||
crossRefItem + 1009
|
||||
DynamiqueElementTextItem + 1010
|
||||
TerminalStripItem +1011
|
||||
ElementPrimitiveDecorator + 2200
|
||||
|
||||
###ELEMENT EDITOR###
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright 2006-2021 The QElectroTech Team -->
|
||||
<!-- Copyright 2006-2023 The QElectroTech Team -->
|
||||
<application>
|
||||
<id type="desktop">qelectrotech.desktop</id>
|
||||
<metadata_license>MIT</metadata_license>
|
||||
|
||||
@@ -126,7 +126,9 @@ INCLUDEPATH += sources/ui
|
||||
# sources/print
|
||||
|
||||
# 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/titleblock/*.h) \
|
||||
$$files(sources/richtext/*.h) \
|
||||
@@ -159,11 +161,17 @@ HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) \
|
||||
$$files(sources/print/*.h) \
|
||||
$$files(sources/TerminalStrip/*.h) \
|
||||
$$files(sources/TerminalStrip/ui/*.h) \
|
||||
$$files(sources/TerminalStrip/ui/ConfigPage/*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) \
|
||||
$$files(sources/editor/*.cpp) \
|
||||
$$files(sources/project/*.cpp) \
|
||||
$$files(sources/titleblock/*.cpp) \
|
||||
$$files(sources/richtext/*.cpp) \
|
||||
$$files(sources/ui/*.cpp) \
|
||||
@@ -196,8 +204,13 @@ SOURCES += $$files(sources/*.cpp) \
|
||||
$$files(sources/print/*.cpp) \
|
||||
$$files(sources/TerminalStrip/*.cpp) \
|
||||
$$files(sources/TerminalStrip/ui/*.cpp) \
|
||||
$$files(sources/TerminalStrip/ui/ConfigPage/*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
|
||||
INCLUDEPATH += sources/TerminalStrip/ui
|
||||
@@ -227,7 +240,8 @@ FORMS += $$files(sources/richtext/*.ui) \
|
||||
$$files(sources/dataBase/ui/*.ui) \
|
||||
$$files(sources/factory/ui/*.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_HEADERS_DIR = sources/ui/
|
||||
@@ -289,7 +303,7 @@ man.extra = sh man/compress_man_pages.sh
|
||||
INSTALLS += target elements tbt lang copyright
|
||||
# Sous Unix, on installe egalement l'icone, un fichier .desktop, des fichiers mime et les pages de manuel
|
||||
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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -84,6 +84,39 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
|
||||
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] = {
|
||||
0x30A4,
|
||||
0x30F3,
|
||||
0x30D0,
|
||||
0x30FC,
|
||||
0x30C8,
|
||||
0x3055,
|
||||
0x308C,
|
||||
0x305F,
|
||||
0x8981,
|
||||
0x7D20};
|
||||
|
||||
names.addName("fr", "Éléments importés");
|
||||
names.addName("en", "Imported elements");
|
||||
names.addName("de", "Importierte elemente");
|
||||
@@ -100,8 +133,9 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
|
||||
names.addName("ro", "Elemente importate");
|
||||
names.addName("tr", QString(turkish_data, 12));
|
||||
names.addName("da", "Importerede elementer");
|
||||
names.addName("hr", "Uvezeni elementi");
|
||||
names.addName("sl", "Uvoženi elementi");
|
||||
names.addName("ja", QString(japanese_data, 10));
|
||||
names.addName("uk", QString(ukrainian_data, 20));
|
||||
#else
|
||||
# if TODO_LIST
|
||||
# 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("ro", "Elemente importate");
|
||||
names.addName("da", "Importerede elementer");
|
||||
names.addName("hr", "Uvezeni elementi");
|
||||
names.addName("sl", "Uvoženi elementi");
|
||||
names.addName("uk", "Імпортовані елементи");
|
||||
#endif
|
||||
|
||||
import.appendChild(names.toXml(m_dom_document));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
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
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -16,6 +16,7 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "bridgeterminalscommand.h"
|
||||
#include "../terminalstripbridge.h"
|
||||
|
||||
BridgeTerminalsCommand::BridgeTerminalsCommand(TerminalStrip *strip,
|
||||
QVector<QSharedPointer<RealTerminal>> real_terminal,
|
||||
@@ -57,8 +58,18 @@ UnBridgeTerminalsCommand::UnBridgeTerminalsCommand(TerminalStrip *strip,
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -189,6 +189,20 @@ QVector<QSharedPointer<RealTerminal>> PhysicalTerminal::realTerminals() const {
|
||||
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
|
||||
* @return the uuid of this physical terminal
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -86,6 +86,7 @@ class PhysicalTerminal
|
||||
int levelCount() const;
|
||||
int levelOf(const QSharedPointer<RealTerminal> &terminal) const;
|
||||
QVector<QSharedPointer<RealTerminal>> realTerminals() const;
|
||||
QSharedPointer<RealTerminal> realTerminal(int pos) const;
|
||||
QUuid uuid() const;
|
||||
int pos() const;
|
||||
int realTerminalCount() const;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -975,8 +975,9 @@ QDomElement TerminalStrip::toXml(QDomDocument &parent_document)
|
||||
|
||||
root_elmt.appendChild(m_data.toXml(parent_document));
|
||||
|
||||
//Undrawn terminals
|
||||
auto xml_layout = parent_document.createElement("layout");
|
||||
//Undrawed terminals
|
||||
auto xml_layout = parent_document.createElement(QStringLiteral("layout"));
|
||||
|
||||
for (auto &phy_t : m_physical_terminals) {
|
||||
xml_layout.appendChild(phy_t->toXml(parent_document));
|
||||
}
|
||||
@@ -1036,8 +1037,10 @@ bool TerminalStrip::fromXml(QDomElement &xml_element)
|
||||
}
|
||||
}
|
||||
|
||||
auto raw_ptr = new PhysicalTerminal(this, real_t_vector);
|
||||
m_physical_terminals.append(raw_ptr->sharedRef());
|
||||
if (!real_t_vector.isEmpty()) {
|
||||
auto raw_ptr = new PhysicalTerminal(this, real_t_vector);
|
||||
m_physical_terminals.append(raw_ptr->sharedRef());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -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
|
||||
* @param real_terminals
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -46,6 +46,7 @@ class TerminalStripBridge
|
||||
static QString xmlTagName() {return QStringLiteral("terminal_strip_bridge");}
|
||||
QDomElement toXml(QDomDocument &parent_document) const;
|
||||
void fromXml(const QDomElement &dom_element);
|
||||
QUuid uuid() const noexcept;
|
||||
|
||||
private:
|
||||
bool addTerminals(const QVector<QSharedPointer<RealTerminal>> &real_terminals);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -34,7 +34,7 @@ QDomElement TerminalStripData::toXml(QDomDocument &xml_document) const
|
||||
|
||||
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);
|
||||
|
||||
if (!m_installation.isEmpty()) {
|
||||
@@ -65,23 +65,23 @@ bool TerminalStripData::fromXml(const QDomElement &xml_element)
|
||||
return false;
|
||||
}
|
||||
#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
|
||||
m_uuid = QUuid(xml_element.attribute(QStringLiteral("uuid")));
|
||||
#endif
|
||||
|
||||
for (auto &xml_info :
|
||||
QETXML::findInDomElement(xml_element.firstChildElement("informations"),
|
||||
QStringLiteral("information")))
|
||||
QETXML::findInDomElement(xml_element.firstChildElement(QStringLiteral("informations")),
|
||||
QStringLiteral("information")))
|
||||
{
|
||||
auto name = xml_info.attribute("name");
|
||||
auto name = xml_info.attribute(QStringLiteral("name"));
|
||||
auto value = xml_info.text();
|
||||
|
||||
if (name == QStringLiteral("installation")) { m_installation = value;}
|
||||
else if (name == QStringLiteral("location")) {m_location = value;}
|
||||
else if (name == QStringLiteral("name")) {m_name = value;}
|
||||
else if (name == QStringLiteral("comment")) {m_comment = value;}
|
||||
else if (name == QStringLiteral("description")) {m_description = value;}
|
||||
if (name == QLatin1String("installation")) { m_installation = value;}
|
||||
else if (name == QLatin1String("location")) {m_location = value;}
|
||||
else if (name == QLatin1String("name")) {m_name = value;}
|
||||
else if (name == QLatin1String("comment")) {m_comment = value;}
|
||||
else if (name == QLatin1String("description")) {m_description = value;}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -101,7 +101,7 @@ TerminalStripData &TerminalStripData::operator=(const TerminalStripData &other)
|
||||
|
||||
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.appendChild(xml_doc.createTextNode(value));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -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>
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2022 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -32,16 +32,20 @@
|
||||
*/
|
||||
FreeTerminalEditor::FreeTerminalEditor(QETProject *project, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::FreeTerminalEditor),
|
||||
m_project(project)
|
||||
ui(new Ui::FreeTerminalEditor),
|
||||
m_project(project)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->m_table_view->setItemDelegate(new FreeTerminalModelDelegate(ui->m_table_view));
|
||||
|
||||
m_model = new FreeTerminalModel(m_project, this);
|
||||
m_model = new FreeTerminalModel(m_project, this);
|
||||
ui->m_table_view->setModel(m_model);
|
||||
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)
|
||||
connect(m_model, &FreeTerminalModel::dataChanged, this, [=] {
|
||||
this->setDisabledMove();
|
||||
@@ -135,6 +139,31 @@ void FreeTerminalEditor::apply()
|
||||
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)
|
||||
{
|
||||
if (m_model)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2022 The QElectroTech Team
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -19,8 +19,8 @@
|
||||
#define FREETERMINALEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "../../qetproject.h"
|
||||
|
||||
class QETProject;
|
||||
class RealTerminal;
|
||||
class FreeTerminalModel;
|
||||
class QTableView;
|
||||
@@ -40,6 +40,8 @@ class FreeTerminalEditor : public QWidget
|
||||
void reload();
|
||||
void apply();
|
||||
|
||||
void setProject(QETProject *project);
|
||||
|
||||
private slots:
|
||||
void on_m_type_cb_activated(int index);
|
||||
void on_m_function_cb_activated(int index);
|
||||
@@ -52,7 +54,7 @@ class FreeTerminalEditor : public QWidget
|
||||
|
||||
private:
|
||||
Ui::FreeTerminalEditor *ui;
|
||||
QETProject *m_project = nullptr;
|
||||
FreeTerminalModel *m_model = nullptr;
|
||||
QPointer <QETProject> m_project;
|
||||
FreeTerminalModel *m_model {nullptr};
|
||||
};
|
||||
#endif // FREETERMINALEDITOR_H
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user