File indexing completed on 2025-04-27 04:08:16

0001 /*
0002  * This file is part of the KDE project
0003  * SPDX-FileCopyrightText: 2014 Dan Leinir Turthra Jensen <admin@leinir.dk>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006  *
0007  */
0008 
0009 #ifndef TEMPLATESMODEL_H
0010 #define TEMPLATESMODEL_H
0011 
0012 #include <QAbstractListModel>
0013 
0014 class TemplatesModel : public QAbstractListModel
0015 {
0016     Q_OBJECT
0017 
0018 public:
0019     enum TemplateRoles {
0020         NameRole = Qt::UserRole + 1,
0021         DescriptionRole,
0022         FileRole,
0023         IconRole,
0024         GroupName,
0025         GroupFolded
0026     };
0027     explicit TemplatesModel(QObject *parent = nullptr);
0028     ~TemplatesModel() override;
0029     QHash<int, QByteArray> roleNames() const override;
0030     QVariant data(const QModelIndex &index, int role) const override;
0031     int rowCount(const QModelIndex &parent) const override;
0032     Q_INVOKABLE QString groupNameOf(int index) const;
0033     Q_INVOKABLE void toggleGroup(const QString& name);
0034     Q_SLOT void populate();
0035 
0036 private:
0037     struct ItemData;
0038     class Private;
0039     Private* d;
0040 };
0041 
0042 #endif // TEMPLATESMODEL_H