4 #ifdef QT_UTILITIES_GUI_QTWIDGETS 5 #include <QApplication> 21 : QAbstractListModel(parent)
30 : QAbstractListModel(parent)
31 , m_categories(categories)
53 qDeleteAll(m_categories);
65 return parent.isValid() ? 0 : m_categories.size();
70 if (index.isValid() && index.row() < m_categories.size()) {
73 return m_categories.at(index.row())->displayName();
74 case Qt::DecorationRole: {
75 const QIcon &icon = m_categories.at(index.row())->icon();
78 #ifdef QT_UTILITIES_GUI_QTWIDGETS
79 QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize)
94 void OptionCategoryModel::categoryChangedName()
96 if (
OptionCategory *senderCategory = qobject_cast<OptionCategory *>(QObject::sender())) {
97 for (
int i = 0, end = m_categories.size(); i < end; ++i) {
98 if (senderCategory == m_categories.at(i)) {
99 QModelIndex index = this->index(i);
100 emit dataChanged(index, index, QVector<int>() << Qt::DisplayRole);
109 void OptionCategoryModel::categoryChangedIcon()
111 if (OptionCategory *senderCategory = qobject_cast<OptionCategory *>(QObject::sender())) {
112 for (
int i = 0, end = m_categories.size(); i < end; ++i) {
113 if (senderCategory == m_categories.at(i)) {
114 QModelIndex index = this->index(i);
115 emit dataChanged(index, index, QVector<int>() << Qt::DecorationRole);
The OptionCategory class wraps associated option pages.
void setCategories(const QList< OptionCategory *> categories)
Sets the categories for the model.
OptionCategory * category(const QModelIndex &index) const
Returns the category for the specified model index.
const QList< OptionCategory * > & categories() const
Returns the categories.
OptionCategoryModel(QObject *parent=nullptr)
Constructs an option category model.
Provides common dialogs such as AboutDialog, EnterPasswordDialog and SettingsDialog.
void iconChanged()
Emitted when the icon changed.
void displayNameChanged()
Emitted when the display name changed.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
virtual ~OptionCategoryModel() override
Destroys the option category model.
int rowCount(const QModelIndex &parent=QModelIndex()) const override