ACF $AcfVersion:0$
CMultiPageGuiCompBase.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QMap>
7#include <QtCore/QVector>
8
9// ACF includes
18
19
20namespace iqtgui
21{
22
24{
25public:
27
28 I_BEGIN_BASE_COMPONENT(CMultiPageGuiCompAttr);
29 I_ASSIGN_MULTI_0(m_pageNamesAttrPtr, "Names", "List of the page titles", true);
30 I_ASSIGN_MULTI_0(m_pageIdsAttrPtr, "PageIds", "List of unique page IDs", true);
31 I_ASSIGN(m_iconSizeAttrPtr, "IconSize", "Size for page icons", false, 16);
32 I_ASSIGN(m_useHorizontalLayoutAttrPtr, "UseHorizontalLayout", "Use horizontal layout", true, false);
33 I_ASSIGN(m_useSameStretchingFactorAttrPtr, "UseSameStretchingFactor", "Set the same stretching factor for all widgets. Only for group box mode", false, false);
34 I_ASSIGN(m_insertSpacerAttrPtr, "InsertSpacer", "If enabled, insert spacer after the last page widget", false, false);
35 I_ASSIGN(m_lazyPagesInitializationAttrPtr, "LazyPagesInitialization", "If enabled, CreateGui for a page will be called only when this page will be selected", true, false);
36 I_ASSIGN(m_supressPageTitleAttrPtr, "SupressPageTitle", "Supress page title on the container widget", true, false);
37 I_ASSIGN(m_defaultPageIndexAttrPtr, "DefaultStartPageIndex", "Index of the start page", true, 0);
38 I_ASSIGN(m_filterWheelEventAttrPtr, "FilterWheelEvents", "If true, the container will filter the wheel events for ComboBoxes and SpinBoxes to avoid an accident changing values in them", true, true);
39 I_END_COMPONENT;
40
41protected:
42 I_MULTITEXTATTR(m_pageNamesAttrPtr);
43 I_MULTIATTR(QByteArray, m_pageIdsAttrPtr);
44 I_ATTR(int, m_iconSizeAttrPtr);
45 I_ATTR(bool, m_useHorizontalLayoutAttrPtr);
46 I_ATTR(bool, m_useSameStretchingFactorAttrPtr);
47 I_ATTR(bool, m_insertSpacerAttrPtr);
48 I_ATTR(bool, m_lazyPagesInitializationAttrPtr);
49 I_ATTR(bool, m_supressPageTitleAttrPtr);
50 I_ATTR(int, m_defaultPageIndexAttrPtr);
51 I_ATTR(bool, m_filterWheelEventAttrPtr);
52};
53
54
58{
59 Q_OBJECT
60public:
63
65 {
69 MI_USER = 1000
70 };
71
72 I_BEGIN_BASE_COMPONENT(CMultiPageGuiCompBase);
73 I_REGISTER_SUBELEMENT(PageModel);
77 I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, imod::IModel, ExtractPageModel);
80 I_ASSIGN_MULTI_0(m_slaveWidgetsVisualCompPtr, "GuiVisualInfos", "Provide visual information for each GUI", false);
81 I_ASSIGN_TO(m_slaveWidgetsModelCompPtr, m_slaveWidgetsVisualCompPtr, false);
82 I_ASSIGN_MULTI_0(m_pageActivatorsCompPtr, "PageActivators", "Optional activators for each page (enable/disable)", false);
83 I_ASSIGN_TO(m_pageActivatorsModelCompPtr, m_pageActivatorsCompPtr, false);
84 I_ASSIGN_MULTI_0(m_pageVisibilityActivatorsCompPtr, "PageVisibilityActivators", "Optional visibility activators for each page (show/hide)", false);
85 I_ASSIGN_TO(m_pageVisibilityActivatorsModelCompPtr, m_pageVisibilityActivatorsCompPtr, false);
86 I_ASSIGN(m_defaultPageSelectionCompPtr, "DefaultStartPageSelection", "If connected, it overrides DefaultStartPageIndex", false, "");
87 I_END_COMPONENT;
88
90
92
96 virtual int GetPagesCount() const = 0;
97
101 virtual iqtgui::IGuiObject* GetPageGuiComponent(int pageIndex) const = 0;
102
103protected:
108 virtual int GetDesignType() const = 0;
109
113 virtual int GetLogicalPageIndex(int physicalWidgetIndex) const;
114
118 virtual bool CreatePage(int pageIndex);
119
123 virtual void RemovePage(int pageIndex);
124
128 virtual void SetCurrentPage(int pageIndex);
129
133 virtual void UpdateVisualElements();
134
138 virtual void CreatePages();
139
143 virtual void ResetPages();
144
145 // reimplemented (iqtgui::CGuiComponentBase)
146 virtual QWidget* CreateQtWidget(QWidget* parentPtr) override;
147
148 // reimplemented (iqtgui::CGuiComponentBase)
149 virtual void OnGuiCreated() override;
150 virtual void OnGuiDestroyed() override;
151 virtual void OnGuiRetranslate() override;
152 virtual void OnTryClose(bool* ignoredPtr = NULL) override;
153
154 // reimplemented (icomp::CComponentBase)
155 virtual void OnComponentCreated() override;
156 virtual void OnComponentDestroyed() override;
157
158 // reimplemented (imod::CMultiModelDispatcherBase)
159 virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet) override;
160
161protected Q_SLOTS:
162 virtual void OnPageChanged(int widgetIndex);
163
164private:
165 class PageModel:
167 public iprm::IOptionsList,
169 {
170 public:
172
173 PageModel();
174
175 void SetParent(CMultiPageGuiCompBase* parentPtr);
176 void UpdatePageState();
177
178 // reimplemented (iprm::ISelectionParam)
179 virtual bool SetSelectedOptionIndex(int index) override;
180 virtual ISelectionParam* GetSubselection(int index) const override;
181
182 // reimplemented (iprm::IOptionsList)
183 virtual int GetOptionsFlags() const override;
184 virtual int GetOptionsCount() const override;
185 virtual QString GetOptionName(int index) const override;
186 virtual QString GetOptionDescription(int index) const override;
187 virtual QByteArray GetOptionId(int index) const override;
188 virtual bool IsOptionEnabled(int index) const override;
189
190 // reimplemented (iqtgui::IMultiVisualStatusProvider)
191 virtual int GetStatusesCount() const override;
192 virtual const IVisualStatus* GetVisualStatus(int statusIndex) const override;
193
194 protected:
195 // reimplemented (istd::IChangeable)
196 virtual void OnEndChanges(const ChangeSet& changeSet) override;
197
198 private:
199 CMultiPageGuiCompBase* m_parentPtr;
200
201 imod::CModelUpdateBridge m_updateBridge;
202 };
203
204 template <class InterfaceType>
205 static InterfaceType* ExtractPageModel(CMultiPageGuiCompBase& component)
206 {
207 return &component.m_pageModel;
208 }
209
210protected:
211 bool EnsurePageInitialized(int pageIndex);
212
213 I_MULTIREF(IVisualStatus, m_slaveWidgetsVisualCompPtr);
214 I_MULTIREF(imod::IModel, m_slaveWidgetsModelCompPtr);
215 I_MULTIREF(iprm::IEnableableParam, m_pageActivatorsCompPtr);
216 I_MULTIREF(imod::IModel, m_pageActivatorsModelCompPtr);
217 I_MULTIREF(iprm::IEnableableParam, m_pageVisibilityActivatorsCompPtr);
218 I_MULTIREF(imod::IModel, m_pageVisibilityActivatorsModelCompPtr);
219 I_REF(iprm::ISelectionParam, m_defaultPageSelectionCompPtr);
220
222
223private:
224 struct PageInfo
225 {
226 PageInfo(): isCreated(false), widgetIndex(-1), widgetPtr(NULL){}
227
228 bool isCreated; // true, if page was created
229 QString pageTitle; // title of this page
230 QByteArray pageId;
231 int widgetIndex; // index of widget in widget container
232 QWidget* widgetPtr; // widget whera page contents will be placed
233 };
234 typedef QMap<int, PageInfo> PageIndexToInfoMap;
235 PageIndexToInfoMap m_pageIndexToInfoMap;
236};
237
238
239} // namespace iqtgui
240
241
242
243
Reflects the changes of observed objects as changes of some other object (over istd::IChangeable),...
Generic implementation of a data model changes notifier.
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition TModelWrap.h:24
Basic implementation of selection parameter.
Interface for objects which can be enabled/disabled.
Constraints of selection from set of possibilities.
Interface allowing to select single option from list of options.
Base class for classes implementing interface iqtgui::IGuiObject.
iqtgui::CGuiComponentBase BaseClass
I_MULTITEXTATTR(m_pageNamesAttrPtr)
virtual QWidget * CreateQtWidget(QWidget *parentPtr) override
Create slave widget object.
virtual void RemovePage(int pageIndex)
Remove a page from the container widget.
imod::CMultiModelDispatcherBase BaseClass2
@ MI_USER
Minimal number which should be used for user-specific data models.
virtual iqtgui::IGuiObject * GetPageGuiComponent(int pageIndex) const =0
Get the UI component for a given page.
bool EnsurePageInitialized(int pageIndex)
virtual void OnGuiRetranslate() override
Called from widget event filter when GUI should be retranslated.
virtual void SetCurrentPage(int pageIndex)
Set current page.
I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, iprm::ISelectionParam, ExtractPageModel)
virtual void UpdateVisualElements()
Update visual status of the page elements.
imod::TModelWrap< PageModel > m_pageModel
virtual void OnComponentDestroyed() override
virtual void CreatePages()
Create all container pages.
virtual void ResetPages()
Clear all container pages.
I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, istd::IChangeable, ExtractPageModel)
virtual void OnGuiDestroyed() override
Called just before GUI is released.
I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, iser::ISerializable, ExtractPageModel)
virtual void OnTryClose(bool *ignoredPtr=NULL) override
Called when the application is attempting to close.
virtual bool CreatePage(int pageIndex)
Create a page in the page container widget.
virtual int GetLogicalPageIndex(int physicalWidgetIndex) const
Get logical page index from a given widget index.
virtual int GetPagesCount() const =0
Get the number of the pages in the UI container.
virtual void OnGuiCreated() override
Called just after GUI is initialized.
virtual int GetDesignType() const =0
Get the container UI mode.
I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, IMultiVisualStatusProvider, ExtractPageModel)
virtual void OnPageChanged(int widgetIndex)
I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, imod::IModel, ExtractPageModel)
iprm::ISelectionParam & GetPageModelRef()
virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet &changeSet) override
Called when some model observed by dispatcher will be changed.
virtual void OnComponentCreated() override
I_REGISTER_SUBELEMENT_INTERFACE_T(PageModel, iprm::IOptionsList, ExtractPageModel)
Common interface for GUI objects used in ACF component context.
Definition IGuiObject.h:133
Common interface for a provider of the multiple visual statuses.
Extends standard information provider to provide additional visual informations.
Common class for all classes which objects can be archived or restored from archive.
Set of change flags (its IDs).
Definition IChangeable.h:36
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
#define NULL
Definition istd.h:74
Standard GUI specific interfaces and components based on Qt.