File indexing completed on 2024-04-21 03:48:22
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 KEDUVOCTEXT_H 0007 #define KEDUVOCTEXT_H 0008 0009 #include "keduvocdocument_export.h" 0010 #include <QDateTime> 0011 0012 #define KV_MAX_GRADE 7 0013 #define KV_MIN_GRADE 0 0014 0015 #define KV_NORM_GRADE 0 // not practiced yet 0016 #define KV_NORM_TEXT I18N_NOOP("Not Practiced Yet") 0017 0018 #define KV_LEV1_GRADE 1 0019 #define KV_LEV1_TEXT I18N_NOOP("Level 1") 0020 0021 #define KV_LEV2_GRADE 2 0022 #define KV_LEV2_TEXT I18N_NOOP("Level 2") 0023 0024 #define KV_LEV3_GRADE 3 0025 #define KV_LEV3_TEXT I18N_NOOP("Level 3") 0026 0027 #define KV_LEV4_GRADE 4 0028 #define KV_LEV4_TEXT I18N_NOOP("Level 4") 0029 0030 #define KV_LEV5_GRADE 5 0031 #define KV_LEV5_TEXT I18N_NOOP("Level 5") 0032 0033 #define KV_LEV6_GRADE 6 0034 #define KV_LEV6_TEXT I18N_NOOP("Level 6") 0035 0036 #define KV_LEV7_GRADE 7 0037 #define KV_LEV7_TEXT I18N_NOOP("Level 7") 0038 0039 typedef unsigned short grade_t; 0040 typedef unsigned short count_t; 0041 0042 class QDomElement; 0043 0044 /** 0045 * A text in vocabulary documents. Associated with it are grade and date information. 0046 * This should be used instead of strings for all things that can be tested and thus get a grade. 0047 @author Frederik Gladhorn <frederik.gladhorn@kdemail.net> 0048 */ 0049 class KEDUVOCDOCUMENT_EXPORT KEduVocText 0050 { 0051 public: 0052 /** default constructor */ 0053 KEduVocText(const QString &text = QString()); 0054 0055 /** copy constructor 0056 * provides safe copy of d pointer 0057 * @param other object to copy from 0058 */ 0059 KEduVocText(const KEduVocText &other); 0060 0061 /** default destructor */ 0062 ~KEduVocText(); 0063 0064 /** 0065 * The translation as string (the word itself) 0066 * @return the translation 0067 */ 0068 QString text() const; 0069 0070 /** 0071 * Sets the translation 0072 * @param expr 0073 */ 0074 void setText(const QString &expr); 0075 0076 /** 0077 * Equal operator to copy grades. 0078 * @param other grades copied 0079 * @return reference to the new grades 0080 */ 0081 KEduVocText &operator=(const KEduVocText &other); 0082 /** 0083 * Compare two sets of grades. 0084 * @param other 0085 * @return true if equal 0086 */ 0087 bool operator==(const KEduVocText &other) const; 0088 0089 /** returns how often this entry has been practiced as int 0090 * @returns total count 0091 */ 0092 count_t practiceCount() const; 0093 0094 /** set how often this entry has been practiced as int 0095 * @param count the new count 0096 */ 0097 void setPracticeCount(count_t count); 0098 0099 /** returns bad query count as int 0100 * @returns bad query count 0101 */ 0102 count_t badCount() const; 0103 0104 /** set bad query count as int 0105 * @param count the new count 0106 */ 0107 void setBadCount(count_t count); 0108 0109 /** increment bad query count of given translation by 1 */ 0110 void incBadCount(); 0111 0112 /** increment query count of given translation by 1 */ 0113 void incPracticeCount(); 0114 0115 /** 0116 * Clears grading and date information. 0117 */ 0118 void resetGrades(); 0119 0120 /** sets the pregrade 0121 * @param grade number of knowledge: 0=known, x=numbers not knows 0122 */ 0123 void setPreGrade(grade_t grade); 0124 0125 /** returns pregrade 0126 */ 0127 grade_t preGrade() const; 0128 0129 /** sets the grade 0130 * @param grade number of knowledge: 0=known, x=numbers not knows 0131 */ 0132 void setGrade(grade_t grade); 0133 0134 /** returns grade as int 0135 * @returns number of knowledge: 0=known, x=numbers not knows 0136 */ 0137 grade_t grade() const; 0138 0139 /** increments grade */ 0140 void incGrade(); 0141 0142 /** decrements grade */ 0143 void decGrade(); 0144 0145 /** returns last practice date as int 0146 */ 0147 QDateTime practiceDate() const; 0148 0149 /** Set last query date 0150 * @param date the new date 0151 */ 0152 void setPracticeDate(const QDateTime &date); 0153 0154 /** returns interval until next practice is due 0155 */ 0156 quint32 interval() const; 0157 0158 /** Set interval until next practice is due. 0159 * @param interval the new interval 0160 */ 0161 void setInterval(quint32 interval); 0162 0163 /** 0164 * If the string inside is empty this returns true. 0165 * @return 0166 */ 0167 bool isEmpty(); 0168 0169 void fromKVTML2(QDomElement &parent); 0170 void toKVTML2(QDomElement &parent); 0171 0172 private: 0173 class KEduVocTextPrivate; 0174 KEduVocTextPrivate *const d; 0175 }; 0176 0177 #endif