CMultiPageGuiCompBase.h
Go to the documentation of this file.
1 #ifndef iqtgui_CMultiPageGuiCompBase_included
2 #define iqtgui_CMultiPageGuiCompBase_included
3 
4 
5 // Qt includes
6 #include <QtCore/QMap>
7 #include <QtCore/QVector>
8 
9 // ACF includes
12 #include <iprm/IEnableableParam.h>
13 #include <iprm/CSelectionParam.h>
14 #include <iprm/COptionsManager.h>
18 
19 
20 namespace iqtgui
21 {
22 
23 
27 {
28  Q_OBJECT
29 public:
32 
33  enum ModelId
34  {
38  MI_USER = 1000
39  };
40 
41  I_BEGIN_BASE_COMPONENT(CMultiPageGuiCompBase);
42  I_REGISTER_SUBELEMENT(PageModel);
43  I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, iprm::ISelectionParam, ExtractPageModel);
44  I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, iprm::IOptionsList, ExtractPageModel);
45  I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, iser::ISerializable, ExtractPageModel);
46  I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, imod::IModel, ExtractPageModel);
47  I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, istd::IChangeable, ExtractPageModel);
49  I_ASSIGN_MULTI_0(m_slaveWidgetsVisualCompPtr, "GuiVisualInfos", "Provide visual information for each GUI", false);
50  I_ASSIGN_TO(m_slaveWidgetsModelCompPtr, m_slaveWidgetsVisualCompPtr, false);
51  I_ASSIGN_MULTI_0(m_pageActivatorsCompPtr, "PageActivators", "Optional activators for each page (enable/disable)", false);
52  I_ASSIGN_TO(m_pageActivatorsModelCompPtr, m_pageActivatorsCompPtr, false);
53  I_ASSIGN_MULTI_0(m_pageNamesAttrPtr, "Names", "List of the page titles", true);
54  I_ASSIGN(m_iconSizeAttrPtr, "IconSize", "Size for page icons", false, 16);
55  I_ASSIGN(m_useHorizontalLayoutAttrPtr, "UseHorizontalLayout", "Use horizontal layout", true, false);
56  I_ASSIGN(m_useSameStretchingFactorAttrPtr, "UseSameStretchingFactor", "Set the same stretching factor for all widgets. Only for group box mode", false, false);
57  I_ASSIGN(m_insertSpacerAttrPtr, "InsertSpacer", "If enabled, insert spacer after the last page widget", false, false);
58  I_ASSIGN_MULTI_0(m_pageVisibilityActivatorsCompPtr, "PageVisibilityActivators", "Optional visibility activators for each page (show/hide)", false);
59  I_ASSIGN_TO(m_pageVisibilityActivatorsModelCompPtr, m_pageVisibilityActivatorsCompPtr, false);
60  I_ASSIGN(m_lazyPagesInitializationAttrPtr, "LazyPagesInitialization", "If enabled, CreateGui for a page will be called only when this page will be selected", true, false);
61  I_ASSIGN(m_supressPageTitleAttrPtr, "SupressPageTitle", "Supress page title on the container widget", true, false);
62  I_END_COMPONENT;
63 
65 
69  virtual int GetPagesCount() const = 0;
70 
74  virtual iqtgui::IGuiObject* GetPageGuiComponent(int pageIndex) const = 0;
75 
76 protected:
81  virtual int GetDesignType() const = 0;
82 
86  virtual int GetLogicalPageIndex(int physicalWidgetIndex) const;
87 
91  virtual bool CreatePage(int pageIndex);
92 
96  virtual void RemovePage(int pageIndex);
97 
101  virtual void SetCurrentPage(int pageIndex);
102 
106  virtual void UpdateVisualElements();
107 
111  virtual void CreatePages();
112 
116  virtual void ResetPages();
117 
118  // reimplemented (iqtgui::CGuiComponentBase)
119  virtual QWidget* CreateQtWidget(QWidget* parentPtr);
120 
121  // reimplemented (iqtgui::CGuiComponentBase)
122  virtual void OnGuiCreated();
123  virtual void OnGuiDestroyed();
124  virtual void OnGuiRetranslate();
125 
126  // reimplemented (icomp::CComponentBase)
127  virtual void OnComponentCreated();
128  virtual void OnComponentDestroyed();
129 
130  // reimplemented (imod::CMultiModelDispatcherBase)
131  virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet);
132 
133 protected Q_SLOTS:
134  virtual void OnPageChanged(int widgetIndex);
135 
136 private:
137  class PageModel:
138  public iprm::CSelectionParam,
139  public iprm::IOptionsList,
141  {
142  public:
144 
145  PageModel();
146 
147  void SetParent(CMultiPageGuiCompBase* parentPtr);
148  void UpdatePageState();
149 
150  // reimplemented (iprm::ISelectionParam)
151  virtual bool SetSelectedOptionIndex(int index);
152 
153  // reimplemented (iprm::IOptionsList)
154  virtual int GetOptionsFlags() const;
155  virtual int GetOptionsCount() const;
156  virtual QString GetOptionName(int index) const;
157  virtual QString GetOptionDescription(int index) const;
158  virtual QByteArray GetOptionId(int index) const;
159  virtual bool IsOptionEnabled(int index) const;
160 
161  // reimplemented (iqtgui::IMultiVisualStatusProvider)
162  virtual int GetStatusesCount() const;
163  virtual const IVisualStatus* GetVisualStatus(int statusIndex) const;
164 
165  protected:
166  // reimplemented (istd::IChangeable)
167  virtual void OnEndChanges(const ChangeSet& changeSet);
168 
169  private:
170  CMultiPageGuiCompBase* m_parentPtr;
171 
172  imod::CModelUpdateBridge m_updateBridge;
173  };
174 
175  template <class InterfaceType>
176  static InterfaceType* ExtractPageModel(CMultiPageGuiCompBase& component)
177  {
178  return &component.m_pageModel;
179  }
180 
181 protected:
182  bool EnsurePageInitialized(int pageIndex);
183 
184  I_MULTIREF(IVisualStatus, m_slaveWidgetsVisualCompPtr);
185  I_MULTIREF(imod::IModel, m_slaveWidgetsModelCompPtr);
186  I_MULTIREF(iprm::IEnableableParam, m_pageActivatorsCompPtr);
187  I_MULTIREF(imod::IModel, m_pageActivatorsModelCompPtr);
188  I_MULTITEXTATTR(m_pageNamesAttrPtr);
189  I_ATTR(int, m_iconSizeAttrPtr);
190  I_ATTR(bool, m_useHorizontalLayoutAttrPtr);
191  I_ATTR(bool, m_useSameStretchingFactorAttrPtr);
192  I_ATTR(bool, m_insertSpacerAttrPtr);
193  I_MULTIREF(iprm::IEnableableParam, m_pageVisibilityActivatorsCompPtr);
194  I_MULTIREF(imod::IModel, m_pageVisibilityActivatorsModelCompPtr);
195  I_ATTR(bool, m_lazyPagesInitializationAttrPtr);
196  I_ATTR(bool, m_supressPageTitleAttrPtr);
197 
199 
200 private:
201  struct PageInfo
202  {
203  PageInfo(): isCreated(false), widgetIndex(-1), widgetPtr(NULL){}
204 
205  bool isCreated; // true, if page was created
206  QString pageTitle; // title of this page
207  int widgetIndex; // index of widget in widget container
208  QWidget* widgetPtr; // widget whera page contents will be placed
209  };
210  typedef QMap<int, PageInfo> PageIndexToInfoMap;
211  PageIndexToInfoMap m_pageIndexToInfoMap;
212 };
213 
214 
215 } // namespace iqtgui
216 
217 
218 #endif // !iqtgui_CMultiPageGuiCompBase_included
219 
220 
virtual void OnPageChanged(int widgetIndex)
virtual void CreatePages()
Create all container pages.
Base class for classes implementing interface iqtgui::IGuiObject.
Extends standard information provider to provide additional visual informations.
Definition: IVisualStatus.h:19
imod::TModelWrap< PageModel > m_pageModel
virtual void UpdateVisualElements()
Update visual status of the page elements.
I_MULTITEXTATTR(m_pageNamesAttrPtr)
Generic implementation of a data model changes notifier.
Constraints of selection from set of possibilities.
Definition: IOptionsList.h:22
virtual void RemovePage(int pageIndex)
Remove a page from the container widget.
virtual int GetDesignType() const =0
Get the container UI mode.
virtual int GetLogicalPageIndex(int physicalWidgetIndex) const
Get logical page index from a given widget index.
Common class for all classes which objects can be archived or restored from archive.
Definition: ISerializable.h:23
virtual void OnComponentCreated()
virtual int GetPagesCount() const =0
Get the number of the pages in the UI container.
Common interface for a provider of the multiple visual statuses.
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
Interface for objects which can be enabled/disabled.
virtual QWidget * CreateQtWidget(QWidget *parentPtr)
Create slave widget object.
imod::CMultiModelDispatcherBase BaseClass2
Common interface for GUI objects using in component context.
Definition: IGuiObject.h:25
Basic implementation of selection parameter.
#define NULL
Definition: istd.h:64
Reflects the changes of observed objects as changes of some other object (over istd::IChangeable), typically delegated to itself.
I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, iprm::ISelectionParam, ExtractPageModel)
iqtgui::CGuiComponentBase BaseClass
Minimal number which should be used for user-specific data models.
virtual void OnGuiDestroyed()
Called just before GUI is released.
Common interface for model objects, that supports Model/Observer design pattern.
Definition: IModel.h:23
Set of change flags (its IDs).
Definition: IChangeable.h:30
virtual bool CreatePage(int pageIndex)
Create a page in the page container widget.
Interface allowing to select single option from list of options.
virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet &changeSet)
virtual void SetCurrentPage(int pageIndex)
Set current page.
virtual void OnGuiCreated()
Called just after GUI is initialized.
virtual void ResetPages()
Clear all container pages.
virtual void OnComponentDestroyed()
bool EnsurePageInitialized(int pageIndex)
virtual iqtgui::IGuiObject * GetPageGuiComponent(int pageIndex) const =0
Get the UI component for a given page.
virtual void OnGuiRetranslate()
Called from widget event filter when GUI should be retranslated.

© 2007-2017 Witold Gantzke and Kirill Lepskiy