File indexing completed on 2023-05-30 09:04:26
0001 /* 0002 * Vocabulary Expression Translation for KDE Edu 0003 * SPDX-FileCopyrightText: 2007-2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net> 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KEDUVOCTRANSLATION_H 0008 #define KEDUVOCTRANSLATION_H 0009 0010 #include "keduvocconjugation.h" 0011 #include "keduvocdocument_export.h" 0012 #include "keduvoctext.h" 0013 #include <QMap> 0014 #include <QString> 0015 #include <QUrl> 0016 class KEduVocExpression; 0017 class KEduVocWordType; 0018 class KEduVocLeitnerBox; 0019 class KEduVocDeclension; 0020 0021 /** 0022 @author Frederik Gladhorn <frederik.gladhorn@kdemail.net> 0023 */ 0024 class KEDUVOCDOCUMENT_EXPORT KEduVocTranslation : public KEduVocText 0025 { 0026 public: 0027 enum Related { 0028 Synonym, 0029 Antonym, 0030 FalseFriend, 0031 }; 0032 0033 /** 0034 * Default constructor for an empty translation. 0035 */ 0036 KEduVocTranslation(KEduVocExpression *entry); 0037 0038 /** 0039 * Constructor 0040 * @param entry 0041 * @param translation is used as translation 0042 */ 0043 KEduVocTranslation(KEduVocExpression *entry, const QString &translation); 0044 0045 /** copy constructor for d-pointer safety */ 0046 KEduVocTranslation(const KEduVocTranslation &other); 0047 0048 /** 0049 * Destructor 0050 */ 0051 ~KEduVocTranslation(); 0052 0053 KEduVocExpression *entry(); 0054 0055 /** Sets the pronunciation of this expression 0056 * @param expression pronunciation of this index 0057 */ 0058 void setPronunciation(const QString &expression); 0059 0060 /** Returns the pronunciation of this expression 0061 * @return pronunciation or "" if none available 0062 */ 0063 QString pronunciation() const; 0064 0065 /** Returns comments of this expression 0066 * @return comment or "" if no comment available 0067 */ 0068 QString comment() const; 0069 0070 /** Sets comment of this expression 0071 * @param expr comment of this index 0072 */ 0073 void setComment(const QString &expr); 0074 0075 /** Sets example this expression 0076 * @param expression example of this index 0077 */ 0078 void setExample(const QString &expression); 0079 0080 /** Returns example of this expression 0081 * @return example or "" if no string available 0082 */ 0083 QString example() const; 0084 0085 /** Sets paraphrase of this expression 0086 * @param expression paraphrase of this index 0087 */ 0088 void setParaphrase(const QString &expression); 0089 0090 /** Returns paraphrase of this expression 0091 * @return paraphrase or "" if no string available 0092 */ 0093 QString paraphrase() const; 0094 0095 /** Sets antonym this expression 0096 * @param expression antonym of this index 0097 */ 0098 void setAntonym(const QString &expression); 0099 0100 /** Returns antonym of this expression 0101 * @return antonym or "" if no string available 0102 */ 0103 QString antonym() const; 0104 0105 /** 0106 * Sets an irregular plural form. 0107 * @param plural plural of the word 0108 */ 0109 void setIrregularPlural(const QString &plural); 0110 0111 /** 0112 * Gets an irregular plural form. 0113 * @return plural of the word 0114 */ 0115 QString irregularPlural() const; 0116 0117 /** Returns the word type of this expression, you will get a 0 pointer 0118 * if wordtype is not set for the translation 0119 * 0120 * @return type or "" if no type available 0121 */ 0122 KEduVocWordType *wordType() const; 0123 0124 /** Sets the word type of this expression 0125 * @param wordType type of this expression ("" = none) 0126 */ 0127 void setWordType(KEduVocWordType *wordType); 0128 0129 /** Returns the leitner box of this translation 0130 * @return the box 0131 */ 0132 KEduVocLeitnerBox *leitnerBox() const; 0133 0134 /** Sets the leitner box of this translation 0135 * @param leitnerBox the box 0136 */ 0137 void setLeitnerBox(KEduVocLeitnerBox *leitnerBox); 0138 0139 /** 0140 * This method is deprecated, please use @see getConjugation() @see setConjugation() 0141 * Returns a conjugation if available 0142 * @param tense tense of the requested conjugation 0143 * @return the conjugation 0144 */ 0145 KEDUVOCDOCUMENT_DEPRECATED KEduVocConjugation &conjugation(const QString &tense); 0146 0147 /** 0148 * Returns a conjugation if available 0149 * @param tense tense of the requested conjugation 0150 * @return the conjugation 0151 */ 0152 KEduVocConjugation getConjugation(const QString &tense) const; 0153 0154 /** adds conjugations or replaces them, if they exist. 0155 * @param tense tense 0156 * @param conjugation conjugation 0157 */ 0158 void setConjugation(const QString &tense, const KEduVocConjugation &conjugation); 0159 0160 /** 0161 * Returns a pointer to the declension object of this translation. 0162 * Returns 0 if no declension object exists! 0163 * @return the declension 0164 */ 0165 KEduVocDeclension *declension(); 0166 0167 /** 0168 * Set a new declension for a translation 0169 * @param declension 0170 */ 0171 void setDeclension(KEduVocDeclension *declension); 0172 0173 /** 0174 * Bad, only used for tense entry page, will be deleted later. Deprecated. 0175 * @param conjugations 0176 */ 0177 void setConjugations(const QMap<QString, KEduVocConjugation> &conjugations); 0178 0179 QStringList conjugationTenses() const; 0180 0181 /** 0182 * Bad, only compatibility. Deprecated. 0183 * @return 0184 */ 0185 KEDUVOCDOCUMENT_DEPRECATED QMap<QString, KEduVocConjugation> conjugations() const; 0186 0187 /** 0188 * Comparison forms of adjectives/adverbs. 0189 */ 0190 KEDUVOCDOCUMENT_DEPRECATED QString comparative() const; 0191 KEDUVOCDOCUMENT_DEPRECATED void setComparative(const QString &comparative); 0192 // TODO rename to comparative and remove the deprecated function 0193 KEduVocText comparativeForm() const; 0194 void setComparativeForm(const KEduVocText &comparative); 0195 0196 KEDUVOCDOCUMENT_DEPRECATED QString superlative() const; 0197 KEDUVOCDOCUMENT_DEPRECATED void setSuperlative(const QString &superlative); 0198 KEduVocText superlativeForm() const; 0199 void setSuperlativeForm(const KEduVocText &superlative); 0200 0201 KEduVocText article() const; 0202 void setArticle(const KEduVocText &article); 0203 0204 /** 0205 * This method is deprecated, please use @see getMultipleChoice() @see setMultipleChoice() 0206 * Returns multiple choice if available 0207 */ 0208 KEDUVOCDOCUMENT_DEPRECATED QStringList &multipleChoice(); 0209 0210 /** 0211 * Returns multiple choice if available 0212 * @return list of multiple choice answers 0213 */ 0214 QStringList getMultipleChoice() const; 0215 0216 /** Sets multiple choice 0217 * @param choices multiple choice block 0218 */ 0219 void setMultipleChoice(const QStringList &choices); 0220 0221 /** Get the sound url for this translation if it exists */ 0222 QUrl soundUrl(); 0223 0224 /** Set the sound url for this translation 0225 * @param url url of the sound file */ 0226 void setSoundUrl(const QUrl &url); 0227 0228 /** Get the image url for this translation if it exists */ 0229 QUrl imageUrl(); 0230 0231 /** Set the image url for this translation 0232 * @param url url of the image 0233 */ 0234 void setImageUrl(const QUrl &url); 0235 0236 /** 0237 * Add a false friend 0238 * @param falseFriend false friend of this index 0239 */ 0240 void addFalseFriend(KEduVocTranslation *falseFriend); 0241 0242 /** 0243 * Remove a false friend 0244 * @param falseFriend false friend of this index 0245 */ 0246 void removeFalseFriend(KEduVocTranslation *falseFriend); 0247 0248 /** 0249 * Returns false friends of this expression 0250 * @return list of false friends 0251 */ 0252 QList<KEduVocTranslation *> falseFriends() const; 0253 0254 /** 0255 * Add a synonym 0256 * @param synonym 0257 */ 0258 void addSynonym(KEduVocTranslation *synonym); 0259 0260 /** 0261 * Remove a synonym 0262 * @param synonym 0263 */ 0264 void removeSynonym(KEduVocTranslation *synonym); 0265 0266 /** 0267 * Returns synonyms of this expression 0268 * @return synonyms 0269 */ 0270 QList<KEduVocTranslation *> synonyms() const; 0271 0272 /** 0273 * Add a antonym 0274 * @param antonym 0275 */ 0276 void addAntonym(KEduVocTranslation *antonym); 0277 0278 /** 0279 * Remove a antonym 0280 * @param antonym 0281 */ 0282 void removeAntonym(KEduVocTranslation *antonym); 0283 0284 /** 0285 * Returns antonyms of this expression 0286 * @return antonyms 0287 */ 0288 QList<KEduVocTranslation *> antonyms() const; 0289 0290 /** 0291 * Equal operator to assign a translation to another one. 0292 * @param translation translation to be copied 0293 * @return reference to the new translation 0294 */ 0295 KEduVocTranslation &operator=(const KEduVocTranslation &translation); 0296 0297 /** 0298 * Compare two translations, including word type etc. 0299 * @param translation 0300 * @return true if equal 0301 */ 0302 bool operator==(const KEduVocTranslation &translation) const; 0303 0304 void fromKVTML2(QDomElement &parent); 0305 void toKVTML2(QDomElement &parent); 0306 0307 private: 0308 class KEduVocTranslationPrivate; 0309 KEduVocTranslationPrivate *const d; 0310 0311 // for the copy constructor 0312 void setEntry(KEduVocExpression *entry); 0313 friend class KEduVocExpression; 0314 }; 0315 0316 #endif