Clone
2
search_and_replace
ispyisail edited this page 2026-09-19 17:31:34 +12:00

Search & Replace

Bulk-edit properties across a whole project: folio titles, element labels and information, conductor text, independent text. Despite the name, this isn't text find/replace — see §2 for what it actually does.

Source: sources/SearchAndReplace/searchandreplaceworker.{cpp,h} (the logic), ui/searchandreplacewidget.cpp (the main scoping tree), ui/replace*dialog.cpp (the per-category editors).


1. Scoping what gets changed

The main dialog is a tree of everything matched, grouped by kind:

  • Folios
  • Text fields (independent text)
  • Elements, further split into simple / master / slave / folio-report / terminal — the same categories Linking elements documents
  • Conductors

Right-click a folio in the tree for Select the elements/conductors/texts of this folio — jumps straight from a search result to a real selection on the canvas, useful for checking a match before you commit to changing it.


2. It sets values, it doesn't find-and-replace text

Each category opens a dialog with one field per property (label, comment, folio title, conductor colour…). Leave a field blank and that property is left completely untouched on everything matched. Fill one in, and it replaces the value outright — not a substring swap, the whole field becomes what you typed.

That distinction matters: there is no "find X, replace with Y" pattern matching here for text content. If you want that, you're setting every matched item's field to the exact same new value.

Clearing a field on purpose

Since an empty box already means "don't touch this," blanking a field needs a separate signal — a checkbox next to each field does that: check it and the field disables, and that property is cleared on every match rather than left alone. Internally this works via a reserved sentinel string (SearchAndReplaceWorker::eraseText()) that the checkbox sets for you; you never type it yourself.

So each field has three real states: blank (leave alone), checked (erase), or filled in (overwrite) — not the usual two.


3. What's editable per category

Matches SearchAndReplaceWorker's four target types:

Category Typical fields
Folio title, author, indexrev, and other title-block fields
Element label and the standard element-information fields
Conductor wire number, formula, function, tension/protocol, wire colour, wire section, drawn colour and second colour, two-colour on/off, dash size, line style, thickness, show-text, text size, text rotation on horizontal and vertical runs, both alignments, and the single-line symbols
Independent text the text content itself

An Advanced mode combines several of these into one operation across mixed selections, rather than working through folios/elements/conductors one dialog at a time.

Two conductor fields are missing: Cable and Bus. They are the only conductor properties Search & Replace does not touch, in either the simple or the advanced path — which is awkward, because a cable name repeated across forty wires is exactly what you would want to rename in one go. Adding them is the first item of discussion #934. Until then, renaming a cable means editing each conductor by hand.


4. Practical notes

  • This changes many things at once with no fine-grained undo per item — it's one bulk operation. Review the scope tree before committing.
  • Because a blank field is a no-op, you can open the dialog, touch only the one property you care about, and everything else on every matched item is guaranteed untouched — safe to run broadly as long as you only fill in what you mean to change.
  • This is a GUI-only feature; there's no CLI equivalent. For scripted bulk edits, see Automating QElectroTech — editing the XML directly.

See also: Linking elements · Variables & formulas