File indexing completed on 2024-03-24 03:54:00
0001 /* 0002 SPDX-FileCopyrightText: 2015 Inge Wallin <inge@lysator.liu.se> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef UTILS_H 0007 #define UTILS_H 0008 0009 // Qt 0010 #include <QColor> 0011 0012 // KEduVocDocument library 0013 #include <KEduVocContainer> 0014 #include <KEduVocWordtype> 0015 0016 class QPainter; 0017 class QRect; 0018 class KEduVocTranslation; 0019 0020 // The WordCount struct contains the number of words in each category. 0021 // This could be used for number of words due, total number of words, etc. 0022 struct WordCount { 0023 WordCount(); 0024 void clear(); 0025 int percentageCompleted() const; 0026 0027 // Fill the WordCount data from the container. 0028 void fillFromContainer(KEduVocContainer &container, int translationIndex, KEduVocContainer::EnumEntriesRecursive recursive = KEduVocContainer::Recursive); 0029 0030 // Fill the WordCount data from the container for the selected practice mode. 0031 void fillFromContainerForPracticeMode(KEduVocContainer &container, 0032 int translationIndex, 0033 const QStringList &activeConjugationTenses, 0034 KEduVocContainer::EnumEntriesRecursive recursive = KEduVocContainer::Recursive); 0035 0036 int grades[KV_MAX_GRADE + 1]; // Number of entries in each grade including grade=0, pregrade=0 0037 int pregrades[KV_MAX_GRADE + 1]; // Number of entries in each grade including grade=0, pregrade=0 0038 int invalid; // Number of invalid entries (not always applicable); 0039 0040 int initialWords; // Number of entries in initial phase (grade=0, pregrade>0) 0041 // This is the sum of the numbers in pregrades[]. 0042 int totalWords; // Total number of words 0043 // This is the sum of grades[], pregrades[] and invalid 0044 0045 private: 0046 bool isValidForProcessing(KEduVocTranslation &trans, KEduVocWordFlags wordType) const; 0047 void evaluateWord(const KEduVocText &item, const QString &text); 0048 }; 0049 0050 struct ConfidenceColors { 0051 enum ColorScheme { 0052 MultiColorScheme, //< The color scheme from the dashboard 0053 ProgressiveColorScheme //< The color scheme from the practice component 0054 }; 0055 0056 ConfidenceColors(ColorScheme colorScheme = MultiColorScheme); 0057 0058 void initColors(ColorScheme colorScheme); 0059 0060 QColor longTermColors[KV_MAX_GRADE + 1]; 0061 QColor initialTermColor; 0062 QColor invalidColor; 0063 QColor frontEndColors[2]; // Placeholders for the wordcloud background colors 0064 }; 0065 0066 void paintColorBar(QPainter &painter, const QRect &rect, const WordCount &wordCount, const ConfidenceColors &colors); 0067 0068 #endif // UTILS_H