Qt Utilities  5.6.0
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 <QObject>
7 #include <QIcon>
8 #include <QList>
9 
10 namespace Dialogs {
11 
12 class OptionPage;
13 
14 class QT_UTILITIES_EXPORT OptionCategory : public QObject
15 {
16  Q_OBJECT
17  Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged)
18  Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
19  Q_PROPERTY(QList<OptionPage *> pages READ pages WRITE assignPages NOTIFY pagesChanged)
20 
21 public:
22  explicit OptionCategory(QObject *parent = nullptr);
23  ~OptionCategory();
24 
25  const QString &displayName() const;
26  void setDisplayName(const QString &displayName);
27  const QIcon &icon() const;
28  void setIcon(const QIcon &icon);
29  const QList<OptionPage *> pages() const;
30  void assignPages(const QList<OptionPage *> pages);
31  bool applyAllPages();
32  void resetAllPages();
33  bool matches(const QString &searchKeyWord) const;
34  int currentIndex() const;
35  void setCurrentIndex(int currentIndex);
36 
37 Q_SIGNALS:
38  void displayNameChanged();
39  void iconChanged();
40  void pagesChanged();
41 
42 private:
43  QString m_displayName;
44  QIcon m_icon;
45  QList<OptionPage *> m_pages;
46  int m_currentIndex;
47 };
48 
52 inline const QString &OptionCategory::displayName() const
53 {
54  return m_displayName;
55 }
56 
60 inline void OptionCategory::setDisplayName(const QString &displayName)
61 {
62  m_displayName = displayName;
63  emit displayNameChanged();
64 }
65 
69 inline const QIcon &OptionCategory::icon() const
70 {
71  return m_icon;
72 }
73 
77 inline void OptionCategory::setIcon(const QIcon &icon)
78 {
79  m_icon = icon;
80  emit iconChanged();
81 }
82 
86 inline const QList<OptionPage *> OptionCategory::pages() const
87 {
88  return m_pages;
89 }
90 
96 inline int OptionCategory::currentIndex() const
97 {
98  return m_currentIndex;
99 }
100 
105 inline void OptionCategory::setCurrentIndex(int currentIndex)
106 {
107  m_currentIndex = currentIndex;
108 }
109 
110 }
111 
112 #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.