File indexing completed on 2024-03-24 03:53:47
0001 /* 0002 SPDX-FileCopyrightText: 2007-2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef READONLYCONTAINERMODEL_H 0007 #define READONLYCONTAINERMODEL_H 0008 0009 #include <memory> 0010 0011 #include <QAbstractItemModel> 0012 #include <QModelIndex> 0013 0014 #include <QObject> 0015 0016 #include <KEduVocDocument> 0017 #include <KEduVocLesson> 0018 0019 /** 0020 * Model for the tree of containers (lessons, word types). 0021 * ReadonlyContainerModel is a read only tree model. 0022 * @see ContainerModel for its subclass that includes more options. 0023 */ 0024 0025 class ReadonlyContainerModel : public QAbstractItemModel 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 explicit ReadonlyContainerModel(KEduVocContainer::EnumContainerType type, QObject *parent = nullptr); 0031 0032 QVariant data(const QModelIndex &index, int role) const override; 0033 Qt::ItemFlags flags(const QModelIndex &index) const override; 0034 0035 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; 0036 0037 QModelIndex index(KEduVocContainer *container) const; 0038 0039 QModelIndex parent(const QModelIndex &index) const override; 0040 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0041 int columnCount(const QModelIndex &parent = QModelIndex()) const override; 0042 0043 KEduVocContainer::EnumContainerType containerType(); 0044 0045 KEduVocDocument *document() const; 0046 0047 public Q_SLOTS: 0048 /** Set the new source kvtml file 0049 * @param doc the new file */ 0050 virtual void setDocument(const std::shared_ptr<KEduVocDocument> &doc); 0051 0052 protected: 0053 virtual KEduVocContainer *rootContainer() const = 0; 0054 KEduVocContainer::EnumContainerType m_type; 0055 std::shared_ptr<KEduVocDocument> m_doc; 0056 }; 0057 0058 #endif