ACF $AcfVersion:0$
Public Types | Public Member Functions | List of all members
iprm::COptionsManager Class Reference

Implementation of a simple options manager. More...

#include <COptionsManager.h>

Inheritance diagram for iprm::COptionsManager:
iprm::CSelectionParam iprm::IOptionsManager iprm::ISelectionParam iprm::IOptionsList iprm::ISelectionParam iser::ISerializable istd::IChangeable iser::ISerializable istd::IChangeable istd::IPolymorphic istd::IChangeable istd::IPolymorphic istd::IPolymorphic iimg::CComposedBitmapProviderComp iprm::COptionsManagerComp

Public Types

typedef CSelectionParam BaseClass
 
- Public Types inherited from iprm::ISelectionParam
enum  ChangeFlags { CF_SELECTION_CHANGED = 0x67364be }
 Data model change notification flags. More...
 
enum  { NO_SELECTION = -1 }
 
- Public Types inherited from istd::IChangeable
enum  ChangeFlags {
  CF_ACF_INTERNAL = 0 , CF_ALL_DATA , CF_ANY , CF_DESTROYING ,
  CF_DELEGATED , CF_NO_UNDO
}
 Data model change notification flags. More...
 
enum  SupportedOperations {
  SO_NONE = 0 , SO_OBSERVE = 1 << 0 , SO_COPY = 1 << 1 , SO_CLONE = 1 << 2 ,
  SO_COMPARE = 1 << 3 , SO_RESET = 1 << 4
}
 Flags for supported operations. More...
 
enum  CompatibilityMode { CM_STRICT , CM_WITHOUT_REFS , CM_WITH_REFS , CM_CONVERT }
 Control how relationship betweeen objects are interpreted. More...
 
typedef QMultiMap< QByteArray, QVariant > ChangeInfoMap
 
- Public Types inherited from iprm::IOptionsManager
enum  ChangeFlags { CF_OPTION_ADDED = 0x26be73a , CF_OPTION_REMOVED }
 Data model change notification flags. More...
 
enum  OptionOperationFlags {
  OOF_COUNT_FIXED = 1 , OOF_SUPPORT_RENAME = 2 , OOF_SUPPORT_INSERT = 4 , OOF_SUPPORT_DELETE = 8 ,
  OOF_SUPPORT_SWAP = 16 , OOF_DISABLE_ALLOWED = 32 , OOF_SUPPORT_ENABLING = 64
}
 Bitwise coded flags used to find out supported features. More...
 
- Public Types inherited from iprm::IOptionsList
enum  ChangeFlags { CF_OPTIONS_CHANGED = 0x8263d86 , CF_OPTION_RENAMED }
 Flags for changes related to this interface. More...
 
enum  OptionsFlags { SCF_NONE = 0 , SCF_SUPPORT_UNIQUE_ID = 256 , SFC_DISABLE_ALLOWED = 32 }
 Flags for controlling constraints behavior. More...
 

Public Member Functions

 COptionsManager ()
 
void SetFixedOptionsList (const iprm::IOptionsList *slaveSelectionConstraintsPtr)
 Set additional fixed list of options.
 
virtual void ResetOptions ()
 Removes all options.
 
int GetOptionIndexById (const QByteArray &optionId) const
 Get the index for the given option ID.
 
int GetOptionIndexByName (const QString &optionName) const
 Get the index for the given option name.
 
bool IsSelectionSerialized () const
 Check if selection is serialized.
 
void SetSelectionSerialized (bool state)
 Turn on or off selection serializing.
 
virtual int GetOptionsFlags () const override
 Get constraints flags.
 
virtual int GetOptionsCount () const override
 Get number of managed options.
 
virtual QString GetOptionName (int index) const override
 Get name of specified option.
 
virtual QString GetOptionDescription (int index) const override
 Get human-readable description for an option.
 
virtual QByteArray GetOptionId (int index) const override
 Get option ID.
 
virtual bool IsOptionEnabled (int index) const override
 Return true if the option is enabled and can be selected.
 
