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

Interface allowing to select single option from list of options. More...

#include <ISelectionParam.h>

Inheritance diagram for iprm::ISelectionParam:
iser::ISerializable istd::IChangeable istd::IPolymorphic iprm::CParamsManagerCompBase::ParamSet iprm::CSelectionParam iprm::IOptionsManager iprm::IParamsManager iser::TCopySerializedWrap< iprm::CSelectionParam > iprm::COptionsManager iprm::CSelectionParamComp iprm::COptionsManager iprm::CParamsManagerCompBase iprm::CParamsManagerCompBase iimg::CComposedBitmapProviderComp iprm::COptionsManagerComp iimg::CComposedBitmapProviderComp iprm::COptionsManagerComp iprm::CMultiParamsManagerComp iprm::CParamsManagerComp iprm::CMultiParamsManagerComp iprm::CParamsManagerComp

Public Types

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 Member Functions

virtual const IOptionsListGetSelectionConstraints () const =0
 Get constraints of this parameter.
 
virtual int GetSelectedOptionIndex () const =0
 Get selected index.
 
virtual bool SetSelectedOptionIndex (int index)=0
 Set index of selected option.
 
virtual ISelectionParamGetSubselection (int index) const =0
 Get sub-selection for specified option.
 
- Public Member Functions inherited from iser::ISerializable
virtual bool Serialize (IArchive &archive)=0
 Load or store state of this object as a archive stream.
 
virtual quint32 GetMinimalVersion (int versionId) const
 Get minimal needed version to correct storing of this data.
 
- Public Member Functions inherited from istd::IChangeable
virtual int GetSupportedOperations () const
 Get set of flags for supported operations.
 
