File indexing completed on 2024-04-28 07:39:20
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 CONTAINERMODEL_H 0007 #define CONTAINERMODEL_H 0008 0009 #include "readonlycontainermodel.h" 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 */ 0022 class ContainerModel : public ReadonlyContainerModel 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 enum ColumnType { ContainerNameColumn = 0, TotalCountColumn, FirstDataColumn }; 0028 0029 explicit ContainerModel(KEduVocContainer::EnumContainerType type, QObject *parent = nullptr); 0030 0031 QVariant data(const QModelIndex &index, int role) const override; 0032 Qt::ItemFlags flags(const QModelIndex &index) const override; 0033 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 0034 int columnCount(const QModelIndex &parent = QModelIndex()) const override; 0035 0036 Qt::DropActions supportedDropActions() const override; 0037 QStringList mimeTypes() const override; 0038 QMimeData *mimeData(const QModelIndexList &indexes) const override; 0039 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; 0040 0041 /** Change the name or checkbox of a lesson. 0042 * @param index which lesson 0043 * @param value new name 0044 * @param role 0045 * @return bool @c true it worked */ 0046 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 0047 0048 QModelIndex appendContainer(const QModelIndex &parent, const QString &containerName = QString()); 0049 0050 void deleteContainer(const QModelIndex &containerIndex); 0051 0052 /** Indicate supported drag actions 0053 @return enum of actions supported **/ 0054 Qt::DropActions supportedDragActions() const override; 0055 0056 Q_SIGNALS: 0057 /** 0058 * emitted when the inPractice state or name of a lesson changed. 0059 */ 0060 void documentModified(); 0061 }; 0062 0063 #endif