ICF 3.0.5.47
Technical documentation of ICF Libraries
CMultiPageWidget.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef iwidgets_CMultiPageWidget_included
7#define iwidgets_CMultiPageWidget_included
8
9
10// Qt includes
11#include <QtCore/QSize>
12#include <QtCore/QMap>
13#include <QtCore/QtGlobal>
14#include <QtGui/QIcon>
15#include <QtWidgets/QWidget>
16
17// ICF includes
19
20
21namespace iwidgets
22{
23
24
29class CMultiPageWidget: public QWidget
30{
31 Q_OBJECT
32public:
33 typedef QWidget BaseClass;
35
78
85 QWidget* parentWidgetPtr = nullptr,
86 int designMode = DT_SIMPLE,
87 int containerGuiFlags = IMultiPageWidgetDelegate::CGF_NONE,
88 Qt::Orientation orientation = Qt::Vertical);
89
93 virtual QWidget* GetContainerWidgetPtr() const;
94
100 void SetDesignMode(int designMode);
101
107 void SetContainerGuiFlags(int containerGuiFlags);
108
114 void SetLayoutOrientation(Qt::Orientation orientation);
115
119 virtual void ResetPages();
120
124 virtual void SetPageHeaderPosition(PageHeaderPosition pageHeaderPosition);
125
131 virtual int InsertPage(
132 QWidget* pageWidgetPtr,
133 const QString& pageTitle,
134 int pageIndex = -1);
135
139 virtual void RemovePage(int pageIndex);
140
144 virtual int GetPagesCount() const;
145
149 virtual QWidget* GetPageWidgetPtr(int pageIndex) const;
150
154 virtual int GetCurrentPage() const;
155
159 virtual bool SetCurrentPage(int pageIndex);
160
164 virtual QString GetPageTitle(int pageIndex) const;
165
169 virtual void SetPageTitle(int pageIndex, const QString& pageTitle);
170
174 virtual QIcon GetPageIcon(int pageIndex) const;
175
179 virtual void SetPageIcon(int pageIndex, const QIcon& pageIcon);
180
184 virtual QString GetPageToolTip(int pageIndex) const;
185
189 virtual void SetPageToolTip(int pageIndex, const QString& pageToolTip);
190
194 virtual bool IsPageEnabled(int pageIndex) const;
195
199 virtual bool SetPageEnabled(int pageIndex, bool isPageEnabled = true);
200
204 virtual bool IsPageVisible(int pageIndex) const;
205
209 virtual bool SetPageVisible(int pageIndex, bool isPageVisible = true);
210
214 virtual QSize GetPageIconSize() const;
215
219 virtual bool SetPageIconSize(const QSize& pageIconSize);
220
224 template<class DelegateImpl>
225 void RegisterMultiPageWidgetDelegate(int uiMode);
226
227 // static methods
231 static bool IsPageIndexChangeSupported(int designMode);
232
233Q_SIGNALS:
237 void EmitPageIndexChanged(int pageIndex);
238
239protected Q_SLOTS:
240 void OnPageIndexChanged(int pageIndex);
241
242private:
243 typedef std::shared_ptr<IMultiPageWidgetDelegate> MultiPageWidgetDelegatePtr;
244
248 bool CreateContainerGui();
249
253 MultiPageWidgetDelegatePtr GetCurrentDelegate() const;
254
255private:
256 typedef QMap<int, MultiPageWidgetDelegatePtr> ContainerWidgetDelegateMap;
257
258 ContainerWidgetDelegateMap m_containerWidgetDelegateMap;
259
263 std::unique_ptr<QWidget> m_guiContainerPtr;
264
265 int m_designMode;
266
267 int m_containerGuiFlags;
268
269 Qt::Orientation m_orientation;
270
271 QSize m_pageIconSize;
272
276 bool m_pageSwitchingBlocked;
277};
278
279
280template<class DelegateImpl>
282{
283 MultiPageWidgetDelegatePtr delegatePtr = MultiPageWidgetDelegatePtr(new DelegateImpl);
284
285 m_containerWidgetDelegateMap[uiMode] = delegatePtr;
286}
287
288
289} // namespace iwidgets
290
291
292#endif // !iwidgets_CMultiPageWidget_included
293
294
Implementation of the widget, which is represented as a set of pages.
virtual QIcon GetPageIcon(int pageIndex) const
Get the page icon.
void OnPageIndexChanged(int pageIndex)
void SetLayoutOrientation(Qt::Orientation orientation)
Set layout orientation for the pages in the container UI.
virtual bool SetPageVisible(int pageIndex, bool isPageVisible=true)
Set page visible/hidden.
virtual bool IsPageVisible(int pageIndex) const
Get if the page visible/hidden.
virtual QSize GetPageIconSize() const
Get the size page icon.
void SetContainerGuiFlags(int containerGuiFlags)
Set flags for container behavior.
void RegisterMultiPageWidgetDelegate(int uiMode)
Register your own page widget delegate objects for the given UI mode.
virtual bool SetCurrentPage(int pageIndex)
Set active page in the container.
virtual bool SetPageEnabled(int pageIndex, bool isPageEnabled=true)
Set page enabled/disabled.
virtual QWidget * GetPageWidgetPtr(int pageIndex) const
Get page's widget from the container.
virtual bool IsPageEnabled(int pageIndex) const
Get if the page enabled/disabled.
virtual void SetPageTitle(int pageIndex, const QString &pageTitle)
Set the page title.
void EmitPageIndexChanged(int pageIndex)
Signal will be emitted whenever the currently selected page will be changed.
virtual QString GetPageTitle(int pageIndex) const
Get the title of the given page.
void SetDesignMode(int designMode)
Set design mode.
virtual void SetPageHeaderPosition(PageHeaderPosition pageHeaderPosition)
Set the position of the page header on the container UI.
virtual void ResetPages()
Remove all pages from the container widget.
CMultiPageWidget(QWidget *parentWidgetPtr=nullptr, int designMode=DT_SIMPLE, int containerGuiFlags=IMultiPageWidgetDelegate::CGF_NONE, Qt::Orientation orientation=Qt::Vertical)
Construct the multi page widget.
virtual void SetPageToolTip(int pageIndex, const QString &pageToolTip)
Set the page tool tip.
virtual bool SetPageIconSize(const QSize &pageIconSize)
Set the size of the icon for all pages in the container.
virtual int GetCurrentPage() const
Get currently active page in the container.
virtual QString GetPageToolTip(int pageIndex) const
Get the page tool tip.
virtual void SetPageIcon(int pageIndex, const QIcon &pageIcon)
Set the page icon.
virtual int InsertPage(QWidget *pageWidgetPtr, const QString &pageTitle, int pageIndex=-1)
Add a new page to the container.
virtual void RemovePage(int pageIndex)
Remove the page from the container.
@ DT_SIMPLE
The pages will be placed simple beside each other.
@ DT_TOOL_BOX
The pages are grouped in a tool box.
@ DT_TAB_WIDGET
The pages are grouped in a tab widget.
@ DT_STACK
The pages are grouped in a stack layout.
@ DT_COLLAPSIBLE_GROUPS
The pages will be placed into collapsible panels.
@ DT_USER
User defined container implementation.
@ DT_MINI_WIDGETS
The pages will be placed into a mini-widget container.
@ DT_SPLITTER
The same as DT_SIMPLE but a splitter manager is used for lay-outing of the pages.
IMultiPageWidgetDelegate::PageHeaderPosition PageHeaderPosition
virtual int GetPagesCount() const
Get the number of the pages in the container.
static bool IsPageIndexChangeSupported(int designMode)
Check if switching of pages is supported for this UI mode.
virtual QWidget * GetContainerWidgetPtr() const
Get page container widget.
@ CGF_NONE
Default behavior of the UI container.
PageHeaderPosition
Enum for describing of page header bar position on the container widget.
Namespace contains implementation of Qt widget extensions.

© Witold Gantzke and Kirill Lepskiy