Compare commits

...

47 Commits

Author SHA1 Message Date
joshua
7e5d41b474 Terminal strip Xref is clickable
When user hover the Xref string of a terminal, the string color change
to blue to advise user the xref is clickable. Double click on the blue
Xref go the folio of the terminal and zoom the view to the terminal.
2025-10-14 22:12:38 +02:00
joshua
f0ec416a91 Terminal strip graphic item can display Xref of terminal 2025-10-03 21:49:21 +02:00
joshua
f6ba47277d Minor : revamp
Use QGIUtility::drawBoundingRectSelection for draw the selection rect
of element instead of a method of the element itself.
Less code.
2025-10-02 21:52:40 +02:00
joshua
74b55f3bf5 Disable deletion if a terminal can't be deleted.
In case of user try to delete a terminal element who is bridged
or belong to a physical terminal with more than one level, the deletion
is aborted to avoid mistake in the terminal strip parent of the terminal
element. A dialog is opened when the deletion can't be to explain to
user what to do for enable the deletion.
2025-07-24 22:24:15 +02:00
joshua
a121fbe530 Add undo / redo command
The undo/redo command of diagram editor is
shared to the terminal strip editor.
2025-07-01 23:37:16 +02:00
joshua
a2ae8255ac Minor fix
During the development, we saved some terminal strip with "phantom"
terminal (terminal added to the strip and after the terminal was removed
from the project but keep in the terminal strip data) and this mistake
was saved in the xml. When we open this project the phantom terminal
don't appear in the layout but the empty physical terminal is still here
in the terminal strip data because the position of the terminals in the
strip is wrong (sometime bigger than the size of the strip, sometime
with a gap, sometime don't start at 0). This commit fix this mistake
when we open a project.
2025-07-01 22:46:18 +02:00
joshua
d711d8fb4a Terminal strip editor can now edit multiple project.
Before this this commit the terminal strip editor couldn't only work on
the first project opened into this editor, all other project opened
after couldn't be edited.
This is now past, terminal strip editor can now edit every project open
in QElectroTech.
2025-06-11 22:43:41 +02:00
joshua
3a6b4807db Fix crash.
Fix crash when :
1°-Open a project with terminal strip and open the terminal strip editor
2°-Close the terminal strip editor and the project (keep qelectrotech
open).
3°-redo step 1 and click on an item in the tree at left of the window,
qet crash.

Qet don't crash anymore but the terminal strip editor continue to work
with the terminal strip of the first opening (exactly the pointer of the
terminal strip) who don't exist anymore. Need more work.
2025-06-09 21:35:00 +02:00
joshua
d699faf501 Change some int to qreal
Made this change to be more compliant with svg
2025-06-08 21:40:32 +02:00
joshua
95e401a266 Class TerminalStripLayoutPattern can be save/load from xml
Add a new class TerminalStripLayoutPatternXml used to
save / load a TerminalStripLayoutPattern class into a xml.

Also create the namespace QETSVG used to read/write some
svg element / attribute to xml. This class is used by the
class TerminalStripLayoutPatternXml.
2025-06-05 23:04:56 +02:00
joshua
2c1b840f9c Use same properties for every terminal level
Initially it was planned to have separate text configuration for every
terminal level. It's not useful, use same properties for every level is
sufficient and visually more consistent.
By consequent every QVector related to these properties was replaced by
a single value.
2025-03-12 21:48:18 +01:00
joshua
2d89d70682 Add possibility to adjust terminal text position
The bounding rectangle used to define the position of the terminal text
can be edited. The y position and height can now be edited. The width is
not editable because is always the width of the rectangle of the of the
terminal.
2025-03-12 21:10:16 +01:00
joshua
7747223dfa Terminal strip item font is editable
The font used in the terminal strip item can be edited
trough the terminal strip layout editor widget
2025-03-12 19:22:30 +01:00
joshua
ae5e188866 Add converter for dpi to pixel font size
Add a little function used to convert if needed the size of a font set
in dpi to pixel. Because the conversion from pdi to pixel can't
be exactly identical, the text size in the diagram can be a little
different, in the other side the switch between screens with different
dpi is no more a problem.
2025-03-12 19:14:45 +01:00
joshua
4ca0bbf682 Minor
Add more help line for the preview of terminal strip configurator
2024-11-07 18:48:53 +01:00
joshua
258bfd7957 terminal strip Layout editor add help preview button 2023-09-20 08:25:58 +02:00
joshua
b422d9c6c5 Demo terminal strip : add 4 level terminal strip 2023-09-20 08:24:12 +02:00
joshua
12b7c7c47c Terminal strip layout editor : add preview of terminal strip layout 2023-09-19 15:23:29 +02:00
joshua
8ca1e0487e Add demo terminal strip class
Not available for user now.
2023-06-28 21:56:03 +02:00
joshua
48f9ef7632 Add AbstractTerminalStrip class to be used by TerminalStripDrawer class 2023-05-15 22:22:12 +02:00
joshua
752fe032e7 Draw strong line for better sepration between terminal 2023-03-19 19:19:53 +01:00
joshua
45b8cb34f3 Fix minor gui wrong behavior 2023-03-10 20:19:12 +01:00
joshua
470e4a059b Add widget to edit terminal strip item layout
The widget is available in the project properties editor.
WIP
2023-02-21 21:44:28 +01:00
joshua
d3223c8ca4 Merge branch 'master' into terminal_strip
* master:
  Fix crash
  Change displayed version on master
  avoid WARNING: mime_xml.path is not defined
  Update changelog
2023-01-08 16:30:59 +01:00
joshua
b1f6b1823a Fix crash 2023-01-08 16:20:13 +01:00
Laurent Trinques
1e2bdc203b Change displayed version on master 2023-01-06 15:28:32 +01:00
Remi Collet
f75f6d3f3f avoid WARNING: mime_xml.path is not defined 2023-01-06 14:07:35 +01:00
joshua
f07e4319d3 Fix ftbfs 2023-01-05 19:20:41 +01:00
Laurent Trinques
d5f0a7932a Update changelog 2023-01-05 10:17:25 +01:00
joshua
4da7f6cd13 TerminalStripLayoutPattern is now shared
TerminalStripLayoutPattern class is now a shared pointer between all
terminal strip item.
QETProject have now a new class : ProjectPropertiesHandler
the goal of this class is to manage every kind of properties used in the
project, this class will be strongly used in future.
2023-01-04 22:40:18 +01:00
joshua
c6739b5bec Fix ftbfs on macOS 2023-01-03 22:30:13 +01:00
Laurent Trinques
cc7e185d59 Merge branch 'master' of ssh://git.tuxfamily.org/gitroot/qet/qet 2023-01-03 01:47:09 +01:00
Laurent Trinques
60ceab8a32 Add unicode HEX codes from a string in Ukranian: "Імпортовані
елементи"
Refresh namesListForIntegrationCategory
2023-01-02 20:13:42 +01:00
joshua
539e0a7a49 Merge branch 'terminal_strip'
* terminal_strip:
  Terminal strip item can saved / loaded to .qet file
  See previous commit...
  Move terminal strip drawer class in is own file
  Fix wrong use of QStringLiteral and QLatin1String
  Double click a TerminalStripItem open the editor
  Minor change about checkable QAction of QetDiagramEditor
  Minor : corrects a minor aesthetic defect when unbridge terminals
  Revamp code
  Add and move terminal strip item are now managed by undo command
  TerminalStripItem : Draw terminal bridge
  Terminal strip item can be added to diagram
  Minor : add QGIUtility namespace
2023-01-02 19:40:08 +01:00
Laurent Trinques
9afef79629 Update Copyright date 2023-01-01 17:05:57 +01:00
joshua
f54bea713e Terminal strip item can saved / loaded to .qet file 2022-12-21 19:18:49 +01:00
joshua
f41b5a4ed4 See previous commit...
Je suis une tête de linotte
2022-12-02 19:39:56 +01:00
joshua
1f99a40f1b Move terminal strip drawer class in is own file 2022-12-02 19:35:17 +01:00
joshua
d23a5bbdc7 Fix wrong use of QStringLiteral and QLatin1String 2022-12-02 18:26:56 +01:00
joshua
81640015e5 Double click a TerminalStripItem open the editor 2022-12-02 18:12:47 +01:00
joshua
a18cd2461f Minor change about checkable QAction of QetDiagramEditor 2022-11-14 21:51:14 +01:00
joshua
aca3b8ad1e Minor : corrects a minor aesthetic defect when unbridge terminals 2022-11-14 21:10:38 +01:00
joshua
9e1ef8c42f Revamp code
-Move MoveElementsCommand class from diagramcommands file to
movegraphicsitemcommand file.
-Rename the to class MoveGraphicsItemCommand.
-Minor code change to make it more modern.
2022-11-08 22:06:50 +01:00
joshua
7fede2277f Add and move terminal strip item are now managed by undo command 2022-11-08 19:20:32 +01:00
joshua
21de926367 TerminalStripItem : Draw terminal bridge 2022-10-23 19:30:58 +02:00
joshua
ff80453f2c Terminal strip item can be added to diagram
Initial commit about graphics item of a terminal strip, Work in
progress.
2022-08-27 21:24:25 +02:00
joshua
d9a0b03e23 Minor : add QGIUtility namespace 2022-07-15 20:48:06 +02:00
557 changed files with 5679 additions and 911 deletions

View File

@@ -1,3 +1,54 @@
====== ChangeLog from 0.8 to 0.9 ======
*Diagram editor :
Improved QElectroTech speed (launch qet, open project, function)
A drop-down list has been added to the toolbar to change the size of the resize handles.
*Element Editor:
The "keep visual rotation" property of element texts is editable from the element editor.
Thanks to the work of antonioaja it is now possible to import a dxf directly from the element editor in a completely transparent way for the user.
In the background QElectroTech uses the dxf2elmt software. https://qelectrotech.org/forum/viewtopic.php?id=2265 https://github.com/antonioaja/dxf2elmt
Improved responsiveness when multiple shapes are selected or deleted, especially when working on a large converted DXF element.
https://qelectrotech.org/forum/viewtopic.php?pid=16612#p16612
*Other:
Add a "side project" tab in the "about" window.
In the general QElectroTech configuration, a drop down list allows to choose the scaling method for hdpi screens.
Allow open polygons (i.e. polylines) when saving in dxf format.
https://qelectrotech.org/forum/viewtopic.php?pid=16611#p16611
Added 'Other' option for slave device contact type.
https://github.com/qelectrotech/qelectrotech-source-mirror/pull/222
https://qelectrotech.org/forum/viewtopic.php?id=2264
*Logs:
Added a QElapsedTimer to calculate the time used to reload the item collection.
Improved QElapsedTimer to calculate the time used to reload the item collection in seconds instead of ms.
Added Linux pc.gpu.RAM information, but requires mesa-utils dependency on the Linux OS.
Added information about mounted disk volumes.
Added CPU architecture for which Qt was compiled in the aboutqetdialog widget and in the logs.
Added MSVC support to MachineInfo.
Added RAM information on Windows of available RAM.
Added QElectroTech version to the log file.
* Elements collection :
Improve collection 8274 elements in 1097 categories (i.e. 9371 files).
* macOS :
Fix sqlite3 database export on macOS, now I use macports with Digikam scripts instead off Homebrew Package Manager.
See: https://invent.kde.org/graphics/digikam/-/tree/master/project/bundles/macports
*Bug fix:
see: https://git.tuxfamily.org/qet/qet.git/log/?h=0.8.1
====== ChangeLog from 0.7 to 0.8 ====== ====== ChangeLog from 0.7 to 0.8 ======

View File

@@ -11,6 +11,7 @@ DiagramImageItem + 1007
QetShapItem + 1008 QetShapItem + 1008
crossRefItem + 1009 crossRefItem + 1009
DynamiqueElementTextItem + 1010 DynamiqueElementTextItem + 1010
TerminalStripItem +1011
ElementPrimitiveDecorator + 2200 ElementPrimitiveDecorator + 2200
###ELEMENT EDITOR### ###ELEMENT EDITOR###

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2006-2021 The QElectroTech Team --> <!-- Copyright 2006-2023 The QElectroTech Team -->
<application> <application>
<id type="desktop">qelectrotech.desktop</id> <id type="desktop">qelectrotech.desktop</id>
<metadata_license>MIT</metadata_license> <metadata_license>MIT</metadata_license>

View File

@@ -126,7 +126,9 @@ INCLUDEPATH += sources/ui
# sources/print # sources/print
# Fichiers sources # Fichiers sources
HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) \ HEADERS += $$files(sources/*.h) \
$$files(sources/project/*.h) \
$$files(sources/ui/*.h) \
$$files(sources/editor/*.h) \ $$files(sources/editor/*.h) \
$$files(sources/titleblock/*.h) \ $$files(sources/titleblock/*.h) \
$$files(sources/richtext/*.h) \ $$files(sources/richtext/*.h) \
@@ -159,11 +161,17 @@ HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) \
$$files(sources/print/*.h) \ $$files(sources/print/*.h) \
$$files(sources/TerminalStrip/*.h) \ $$files(sources/TerminalStrip/*.h) \
$$files(sources/TerminalStrip/ui/*.h) \ $$files(sources/TerminalStrip/ui/*.h) \
$$files(sources/TerminalStrip/ui/ConfigPage/*h) \
$$files(sources/TerminalStrip/UndoCommand/*.h) \ $$files(sources/TerminalStrip/UndoCommand/*.h) \
$$files(sources/dxf/*.h) $$files(sources/TerminalStrip/GraphicsItem/*.h) \
$$files(sources/TerminalStrip/GraphicsItem/properties/*.h) \
$$files(sources/xml/*.h) \
$$files(sources/dxf/*.h) \
$$files(sources/svg/*.h)
SOURCES += $$files(sources/*.cpp) \ SOURCES += $$files(sources/*.cpp) \
$$files(sources/editor/*.cpp) \ $$files(sources/editor/*.cpp) \
$$files(sources/project/*.cpp) \
$$files(sources/titleblock/*.cpp) \ $$files(sources/titleblock/*.cpp) \
$$files(sources/richtext/*.cpp) \ $$files(sources/richtext/*.cpp) \
$$files(sources/ui/*.cpp) \ $$files(sources/ui/*.cpp) \
@@ -196,8 +204,13 @@ SOURCES += $$files(sources/*.cpp) \
$$files(sources/print/*.cpp) \ $$files(sources/print/*.cpp) \
$$files(sources/TerminalStrip/*.cpp) \ $$files(sources/TerminalStrip/*.cpp) \
$$files(sources/TerminalStrip/ui/*.cpp) \ $$files(sources/TerminalStrip/ui/*.cpp) \
$$files(sources/TerminalStrip/ui/ConfigPage/*cpp) \
$$files(sources/TerminalStrip/UndoCommand/*.cpp) \ $$files(sources/TerminalStrip/UndoCommand/*.cpp) \
$$files(sources/dxf/*.cpp) $$files(sources/TerminalStrip/GraphicsItem/*.cpp) \
$$files(sources/TerminalStrip/GraphicsItem/properties/*.cpp) \
$$files(sources/xml/*.cpp) \
$$files(sources/dxf/*.cpp) \
$$files(sources/svg/*.cpp)
# Needed for use promote QTreeWidget in terminalstripeditor.ui # Needed for use promote QTreeWidget in terminalstripeditor.ui
INCLUDEPATH += sources/TerminalStrip/ui INCLUDEPATH += sources/TerminalStrip/ui
@@ -227,7 +240,8 @@ FORMS += $$files(sources/richtext/*.ui) \
$$files(sources/dataBase/ui/*.ui) \ $$files(sources/dataBase/ui/*.ui) \
$$files(sources/factory/ui/*.ui) \ $$files(sources/factory/ui/*.ui) \
$$files(sources/print/*.ui) \ $$files(sources/print/*.ui) \
$$files(sources/TerminalStrip/ui/*.ui) $$files(sources/TerminalStrip/ui/*.ui) \
$$files(sources/TerminalStrip/ui/ConfigPage/*.ui)
UI_SOURCES_DIR = sources/ui/ UI_SOURCES_DIR = sources/ui/
UI_HEADERS_DIR = sources/ui/ UI_HEADERS_DIR = sources/ui/
@@ -289,7 +303,7 @@ man.extra = sh man/compress_man_pages.sh
INSTALLS += target elements tbt lang copyright INSTALLS += target elements tbt lang copyright
# Sous Unix, on installe egalement l'icone, un fichier .desktop, des fichiers mime et les pages de manuel # Sous Unix, on installe egalement l'icone, un fichier .desktop, des fichiers mime et les pages de manuel
unix { unix {
INSTALLS += desktop mime_xml mime_desktop mime_package icons man examples appdata INSTALLS += desktop mime_package icons man examples appdata
} }
# Options de compilation communes a Unix et MacOS X # Options de compilation communes a Unix et MacOS X

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -84,6 +84,39 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
0x006C, 0x006C,
0x0065, 0x0065,
0x0072}; 0x0072};
const QChar ukrainian_data[20] = {
0x0406,
0x043c,
0x043f,
0x043e,
0x0440,
0x0442,
0x043e,
0x0432,
0x0430,
0x043d,
0x0456,
0x0020,
0x0435,
0x043b,
0x0435,
0x043c,
0x0435,
0x043d,
0x0442,
0x0438};
const QChar japanese_data[10] = {
0x30A4,
0x30F3,
0x30D0,
0x30FC,
0x30C8,
0x3055,
0x308C,
0x305F,
0x8981,
0x7D20};
names.addName("fr", "Éléments importés"); names.addName("fr", "Éléments importés");
names.addName("en", "Imported elements"); names.addName("en", "Imported elements");
names.addName("de", "Importierte elemente"); names.addName("de", "Importierte elemente");
@@ -100,8 +133,9 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
names.addName("ro", "Elemente importate"); names.addName("ro", "Elemente importate");
names.addName("tr", QString(turkish_data, 12)); names.addName("tr", QString(turkish_data, 12));
names.addName("da", "Importerede elementer"); names.addName("da", "Importerede elementer");
names.addName("hr", "Uvezeni elementi");
names.addName("sl", "Uvoženi elementi"); names.addName("sl", "Uvoženi elementi");
names.addName("ja", QString(japanese_data, 10));
names.addName("uk", QString(ukrainian_data, 20));
#else #else
# if TODO_LIST # if TODO_LIST
# pragma message("@TODO remove code for QT 6 or later") # pragma message("@TODO remove code for QT 6 or later")
@@ -120,8 +154,8 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
names.addName("ca", "Elements importats"); names.addName("ca", "Elements importats");
names.addName("ro", "Elemente importate"); names.addName("ro", "Elemente importate");
names.addName("da", "Importerede elementer"); names.addName("da", "Importerede elementer");
names.addName("hr", "Uvezeni elementi");
names.addName("sl", "Uvoženi elementi"); names.addName("sl", "Uvoženi elementi");
names.addName("uk", "Імпортовані елементи");
#endif #endif
import.appendChild(names.toXml(m_dom_document)); import.appendChild(names.toXml(m_dom_document));

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View 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}};
}
}

View 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

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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

View 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

View 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

View 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());
}
}

View 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

View 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();
}
}
}

View 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

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -16,6 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "bridgeterminalscommand.h" #include "bridgeterminalscommand.h"
#include "../terminalstripbridge.h"
BridgeTerminalsCommand::BridgeTerminalsCommand(TerminalStrip *strip, BridgeTerminalsCommand::BridgeTerminalsCommand(TerminalStrip *strip,
QVector<QSharedPointer<RealTerminal>> real_terminal, QVector<QSharedPointer<RealTerminal>> real_terminal,
@@ -57,8 +58,18 @@ UnBridgeTerminalsCommand::UnBridgeTerminalsCommand(TerminalStrip *strip,
if (strip->canUnBridge(real_terminal)) if (strip->canUnBridge(real_terminal))
{ {
m_terminals = real_terminal;
m_bridge = strip->isBridged(real_terminal.first()); m_bridge = strip->isBridged(real_terminal.first());
//If bridge have one more terminals than @real_terminal
//that mean every terminals of the bridge must be unbridged by this undo command,
//else the single terminal who's not umbridged by this undo command
//continue to have a bridge (to nothing) and this nowhere bridge is visible
//in the terminal strip graphic item and terminal strip editor dialog.
if (m_bridge->realTerminals().size() == real_terminal.size() + 1) {
m_terminals = m_bridge->realTerminals();
} else {
m_terminals = real_terminal;
}
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -189,6 +189,20 @@ QVector<QSharedPointer<RealTerminal>> PhysicalTerminal::realTerminals() const {
return m_real_terminal; return m_real_terminal;
} }
/**
* @brief PhysicalTerminal::realTerminal
* @param pos
* @return the real terminal at position pos.
* Note that the returned QSharedPointer can be null
*/
QSharedPointer<RealTerminal> PhysicalTerminal::realTerminal(int pos) const
{
if (pos < m_real_terminal.size()) {
return m_real_terminal.at(pos);
}
else return QSharedPointer<RealTerminal>{};
}
/** /**
* @brief uuid * @brief uuid
* @return the uuid of this physical terminal * @return the uuid of this physical terminal

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -86,6 +86,7 @@ class PhysicalTerminal
int levelCount() const; int levelCount() const;
int levelOf(const QSharedPointer<RealTerminal> &terminal) const; int levelOf(const QSharedPointer<RealTerminal> &terminal) const;
QVector<QSharedPointer<RealTerminal>> realTerminals() const; QVector<QSharedPointer<RealTerminal>> realTerminals() const;
QSharedPointer<RealTerminal> realTerminal(int pos) const;
QUuid uuid() const; QUuid uuid() const;
int pos() const; int pos() const;
int realTerminalCount() const; int realTerminalCount() const;

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -975,8 +975,9 @@ QDomElement TerminalStrip::toXml(QDomDocument &parent_document)
root_elmt.appendChild(m_data.toXml(parent_document)); root_elmt.appendChild(m_data.toXml(parent_document));
//Undrawn terminals //Undrawed terminals
auto xml_layout = parent_document.createElement("layout"); auto xml_layout = parent_document.createElement(QStringLiteral("layout"));
for (auto &phy_t : m_physical_terminals) { for (auto &phy_t : m_physical_terminals) {
xml_layout.appendChild(phy_t->toXml(parent_document)); xml_layout.appendChild(phy_t->toXml(parent_document));
} }
@@ -1036,9 +1037,11 @@ bool TerminalStrip::fromXml(QDomElement &xml_element)
} }
} }
if (!real_t_vector.isEmpty()) {
auto raw_ptr = new PhysicalTerminal(this, real_t_vector); auto raw_ptr = new PhysicalTerminal(this, real_t_vector);
m_physical_terminals.append(raw_ptr->sharedRef()); m_physical_terminals.append(raw_ptr->sharedRef());
} }
}
} }

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -120,6 +120,14 @@ void TerminalStripBridge::fromXml(const QDomElement &dom_element)
} }
} }
/**
* @brief TerminalStripBridge::uuid
* @return The uuid of this terminal
*/
QUuid TerminalStripBridge::uuid() const noexcept {
return m_uuid;
}
/** /**
* @brief TerminalStripBridge::addTerminals * @brief TerminalStripBridge::addTerminals
* @param real_terminals * @param real_terminals

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -46,6 +46,7 @@ class TerminalStripBridge
static QString xmlTagName() {return QStringLiteral("terminal_strip_bridge");} static QString xmlTagName() {return QStringLiteral("terminal_strip_bridge");}
QDomElement toXml(QDomDocument &parent_document) const; QDomElement toXml(QDomDocument &parent_document) const;
void fromXml(const QDomElement &dom_element); void fromXml(const QDomElement &dom_element);
QUuid uuid() const noexcept;
private: private:
bool addTerminals(const QVector<QSharedPointer<RealTerminal>> &real_terminals); bool addTerminals(const QVector<QSharedPointer<RealTerminal>> &real_terminals);

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -34,7 +34,7 @@ QDomElement TerminalStripData::toXml(QDomDocument &xml_document) const
root_elmt.setAttribute(QStringLiteral("uuid"), m_uuid.toString()); root_elmt.setAttribute(QStringLiteral("uuid"), m_uuid.toString());
auto info_elmt = xml_document.createElement("informations"); auto info_elmt = xml_document.createElement(QStringLiteral("informations"));
root_elmt.appendChild(info_elmt); root_elmt.appendChild(info_elmt);
if (!m_installation.isEmpty()) { if (!m_installation.isEmpty()) {
@@ -65,23 +65,23 @@ bool TerminalStripData::fromXml(const QDomElement &xml_element)
return false; return false;
} }
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
m_uuid = QUuid::fromString(xml_element.attribute(QLatin1String("uuid"))); m_uuid = QUuid::fromString(xml_element.attribute(QStringLiteral("uuid")));
#else #else
m_uuid = QUuid(xml_element.attribute(QStringLiteral("uuid"))); m_uuid = QUuid(xml_element.attribute(QStringLiteral("uuid")));
#endif #endif
for (auto &xml_info : for (auto &xml_info :
QETXML::findInDomElement(xml_element.firstChildElement("informations"), QETXML::findInDomElement(xml_element.firstChildElement(QStringLiteral("informations")),
QStringLiteral("information"))) QStringLiteral("information")))
{ {
auto name = xml_info.attribute("name"); auto name = xml_info.attribute(QStringLiteral("name"));
auto value = xml_info.text(); auto value = xml_info.text();
if (name == QStringLiteral("installation")) { m_installation = value;} if (name == QLatin1String("installation")) { m_installation = value;}
else if (name == QStringLiteral("location")) {m_location = value;} else if (name == QLatin1String("location")) {m_location = value;}
else if (name == QStringLiteral("name")) {m_name = value;} else if (name == QLatin1String("name")) {m_name = value;}
else if (name == QStringLiteral("comment")) {m_comment = value;} else if (name == QLatin1String("comment")) {m_comment = value;}
else if (name == QStringLiteral("description")) {m_description = value;} else if (name == QLatin1String("description")) {m_description = value;}
} }
return true; return true;
@@ -101,7 +101,7 @@ TerminalStripData &TerminalStripData::operator=(const TerminalStripData &other)
QDomElement TerminalStripData::infoToXml(QDomDocument &xml_doc, const QString &name, const QString &value) QDomElement TerminalStripData::infoToXml(QDomDocument &xml_doc, const QString &name, const QString &value)
{ {
auto xml_elmt = xml_doc.createElement("information"); auto xml_elmt = xml_doc.createElement(QStringLiteral("information"));
xml_elmt.setAttribute(QStringLiteral("name"), name); xml_elmt.setAttribute(QStringLiteral("name"), name);
xml_elmt.appendChild(xml_doc.createTextNode(value)); xml_elmt.appendChild(xml_doc.createTextNode(value));

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -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);
}

View File

@@ -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

View 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());
}
}
}

View 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

View 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>

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2022 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -42,6 +42,10 @@ FreeTerminalEditor::FreeTerminalEditor(QETProject *project, QWidget *parent) :
ui->m_table_view->setModel(m_model); ui->m_table_view->setModel(m_model);
ui->m_table_view->setCurrentIndex(m_model->index(0,0)); ui->m_table_view->setCurrentIndex(m_model->index(0,0));
if (m_project) {
connect(m_project, &QObject::destroyed, this, &FreeTerminalEditor::reload);
}
//Disabled the move if the table is currently edited (yellow cell) //Disabled the move if the table is currently edited (yellow cell)
connect(m_model, &FreeTerminalModel::dataChanged, this, [=] { connect(m_model, &FreeTerminalModel::dataChanged, this, [=] {
this->setDisabledMove(); this->setDisabledMove();
@@ -135,6 +139,31 @@ void FreeTerminalEditor::apply()
reload(); reload();
} }
/**
* @brief FreeTerminalEditor::setProject
* Set @project as project handled by this editor.
* If a previous project was setted, everything is clear.
* This function track the destruction of the project,
* that mean if the project pointer is deleted
* no need to call this function with a nullptr,
* everything is made inside this class.
* @param project
*/
void FreeTerminalEditor::setProject(QETProject *project)
{
if(m_project) {
disconnect(m_project, &QObject::destroyed, this, &FreeTerminalEditor::reload);
}
m_project = project;
if (m_model) {
m_model->setProject(project);
}
if (m_project) {
connect(m_project, &QObject::destroyed, this, &FreeTerminalEditor::reload);
}
reload();
}
void FreeTerminalEditor::on_m_type_cb_activated(int index) void FreeTerminalEditor::on_m_type_cb_activated(int index)
{ {
if (m_model) if (m_model)

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2006-2022 The QElectroTech Team Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
@@ -19,8 +19,8 @@
#define FREETERMINALEDITOR_H #define FREETERMINALEDITOR_H
#include <QWidget> #include <QWidget>
#include "../../qetproject.h"
class QETProject;
class RealTerminal; class RealTerminal;
class FreeTerminalModel; class FreeTerminalModel;
class QTableView; class QTableView;
@@ -40,6 +40,8 @@ class FreeTerminalEditor : public QWidget
void reload(); void reload();
void apply(); void apply();
void setProject(QETProject *project);
private slots: private slots:
void on_m_type_cb_activated(int index); void on_m_type_cb_activated(int index);
void on_m_function_cb_activated(int index); void on_m_function_cb_activated(int index);
@@ -52,7 +54,7 @@ class FreeTerminalEditor : public QWidget
private: private:
Ui::FreeTerminalEditor *ui; Ui::FreeTerminalEditor *ui;
QETProject *m_project = nullptr; QPointer <QETProject> m_project;
FreeTerminalModel *m_model = nullptr; FreeTerminalModel *m_model {nullptr};
}; };
#endif // FREETERMINALEDITOR_H #endif // FREETERMINALEDITOR_H

Some files were not shown because too many files have changed in this diff Show More