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()) {
75 return m_categories.at(index.row())->displayName();
76 case Qt::DecorationRole: {
77 const QIcon &icon = m_categories.at(index.row())->icon();
80 #ifdef QT_UTILITIES_GUI_QTWIDGETS
81 QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize)
95 void OptionCategoryModel::categoryChangedName()
97 const auto *
const senderCategory = qobject_cast<const OptionCategory *>(QObject::sender());
98 if (!senderCategory) {
101 for (
int i = 0, end = m_categories.size(); i < end; ++i) {
102 if (senderCategory == m_categories.at(i)) {
103 QModelIndex index = this->index(i);
104 emit dataChanged(index, index, QVector<int>({ Qt::DisplayRole }));
112 void OptionCategoryModel::categoryChangedIcon()
114 const auto *
const senderCategory = qobject_cast<const OptionCategory *>(QObject::sender());
115 if (!senderCategory) {
118 for (
int i = 0, end = m_categories.size(); i < end; ++i) {
119 if (senderCategory == m_categories.at(i)) {
120 QModelIndex index = this->index(i);
121 emit dataChanged(index, index, QVector<int>({ Qt::DecorationRole }));