File indexing completed on 2022-10-04 13:56:36

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