Merged
Conversation
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.
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.
This pull request refactors the
ScalarSourceModeland related classes to use a more flexible and extensible item-based model, transitioning fromQAbstractListModeltoQStandardItemModel. 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
ScalarSourceModelto inherit fromQStandardItemModelinstead ofQAbstractListModel, enabling support for multiple columns and more flexible item management. IntroducedItem,NameItem, andIdItemclasses to represent dataset properties as model items. [1] [2] [3]Rowhelper class to group related items (name and ID) for each dataset, simplifying row management and data retrieval.Dataset management improvements
_datasetslist 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]hasDataset,removeDataset, andgetRowIndexmore reliable and efficient. [1] [2]API and usability changes
setCurrentSourceIndexto take astd::int32_tinstead ofbool, and using{}for default-constructed return values. (src/ScalarAction.hL54-R54, F3d0657dL72R75)Code cleanup and removal of obsolete logic
updateDatamethod and related manual update logic, since data changes are now handled by item signals and the model's structure.ScalarAction::addDataset, clarifying its redundancy. [1] [2]These changes collectively modernize the dataset model, improve maintainability, and lay the groundwork for future UI enhancements.