Commit Graph

77 Commits

Author SHA1 Message Date
ispyisail bc79a5df7a Keep a conductor's row in step, and index the columns the view scans
Three fixes to the tables added by this slice.

A conductor's text was written once at insert and never again. Renaming a
wire left the database holding the old number, so the wiring list showed a
stale value until the next full repopulate -- elements have
elementInfoChanged() for exactly this and conductors had nothing.
Conductor::setProperties() has around a dozen call sites (auto-numbering,
the properties dialog, element moves, the delete command's re-links), so
rather than adding a call to each and missing the ones added later, listen
to the propertiesChange() signal it already emits. Qt::UniqueConnection
means a repeated insert or a full repopulate cannot double-subscribe, and
the connection is established on both insert paths because conductors read
from a file never pass through addConductor().

addConductor() and populateConductorTable() each carried their own copy of
the same seven bindValue() lines. They had not drifted yet, but that is the
same duplication the element paths had before bindElementValues(), where
they had drifted -- one binding kindInformations()["type"] and the other
masterTypeToString(). One bindConductorValues() for both.

Finally, index the conductor columns that get looked up per element rather
than per conductor. element_nomenclature_view counts the wires touching each
element with a correlated subquery, so without an index every element row
full-scans the conductor table and the cost grows as elements x conductors.
Measured on a standalone SQLite harness at 2000 elements x 5000 conductors:
2134 ms unindexed, 10 ms indexed. diagram_uuid is indexed too, since the
wiring list view joins on it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 19:26:40 +12:00
ispyisail 43da912aad Add terminal and conductor tables to projectDataBase
Slice 2 of discussion #503 (from-to wiring list built on projectDataBase),
building on the conductor uuid from slice 1 (#625). Pure plumbing: two
new additive tables plus their populate/add/remove hooks. No view, no UI,
no visible behavior change yet -- the wiring-list view is slice 3.

Follows the existing shape of the class throughout: same table/column
naming, same prepared-statement idiom in prepareQuery(), same
bind/exec/qDebug-lastError error handling, same DELETE-then-loop
populate pattern.

- `terminal (uuid, element_uuid, name)` and
  `conductor (uuid, diagram_uuid, terminal1_uuid, terminal1_element_uuid,
   terminal2_uuid, terminal2_element_uuid, text)` created alongside the
  existing tables in createDataBase().
- populateConductorTable() added as a fifth populate* call in updateDB().
  Terminal population is folded into it, since a terminal only matters
  here in the context of a conductor referencing it.
- addConductor()/removeConductor() hooked into the already-existing
  Conductor::Type branch of Diagram::addItem()/removeItem(), mirroring
  the Element::Type branch directly above.

Two things the original schema sketch in the discussion got wrong, found
by testing rather than inspection:

1. Terminal::uuid() is NOT unique per placed terminal. It is the
   terminal-position id baked into the catalog .elmt definition ("the
   top terminal"), so every placed instance of the same catalog element
   shares it. A terminal instance is only uniquely identified by
   (uuid, element_uuid) together, so that pair is the terminal table's
   primary key and the conductor table carries both halves for each
   endpoint. With uuid alone as PK, the second placed instance of any
   element silently lost its terminals to the INSERT OR IGNORE.
2. Conductors whose terminals predate terminal uuids are omitted rather
   than given a fabricated identity, as agreed in the discussion. This
   turns out to matter far more than expected in practice -- see below.

Testing (all live, in the running app):

- Incremental add: fresh project, two vertically aligned contacts placed
  so autoconnect creates a conductor -> 2 terminals, 1 conductor.
- Incremental remove: deleting that conductor -> conductor count 1 -> 0.
- Undo: ctrl+Z after the delete -> back to 1, no duplicate-primary-key
  error (the same Conductor object keeps its uuid).
- Bulk populate: examples/weneedpolonez-Polonez_MR89_wiring_diagram.qet
  (366 conductors) -> 478 terminals, 280 conductors; the 86 conductors
  touching legacy terminals correctly omitted.
- Join correctness: conductor -> terminal (composite key) -> element_info
  resolves real from-to rows with real element labels.
- Legacy-only project: examples/industrial.qet has 1794 terminals and
  *zero* terminal uuids, so all 671 of its conductors are omitted. Loads
  and renders fine, no crash, no spurious rows -- but worth stating
  plainly that a from-to wiring list for that project would be empty
  today. This is a property of the element catalog definitions, not of
  the project file, and is the strongest argument for surfacing an
  "N conductors excluded" count to the user when the view lands.
- No SQL errors logged in any of the above.

Known limitation, consistent with existing behavior: removeDiagram()
does not cascade-delete the conductor rows of that diagram, exactly as
it already does not cascade to element/element_info. A full updateDB()
rebuild clears them, and the future wiring-list view INNER JOINs from
conductor, so orphan terminal rows never surface.
2026-08-21 19:07:49 +12:00
Kellermorph e91bab14fe Update 2026-08-01 14:26:39 +02:00
Kellermorph b3a8ae898e PLC Manager 2026-07-27 22:16:52 +02:00
Dieter Mayer c3392bf025 Wrap deprecated QSqlDatabase::exec() in QSqlQuery
QSqlDatabase::exec(const QString&) is deprecated in Qt6. Route the
PRAGMA/CREATE TABLE statements through QSqlQuery(db).exec() instead.
Clears 11 -Wdeprecated-declarations warnings; same statements, same
database connection, no behavioural change.
2026-07-14 19:27:17 +02:00
Kellermorph c071e92c58 Feature: Allow excluding specific elements from BOM (Nomenclature) 2026-05-28 12:23:54 +02:00
Laurent Trinques 4044d04cc5 One year
Auto-build doxygen docs / doxygen (push) Has been cancelled
Auto-build doxygen docs / deploy (push) Has been cancelled
2026-01-16 15:24:35 +01:00
Laurent Trinques 58339f9016 Fix copyright years 2025-10-17 09:58:39 +02:00
plc-user ad29893842 use "%" for string-concatenation
Qt-Docs says it's less memory-usage...
2025-05-22 21:33:32 +02:00
Laurent Trinques 1af3c5b852 Merge pull request #361 from plc-user/master
element-editor: add mirror and flip for "text"
2025-02-18 06:27:14 +01:00
plc-user 67112bf8e5 fix typo in enum-entry and comments 2025-02-17 09:33:35 +01:00
Laurent Trinques 0be9e2beae minor add qInfo-Text "SQLite version: " 2025-02-15 17:10:39 +01:00
Laurent Trinques 43f0107eb1 Revert "Try Clazy fix-its"
Segfault on old Qt versions!
This reverts commit dba7caed30.
2025-02-14 16:17:58 +01:00
Laurent Trinques dba7caed30 Try Clazy fix-its
clazy is a compiler plugin which allows clang to understand Qt
semantics. You get more than 50 Qt related compiler warnings, ranging
from unneeded memory allocations to misusage of API, including fix-its
for automatic refactoring.

https://invent.kde.org/sdk/clazy
2025-02-14 15:52:23 +01:00
plc-user 79f894a327 Set default-location for projects to documents-dir.
All export files that are derived from the project (BOM,
nomenclature, etc.) are saved in the same directory by default.
In this context, the standard directories have been grouped
together in qetapp.cpp / qetapp.h so that only one place needs
to be searched for in case of any adjustments.
2025-01-26 11:32:46 +01:00
Laurent Trinques 77bfe84a4c One year 2025-01-04 13:37:40 +01:00
Laurent Trinques c1706cb055 Add new variables to elementInfoKeys
aux1, aux2, aux3, aux4
See:
https://qelectrotech.org/forum/viewtopic.php?pid=20558#p20558
2024-11-03 14:40:24 +01:00
plc-user ef66350b30 correct comments 2024-04-07 10:55:28 +02:00
plc-user f74616d2e4 correct comments 2024-04-07 10:42:37 +02:00
Laurent Trinques e73cf633ce 2023->2024 2024-03-29 10:09:48 +01:00
Laurent Trinques 9afef79629 Update Copyright date 2023-01-01 17:05:57 +01:00
Laurent Trinques 2ace2ca104 macOS restore sqlite3 database export 2022-12-30 07:20:50 +01:00
luz paz 1994235bc5 Fix various typos in source documentation and comments (cont.)
Found via `codespell`
2022-12-04 20:46:32 +01:00
joshua 2e70d2e599 Nomenclature now use properly the element type 'thumbnail'
Use function provided by ElementData to check element type and
master type instead of use plain text (code is more strong)
2022-06-01 22:29:12 +02:00
Laurent Trinques fad6983cf1 Element::Thumbnail fix for BOM pages 2022-05-16 09:30:32 +02:00
Laurent Trinques daeec311b2 Element::Thumbnail WIP 2022-05-16 08:59:25 +02:00
Laurent Trinques db8c76c184 Element::Thumbnail WIP 2022-05-15 14:29:01 +02:00
joshua 5a8197b2b3 Element query widget : make code more readable 2021-04-11 14:08:21 +02:00
joshua c1169f0e04 Element nomenclature sql query minor fix
Filter "is empty" don't work for any case :
We must to filter for NULL and empty string then replace the sql
sentence "value IS NULL" by "(value IS NULL OR value = '')"
2021-04-11 14:03:02 +02:00
joshua 794af49a3a Element nomenclature SQL query : minor fix
the filter "is not empty" in nomenclature don't work for every case.
Replace SQL sentence "IS NULL" by "!= ''" because an empty string is not
a NULL value string, but a NULL value string is like an empty string
2021-04-11 12:39:38 +02:00
Laurent Trinques ef58f34c14 Update Copyright date 2021-02-20 12:13:46 +01:00
joshua 2513961cd6 Revert "Update Copyright date"
This reverts commit d04bccc384.
2021-02-06 19:00:48 +01:00
Laurent Trinques d04bccc384 Update Copyright date 2021-02-06 18:33:42 +01:00
Simon De Backer d15443cf93 Wip Fix preprocessor on Cmake 2020-12-10 18:49:35 +01:00
Simon De Backer d0c129478e Mod Cmake en preprocessor 2020-12-10 00:08:26 +01:00
Simon De Backer 10c4c3d528 Wip Fix preprocessor on Cmake 2020-12-08 19:57:35 +01:00
Claveau Joshua aa858ba32d project database : minor 2020-11-22 12:16:17 +01:00
Claveau Joshua a303a38d0d ProjectDatabase improvement
Use transaction / commit when several elements was changed instead of
update one by one each element.
2020-11-22 11:31:43 +01:00
Claveau Joshua af7d1df5ab Replace function by another one.
Replace function QETApp::elementInfoKeys() and
QETApp::elementInfoToVar(const QString &info) by function provided by
QETInformation.
2020-11-14 19:09:40 +01:00
Claveau Joshua 49b2e4ad0a Replace function by another one
Replace QETApp::diagramInfoKeys() by QETInformation::diagramInfoKeys()
and QETApp::diagramTranslatedInfoKey(str) by
QETInformation::translatedInfoKey(str)
2020-11-08 20:23:16 +01:00
Claveau Joshua 6f60156e00 Change function QETApp::elementTranslatedInfoKey
Use the function QETInformation::translatedInfoKey(const QString &info)
instead of QETApp::elementTranslatedInfoKey(const QString &info).

The final goal is to remove all information from the QETApp and use
instea QETInformation who is dedicated to this
2020-11-08 19:16:02 +01:00
Claveau Joshua 62333506f1 Improve update of the project database 2020-11-02 19:13:56 +01:00
Claveau Joshua b514c39883 Improve update of the project database 2020-11-01 21:27:40 +01:00
Claveau Joshua b1eb59f3ea Improve previous comit 2020-10-22 21:07:41 +02:00
Laurent Trinques cb29a4d383 Fix date on summary pages 2020-10-22 18:28:52 +02:00
Claveau Joshua 6437bf212a Add macro to disable/enable project database export 2020-10-02 20:09:03 +02:00
Simon De Backer 36dbe65457 Add TODO compile var + Fix doxygen issue
You can make your code warn on compile time for the TODO's
In order to do so, uncomment the following line. in pro file
DEFINES += TODO_LIST
2020-09-24 17:01:33 +02:00
Laurent Trinques 1cf48f62e9 Fix commit "Change the way how the database is exported to file" :
produce a fail to build on OSX
2020-09-23 11:25:46 +02:00
Simon De Backer 2a69e540d6 Fix Qt 6 definition of macro ‘Q_DECLARE_MOVABLE_CONTAINER’
adding #include <QHash>

+ code fail to compile if it uses deprecated APIs.
=> see .pro file
2020-09-21 21:19:50 +02:00
Simon De Backer c7ffae7918 Fix Qt 6 deprecated Qt::SystemLocaleShortDate
The format options
Qt::SystemLocaleDate, Qt::SystemLocaleShortDate
and Qt::SystemLocaleLongDate
shall be removed in Qt 6.
	Their use should be replaced with
QLocale::system().toString(date, QLocale::ShortFormat)
or
QLocale::system().toString(date, QLocale::LongFormat).
2020-09-21 20:23:20 +02:00