Compare commits

..

33 Commits

Author SHA1 Message Date
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
552 changed files with 4285 additions and 815 deletions
+51
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 ======
+1
View File
@@ -11,6 +11,7 @@ DiagramImageItem + 1007
QetShapItem + 1008
crossRefItem + 1009
DynamiqueElementTextItem + 1010
TerminalStripItem +1011
ElementPrimitiveDecorator + 2200
###ELEMENT EDITOR###
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2006-2021 The QElectroTech Team -->
<!-- Copyright 2006-2023 The QElectroTech Team -->
<application>
<id type="desktop">qelectrotech.desktop</id>
<metadata_license>MIT</metadata_license>
+15 -3
View File
@@ -126,7 +126,9 @@ INCLUDEPATH += sources/ui
# sources/print
# Fichiers sources
HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) \
HEADERS += $$files(sources/*.h) \
$$files(sources/project/*.h) \
$$files(sources/ui/*.h) \
$$files(sources/editor/*.h) \
$$files(sources/titleblock/*.h) \
$$files(sources/richtext/*.h) \
@@ -159,11 +161,16 @@ HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) \
$$files(sources/print/*.h) \
$$files(sources/TerminalStrip/*.h) \
$$files(sources/TerminalStrip/ui/*.h) \
$$files(sources/TerminalStrip/ui/ConfigPage/*h) \
$$files(sources/TerminalStrip/UndoCommand/*.h) \
$$files(sources/TerminalStrip/GraphicsItem/*.h) \
$$files(sources/TerminalStrip/GraphicsItem/properties/*.h) \
$$files(sources/xml/*.h) \
$$files(sources/dxf/*.h)
SOURCES += $$files(sources/*.cpp) \
$$files(sources/editor/*.cpp) \
$$files(sources/project/*.cpp) \
$$files(sources/titleblock/*.cpp) \
$$files(sources/richtext/*.cpp) \
$$files(sources/ui/*.cpp) \
@@ -196,7 +203,11 @@ SOURCES += $$files(sources/*.cpp) \
$$files(sources/print/*.cpp) \
$$files(sources/TerminalStrip/*.cpp) \
$$files(sources/TerminalStrip/ui/*.cpp) \
$$files(sources/TerminalStrip/ui/ConfigPage/*cpp) \
$$files(sources/TerminalStrip/UndoCommand/*.cpp) \
$$files(sources/TerminalStrip/GraphicsItem/*.cpp) \
$$files(sources/TerminalStrip/GraphicsItem/properties/*.cpp) \
$$files(sources/xml/*.cpp) \
$$files(sources/dxf/*.cpp)
# Needed for use promote QTreeWidget in terminalstripeditor.ui
@@ -227,7 +238,8 @@ FORMS += $$files(sources/richtext/*.ui) \
$$files(sources/dataBase/ui/*.ui) \
$$files(sources/factory/ui/*.ui) \
$$files(sources/print/*.ui) \
$$files(sources/TerminalStrip/ui/*.ui)
$$files(sources/TerminalStrip/ui/*.ui) \
$$files(sources/TerminalStrip/ui/ConfigPage/*.ui)
UI_SOURCES_DIR = sources/ui/
UI_HEADERS_DIR = sources/ui/
@@ -289,7 +301,7 @@ man.extra = sh man/compress_man_pages.sh
INSTALLS += target elements tbt lang copyright
# Sous Unix, on installe egalement l'icone, un fichier .desktop, des fichiers mime et les pages de manuel
unix {
INSTALLS += desktop mime_xml mime_desktop mime_package icons man examples appdata
INSTALLS += desktop mime_package icons man examples appdata
}
# Options de compilation communes a Unix et MacOS X
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -84,6 +84,39 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
0x006C,
0x0065,
0x0072};
const QChar ukrainian_data[20] = {
0x0406,
0x043c,
0x043f,
0x043e,
0x0440,
0x0442,
0x043e,
0x0432,
0x0430,
0x043d,
0x0456,
0x0020,
0x0435,
0x043b,
0x0435,
0x043c,
0x0435,
0x043d,
0x0442,
0x0438};
const QChar japanese_data[10] = {
0x30A4,
0x30F3,
0x30D0,
0x30FC,
0x30C8,
0x3055,
0x308C,
0x305F,
0x8981,
0x7D20};
names.addName("fr", "Éléments importés");
names.addName("en", "Imported elements");
names.addName("de", "Importierte elemente");
@@ -100,8 +133,9 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
names.addName("ro", "Elemente importate");
names.addName("tr", QString(turkish_data, 12));
names.addName("da", "Importerede elementer");
names.addName("hr", "Uvezeni elementi");
names.addName("sl", "Uvoženi elementi");
names.addName("ja", QString(japanese_data, 10));
names.addName("uk", QString(ukrainian_data, 20));
#else
# if TODO_LIST
# pragma message("@TODO remove code for QT 6 or later")
@@ -120,8 +154,8 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
names.addName("ca", "Elements importats");
names.addName("ro", "Elemente importate");
names.addName("da", "Importerede elementer");
names.addName("hr", "Uvezeni elementi");
names.addName("sl", "Uvoženi elementi");
names.addName("uk", "Імпортовані елементи");
#endif
import.appendChild(names.toXml(m_dom_document));
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -0,0 +1,152 @@
/*
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 QUuid &bridge) :
m_label { label },
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 };
}
private:
QString m_label;
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"),
lvl_1)};
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
new DemoRealTerminal( QStringLiteral("0vdc"),
lvl_2)};
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
new DemoRealTerminal( QStringLiteral("signal"),
lvl_3)};
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
new DemoRealTerminal( QStringLiteral("teach"),
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"),
lvl_1)};
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
new DemoRealTerminal( QStringLiteral("0vdc"),
lvl_2)};
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
new DemoRealTerminal( QStringLiteral("signal"),
lvl_3)};
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
new DemoRealTerminal( QStringLiteral("teach"),
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"),
lvl_1)};
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
new DemoRealTerminal( QStringLiteral("0vdc"),
lvl_2)};
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
new DemoRealTerminal( QStringLiteral("signal"),
lvl_3)};
real_terminals_vector << QSharedPointer<AbstractRealTerminalInterface> {
new DemoRealTerminal( QStringLiteral("teach"),
lvl_4)};
m_physical_terminal << QSharedPointer<AbstractPhysicalTerminalInterface> {
new DemoPhysicalTerminal {real_terminals_vector}};
}
}
@@ -0,0 +1,50 @@
/*
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEMOTERMINALSTRIP_H
#define DEMOTERMINALSTRIP_H
#include "terminalstripdrawer.h"
namespace TerminalStripDrawer {
class DemoTerminalStrip : public AbstractTerminalStripInterface
{
public:
DemoTerminalStrip();
QString installation() const override {
return QStringLiteral("=INST");
}
QString location() const override {
return QStringLiteral("+LOC" );
}
QString name() const override {
return QStringLiteral("X1");
}
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> physicalTerminal() const override;
private:
void build();
private:
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> m_physical_terminal;
};
} //End namespace TerminalStripDrawer
#endif // DEMOTERMINALSTRIP_H
@@ -0,0 +1,78 @@
/*
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 <QDebug>
TerminalStripLayoutPattern::TerminalStripLayoutPattern()
{
updateHeaderTextOption();
updateTerminalsTextOption();
}
void TerminalStripLayoutPattern::setHeaderTextAlignment(const Qt::Alignment &alignment)
{
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;
}
void TerminalStripLayoutPattern::setTerminalsTextAlignment(const QVector<Qt::Alignment> &alignment)
{
m_terminals_text_alignment = alignment;
updateTerminalsTextOption();
}
QVector<Qt::Alignment> TerminalStripLayoutPattern::terminalsTextAlignment() const
{
return m_terminals_text_alignment;
}
QVector<QTextOption> TerminalStripLayoutPattern::terminalsTextOption() const
{
return m_terminals_text_option;
}
void TerminalStripLayoutPattern::updateHeaderTextOption()
{
m_header_text_option.setAlignment(m_header_text_alignment);
m_header_text_option.setWrapMode(QTextOption::WordWrap);
}
void TerminalStripLayoutPattern::updateTerminalsTextOption()
{
if (m_terminals_text_option.size() ==
m_terminals_text_alignment.size())
{
for (auto i = 0 ; i<m_terminals_text_option.size() ; ++i)
{
m_terminals_text_option[i].setAlignment(m_terminals_text_alignment.at(i));
m_terminals_text_option[i].setWrapMode(QTextOption::WordWrap);
}
}
else {
qDebug() << "TerminalStripLayoutPattern::updateTerminalsTextOption() : Wrong vector size";
}
}
@@ -0,0 +1,113 @@
/*
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 <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
QRect 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
QRect m_spacer_rect{0, 50, 10, 90};
//Terminals
QVector<QRect> m_terminal_rect
{
QRect{0, 0, 20, 190},
QRect{0, 10, 20, 170},
QRect{0, 20, 20, 150},
QRect{0, 30, 20, 130}
};
void setTerminalsTextAlignment(const QVector<Qt::Alignment> &alignment);
QVector<Qt::Alignment> terminalsTextAlignment() const;
QVector<QTextOption> terminalsTextOption() const;
QVector<QRect> m_terminals_text_rect
{
QRect{0,35,20,50},
QRect{0,35,20,50},
QRect{0,35,20,50},
QRect{0,35,20,50}
};
QVector<Qt::Orientation> m_terminals_text_orientation
{
Qt::Vertical,
Qt::Vertical,
Qt::Vertical,
Qt::Vertical
};
int m_bridge_point_d{5};
QVector<int> m_bridge_point_y_offset{50,70,90,110};
QUuid m_uuid{QUuid::createUuid()};
QString m_name;
private:
void updateHeaderTextOption();
void updateTerminalsTextOption();
private:
Qt::Alignment m_header_text_alignment{Qt::AlignCenter};
QTextOption m_header_text_option;
QVector<Qt::Alignment> m_terminals_text_alignment
{
Qt::AlignRight | Qt::AlignVCenter,
Qt::AlignRight | Qt::AlignVCenter,
Qt::AlignRight | Qt::AlignVCenter,
Qt::AlignRight | Qt::AlignVCenter
};
QVector<QTextOption> m_terminals_text_option
{
QTextOption(),
QTextOption(),
QTextOption(),
QTextOption()
};
};
#endif // TERMINALSTRIPLAYOUTPATTERN_H
@@ -0,0 +1,32 @@
/*
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "terminalstriplayoutshandler.h"
#include <QObject>
TerminalStripLayoutsHandler::TerminalStripLayoutsHandler()
{
m_default_layout = QSharedPointer<TerminalStripLayoutPattern>::create();
m_default_layout->m_name = QObject::tr("Disposition par défaut");
}
QSharedPointer<TerminalStripLayoutPattern> TerminalStripLayoutsHandler::defaultLayout()
{
return m_default_layout;
}
@@ -0,0 +1,41 @@
/*
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TERMINALSTRIPLAYOUTSHANDLER_H
#define TERMINALSTRIPLAYOUTSHANDLER_H
#include <QSet>
#include <QSharedPointer>
#include "terminalstriplayoutpattern.h"
/**
* @brief The TerminalStripLayoutsHandler class
* Manage and provide TerminalStripLayoutPattern
*/
class TerminalStripLayoutsHandler
{
public:
TerminalStripLayoutsHandler();
QSharedPointer<TerminalStripLayoutPattern> defaultLayout();
private:
QSet<QSharedPointer<TerminalStripLayoutPattern>> m_layout_set;
QSharedPointer<TerminalStripLayoutPattern> m_default_layout;
};
#endif // TERMINALSTRIPLAYOUTSHANDLER_H
@@ -0,0 +1,300 @@
/*
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)
{
//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->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);
int 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_rect{m_pattern->m_terminals_text_rect};
const auto terminals_text_orientation{m_pattern->m_terminals_text_orientation};
const auto terminals_text_option{m_pattern->terminalsTextOption()};
QRect terminal_rect;
QHash<QUuid, QVector<QPointF>> bridges_anchor_points;
//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 QPoint 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(QPoint{terminal_rect.x(), terminal_rect.y() + terminal_rect.height()/2},
QPoint{terminal_rect.width(), terminal_rect.y() + terminal_rect.height()/2});
painter->restore();
}
//Draw text
painter->save();
if (terminals_text_orientation[index_] == Qt::Horizontal)
{
text_rect = terminals_text_rect[index_];
}
else
{
const auto rect_{terminals_text_rect[index_]};
painter->translate(rect_.bottomLeft());
painter->rotate(270);
text_rect.setRect(0, 0, rect_.height(), terminal_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[index_]);
if (m_preview_draw)
{
painter->setPen(Qt::blue);
painter->drawRect(text_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();
}
}
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 QRect{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;
}
int 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;
}
int TerminalStripDrawer::width() const
{
if (m_pattern)
{
int 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
@@ -0,0 +1,93 @@
/*
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
{
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;
};
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);
private:
int height() const;
int width() const;
private:
QSharedPointer <AbstractTerminalStripInterface> m_strip;
QSharedPointer<TerminalStripLayoutPattern> m_pattern;
bool m_preview_draw { false };
};
}
#endif // TERMINALSTRIPDRAWER_H
@@ -0,0 +1,132 @@
/*
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 "../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::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED (event);
if (m_strip) {
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());
}
}
@@ -0,0 +1,63 @@
/*
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 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
@@ -0,0 +1,133 @@
/*
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 "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());
}
TrueBridge::TrueBridge(QSharedPointer<TerminalStripBridge> bridge) :
m_bridge { bridge }
{}
QUuid TrueBridge::uuid() const
{
if (m_bridge) {
return m_bridge->uuid();
} else {
return QUuid();
}
}
}
@@ -0,0 +1,77 @@
/*
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;
private:
QSharedPointer<RealTerminal> m_real;
};
class TrueBridge : public AbstractBridgeInterface
{
public:
TrueBridge(QSharedPointer<TerminalStripBridge> bridge);
QUuid uuid() const override;
private:
QSharedPointer<TerminalStripBridge> m_bridge;
};
}
#endif // TRUETERMINALSTRIP_H
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,6 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "bridgeterminalscommand.h"
#include "../terminalstripbridge.h"
BridgeTerminalsCommand::BridgeTerminalsCommand(TerminalStrip *strip,
QVector<QSharedPointer<RealTerminal>> real_terminal,
@@ -57,8 +58,18 @@ UnBridgeTerminalsCommand::UnBridgeTerminalsCommand(TerminalStrip *strip,
if (strip->canUnBridge(real_terminal))
{
m_terminals = real_terminal;
m_bridge = strip->isBridged(real_terminal.first());
m_bridge = strip->isBridged(real_terminal.first());
//If bridge have one more terminals than @real_terminal
//that mean every terminals of the bridge must be unbridged by this undo command,
//else the single terminal who's not umbridged by this undo command
//continue to have a bridge (to nothing) and this nowhere bridge is visible
//in the terminal strip graphic item and terminal strip editor dialog.
if (m_bridge->realTerminals().size() == real_terminal.size() + 1) {
m_terminals = m_bridge->realTerminals();
} else {
m_terminals = real_terminal;
}
}
}
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
+4 -3
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -975,8 +975,9 @@ QDomElement TerminalStrip::toXml(QDomDocument &parent_document)
root_elmt.appendChild(m_data.toXml(parent_document));
//Undrawn terminals
auto xml_layout = parent_document.createElement("layout");
//Undrawed terminals
auto xml_layout = parent_document.createElement(QStringLiteral("layout"));
for (auto &phy_t : m_physical_terminals) {
xml_layout.appendChild(phy_t->toXml(parent_document));
}
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -120,6 +120,14 @@ void TerminalStripBridge::fromXml(const QDomElement &dom_element)
}
}
/**
* @brief TerminalStripBridge::uuid
* @return The uuid of this terminal
*/
QUuid TerminalStripBridge::uuid() const noexcept {
return m_uuid;
}
/**
* @brief TerminalStripBridge::addTerminals
* @param real_terminals
+2 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -46,6 +46,7 @@ class TerminalStripBridge
static QString xmlTagName() {return QStringLiteral("terminal_strip_bridge");}
QDomElement toXml(QDomDocument &parent_document) const;
void fromXml(const QDomElement &dom_element);
QUuid uuid() const noexcept;
private:
bool addTerminals(const QVector<QSharedPointer<RealTerminal>> &real_terminals);
+12 -12
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -34,7 +34,7 @@ QDomElement TerminalStripData::toXml(QDomDocument &xml_document) const
root_elmt.setAttribute(QStringLiteral("uuid"), m_uuid.toString());
auto info_elmt = xml_document.createElement("informations");
auto info_elmt = xml_document.createElement(QStringLiteral("informations"));
root_elmt.appendChild(info_elmt);
if (!m_installation.isEmpty()) {
@@ -65,23 +65,23 @@ bool TerminalStripData::fromXml(const QDomElement &xml_element)
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
m_uuid = QUuid::fromString(xml_element.attribute(QLatin1String("uuid")));
m_uuid = QUuid::fromString(xml_element.attribute(QStringLiteral("uuid")));
#else
m_uuid = QUuid(xml_element.attribute(QStringLiteral("uuid")));
#endif
for (auto &xml_info :
QETXML::findInDomElement(xml_element.firstChildElement("informations"),
QStringLiteral("information")))
QETXML::findInDomElement(xml_element.firstChildElement(QStringLiteral("informations")),
QStringLiteral("information")))
{
auto name = xml_info.attribute("name");
auto name = xml_info.attribute(QStringLiteral("name"));
auto value = xml_info.text();
if (name == QStringLiteral("installation")) { m_installation = value;}
else if (name == QStringLiteral("location")) {m_location = value;}
else if (name == QStringLiteral("name")) {m_name = value;}
else if (name == QStringLiteral("comment")) {m_comment = value;}
else if (name == QStringLiteral("description")) {m_description = value;}
if (name == QLatin1String("installation")) { m_installation = value;}
else if (name == QLatin1String("location")) {m_location = value;}
else if (name == QLatin1String("name")) {m_name = value;}
else if (name == QLatin1String("comment")) {m_comment = value;}
else if (name == QLatin1String("description")) {m_description = value;}
}
return true;
@@ -101,7 +101,7 @@ TerminalStripData &TerminalStripData::operator=(const TerminalStripData &other)
QDomElement TerminalStripData::infoToXml(QDomDocument &xml_doc, const QString &name, const QString &value)
{
auto xml_elmt = xml_doc.createElement("information");
auto xml_elmt = xml_doc.createElement(QStringLiteral("information"));
xml_elmt.setAttribute(QStringLiteral("name"), name);
xml_elmt.appendChild(xml_doc.createTextNode(value));
+1 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2006-2021 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -0,0 +1,48 @@
/*
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "terminalstripprojectconfigpage.h"
#include "../../../qeticons.h"
#include "../terminalstriplayouteditor.h"
#include "../../../qetproject.h"
#include <QVBoxLayout>
TerminalStripProjectConfigPage::TerminalStripProjectConfigPage(QETProject *project,
QWidget *parent) :
ProjectConfigPage { project, parent }
{
initWidgets();
}
QString TerminalStripProjectConfigPage::title() const {
return tr("Plan de bornes");
}
QIcon TerminalStripProjectConfigPage::icon() const {
return QET::Icons::TerminalStrip;
}
void TerminalStripProjectConfigPage::initWidgets()
{
m_layout_editor = new TerminalStripLayoutEditor{ project()->projectPropertiesHandler().terminalStripLayoutHandler().defaultLayout(),
this };
auto v_layout = new QVBoxLayout { this };
v_layout->addWidget(m_layout_editor);
setLayout(v_layout);
}
@@ -0,0 +1,46 @@
/*
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TERMINALSTRIPPROJECTCONFIGPAGE_H
#define TERMINALSTRIPPROJECTCONFIGPAGE_H
#include "../../../ui/configpage/projectconfigpages.h"
class TerminalStripLayoutEditor;
class TerminalStripProjectConfigPage : public ProjectConfigPage
{
Q_OBJECT
public:
TerminalStripProjectConfigPage(QETProject *project, QWidget *parent = nullptr);
QString title() const override;
QIcon icon() const override;
void applyProjectConf() override {}
protected:
void initWidgets() override;
void initLayout() override{}
void readValuesFromProject() override {}
void adjustReadOnly() override {}
private:
TerminalStripLayoutEditor *m_layout_editor { nullptr };
};
#endif // TERMINALSTRIPPROJECTCONFIGPAGE_H
@@ -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());
}
}
}
@@ -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
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddTerminalStripItemDialog</class>
<widget class="QDialog" name="AddTerminalStripItemDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>326</width>
<height>100</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Ajouter le plan de bornes suivant :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_terminal_strip_cb"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddTerminalStripItemDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddTerminalStripItemDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
@@ -1,5 +1,5 @@
/*
Copyright 2006-2022 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
/*
Copyright 2006-2022 The QElectroTech Team
Copyright 2006-2023 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

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