File indexing completed on 2024-04-21 03:50:59

0001 /*
0002     SPDX-FileCopyrightText: 2008-2009 Frederik Gladhorn <gladhorn@kde.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef LESSONMODEL_H
0007 #define LESSONMODEL_H
0008 
0009 #include "containermodel.h"
0010 
0011 /**
0012  * Model for the tree of lessons.
0013  */
0014 class LessonModel : public ContainerModel
0015 {
0016     Q_OBJECT
0017 
0018 public:
0019     /** When splitting a lesson into smaller ones - how to sort the entries into lessons.*/
0020     enum SplitLessonOrder {
0021         Sorted, /**< The order of the entries in the document */
0022         Random /**< Randomized */
0023     };
0024 
0025     explicit LessonModel(QObject *parent = nullptr);
0026 
0027     Qt::ItemFlags flags(const QModelIndex &index) const override;
0028     QVariant data(const QModelIndex &index, int role) const override;
0029     bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
0030 
0031     /**
0032      * Divide a lesson into smaller ones.
0033      * Tip: If you create a lesson that is >= the original one and use random order, you get your lesson reshuffled. Maybe that is sometimes useful. For now the
0034      * lessons are appended at the end.
0035      * @param containerIndex lesson to split
0036      * @param entriesPerLesson number of entries in each new lesson
0037      * @param order one of SplitLessonOrder
0038      */
0039     void splitLesson(const QModelIndex &containerIndex, int entriesPerLesson, SplitLessonOrder order);
0040 
0041 protected:
0042     KEduVocContainer *rootContainer() const override;
0043 };
0044 
0045 #endif