Skip to content

chore(color): refactor the classes used to manage models and labels - #7739

Open
philmoz wants to merge 2 commits into
mainfrom
philmoz/refactor-model-label
Open

chore(color): refactor the classes used to manage models and labels#7739
philmoz wants to merge 2 commits into
mainfrom
philmoz/refactor-model-label

Conversation

@philmoz

@philmoz philmoz commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Refactor:

  • Rework the classes used to manage models and labels to simplify the interface. The interface is reduced from 3 classes (ModelCell, ModelMap and ModelsList) to 2 by removing the ModelMap class and moving the functionality to the other two. The primary interface object has been renamed modelCellManager to make to code more readable.
  • Use storageDirty to mark the labels file for update instead of saving immediately.
  • Remove the delete / rebuild of the model management class objects when labels are renamed or deleted. Keeps the ModelCell pointers valid so the manage models page does not need to be rebuilt.

Enhancements:

  • prevent invalid characters from being entered with the keyboard when creating labels (instead of deleting after entering the label).
  • when a model is duplicated a unique name is set on the new model based on the current name and focus is set to the new model button in the manage models UI.

@philmoz philmoz added this to the 3.0 milestone Sep 1, 2026
@philmoz philmoz added color Related generally to color LCD radios house keeping 🧹 Cleanup of code and house keeping labels Sep 1, 2026
@pfeerick

pfeerick commented Sep 1, 2026

Copy link
Copy Markdown
Member
  • when a model is duplicated revert the name of the new model to the default name (MODELxx) and set focus to the new model button in the manage models UI.

This is because it would be harder to figure out what numerical number to add to the end to differentiate? As I don't see having to re-enter "Skyhunter" a second time if I duplicate the model as an enhancement (let alone anything more complex naming). If so, I get it, but it certainly isn't an enhancement.

@philmoz

philmoz commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author
  • when a model is duplicated revert the name of the new model to the default name (MODELxx) and set focus to the new model button in the manage models UI.

This is because it would be harder to figure out what numerical number to add to the end to differentiate? As I don't see having to re-enter "Skyhunter" a second time if I duplicate the model as an enhancement (let alone anything more complex naming). If so, I get it, but it certainly isn't an enhancement.

Well I thought it would be better than having multiple models all with the same name; but yes it would be better to try and append a unique number to the current name.

If there is no space for a unique number would it be better to fall back to the default name or truncate the current name to make room?

Rename and select duplicated model.
Prevent entry of excluded characters when editing a label.
@pfeerick

pfeerick commented Sep 1, 2026

Copy link
Copy Markdown
Member

Well I thought it would be better than having multiple models all with the same name;

I am in full agreement on that!

but yes it would be better to try and append a unique number to the current name.

If there is no space for a unique number would it be better to fall back to the default name or truncate the current name to make room?

The easy option is to fall back, but truncation preserves as much of the original name as possible. It may even be worth considering splitting that behaviour out of this PR, as ideally you want bw and colorlcd to behave the same way, so may require changes there to keep from introducing diverging behaviours (in a PR ostensibly focused on colorlcd refactor)?

@philmoz

philmoz commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

The easy option is to fall back, but truncation preserves as much of the original name as possible. It may even be worth considering splitting that behaviour out of this PR, as ideally you want bw and colorlcd to behave the same way, so may require changes there to keep from introducing diverging behaviours (in a PR ostensibly focused on colorlcd refactor)?

The issue with B&W is the model duplication is done by just physically copying the model yaml file.
The rename is possible now with color radios because of the ability to rewrite the model file without mangling the active model data. This isn't an option for B&W at the moment.

@philmoz
philmoz force-pushed the philmoz/refactor-model-label branch from e4f6bee to a556d72 Compare September 1, 2026 03:16
@philmoz

philmoz commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

Updated to try and generate a unique name from the current name by appending a number as "(x)" to the current name.
If the current name is too long it is truncated and if a unique name can't be created it falls back to the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

color Related generally to color LCD radios house keeping 🧹 Cleanup of code and house keeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants