COptionsManager.h
Go to the documentation of this file.
1 #ifndef iprm_COptionsManager_included
2 #define iprm_COptionsManager_included
3 
4 
5 // Qt includes
6 #include <QtCore/QVector>
7 
8 // ACF includes
9 #include <iprm/IOptionsManager.h>
10 #include <iprm/CSelectionParam.h>
11 
12 
13 namespace iprm
14 {
15 
16 
17 class IOptionsList;
18 
19 
24  public CSelectionParam,
25  virtual public IOptionsManager
26 {
27 public:
29 
31 
35  void SetFixedOptionsList(const iprm::IOptionsList* slaveSelectionConstraintsPtr);
36 
40  virtual void ResetOptions();
41 
46  int GetOptionIndexById(const QByteArray& optionId) const;
47 
53  int GetOptionIndexByName(const QString& optionName) const;
54 
58  bool IsSelectionSerialized() const;
62  void SetSelectionSerialized(bool state);
63 
64  // reimplemented (iprm::IOptionsList)
65  virtual int GetOptionsFlags() const;
66  virtual int GetOptionsCount() const;
67  virtual QString GetOptionName(int index) const;
68  virtual QString GetOptionDescription(int index) const;
69  virtual QByteArray GetOptionId(int index) const;
70  virtual bool IsOptionEnabled(int index) const;
71 
72  // reimplemented (iprm::IOptionsManager)
73  virtual int GetOptionOperationFlags(int index = -1) const;
74  virtual bool SetOptionEnabled(int index, bool isEnabled = true);
75  virtual bool RemoveOption(int index);
76  virtual bool InsertOption(
77  const QString& optionName,
78  const QByteArray& optionId,
79  const QString& optionDescription = QString(),
80  int index = -1);
81  virtual bool SwapOptions(int index1, int index2);
82  virtual bool SetOptionName(int index, const QString& optionName);
83  virtual bool SetOptionDescription(int index, const QString& optionDescription);
84 
85  // reimplemented (iser::ISerializable)
86  virtual bool Serialize(iser::IArchive& archive);
87 
88 private:
89  struct OptionInfo
90  {
91  OptionInfo()
92  :isEnabled(true)
93  {
94  }
95 
96  OptionInfo(const QString& optionName, QByteArray optionId, const QString& optionDescription)
97  :optionName(optionName),
98  optionId(optionId),
99  optionDescription(optionDescription),
100  isEnabled(true)
101  {
102  }
103 
104  QString optionName;
105  QByteArray optionId;
106  QString optionDescription;
107  bool isEnabled;
108  };
109 
110  typedef QVector<OptionInfo> Options;
111 
112  Options m_options;
113 
114  const iprm::IOptionsList* m_slaveSelectionConstraintsPtr;
115 
116  bool m_isSelectionSerialized;
117 };
118 
119 
120 } // namespace iprm
121 
122 
123 #endif // !iprm_COptionsManager_included
124 
125 
void SetFixedOptionsList(const iprm::IOptionsList *slaveSelectionConstraintsPtr)
Set additional fixed list of options.
virtual bool SetOptionName(int index, const QString &optionName)
Set a new name for the option at the given index optionIndex.
int GetOptionIndexById(const QByteArray &optionId) const
Get the index for the given option ID.
virtual bool Serialize(iser::IArchive &archive)
Load or store state of this object as a archive stream.
void SetSelectionSerialized(bool state)
Turn on or off selection serializing.
virtual bool SwapOptions(int index1, int index2)
Swap two options.
Constraints of selection from set of possibilities.
Definition: IOptionsList.h:22
virtual bool IsOptionEnabled(int index) const
Return true if the option is enabled and can be selected.
int GetOptionIndexByName(const QString &optionName) const
Get the index for the given option name.
Common interface for the management of the dynamic selection constraints.
virtual QString GetOptionName(int index) const
Get name of specified option.
Represent input/output persistence archive.
Definition: IArchive.h:30
virtual QByteArray GetOptionId(int index) const
Get option ID.
virtual QString GetOptionDescription(int index) const
Get human readable description for a option with the index index.
CSelectionParam BaseClass
virtual bool SetOptionEnabled(int index, bool isEnabled=true)
Enables a given option.
Basic implementation of selection parameter.
virtual int GetOptionsCount() const
Get number of managed options.
virtual void ResetOptions()
Removes all options.
bool IsSelectionSerialized() const
Check if selection is serialized.
virtual int GetOptionsFlags() const
Get constraints flags.
virtual int GetOptionOperationFlags(int index=-1) const
Get operation control flags of some option or whole manager.
virtual bool RemoveOption(int index)
Remove an option at the given index.
Implementation of a simple options manager.
virtual bool InsertOption(const QString &optionName, const QByteArray &optionId, const QString &optionDescription=QString(), int index=-1)
Insert an option at some position.
virtual bool SetOptionDescription(int index, const QString &optionDescription)
Set a new description for the option at the given index optionIndex.

© 2007-2017 Witold Gantzke and Kirill Lepskiy