ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EntityListMdiWindow Class Referenceabstract

Base class for entity list MDI windows providing stale indicator support. More...

#include <EntityListMdiWindow.hpp>

Inheritance diagram for EntityListMdiWindow:
Inheritance graph
Collaboration diagram for EntityListMdiWindow:
Collaboration graph

Public Slots

void markAsStale ()
 Mark the list as stale (data changed on server).
 
void clearStaleIndicator ()
 Clear the stale indicator.
 
void reload ()
 Reload data from the server.
 

Public Member Functions

 EntityListMdiWindow (QWidget *parent=nullptr)
 
QSize sizeHint () const override
 

Protected Member Functions

virtual void doReload ()=0
 Subclass implementation of the reload operation.
 
virtual void saveSettings ()
 Save window settings (column visibility, window size, etc.).
 
void closeEvent (QCloseEvent *event) override
 
void initializeTableSettings (QTableView *tableView, QAbstractItemModel *sourceModel, std::string_view settingsGroup, const QVector< int > &defaultHiddenColumns={}, const QSize &defaultSize={900, 400}, int settingsVersion=1, QSplitter *splitter=nullptr)
 Configure table header, column visibility, and settings persistence.
 
void initializeStaleIndicator (QAction *refreshAction, const QString &iconPath)
 Initialize the stale indicator support.
 
QProgressBar * loadingBar ()
 Return the shared loading progress bar.
 
void beginLoading ()
 Show the loading bar and disable the reload action.
 
void endLoading ()
 Hide the loading bar and re-enable the reload action.
 
void connectModel (AbstractClientModel *model)
 Wire endLoading() to the model's standard lifecycle signals.
 
virtual QString normalRefreshTooltip () const
 Get the normal (non-stale) tooltip text for the refresh action.
 
virtual QString staleRefreshTooltip () const
 Get the stale tooltip text for the refresh action.
 

Protected Attributes

QSize savedWindowSize_
 Saved window size from QSettings.
 

Detailed Description

Base class for entity list MDI windows providing stale indicator support.

This class provides common functionality for entity list windows including:

Subclasses must:

  1. Call initializeStaleIndicator() after creating their refresh action
  2. Implement reload() to refresh data from the server
  3. Call clearStaleIndicator() at the start of their reload() implementation

Example usage in subclass:

void MyEntityMdiWindow::setupToolbar() {
refreshAction_ = toolbar_->addAction(...);
initializeStaleIndicator(refreshAction_, IconUtils::iconPath(Icon::ArrowSync));
}
void MyEntityMdiWindow::reload() {
model_->refresh();
}
void clearStaleIndicator()
Clear the stale indicator.
Definition EntityListMdiWindow.cpp:69
void initializeStaleIndicator(QAction *refreshAction, const QString &iconPath)
Initialize the stale indicator support.
Definition EntityListMdiWindow.cpp:46
static QString iconPath(Icon icon)
Gets the resource path for a semantic icon using the current global theme.
Definition IconUtils.cpp:130

Member Function Documentation

◆ markAsStale

void markAsStale ( )
slot

Mark the list as stale (data changed on server).

Starts a pulse animation on the refresh action to indicate that server-side data has changed and the list should be reloaded.

◆ clearStaleIndicator

void clearStaleIndicator ( )
slot

Clear the stale indicator.

Stops the pulse animation and restores the normal refresh icon. Call this at the start of reload() implementations.

◆ reload

void reload ( )
slot

Reload data from the server.

Clears the stale indicator, shows the loading bar, disables the reload action, then delegates to doReload(). Subclasses must not override this.

◆ doReload()

virtual void doReload ( )
protectedpure virtual

Subclass implementation of the reload operation.

Called by reload() after the loading state has been set up. Do NOT call clearStaleIndicator() or beginLoading() here — the base class handles both before invoking doReload().

Implemented in BadgeDefinitionMdiWindow, BadgeSeverityMdiWindow, and CodeDomainMdiWindow.

◆ saveSettings()

void saveSettings ( )
protectedvirtual

Save window settings (column visibility, window size, etc.).

When initializeTableSettings() has been called, this saves header state and window size automatically. Otherwise it is a no-op. Called automatically on close via closeEvent().

◆ initializeTableSettings()

void initializeTableSettings ( QTableView *  tableView,
QAbstractItemModel *  sourceModel,
std::string_view  settingsGroup,
const QVector< int > &  defaultHiddenColumns = {},
const QSize &  defaultSize = {900, 400},
int  settingsVersion = 1,
QSplitter *  splitter = nullptr 
)
protected

Configure table header, column visibility, and settings persistence.

Call once in setupTable() after creating tableView and model. Sets ResizeToContents on all columns, wires up column visibility context menu, restores saved header state and window size.

Parameters
tableViewThe QTableView to manage
sourceModelThe source model (for column count/headers)
settingsGroupQSettings group name (e.g. "CountryListWindow")
defaultHiddenColumnsColumns hidden by default when no saved state
defaultSizeDefault window size when no saved size
settingsVersionBump when column layout changes to discard old state

◆ initializeStaleIndicator()

void initializeStaleIndicator ( QAction *  refreshAction,
const QString &  iconPath 
)
protected

Initialize the stale indicator support.

Call this after creating the refresh action in setupToolbar().

Parameters
refreshActionThe refresh/reload action to animate
iconPathPath to the refresh icon SVG resource

◆ loadingBar()

QProgressBar * loadingBar ( )
protected

Return the shared loading progress bar.

Subclasses insert this widget into their layout in setupUi(), placing it between the toolbar and the table view: layout->addWidget(toolbar_); layout->addWidget(loadingBar()); // <– add this line layout->addWidget(tableView_);

◆ beginLoading()

void beginLoading ( )
protected

Show the loading bar and disable the reload action.

Call at the start of reload(), after clearStaleIndicator().

◆ endLoading()

void endLoading ( )
protected

Hide the loading bar and re-enable the reload action.

Call from onDataLoaded() and onLoadError().

◆ connectModel()

void connectModel ( AbstractClientModel model)
protected

Wire endLoading() to the model's standard lifecycle signals.

Connects AbstractClientModel::dataLoaded and AbstractClientModel::loadError to endLoading() so that subclasses do not need to call endLoading() manually in every handler.

◆ normalRefreshTooltip()

virtual QString normalRefreshTooltip ( ) const
protectedvirtual

◆ staleRefreshTooltip()

virtual QString staleRefreshTooltip ( ) const
protectedvirtual

Get the stale tooltip text for the refresh action.

Override this to customize the tooltip text.

Member Data Documentation

◆ savedWindowSize_

QSize savedWindowSize_
protected

Saved window size from QSettings.

Set by initializeTableSettings() when restoring a previously saved window size. Used by sizeHint() to return the saved size instead of the default.