Item Details Presentation
Relevant source files
The following files were used as context for generating this wiki page:
The Item Details Presentation system is responsible for managing and displaying the granular data of a selected Service Request (SSA) record. It serves as the bridge between the raw domain data retrieved from the database and the visual representation in the QML user interface. This system ensures that when a user interacts with the main data table, the corresponding details are formatted and presented accurately.
Within the project architecture, this functionality is primarily encapsulated in the DetailsViewModel, which is a child component of the MainViewModel. It transforms SsaRecord objects into a list of displayable fields, adhering to the project's goal of maintaining a clean separation between the business domain and the presentation layer.
Sources: src/presentation/MainViewModel.h:43, src/presentation/DetailsViewModel.cpp:21-38
Architecture and Data Flow
The Item Details Presentation follows a reactive pattern where the selection of a row in the main table triggers an update in the details view. The MainViewModel acts as the coordinator, receiving row selection signals and delegating the record extraction to the SsaTableModel before passing it to the DetailsViewModel.
Component Interaction
The following diagram illustrates how a user selection flows through the system to update the item details.
Selection Logic
When selectRow(int row) is called on the MainViewModel, it performs a bounds check. If the row is valid, it retrieves the SsaRecord from the SsaTableModel. If the index is invalid or the table is empty, it passes a nullptr to the details view, which resets the display to a "No SSA selected" state.
Sources: src/presentation/MainViewModel.cpp:166-172, src/presentation/DetailsViewModel.cpp:24-28
The DetailsViewModel
The DetailsViewModel is a QObject-based class designed to be consumed by QML. It exposes properties that describe the currently selected item, such as its title and a collection of fields (key-value pairs).
Core Properties
| Property | Type | Description |
|---|---|---|
title | QString | A formatted string showing the SSA number or a placeholder (e.g., "SSA 202500001"). |
fields | QVariantList | A list of QVariantMap objects, each containing a label and a value for display. |
selectedSsa | QString | The unique identifier (SSA number) of the currently selected record. |
Sources: src/presentation/DetailsViewModel.h:13-14, src/presentation/DetailsViewModel.cpp:32-40
Field Formatting Logic
The formatting process iterates through all available columns defined in the ColumnCatalog. For every column that contains a non-empty value in the SsaRecord, the system creates a display field.
for (const auto& column : domain::ColumnCatalog::all()) {
const auto value = record->valueOf(column.key);
if (value.empty()) {
continue;
}
QVariantMap field;
field.insert("label", QString::fromStdString(column.label));
field.insert("value", QString::fromStdString(value));
fields_.push_back(field);
}
Sources: src/presentation/DetailsViewModel.cpp:32-41
Layout and Visibility Preferences
The presentation of item details is also governed by user preferences, managed by the MainViewModel. Users can toggle the visibility of the details panel and adjust its width, with constraints enforced at the domain level.
| Configuration | Domain Constant | Range / Default |
|---|---|---|
| Min Panel Width | kMinDetailsPanelWidth | 280 |
| Max Panel Width | kMaxDetailsPanelWidth | 680 |
| Default Width | kDefaultDetailsPanelWidth | 360 |
| Default Visibility | N/A | true |
Sources: src/domain/SsaTypes.h:18-20, src/presentation/MainViewModel.h:116
Width Clamping
The system ensures that the panel width remains within functional limits using a clamping function in the domain layer. This prevents the UI from becoming unusable if an invalid width is loaded from preferences.
Sources: src/domain/SsaTypes.h:27-29, src/presentation/MainViewModel.cpp:94-102
Integration with External Commands
The "Item Details" context often serves as the starting point for external actions, such as opening the selected SSA in a legacy system or an external browser. The MainViewModel provides a slot openSelectedSsa() which retrieves the selectedSsa ID from the DetailsViewModel and passes it to the CommandViewModel.
Sources: src/presentation/MainViewModel.cpp:202-207, src/presentation/MainViewModel.h:74
Summary
The Item Details Presentation system provides a reactive and decoupled way to view specific record data. By utilizing a specialized DetailsViewModel, the project transforms internal SsaRecord structures into a UI-friendly list of fields. It integrates deeply with the application's preference system to maintain a consistent user experience regarding layout visibility and panel sizing, while also enabling external command execution based on the current selection.