mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-27 20:44:13 +02:00
a756bc0722
setQuery() restored the loaded SQL text into the line edit but never restored the "Edit SQL query" checkbox, so a custom query (a join, a subquery, a view other than project_summary_view) displayed correctly while the widget stayed in built-in mode. queryStr() only consults that checkbox, so accepting the dialog without touching anything silently replaced the custom query with a freshly generated one. Detect it instead of trusting a flag that was never set: after parsing columns from the loaded query, rebuild the query those columns would produce and compare it against what was loaded. A mismatch means the widget cannot reconstruct it, so it must be user-written -- check the box and keep the literal text. Verified against both cases this has to get right, not just the one in the report: a genuinely custom query (join) now round-trips through an untouched accept+save byte-for-byte, and a plain built-in query written before the #238 pos-ordering fix (examples/industrial.qet, no ORDER BY clause) is classified as custom rather than silently gaining an ORDER BY it didn't have -- it round-trips unchanged rather than being corrupted, though its column picker is now disabled until a user rebuilds it by hand. Based on the patch attached to #885.