qtutilities/settingsdialog/optioncategory.cpp

104 lines
2.1 KiB
C++
Raw Normal View History

2015-09-06 20:19:21 +02:00
#include "./optioncategory.h"
#include "./optionpage.h"
2015-04-22 18:57:44 +02:00
namespace Dialogs {
/*!
* \class Dialogs::OptionCategory
* \brief The OptionCategory class wraps associated option pages.
*/
/*!
* \brief Constructs a option category.
*/
2017-05-01 03:16:25 +02:00
OptionCategory::OptionCategory(QObject *parent)
: QObject(parent)
, m_currentIndex(0)
{
}
2015-04-22 18:57:44 +02:00
/*!
* \brief Destroys the option category.
*/
OptionCategory::~OptionCategory()
{
qDeleteAll(m_pages);
}
/*!
* \brief Applies all pages.
* \remarks Pages which have not been shown yet must have not been initialized anyways
* and hence are skipped.
2015-04-22 18:57:44 +02:00
* \sa OptionPage::apply()
*/
bool OptionCategory::applyAllPages()
{
2017-05-01 03:16:25 +02:00
for (OptionPage *page : m_pages) {
if (!page->hasBeenShown()) {
continue;
}
2017-05-01 03:16:25 +02:00
if (!page->apply()) {
2015-04-22 18:57:44 +02:00
return false;
}
}
return true;
}
/*!
* \brief Resets all pages.
* \remarks Pages which have not been shown yet must have not been initialized anyways
* and hence are skipped.
2015-04-22 18:57:44 +02:00
* \sa OptionPage::reset()
*/
void OptionCategory::resetAllPages()
{
2017-05-01 03:16:25 +02:00
for (OptionPage *page : m_pages) {
if (page->hasBeenShown()) {
page->reset();
}
2015-04-22 18:57:44 +02:00
}
}
/*!
2017-05-04 22:46:37 +02:00
* \brief Returns whether the option category matches the specified \a
* searchKeyWord.
2015-04-22 18:57:44 +02:00
*/
bool OptionCategory::matches(const QString &searchKeyWord) const
{
2017-05-01 03:16:25 +02:00
for (OptionPage *page : m_pages) {
if (page->matches(searchKeyWord)) {
2015-04-22 18:57:44 +02:00
return true;
}
}
return false;
}
/*!
* \brief Assigns the specified \a pages to the category.
*
* Previously assigned pages get deleted. The pagesChanged() signal is emitted.
* The category takes ownership over the given \a pages.
*/
void OptionCategory::assignPages(const QList<OptionPage *> pages)
{
qDeleteAll(m_pages);
m_pages = pages;
emit pagesChanged();
}
/*!
* \fn OptionCategory::displayNameChanged()
* \brief Emitted when the display name changed.
*/
/*!
* \fn OptionCategory::iconChanged()
* \brief Emitted when the icon changed.
*/
/*!
* \fn OptionCategory::pagesChanged()
* \brief Emitted when the pages changed.
*/
} // namespace Dialogs