File indexing completed on 2024-04-21 03:51:09
0001 /* 0002 SPDX-FileCopyrightText: 2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef STATISTICSMODEL_H 0007 #define STATISTICSMODEL_H 0008 0009 #include "containermodel.h" 0010 0011 #include "documentsettings.h" 0012 #include "prefs.h" 0013 0014 class StatisticsModel : public ContainerModel 0015 { 0016 Q_OBJECT 0017 0018 public: 0019 enum GradeRoles { 0020 TotalPercent = Qt::UserRole, 0021 TotalCount, 0022 Grade0, 0023 Grade1, 0024 Grade2, 0025 Grade3, 0026 Grade4, 0027 Grade5, 0028 Grade6, 0029 Grade7, 0030 Container, 0031 ActiveConjugationTenses 0032 }; 0033 0034 explicit StatisticsModel(QObject *parent = nullptr); 0035 0036 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 0037 QVariant data(const QModelIndex &index, int role) const override; 0038 Qt::ItemFlags flags(const QModelIndex &index) const override; 0039 int columnCount(const QModelIndex &parent = QModelIndex()) const override; 0040 0041 /** Indicate supported drag actions 0042 @return enum of actions supported **/ 0043 Qt::DropActions supportedDragActions() const override; 0044 0045 void updateDocumentSettings(); 0046 std::shared_ptr<KEduVocDocument> document() const; 0047 0048 public Q_SLOTS: 0049 virtual void setDocument(const std::shared_ptr<KEduVocDocument> &doc) override; 0050 0051 protected: 0052 KEduVocContainer *rootContainer() const override; 0053 0054 private: 0055 int averageGradeForPracticeMode(KEduVocContainer *container, int translation) const; 0056 int entryCountForPracticeMode(KEduVocContainer *container, int translation) const; 0057 int expressionsOfGradeForPracticeMode(KEduVocContainer *container, int translation, grade_t grade) const; 0058 void loadDocumentsSettings(); 0059 0060 private: 0061 QList<QSharedPointer<DocumentSettings>> m_documentSettings; 0062 }; 0063 0064 // For index.data() 0065 Q_DECLARE_METATYPE(KEduVocContainer *) 0066 0067 #endif