File indexing completed on 2024-04-21 03:48:21

0001 /*
0002  * Vocabulary Expression for KDE Edu
0003  * SPDX-FileCopyrightText: 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
0004  * SPDX-FileCopyrightText: 2005-2007 Peter Hedlund <peter.hedlund@kdemail.net>
0005  * SPDX-FileCopyrightText: 2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 #ifndef KEDUVOCEXPRESSION_H
0009 #define KEDUVOCEXPRESSION_H
0010 
0011 #include "keduvocdocument_export.h"
0012 
0013 #include <QDateTime>
0014 
0015 #include "keduvocarticle.h"
0016 #include "keduvoclesson.h"
0017 #include "keduvocmultiplechoice.h"
0018 #include "keduvoctranslation.h"
0019 
0020 class KEduVocLesson;
0021 
0022 /**
0023   This class contains one vocabulary expression as an original with one or more
0024   translations
0025   */
0026 class KEDUVOCDOCUMENT_EXPORT KEduVocExpression
0027 {
0028 public:
0029     /** default constructor for an empty vocabulary expression
0030      */
0031     explicit KEduVocExpression();
0032 
0033     /** Constructor for a vocabulary expression with one translation
0034      *
0035      * @param expression       translation
0036      */
0037     explicit KEduVocExpression(const QString &expression);
0038 
0039     /** Constructor for a vocabulary expression with an original and one or more translations
0040      *
0041      * @param translations      translations
0042      */
0043     explicit KEduVocExpression(const QStringList &translations);
0044 
0045     KEduVocExpression(const KEduVocExpression &other);
0046 
0047     ~KEduVocExpression();
0048 
0049     /** return the lesson
0050      */
0051     KEduVocLesson *lesson() const;
0052 
0053     /** reset all grades of the entry
0054      * @param index     identifier (language)
0055      */
0056     void resetGrades(int index);
0057 
0058     /** returns flag if entry is activated for queries
0059      */
0060     bool isActive() const;
0061 
0062     /** set entry active (enabled for queries)
0063      */
0064     void setActive(bool flag = true);
0065 
0066     int sizeHint() const;
0067     void setSizeHint(int sizeHint);
0068 
0069     /**
0070      * Add a translation to this expression
0071      * @param index            number of translation = the identifier
0072      * @param expression       the translation
0073      */
0074     void setTranslation(int index, const QString &expression);
0075 
0076     /** removes a translation
0077      *
0078      * @param index            number of translation 1..x
0079      */
0080     void removeTranslation(int index);
0081 
0082     /**
0083      * Get a pointer to the translation
0084      * @param index of the language identifier
0085      * @return the translation
0086      */
0087     KEduVocTranslation *translation(int index);
0088     KEduVocTranslation *translation(int index) const;
0089 
0090     QList<int> translationIndices() const;
0091 
0092     KEduVocExpression &operator=(const KEduVocExpression &expression);
0093     bool operator==(const KEduVocExpression &expression) const;
0094 
0095 private:
0096     class KEduVocExpressionPrivate;
0097     KEduVocExpressionPrivate *const d;
0098 
0099     /** only called by lesson to add itself to the lesson list
0100      */
0101     void setLesson(KEduVocLesson *l);
0102 
0103     friend class KEduVocLesson;
0104 };
0105 
0106 #endif // KEduVocExpression_H