Debian Codegraph @

settingsdialog/optioncategory.h

raw symbols SCIP
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))
11 Q_MOC_INCLUDE("settingsdialog/optionpage.h")
12 #endif
13
14 namespace QtUtilities {
15
16 class OptionPage;
17
18 class 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
24 public:
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 void retranslateAllPages();
37 bool matches(const QString &searchKeyWord) const;
38 int currentIndex() const;
39 void setCurrentIndex(int currentIndex);
40
41 Q_SIGNALS:
42 void displayNameChanged(const QString &displayName);
43 void iconChanged(const QIcon &icon);
44 void pagesChanged(const QList<QtUtilities::OptionPage *> &pages);
45
46 private:
47 QString m_displayName;
48 QIcon m_icon;
49 QList<OptionPage *> m_pages;
50 int m_currentIndex;
51 };
52
53 /*!
54 * \brief Returns the display name of the category.
55 */
56 inline const QString &OptionCategory::displayName() const
57 {
58 return m_displayName;
59 }
60
61 /*!
62 * \brief Sets the display name of the category.
63 */
64 inline void OptionCategory::setDisplayName(const QString &displayName)
65 {
66 emit displayNameChanged(m_displayName = displayName);
67 }
68
69 /*!
70 * \brief Returns the icon of the category.
71 */
72 inline const QIcon &OptionCategory::icon() const
73 {
74 return m_icon;
75 }
76
77 /*!
78 * \brief Sets the icon of the category.
79 */
80 inline void OptionCategory::setIcon(const QIcon &icon)
81 {
82 emit iconChanged(m_icon = icon);
83 }
84
85 /*!
86 * \brief Returns the assigned pages.
87 */
88 inline const QList<OptionPage *> &OptionCategory::pages() const
89 {
90 return m_pages;
91 }
92
93 /*!
94 * \brief Returns the index of the currently shown page.
95 * \remarks The returned index might be invalid/out of range.
96 * \sa setCurrentIndex()
97 */
98 inline int OptionCategory::currentIndex() const
99 {
100 return m_currentIndex;
101 }
102
103 /*!
104 * \brief Sets the current index.
105 * \sa currentIndex()
106 */
107 inline void OptionCategory::setCurrentIndex(int currentIndex)
108 {
109 m_currentIndex = currentIndex;
110 }
111 } // namespace QtUtilities
112
113 #endif // DIALOGS_OPTIONSCATEGORY_H