File indexing completed on 2025-01-26 05:06:21
0001 /* 0002 SPDX-FileCopyrightText: 2014 Eike Hein <hein@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QAbstractListModel> 0010 #include <QMimeType> 0011 #include <QStringList> 0012 0013 class MimeTypesModel : public QAbstractListModel 0014 { 0015 Q_OBJECT 0016 0017 Q_PROPERTY(QStringList checkedTypes READ checkedTypes WRITE setCheckedTypes NOTIFY checkedTypesChanged) 0018 0019 public: 0020 explicit MimeTypesModel(QObject *parent = nullptr); 0021 ~MimeTypesModel() override; 0022 0023 QHash<int, QByteArray> roleNames() const override; 0024 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0025 bool setData(const QModelIndex &index, const QVariant &value, int role) override; 0026 0027 int rowCount(const QModelIndex &parent = QModelIndex()) const override 0028 { 0029 Q_UNUSED(parent) 0030 return m_mimeTypesList.size(); 0031 } 0032 0033 QStringList checkedTypes() const; 0034 void setCheckedTypes(const QStringList &list); 0035 0036 Q_SIGNALS: 0037 void checkedTypesChanged() const; 0038 0039 private: 0040 int indexOfType(const QString &name) const; 0041 0042 QList<QMimeType> m_mimeTypesList; 0043 QList<bool> m_checkedRows; 0044 };