Qt Utilities  5.12.1
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
optioncategory.cpp
Go to the documentation of this file.
1 #include "./optioncategory.h"
2 #include "./optionpage.h"
3 
4 namespace Dialogs {
5 
15  : QObject(parent)
16  , m_currentIndex(0)
17 {
18 }
19 
24 {
25  qDeleteAll(m_pages);
26 }
27 
35 {
36  for (OptionPage *page : m_pages) {
37  if (!page->hasBeenShown()) {
38  continue;
39  }
40  if (!page->apply()) {
41  return false;
42  }
43  }
44  return true;
45 }
46 
54 {
55  for (OptionPage *page : m_pages) {
56  if (page->hasBeenShown()) {
57  page->reset();
58  }
59  }
60 }
61 
66 bool OptionCategory::matches(const QString &searchKeyWord) const
67 {
68  for (OptionPage *page : m_pages) {
69  if (page->matches(searchKeyWord)) {
70  return true;
71  }
72  }
73  return false;
74 }
75 
82 void OptionCategory::assignPages(const QList<OptionPage *> pages)
83 {
84  qDeleteAll(m_pages);
85  m_pages = pages;
86  emit pagesChanged();
87 }
88 
103 } // namespace Dialogs
The OptionPage class is the base class for SettingsDialog pages.
Definition: optionpage.h:15
void assignPages(const QList< OptionPage *> pages)
Assigns the specified pages to the category.
bool applyAllPages()
Applies all pages.
~OptionCategory() override
Destroys the option category.
Provides common dialogs such as AboutDialog, EnterPasswordDialog and SettingsDialog.
Definition: dialogutils.h:12
void resetAllPages()
Resets all pages.
void pagesChanged()
Emitted when the pages changed.
bool matches(const QString &searchKeyWord) const
Returns whether the option category matches the specified searchKeyWord.
const QList< OptionPage * > pages() const
OptionCategory(QObject *parent=nullptr)
Constructs a option category.