Qt Utilities  5.8.1
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
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 namespace Dialogs {
11 
12 class OptionPage;
13 
14 class QT_UTILITIES_EXPORT OptionCategory : public QObject {
15  Q_OBJECT
16  Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged)
17  Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
18  Q_PROPERTY(QList<OptionPage *> pages READ pages WRITE assignPages NOTIFY pagesChanged)
19 
20 public:
21  explicit OptionCategory(QObject *parent = nullptr);
22  ~OptionCategory();
23 
24  const QString &displayName() const;
25  void setDisplayName(const QString &displayName);
26  const QIcon &icon() const;
27  void setIcon(const QIcon &icon);
28  const QList<OptionPage *> pages() const;
29  void assignPages(const QList<OptionPage *> pages);
30  bool applyAllPages();
31  void resetAllPages();
32  bool matches(const QString &searchKeyWord) const;
33  int currentIndex() const;
34  void setCurrentIndex(int currentIndex);
35 
36 Q_SIGNALS:
37  void displayNameChanged();
38  void iconChanged();
39  void pagesChanged();
40 
41 private:
42  QString m_displayName;
43  QIcon m_icon;
44  QList<OptionPage *> m_pages;
45  int m_currentIndex;
46 };
47 
51 inline const QString &OptionCategory::displayName() const
52 {
53  return m_displayName;
54 }
55 
59 inline void OptionCategory::setDisplayName(const QString &displayName)
60 {
61  m_displayName = displayName;
62  emit displayNameChanged();
63 }
64 
68 inline const QIcon &OptionCategory::icon() const
69 {
70  return m_icon;
71 }
72 
76 inline void OptionCategory::setIcon(const QIcon &icon)
77 {
78  m_icon = icon;
79  emit iconChanged();
80 }
81 
85 inline const QList<OptionPage *> OptionCategory::pages() const
86 {
87  return m_pages;
88 }
89 
95 inline int OptionCategory::currentIndex() const
96 {
97  return m_currentIndex;
98 }
99 
104 inline void OptionCategory::setCurrentIndex(int currentIndex)
105 {
106  m_currentIndex = currentIndex;
107 }
108 } // namespace Dialogs
109 
110 #endif // DIALOGS_OPTIONSCATEGORY_H
void setIcon(const QIcon &icon)
Sets the icon of the category.
The OptionCategory class wraps associated option pages.
The OptionPage class is the base class for SettingsDialog pages.
Definition: optionpage.h:15
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
void setDisplayName(const QString &displayName)
Sets the display name of the category.
Provides common dialogs such as AboutDialog, EnterPasswordDialog and SettingsDialog.
Definition: dialogutils.h:12
int currentIndex() const
Returns the index of the currently shown page.
const QIcon & icon() const
const QList< OptionPage * > pages() const
void setCurrentIndex(int currentIndex)
Sets the current index.