Qt Utilities 6.14.4
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Loading...
Searching...
No Matches
optioncategory.cpp
Go to the documentation of this file.
1#include "./optioncategory.h"
2#include "./optionpage.h"
3
4#include <QCoreApplication>
5#include <QEvent>
6
7namespace QtUtilities {
8
18 : QObject(parent)
19 , m_currentIndex(0)
20{
21}
22
27{
28 qDeleteAll(m_pages);
29}
30
38{
39 for (OptionPage *page : m_pages) {
40 if (!page->hasBeenShown()) {
41 continue;
42 }
43 if (!page->apply()) {
44 return false;
45 }
46 }
47 return true;
48}
49
57{
58 for (OptionPage *page : m_pages) {
59 if (page->hasBeenShown()) {
60 page->reset();
61 }
62 }
63}
64
70{
71 auto event = QEvent(QEvent::LanguageChange);
72 for (auto *const page : m_pages) {
73 if (page->hasBeenShown()) {
74 QCoreApplication::sendEvent(page->widget(), &event);
75 }
76 }
77}
78
83bool OptionCategory::matches(const QString &searchKeyWord) const
84{
85 for (OptionPage *page : m_pages) {
86 if (page->matches(searchKeyWord)) {
87 return true;
88 }
89 }
90 return false;
91}
92
99void OptionCategory::assignPages(const QList<OptionPage *> &pages)
100{
101 qDeleteAll(m_pages);
102 emit pagesChanged(m_pages = pages);
103}
104
119} // namespace QtUtilities
bool matches(const QString &searchKeyWord) const
Returns whether the option category matches the specified searchKeyWord.
OptionCategory(QObject *parent=nullptr)
Constructs a option category.
void resetAllPages()
Resets all pages.
void assignPages(const QList< OptionPage * > &pages)
Assigns the specified pages to the category.
void retranslateAllPages()
Triggers retranslation of all pages.
QList< OptionPage * > pages
void pagesChanged(const QList< QtUtilities::OptionPage * > &pages)
Emitted when the pages changed.
~OptionCategory() override
Destroys the option category.
bool applyAllPages()
Applies all pages.
The OptionPage class is the base class for SettingsDialog pages.
Definition optionpage.h:34