virtual int GetOptionOperationFlags (int index=-1) const override
 Get operation control flags of some option or whole manager.
 
virtual bool SetOptionEnabled (int index, bool isEnabled=true) override
 Enables or disables a given option.
 
virtual bool RemoveOption (int index) override
 Remove an option at the given index.
 
virtual bool InsertOption (const QString &optionName, const QByteArray &optionId, const QString &optionDescription=QString(), int index=-1) override
 Insert an option at some position.
 
virtual bool SwapOptions (int index1, int index2) override
 Swap two options.
 
virtual bool SetOptionName (int index, const QString &optionName) override
 Set a new name for the option at the given index.
 
virtual bool SetOptionDescription (int index, const QString &optionDescription) override
 Set a new description for the option at the given index.
 
virtual bool Serialize (iser::IArchive &archive) override
 Load or store state of this object as a archive stream.
 
virtual int GetSupportedOperations () const override
 Get set of flags for supported operations.
 
virtual bool CopyFrom (const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
 
- Public Member Functions inherited from iprm::CSelectionParam
 CSelectionParam ()
 
void SetSelectionConstraints (const IOptionsList *constraintsPtr)
 Set selection constraints for this selection object.
 
void SetSubselection (int selectionIndex, ISelectionParam *selectionPtr)
 Set sub-selection for a given option index.
 
bool SetSelectedOptionById (const QByteArray &selectedOptionId)
 Set selection index according to a given option ID.
 
int GetOptionIndexById (const QByteArray &optionId) const
 Get index of an option by ID.
 
ISelectionParamGetActiveSubselection () const
 Get sub-selection for the currently selected option.
 
virtual const IOptionsListGetSelectionConstraints () const override
 Get constraints of this parameter.
 
virtual int GetSelectedOptionIndex () const override
 Get selected index.
 
virtual bool SetSelectedOptionIndex (int index) override
 Set index of selected option.
 
virtual ISelectionParamGetSubselection (int index) const override
 Get sub-selection for specified option.
 
virtual bool CopyFrom (const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
 Copy this object from another one.
 
virtual istd::TUniqueInterfacePtr< istd::IChangeableCloneMe (CompatibilityMode mode=CM_WITHOUT_REFS) const override
 Make a copy of this object.
 
- Public Member Functions inherited from iser::ISerializable
virtual quint32 GetMinimalVersion (int versionId) const
 Get minimal needed version to correct storing of this data.
 
- Public Member Functions inherited from istd::IChangeable
virtual bool IsEqual (const IChangeable &object) const
 Compare this object with another object.
 
virtual bool ResetData (CompatibilityMode mode=CM_WITHOUT_REFS)
 Reset data to its default state.
 
virtual void BeginChanges (const ChangeSet &changeSet)
 Starts the change transaction.
 
virtual void EndChanges (const ChangeSet &changeSet)
 Ends the change transaction.
 
virtual void BeginChangeGroup (const ChangeSet &changeSet)
 Starts group of changes.
 
virtual void EndChangeGroup (const ChangeSet &changeSet)
 Ends group of changes.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Additional Inherited Members

- Static Public Member Functions inherited from istd::IChangeable
static const ChangeSetGetNoChanges ()
 Get empty set of changes.
 
static const ChangeSetGetAnyChange ()
 Get anonymous change set.
 
static const ChangeSetGetAllChanges ()
 Get anonymous change set.
 
static const ChangeSetGetDelegatedChanges ()
 Get delegated change set.
 
- Protected Member Functions inherited from iprm::CSelectionParam
int CalcIndexFromId (const QByteArray &optionId, int suggestedIndex=NO_SELECTION) const
 Calculate optimal index based on current selected index and ID.
 
bool SyncIndexWithId ()
 Synchronize current index to optimal one.
 
- Protected Member Functions inherited from istd::IChangeable
virtual void OnBeginChanges ()
 Callback function for begin change event.
 
virtual void OnEndChanges (const ChangeSet &changeSet)
 Callback function for end change event.
 

Detailed Description

Implementation of a simple options manager.

Definition at line 23 of file COptionsManager.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 28 of file COptionsManager.h.

Constructor & Destructor Documentation

◆ COptionsManager()

iprm::COptionsManager::COptionsManager ( )

Member Function Documentation

◆ CopyFrom()

virtual bool iprm::COptionsManager::CopyFrom ( const IChangeable &  object,
CompatibilityMode  mode = CM_WITHOUT_REFS 
)
overridevirtual

◆ GetOptionDescription()

virtual QString iprm::COptionsManager::GetOptionDescription ( int  index) const
overridevirtual

Get human-readable description for an option.

Returns detailed description or tooltip text for an option.

Parameters
indexOption index (0-based).
Returns
Option description as QString, or empty string if no description exists or index is out of range.
QString description = options->GetOptionDescription(2);
if (!description.isEmpty())
{
qDebug() << "Description:" << description;
}
See also
GetOptionName

Implements iprm::IOptionsList.

◆ GetOptionId()

virtual QByteArray iprm::COptionsManager::GetOptionId ( int  index) const
overridevirtual

Get option ID.

Returns the unique identifier for an option. The ID is stable and doesn't change when options are reordered, making it suitable for persistent references.

Parameters
indexOption index (0-based).
Returns
Option ID as QByteArray, or empty array if index is out of range.
Note
The ID must be unique if SCF_SUPPORT_UNIQUE_ID flag is set.
Use FindOptionIndexById() to find an option by its ID.
QByteArray id = options->GetOptionId(1);
qDebug() << "Option ID:" << id;
// Later, find the option by ID
int index = iprm::FindOptionIndexById(id, *options);
int FindOptionIndexById(const QByteArray &id, const iprm::IOptionsList &list)
Find the option index by the given ID.
See also
OptionsFlags, FindOptionIndexById

Implements iprm::IOptionsList.

◆ GetOptionIndexById()

int iprm::COptionsManager::GetOptionIndexById ( const QByteArray &  optionId) const

Get the index for the given option ID.

Returns
found option index, or a negative value if the option with the requested ID was not found.

◆ GetOptionIndexByName()

int iprm::COptionsManager::GetOptionIndexByName ( const QString &  optionName) const

Get the index for the given option name.

Returns
found option index, or a negative value if the option with the requested name was not found.
Note
If the container contains more options with the same name, the first found option index will be returned.

◆ GetOptionName()

virtual QString iprm::COptionsManager::GetOptionName ( int  index) const
overridevirtual

Get name of specified option.

Returns the display name for an option.

Parameters
indexOption index (0-based).
Returns
Option name as QString, or empty string if index is out of range.
QString name = options->GetOptionName(0);
qDebug() << "First option:" << name;
See also
GetOptionDescription, GetOptionId

Implements iprm::IOptionsList.

◆ GetOptionOperationFlags()

virtual int iprm::COptionsManager::GetOptionOperationFlags ( int  index = -1) const
overridevirtual

Get operation control flags of some option or whole manager.

Returns flags indicating which operations are supported, either for the entire manager (index < 0) or for a specific option.

Parameters
indexIndex addressing position in the option list.
  • Negative value: Returns general manager-level flags.
  • Zero or positive: Returns flags for specific option at that position.
  • Value equal to count: Returns flags for potential insert at end.
Returns
Bitwise OR combination of OptionOperationFlags values.
Note
TODO: Consider merging this with IOptionsList::GetOptionsFlags().
// Check general manager capabilities
int flags = manager.GetOptionOperationFlags(-1);
{
qDebug() << "Can insert new options";
}
// Check if first option can be renamed
int firstFlags = manager.GetOptionOperationFlags(0);
{
manager.SetOptionName(0, "New Name");
}
@ OOF_SUPPORT_RENAME
Active if rename of options is supported.
@ OOF_SUPPORT_INSERT
Active if insert of options is possible.
See also
OptionOperationFlags

Implements iprm::IOptionsManager.

◆ GetOptionsCount()

virtual int iprm::COptionsManager::GetOptionsCount ( ) const
overridevirtual

Get number of managed options.

Returns
Total count of options in the list (including disabled options).
int count = options->GetOptionsCount();
for (int i = 0; i < count; ++i)
{
// Process each option
}
See also
GetOptionName

Implements iprm::IOptionsList.

◆ GetOptionsFlags()

virtual int iprm::COptionsManager::GetOptionsFlags ( ) const
overridevirtual

Get constraints flags.

Returns flags that describe how the constraints object behaves and what features it supports.

Returns
Bitwise OR combination of OptionsFlags values.
int flags = options->GetOptionsFlags();
{
qDebug() << "Options have unique IDs";
}
{
qDebug() << "Options can be disabled";
}
@ SFC_DISABLE_ALLOWED
If set, some options can be disabled.
@ SCF_SUPPORT_UNIQUE_ID
If set, every option must have a unique ID.
See also
OptionsFlags

Implements iprm::IOptionsList.

◆ GetSupportedOperations()

virtual int iprm::COptionsManager::GetSupportedOperations ( ) const
overridevirtual

Get set of flags for supported operations.

See also
SupportedOperations

Reimplemented from istd::IChangeable.

◆ InsertOption()

virtual bool iprm::COptionsManager::InsertOption ( const QString &  optionName,
const QByteArray &  optionId,
const QString &  optionDescription = QString(),
int  index = -1 
)
overridevirtual

Insert an option at some position.

Adds a new option to the list at the specified position.

Parameters
optionNameName of the option (display text).
optionIdID of the option. According to data model constraints, this needs to be unique if SCF_SUPPORT_UNIQUE_ID flag is set.
optionDescriptionDescription/tooltip text for the option (optional).
indexPosition where the new option will be inserted.
  • Negative value: Option will be added to the end of the list.
  • Zero or positive: Insert at specified position.
Returns
true if the operation was successful, false otherwise.
Note
Check OOF_SUPPORT_INSERT flag before calling.
Triggers CF_OPTION_ADDED notification on success.
int flags = manager.GetOptionOperationFlags(-1);
{
// Add to end
bool added = manager.InsertOption(
"New Option",
"opt_new",
"Description of new option",
-1);
if (added)
{
qDebug() << "Option added";
}
// Insert at specific position
manager.InsertOption("First Option", "opt_first", "", 0);
}
See also
RemoveOption, OOF_SUPPORT_INSERT, CF_OPTION_ADDED

Implements iprm::IOptionsManager.

◆ IsOptionEnabled()

virtual bool iprm::COptionsManager::IsOptionEnabled ( int  index) const
overridevirtual

Return true if the option is enabled and can be selected.

Checks whether an option is currently enabled. Disabled options cannot be selected but remain visible in the list.

Parameters
indexOption index (0-based).
Returns
true if option is enabled and can be selected, false if disabled or index is out of range.
for (int i = 0; i < options->GetOptionsCount(); ++i)
{
if (options->IsOptionEnabled(i))
{
QString name = options->GetOptionName(i);
qDebug() << "Enabled option:" << name;
}
}
See also
SFC_DISABLE_ALLOWED

Implements iprm::IOptionsList.

◆ IsSelectionSerialized()

bool iprm::COptionsManager::IsSelectionSerialized ( ) const

Check if selection is serialized.

◆ RemoveOption()

virtual bool iprm::COptionsManager::RemoveOption ( int  index)
overridevirtual

Remove an option at the given index.

Deletes the option at the specified position from the list.

Parameters
indexOption index (0-based).
Returns
true if the operation was successful, false otherwise.
Note
Check OOF_SUPPORT_DELETE flag before calling.
If the removed option was selected, selection may be cleared or moved.
Triggers CF_OPTION_REMOVED notification on success.
int flags = manager.GetOptionOperationFlags(-1);
{
bool removed = manager.RemoveOption(2);
if (removed)
{
qDebug() << "Option removed successfully";
}
}
@ OOF_SUPPORT_DELETE
Active if delete of options is possible.
See also
InsertOption, OOF_SUPPORT_DELETE, CF_OPTION_REMOVED

Implements iprm::IOptionsManager.

◆ ResetOptions()

virtual void iprm::COptionsManager::ResetOptions ( )
virtual

Removes all options.

◆ Serialize()

virtual bool iprm::COptionsManager::Serialize ( iser::IArchive archive)
overridevirtual

Load or store state of this object as a archive stream.

Type of operation is depending on archive type.

See also
iser::IArchive

Reimplemented from iprm::CSelectionParam.

◆ SetFixedOptionsList()

void iprm::COptionsManager::SetFixedOptionsList ( const iprm::IOptionsList slaveSelectionConstraintsPtr)

Set additional fixed list of options.

◆ SetOptionDescription()

virtual bool iprm::COptionsManager::SetOptionDescription ( int  optionIndex,
const QString &  optionDescription 
)
overridevirtual

Set a new description for the option at the given index.

Changes the description/tooltip text of an option.

Parameters
optionIndexOption index (0-based).
optionDescriptionNew description for the option.
Returns
true if operation succeeded, false otherwise.
bool success = manager.SetOptionDescription(0, "Updated description text");
if (success)
{
qDebug() << "Description updated";
}
See also
GetOptionDescription

Implements iprm::IOptionsManager.

◆ SetOptionEnabled()

virtual bool iprm::COptionsManager::SetOptionEnabled ( int  index,
bool  isEnabled = true 
)
overridevirtual

Enables or disables a given option.

Changes the enabled state of an option. Only enabled options can be selected.

Parameters
indexOption index (0-based).
isEnabledtrue to enable, false to disable.
Returns
true if operation succeeded, false otherwise.
Note
Check OOF_SUPPORT_ENABLING flag before calling.
Triggers change notification on success.
// Disable second option
bool success = manager.SetOptionEnabled(1, false);
if (success)
{
qDebug() << "Option disabled";
}
// Re-enable it
manager.SetOptionEnabled(1, true);
See also
IsOptionEnabled, OOF_SUPPORT_ENABLING

Implements iprm::IOptionsManager.

◆ SetOptionName()

virtual bool iprm::COptionsManager::SetOptionName ( int  optionIndex,
const QString &  optionName 
)
overridevirtual

Set a new name for the option at the given index.

Changes the display name of an option.

Parameters
optionIndexOption index (0-based).
optionNameNew name for the option.
Returns
true if rename succeeded, false otherwise.
Note
Check OOF_SUPPORT_RENAME flag before calling.
Triggers CF_OPTION_RENAMED notification on success.
int flags = manager.GetOptionOperationFlags(0);
{
bool renamed = manager.SetOptionName(0, "Updated Name");
if (renamed)
{
qDebug() << "Option renamed";
}
}
See also
GetOptionName, OOF_SUPPORT_RENAME, CF_OPTION_RENAMED

Implements iprm::IOptionsManager.

◆ SetSelectionSerialized()

void iprm::COptionsManager::SetSelectionSerialized ( bool  state)

Turn on or off selection serializing.

◆ SwapOptions()

virtual bool iprm::COptionsManager::SwapOptions ( int  index1,
int  index2 
)
overridevirtual

Swap two options.

Exchanges the positions of two options in the list.

Parameters
index1Index of first option.
index2Index of second option.
Returns
true if swap succeeded, false otherwise.
Note
Check OOF_SUPPORT_SWAP flag before calling.
Option IDs remain stable; only list positions change.
// Swap first and third options
int flags = manager.GetOptionOperationFlags(-1);
{
bool swapped = manager.SwapOptions(0, 2);
if (swapped)
{
qDebug() << "Options swapped";
}
}
@ OOF_SUPPORT_SWAP
Active if swap of options is possible.
See also
OOF_SUPPORT_SWAP

Implements iprm::IOptionsManager.


The documentation for this class was generated from the following file: