qtutilities/settingsdialog/optioncategory.h

114 lines
2.6 KiB
C
Raw Normal View History

#ifndef DIALOGS_OPTIONSCATEGORY_H
#define DIALOGS_OPTIONSCATEGORY_H
2015-04-22 18:57:44 +02:00
#include "../global.h"
2015-04-22 18:57:44 +02:00
#include <QIcon>
#include <QList>
2017-05-01 03:16:25 +02:00
#include <QObject>
2015-04-22 18:57:44 +02:00
2020-09-02 19:49:40 +02:00
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
Q_MOC_INCLUDE("settingsdialog/optionpage.h")
#endif
namespace QtUtilities {
2015-04-22 18:57:44 +02:00
class OptionPage;
2017-05-01 03:16:25 +02:00
class QT_UTILITIES_EXPORT OptionCategory : public QObject {
2015-04-22 18:57:44 +02:00
Q_OBJECT
Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged)
Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
Q_PROPERTY(QList<OptionPage *> pages READ pages WRITE assignPages NOTIFY pagesChanged)
public:
explicit OptionCategory(QObject *parent = nullptr);
2018-10-10 21:12:58 +02:00
~OptionCategory() override;
2017-05-01 03:16:25 +02:00
2015-04-22 18:57:44 +02:00
const QString &displayName() const;
void setDisplayName(const QString &displayName);
const QIcon &icon() const;
void setIcon(const QIcon &icon);
const QList<OptionPage *> &pages() const;
void assignPages(const QList<OptionPage *> &pages);
2015-04-22 18:57:44 +02:00
bool applyAllPages();
void resetAllPages();
void retranslateAllPages();
2015-04-22 18:57:44 +02:00
bool matches(const QString &searchKeyWord) const;
int currentIndex() const;
void setCurrentIndex(int currentIndex);
2017-05-01 03:16:25 +02:00
Q_SIGNALS:
void displayNameChanged(const QString &displayName);
void iconChanged(const QIcon &icon);
void pagesChanged(const QList<QtUtilities::OptionPage *> &pages);
2015-04-22 18:57:44 +02:00
private:
QString m_displayName;
QIcon m_icon;
QList<OptionPage *> m_pages;
int m_currentIndex;
2015-04-22 18:57:44 +02:00
};
/*!
* \brief Returns the display name of the category.
*/
inline const QString &OptionCategory::displayName() const
{
return m_displayName;
}
/*!
* \brief Sets the display name of the category.
*/
inline void OptionCategory::setDisplayName(const QString &displayName)
{
emit displayNameChanged(m_displayName = displayName);
2015-04-22 18:57:44 +02:00
}
/*!
* \brief Returns the icon of the category.
*/
inline const QIcon &OptionCategory::icon() const
{
return m_icon;
}
/*!
* \brief Sets the icon of the category.
*/
inline void OptionCategory::setIcon(const QIcon &icon)
{
emit iconChanged(m_icon = icon);
2015-04-22 18:57:44 +02:00
}
/*!
* \brief Returns the assigned pages.
*/
inline const QList<OptionPage *> &OptionCategory::pages() const
2015-04-22 18:57:44 +02:00
{
return m_pages;
}
/*!
* \brief Returns the index of the currently shown page.
* \remarks The returned index might be invalid/out of range.
* \sa setCurrentIndex()
*/
inline int OptionCategory::currentIndex() const
{
return m_currentIndex;
}
/*!
* \brief Sets the current index.
* \sa currentIndex()
*/
inline void OptionCategory::setCurrentIndex(int currentIndex)
{
m_currentIndex = currentIndex;
}
} // namespace QtUtilities
2015-04-22 18:57:44 +02:00
#endif // DIALOGS_OPTIONSCATEGORY_H