Qt Utilities 6.12.0
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Loading...
Searching...
No Matches
optioncategory.h
Go to the documentation of this file.
1#ifndef DIALOGS_OPTIONSCATEGORY_H
2#define DIALOGS_OPTIONSCATEGORY_H
3
4#include "../global.h"
5
6#include <QIcon>
7#include <QList>
8#include <QObject>
9
10#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
11Q_MOC_INCLUDE("settingsdialog/optionpage.h")
12#endif
13
14namespace QtUtilities {
15
16class OptionPage;
17
18class QT_UTILITIES_EXPORT OptionCategory : public QObject {
19 Q_OBJECT
20 Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged)
21 Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
22 Q_PROPERTY(QList<OptionPage *> pages READ pages WRITE assignPages NOTIFY pagesChanged)
23
24public:
25 explicit OptionCategory(QObject *parent = nullptr);
26 ~OptionCategory() override;
27
28 const QString &displayName() const;
29 void setDisplayName(const QString &displayName);
30 const QIcon &icon() const;
31 void setIcon(const QIcon &icon);
32 const QList<OptionPage *> &pages() const;
33 void assignPages(const QList<OptionPage *> &pages);
34 bool applyAllPages();
35 void resetAllPages();
36 bool matches(const QString &searchKeyWord) const;
37 int currentIndex() const;
38 void setCurrentIndex(int currentIndex);
39
40Q_SIGNALS:
41 void displayNameChanged(const QString &displayName);
42 void iconChanged(const QIcon &icon);
43 void pagesChanged(const QList<QtUtilities::OptionPage *> &pages);
44
45private:
46 QString m_displayName;
47 QIcon m_icon;
48 QList<OptionPage *> m_pages;
49 int m_currentIndex;
50};
51
55inline const QString &OptionCategory::displayName() const
56{
57 return m_displayName;
58}
59
63inline void OptionCategory::setDisplayName(const QString &displayName)
64{
65 emit displayNameChanged(m_displayName = displayName);
66}
67
71inline const QIcon &OptionCategory::icon() const
72{
73 return m_icon;
74}
75
79inline void OptionCategory::setIcon(const QIcon &icon)
80{
81 emit iconChanged(m_icon = icon);
82}
83
87inline const QList<OptionPage *> &OptionCategory::pages() const
88{
89 return m_pages;
90}
91
98{
99 return m_currentIndex;
100}
101
106inline void OptionCategory::setCurrentIndex(int currentIndex)
107{
108 m_currentIndex = currentIndex;
109}
110} // namespace QtUtilities
111
112#endif // DIALOGS_OPTIONSCATEGORY_H
The OptionCategory class wraps associated option pages.
void setCurrentIndex(int currentIndex)
Sets the current index.
void setDisplayName(const QString &displayName)
Sets the display name of the category.
void pagesChanged(const QList< QtUtilities::OptionPage * > &pages)
Emitted when the pages changed.
int currentIndex() const
Returns the index of the currently shown page.
void displayNameChanged(const QString &displayName)
Emitted when the display name changed.
void setIcon(const QIcon &icon)
Sets the icon of the category.
QList< OptionPage * > pages
void iconChanged(const QIcon &icon)
Emitted when the icon changed.
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.