ORE Studio 0.0.4
Loading...
Searching...
No Matches
Signals | Public Member Functions | List of all members
ChangeReasonCache Class Referencefinal

Shared cache for change reasons used across all entity dialogs. More...

#include <ChangeReasonCache.hpp>

Inherits QObject.

Collaboration diagram for ChangeReasonCache:
Collaboration graph

Signals

void loaded ()
 Emitted when reasons and categories have been loaded.
 
void loadError (const QString &error_message)
 Emitted when an error occurs during loading.
 
void refreshed ()
 Emitted when the cache is refreshed due to server event.
 

Public Member Functions

 ChangeReasonCache (ClientManager *clientManager, QObject *parent=nullptr)
 
void loadAll ()
 Load all change reasons and categories from the server.
 
bool isLoaded () const
 Check if reasons have been loaded.
 
bool isLoading () const
 Check if loading is in progress.
 
const std::vector< dq::domain::change_reason > & allReasons () const
 Get all change reasons.
 
std::vector< dq::domain::change_reasongetReasonsForAmend (const std::string &category_code) const
 Get change reasons filtered for amend operations.
 
std::vector< dq::domain::change_reasongetReasonsForDelete (const std::string &category_code) const
 Get change reasons filtered for delete operations.
 
const dq::domain::change_reasongetReasonByCode (const std::string &code) const
 Get a reason by its code.
 
bool isValidReasonCode (const std::string &code) const
 Check if a reason code is valid.
 
const std::vector< dq::domain::change_reason_category > & allCategories () const
 Get all change reason categories.
 

Detailed Description

Shared cache for change reasons used across all entity dialogs.

This class manages fetching and caching of change reasons from the server. It listens for change_reason_changed events to automatically refresh the cache when reasons are modified.

Typical usage:

  1. Create once in MainWindow, pass to dialogs that need it
  2. Call loadAll() after connection to preload reasons
  3. Use getReasonsForAmend/getReasonsForDelete to get filtered lists
  4. Cache automatically refreshes on server events

Member Function Documentation

◆ loadAll()

void loadAll ( )

Load all change reasons and categories from the server.

This should be called after successful connection. The cache will automatically refresh when change_reason_changed events are received.

◆ getReasonsForAmend()

std::vector< dq::domain::change_reason > getReasonsForAmend ( const std::string &  category_code) const

Get change reasons filtered for amend operations.

Parameters
category_codeFilter by category (e.g., "common")
Returns
Reasons where applies_to_amend is true, sorted by display_order

◆ getReasonsForDelete()

std::vector< dq::domain::change_reason > getReasonsForDelete ( const std::string &  category_code) const

Get change reasons filtered for delete operations.

Parameters
category_codeFilter by category (e.g., "common")
Returns
Reasons where applies_to_delete is true, sorted by display_order

◆ getReasonByCode()

const dq::domain::change_reason * getReasonByCode ( const std::string &  code) const

Get a reason by its code.

Parameters
codeThe reason code (e.g., "common.rectification")
Returns
Pointer to reason if found, nullptr otherwise

◆ isValidReasonCode()

bool isValidReasonCode ( const std::string &  code) const

Check if a reason code is valid.

Parameters
codeThe reason code to validate
Returns
true if the code exists in the cache