virtual bool CopyFrom (const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
 Copy this object from another one.
 
virtual bool IsEqual (const IChangeable &object) const
 Compare this object with another object.
 
virtual istd::TUniqueInterfacePtr< istd::IChangeableCloneMe (CompatibilityMode mode=CM_WITHOUT_REFS) const
 Make a copy of this 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 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

Interface allowing to select single option from list of options.

ISelectionParam provides a mechanism for selecting one option from a list of available choices. It's similar to a combo box or radio button group in UI terms.

The selection is constrained by an IOptionsList that defines available options. Each option can have sub-selections, enabling hierarchical selection structures (e.g., selecting a category, then a sub-category).

Usage Example

// Create options manager
options.InsertOption("Small", "size_small", "Small size");
options.InsertOption("Medium", "size_medium", "Medium size");
options.InsertOption("Large", "size_large", "Large size");
// Create selection parameter
selection.SetSelectionConstraints(&options);
// Set selection by index
selection.SetSelectedOptionIndex(1); // Select "Medium"
// Get selected index
int index = selection.GetSelectedOptionIndex(); // Returns 1
// Check for no selection
{
qDebug() << "Nothing selected";
}
// Get the constraints to examine options
const iprm::IOptionsList* constraints = selection.GetSelectionConstraints();
QString selectedName = constraints->GetOptionName(index);
Implementation of a simple options manager.
virtual bool InsertOption(const QString &optionName, const QByteArray &optionId, const QString &optionDescription=QString(), int index=-1) override
Insert an option at some position.
Basic implementation of selection parameter.
virtual int GetSelectedOptionIndex() const override
Get selected index.
virtual bool SetSelectedOptionIndex(int index) override
Set index of selected option.
void SetSelectionConstraints(const IOptionsList *constraintsPtr)
Set selection constraints for this selection object.
virtual const IOptionsList * GetSelectionConstraints() const override
Get constraints of this parameter.
Constraints of selection from set of possibilities.
virtual QString GetOptionName(int index) const =0
Get name of specified option.
@ NO_SELECTION
Indicates no option is currently selected.

Hierarchical Selection Example

// Main selection
iprm::CSelectionParam mainSelection;
mainSelection.SetSelectionConstraints(&mainOptions);
// Sub-selection for first option
subSelection->SetSelectionConstraints(&subOptions);
mainSelection.SetSubselection(0, subSelection);
// Select main option
mainSelection.SetSelectedOptionIndex(0);
// Access active sub-selection
iprm::ISelectionParam* activeSub = mainSelection.GetSubselection(0);
if (activeSub)
{
activeSub->SetSelectedOptionIndex(2);
}
virtual ISelectionParam * GetSubselection(int index) const override
Get sub-selection for specified option.
void SetSubselection(int selectionIndex, ISelectionParam *selectionPtr)
Set sub-selection for a given option index.
Interface allowing to select single option from list of options.
virtual bool SetSelectedOptionIndex(int index)=0
Set index of selected option.
Note
Inherits from iser::ISerializable, so selections can be saved/loaded.
Supports change notification via CF_SELECTION_CHANGED flag.
See also
IOptionsList, IOptionsManager, CSelectionParam

Definition at line 91 of file ISelectionParam.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
NO_SELECTION 

Indicates no option is currently selected.

Definition at line 106 of file ISelectionParam.h.

◆ ChangeFlags

Data model change notification flags.

Used with the observer pattern to detect when selection changes.

See also
istd::IChangeable::ChangeSet
Enumerator
CF_SELECTION_CHANGED 

Selection index has changed.

Definition at line 101 of file ISelectionParam.h.

Member Function Documentation

◆ GetSelectedOptionIndex()

virtual int iprm::ISelectionParam::GetSelectedOptionIndex ( ) const
pure virtual

Get selected index.

Returns the index of the currently selected option.

Returns
Index of selected option (0-based), or NO_SELECTION (-1) if no option is selected.
int index = selection.GetSelectedOptionIndex();
{
qDebug() << "No selection";
}
else
{
qDebug() << "Selected index:" << index;
}
See also
SetSelectedOptionIndex, NO_SELECTION

Implemented in iprm::CParamsManagerCompBase, iprm::CParamsManagerCompBase::ParamSet, and iprm::CSelectionParam.

◆ GetSelectionConstraints()

virtual const IOptionsList * iprm::ISelectionParam::GetSelectionConstraints ( ) const
pure virtual

Get constraints of this parameter.

Returns the options list that defines available choices for this selection. Constraints describe allowed parameter ranges and related information.

Returns
Pointer to IOptionsList defining available options, owned by the parameter or external manager. Do not delete.
const iprm::IOptionsList* options = selection.GetSelectionConstraints();
if (options)
{
int count = options->GetOptionsCount();
for (int i = 0; i < count; ++i)
{
QString name = options->GetOptionName(i);
qDebug() << "Option" << i << ":" << name;
}
}
virtual int GetOptionsCount() const =0
Get number of managed options.
See also
IOptionsList

Implemented in iprm::CParamsManagerCompBase, iprm::CParamsManagerCompBase::ParamSet, and iprm::CSelectionParam.

◆ GetSubselection()

virtual ISelectionParam * iprm::ISelectionParam::GetSubselection ( int  index) const
pure virtual

Get sub-selection for specified option.

Retrieves the hierarchical sub-selection associated with a specific option. This enables multi-level selection structures (e.g., Category -> Subcategory).

Parameters
indexIndex of the option whose sub-selection to retrieve.
Returns
Pointer to sub-selection parameter, or NULL if no sub-selection exists for this option.
Note
The returned pointer belongs to the selection's data model. Do not delete.
Sub-selections are independent selection parameters that can have their own constraints and further sub-selections.
// Get sub-selection for currently selected option
int selectedIndex = selection.GetSelectedOptionIndex();
if (selectedIndex >= 0)
{
iprm::ISelectionParam* subSelection = selection.GetSubselection(selectedIndex);
if (subSelection)
{
// Work with sub-selection
subSelection->SetSelectedOptionIndex(0);
}
}
// Check all options for sub-selections
const iprm::IOptionsList* options = selection.GetSelectionConstraints();
int count = options->GetOptionsCount();
for (int i = 0; i < count; ++i)
{
if (sub)
{
qDebug() << "Option" << i << "has a sub-selection";
}
}
virtual ISelectionParam * GetSubselection(int index) const =0
Get sub-selection for specified option.

Implemented in iprm::CParamsManagerCompBase, iprm::CParamsManagerCompBase::ParamSet, iprm::CSelectionParam, and iprm::CSelectionParamComp.

◆ SetSelectedOptionIndex()

virtual bool iprm::ISelectionParam::SetSelectedOptionIndex ( int  index)
pure virtual

Set index of selected option.

Changes the selected option to the specified index.

Parameters
indexIndex of the option to select (0-based), or NO_SELECTION to clear the selection.
Returns
true if selection change was possible and successful, false otherwise.
Note
Returns false if index is out of range or the option is disabled.
Triggers CF_SELECTION_CHANGED notification on success.
// Select third option
bool success = selection.SetSelectedOptionIndex(2);
if (success)
{
qDebug() << "Selection changed";
}
// Clear selection
selection.SetSelectedOptionIndex(iprm::ISelectionParam::NO_SELECTION);
See also
GetSelectedOptionIndex, CF_SELECTION_CHANGED

Implemented in iprm::CParamsManagerCompBase, iprm::CParamsManagerCompBase::ParamSet, and iprm::CSelectionParam.


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