File indexing completed on 2025-01-05 05:23:47

0001 /*
0002     This file is part of the Okteta Kasten Framework, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef STRUCTURESSELECTIONMODEL_HPP
0010 #define STRUCTURESSELECTIONMODEL_HPP
0011 
0012 // tool
0013 #include "../structuremetadata.hpp"
0014 #include "structureenabledlist.hpp"
0015 // Qt
0016 #include <QAbstractListModel>
0017 #include <QVector>
0018 #include <QMap>
0019 
0020 namespace Kasten {
0021 class StructureDefinitionFile;
0022 }
0023 class StructuresSelectionModel : public QAbstractListModel
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     enum Roles {
0029         MetaDataRole = Qt::UserRole,
0030         CommentRole,
0031     };
0032 
0033 public:
0034     explicit StructuresSelectionModel(QObject* parent);
0035     ~StructuresSelectionModel() override;
0036 
0037 public:
0038     QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
0039     bool setData(const QModelIndex& index, const QVariant &value, int role = Qt::EditRole) override;
0040     int rowCount(const QModelIndex& parent = QModelIndex()) const override;
0041 
0042 public:
0043     void setStructures(const QMap<QString, Kasten::StructureDefinitionFile*>& structureDefs);
0044     void setEnabledStructures(const QStringList& enabledStructures);
0045     QStringList enabledStructures() const;
0046     const StructureEnabledList& enabledList() const;
0047 
0048 Q_SIGNALS:
0049     void enabledStructuresChanged();
0050 
0051 private:
0052     QVector<StructureMetaData> m_metaDataList;
0053     StructureEnabledList m_enabledList;
0054 };
0055 
0056 #endif