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

0001 /*
0002  * SPDX-FileCopyrightText: 2007 Jeremy Whiting <jpwhiting@kde.org>
0003  * SPDX-FileCopyrightText: 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KEDUVOCWORDTYPE_H
0008 #define KEDUVOCWORDTYPE_H
0009 
0010 #include "keduvocdocument_export.h"
0011 
0012 #include "keduvoccontainer.h"
0013 
0014 #include "keduvocwordflags.h"
0015 
0016 #include <QList>
0017 #include <QString>
0018 
0019 class KEduVocExpression;
0020 class KEduVocTranslation;
0021 
0022 /** class to store translation word types */
0023 class KEDUVOCDOCUMENT_EXPORT KEduVocWordType :public KEduVocContainer
0024 {
0025 public:
0026 
0027 
0028     /** default constructor */
0029     explicit KEduVocWordType(const QString& name, KEduVocWordType *parent = nullptr);
0030 
0031     /** destructor */
0032     ~KEduVocWordType() override;
0033 
0034     /** assignment operator */
0035 //     KEduVocWordType& operator= ( const KEduVocWordType& );
0036 
0037     /**
0038      * Internally (different from the name) the class can have one of the preset word types. These are used to determine special properties (verbs have conjugations available for example).
0039      * @param flags
0040      */
0041     void setWordType(KEduVocWordFlags flags);
0042 
0043     /**
0044      * Return the raw WordTypeFlags. Returns NoInformation if no flags are set.
0045      * @return WordTypeFlags
0046      */
0047      KEduVocWordFlags wordType() const;
0048 
0049     /**
0050      * Return a child class (or this class) that is of the specified type. Returns 0 if no class of that type is found.
0051      * @param flags
0052      * @return
0053      */
0054     KEduVocWordType* childOfType(KEduVocWordFlags flags);
0055 
0056     /**
0057      * The word type class does keep track of individual translations, because for one entry, the translations can have different word types (eg. genders of nouns tend to be different in different languages).
0058      * @param row
0059      * @return
0060      */
0061     KEduVocTranslation * translation(int row);
0062 
0063     /**
0064      * get a list of all entries in the lesson
0065      * @param recursive include entries in sublessons
0066      * @return
0067      */
0068     QList < KEduVocExpression* > entries(EnumEntriesRecursive recursive = NotRecursive) Q_DECL_OVERRIDE;
0069 
0070     KEduVocExpression* entry(int row, EnumEntriesRecursive recursive = NotRecursive) Q_DECL_OVERRIDE;
0071 
0072     /** get the number of entries in the lesson */
0073     int entryCount(EnumEntriesRecursive recursive = NotRecursive) Q_DECL_OVERRIDE;
0074 
0075 private:
0076     class Private;
0077     Private * const d;
0078 
0079     /** add an entry to the lesson
0080      * @param entryid id of the entry to add
0081      */
0082     void addTranslation(KEduVocTranslation* translation);
0083 
0084     /** remove an entry from the lesson
0085      * @param entryid id of the entry to remove
0086      */
0087     void removeTranslation(KEduVocTranslation* translation);
0088 
0089     friend class KEduVocTranslation;
0090 };
0091 
0092 #endif