1 | /*************************************************************************** |
2 | Vocabulary Expression for KDE Edu |
3 | ----------------------------------------------------------------------- |
4 | copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de> |
5 | |
6 | (C) 2005-2007 Peter Hedlund <peter.hedlund@kdemail.net> |
7 | Copyright 2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net> |
8 | ***************************************************************************/ |
9 | |
10 | /*************************************************************************** |
11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * |
16 | * * |
17 | ***************************************************************************/ |
18 | |
19 | #ifndef KEDUVOCEXPRESSION_H |
20 | #define KEDUVOCEXPRESSION_H |
21 | |
22 | #include "libkeduvocdocument_export.h" |
23 | |
24 | #include <QtCore/QDateTime> |
25 | |
26 | #include "keduvoclesson.h" |
27 | #include "keduvocarticle.h" |
28 | #include "keduvocmultiplechoice.h" |
29 | #include "keduvoctranslation.h" |
30 | |
31 | class KEduVocLesson; |
32 | |
33 | /** |
34 | This class contains one vocabulary expression as an original with one or more |
35 | translations |
36 | */ |
37 | class KEDUVOCDOCUMENT_EXPORT KEduVocExpression |
38 | { |
39 | public: |
40 | |
41 | /** default constructor for an empty vocabulary expression |
42 | */ |
43 | explicit KEduVocExpression(); |
44 | |
45 | /** Constructor for a vocabulary expression with one translation |
46 | * |
47 | * @param expression translation |
48 | * @param lesson lesson number |
49 | */ |
50 | explicit KEduVocExpression( const QString & expression ); |
51 | |
52 | /** Constructor for a vocabulary expression with an original and one or more translations |
53 | * |
54 | * @param expression expression |
55 | * @param separator expression will be split into an original and one or more translations using separator |
56 | * @param lesson lesson number, 0 for none |
57 | */ |
58 | explicit KEduVocExpression( const QStringList & translations ); |
59 | |
60 | KEduVocExpression(const KEduVocExpression& other); |
61 | |
62 | ~KEduVocExpression(); |
63 | |
64 | /** return the lesson |
65 | */ |
66 | KEduVocLesson * lesson() const; |
67 | |
68 | |
69 | /** reset all grades of the entry |
70 | * @param index identifier (language) |
71 | */ |
72 | void resetGrades( int index ); |
73 | |
74 | /** returns flag if entry is activated for queries |
75 | */ |
76 | bool isActive() const; |
77 | |
78 | /** set entry active (enabled for queries) |
79 | */ |
80 | void setActive( bool flag = true ); |
81 | |
82 | int sizeHint() const; |
83 | void setSizeHint( int sizeHint ); |
84 | |
85 | void setTranslation( int index, KEduVocTranslation* translation ); |
86 | /** |
87 | * Add a translation to this expression |
88 | * @param index number of translation = the identifier |
89 | * @param expression the translation |
90 | */ |
91 | void setTranslation( int index, const QString &expression ); |
92 | |
93 | /** removes a translation |
94 | * |
95 | * @param index number of translation 1..x |
96 | */ |
97 | void removeTranslation( int index ); |
98 | |
99 | /** |
100 | * Get a pointer to the translation |
101 | * @param index of the language identifier |
102 | * @return the translation |
103 | */ |
104 | KEduVocTranslation* translation( int index ); |
105 | KEduVocTranslation* translation( int index ) const; |
106 | |
107 | QList<int> translationIndices() const; |
108 | |
109 | KEduVocExpression& operator= ( const KEduVocExpression &expression ); |
110 | bool operator== ( const KEduVocExpression &expression ) const; |
111 | |
112 | private: |
113 | class KEduVocExpressionPrivate; |
114 | KEduVocExpressionPrivate* const d; |
115 | |
116 | /** only called by lesson to add itself to the lesson list |
117 | */ |
118 | void setLesson( KEduVocLesson * l ); |
119 | |
120 | friend class KEduVocLesson; |
121 | }; |
122 | |
123 | #endif // KEduVocExpression_H |
124 | |