Skip to content

Feature/Fix gui name rename crash#230

Merged
ThomasKroes merged 2 commits intomasterfrom
feature/fix_gui_name_rename_crash
Feb 19, 2026
Merged

Feature/Fix gui name rename crash#230
ThomasKroes merged 2 commits intomasterfrom
feature/fix_gui_name_rename_crash

Conversation

@ThomasKroes
Copy link
Contributor

This pull request refactors the ScalarSourceModel and related classes to use a more flexible and extensible item-based model, transitioning from QAbstractListModel to QStandardItemModel. The changes improve dataset management, enable support for multiple columns (such as name and ID), and clean up how datasets are tracked, displayed, and updated in the UI.

The most important changes are:

Model architecture and extensibility

  • Refactored ScalarSourceModel to inherit from QStandardItemModel instead of QAbstractListModel, enabling support for multiple columns and more flexible item management. Introduced Item, NameItem, and IdItem classes to represent dataset properties as model items. [1] [2] [3]
  • Added a Row helper class to group related items (name and ID) for each dataset, simplifying row management and data retrieval.

Dataset management improvements

  • Replaced the internal _datasets list with dynamic item-based tracking, updating all methods (addDataset, removeDataset, getDatasets, etc.) to operate on the model's items. This improves robustness and reduces manual bookkeeping. [1] [2]
  • Improved dataset lookup and row indexing using the dataset's unique ID, making operations like hasDataset, removeDataset, and getRowIndex more reliable and efficient. [1] [2]

API and usability changes

  • Added support for multiple columns (Name and ID), with custom header data and per-role display logic for each item type.
  • Updated method signatures for clarity and correctness, such as changing setCurrentSourceIndex to take a std::int32_t instead of bool, and using {} for default-constructed return values. (src/ScalarAction.hL54-R54, F3d0657dL72R75)

Code cleanup and removal of obsolete logic

  • Removed the now-unnecessary updateData method and related manual update logic, since data changes are now handled by item signals and the model's structure.
  • Commented out an obsolete signal connection in ScalarAction::addDataset, clarifying its redundancy. [1] [2]

These changes collectively modernize the dataset model, improve maintainability, and lay the groundwork for future UI enhancements.

Convert ScalarSourceModel from QAbstractListModel to QStandardItemModel and introduce typed row items (NameItem, IdItem, Item) and a two-column layout (Name/ID). Datasets are now stored as rows (with helper Row class) and looked up by dataset ID via matching; getDatasets(), getDataset(), add/remove dataset and removeAllDatasets were adapted accordingly. Added getRowIndex() and removed the old per-dataset vector/updateData machinery. Update GUI data handling into Item/NameItem/IdItem (decoration, display and tooltip roles) and connect GUI name changes to emit updates. In ScalarAction: use getRowIndex() instead of rowIndex(), changed setCurrentSourceIndex parameter to std::int32_t, simplified getCurrentDataset() return, and left a TODO-commented dataset connection block. These changes centralize model data in QStandardItem rows, enable multi-column metadata, and simplify dataset lookup/removal by ID.
Give Item/NameItem/Row access to their parent ScalarSourceModel by adding a const ScalarSourceModel& parameter and storing it in Item::_scalarSourceModel. Update construction sites (appendRow/Row) to pass *this. Use the model reference in Item::data() to respect getShowFullPathName() and use getGuiName() for display. Add getScalarSourceModel() accessor. Also change getDatasets() to return by value and remove some dead/commented code. These changes allow items to query model state reliably and simplify row construction.
@ThomasKroes ThomasKroes self-assigned this Feb 19, 2026
@ThomasKroes ThomasKroes added the bug Something isn't working label Feb 19, 2026
@ThomasKroes ThomasKroes merged commit 69024fc into master Feb 19, 2026
2 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments