Fix #413: paste no longer adds '_' label to conductors that had no label - #523
Open
ispyisail wants to merge 1 commit into
Open
Fix #413: paste no longer adds '_' label to conductors that had no label#523ispyisail wants to merge 1 commit into
ispyisail wants to merge 1 commit into
Conversation
When erase-label-on-copy is enabled, PasteDiagramCommand::redo() reset
all pasted conductors to the diagram default text (typically "_"), even
conductors that originally had an empty label (""). This silently enrolled
them in autonumbering against the user's intent, causing confusion.
Two changes:
- Move the conductor-reset loop outside the per-element loop so it runs
once per paste rather than once per pasted element.
- Guard the reset with `!cp.text.isEmpty()`: conductors with no label
keep their empty label; only conductors that carried a real label are
reset to the diagram default so they can be renumbered.
Fixes qelectrotech#413.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Hello @ispyisail have you tryed to remove underscore for default conduction in ,new diagram folio in project setingss, berore? maybe we could delete underscore for conductor 's labels. |
Contributor
|
I ’m fed up with seeing beginners’ projects everywhere with underscores all over the place around the QET conductors... |
Contributor
Author
|
You need to decide how you want it to work, maybe you happy with the exiting code/function? I have provided an alternative which you can reject. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When erase-label-on-copy is enabled (the default), copy-pasting conductors that had no label (
num="") caused them to gain a_label on the paste. The user's original conductor was visually clean (no text), but every copy came out labelled, requiring manual cleanup.Root cause (traced through the code)
PasteDiagramCommand::redo()indiagramcommands.cppreset every pasted conductor to the diagram's default text:cp.text = c->diagram() ? c->diagram()->defaultConductorProperties.text : "_";ConductorPropertiesinitialisestextto"_"by default (conductorproperties.cpp:246), sodiagram->defaultConductorProperties.textis"_"unless the user has explicitly changed it in Project/Diagram Properties. A conductor that arrived from the clipboard withtext = ""(fromnum="") was unconditionally overwritten with"_".Additionally the conductor-reset loop was nested inside the per-element loop, so with N pasted elements the conductors were reset N times (harmless but wasteful).
Fix
Two changes in
diagramcommands.cpp:text == ""keep their empty label after paste.if (!cp.text.isEmpty()) cp.text = diagram->defaultConductorProperties.text;This preserves the existing behaviour for labelled conductors (they are cleared to the diagram default so autonumbering can renumber them), while leaving blank conductors alone.
Test plan
_).Fixes #413.
🤖 Generated with Claude Code