• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

parley

  • sources
  • kde-4.14
  • kdeedu
  • parley
  • src
  • scripts
  • scripting
translation.h
Go to the documentation of this file.
1 /***************************************************************************
2 
3  Copyright 2008 Avgoustinos Kadis <avgoustinos.kadis@kdemail.net>
4 
5  ***************************************************************************/
6 
7 /***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef SCRIPTINGSCRIPTOBJECTTRANSLATION_H
16 #define SCRIPTINGSCRIPTOBJECTTRANSLATION_H
17 
18 #include <keduvocdeclension.h>
19 #include <keduvocconjugation.h>
20 
21 #include "keduvoctranslation.h"
22 #include "keduvocwordtype.h"
23 #include "expression.h"
24 #include "text.h"
25 
26 #include <QObject>
27 
28 namespace Scripting
29 {
30 
36 class Translation : public Text
37 {
38  Q_OBJECT
40  Q_PROPERTY(QString pronunciation READ pronunciation WRITE setPronunciation)
42  Q_PROPERTY(QString comment READ comment WRITE setComment)
44  Q_PROPERTY(QString example READ example WRITE setExample)
46  Q_PROPERTY(QString paraphrase READ paraphrase WRITE setParaphrase)
47 // Q_PROPERTY ( QString antonym READ antonym WRITE setAntonym )
48 // Q_PROPERTY ( QString irregularPlural READ irregularPlural WRITE setIrregularPlural )
50  Q_PROPERTY(QString comparative READ comparative WRITE setComparative)
52  Q_PROPERTY(QString superlative READ superlative WRITE setSuperlative)
54  Q_PROPERTY(QString soundUrl READ soundUrl WRITE setSoundUrl)
56  Q_PROPERTY(QString imageUrl READ soundUrl WRITE setImageUrl)
57 public:
58  /*
59  * Default constructor for an empty translation.
60  */
61  Translation(Expression * entry);
62 
63  /*
64  * Constructor
65  * @param translation is used as translation
66  */
67  Translation(Expression * entry, const QString & translation);
68 
69  /*
70  * Constructor from KEduVocTranslation (not used by scripts)
71  * @param translation KEduVocTranslation to initialize Scripting::Translation
72  */
73  Translation(KEduVocTranslation * translation);
74 
75  ~Translation();
76 
77  KEduVocTranslation* kEduVocTranslation() {
78  return m_translation;
79  }
80 
81  template <class T, class S>
82  QVariantList toVariantList(QList<T*> objList) const;
83 
84 // static QMap<QString,KEduVocConjugation::ConjugationNumber> & getConjNumberMap ();
85 
86 // static QMap<QString,KEduVocConjugation::ConjugationPerson> & getConjPersonMap ();
87 
88  /* returns the pronunciation of this translation */
89  QString pronunciation() const {
90  return m_translation->pronunciation();
91  }
92  /* sets the pronunciation of this expression */
93  void setPronunciation(const QString & expression) {
94  m_translation->setPronunciation(expression);
95  }
96 
97  /* returns the translation commment */
98  QString comment() const {
99  return m_translation->comment();
100  }
101  /* sets the translation commment */
102  void setComment(const QString & expr) {
103  m_translation->setComment(expr);
104  }
105 
106  /* returns example of this expression
107  * @return example or "" if no string available
108  */
109  QString example() const {
110  return m_translation->example();
111  }
112 
113  /* sets example of this expression */
114  void setExample(const QString & expression) {
115  m_translation->setExample(expression);
116  }
117 
118  /* sets paraphrase of this expression
119  * @param expression paraphrase of this index
120  */
121  void setParaphrase(const QString & expression) {
122  m_translation->setParaphrase(expression);
123  }
124 
125  /* returns paraphrase of this expression
126  * @return paraphrase or "" if no string available
127  */
128  QString paraphrase() const {
129  return m_translation->paraphrase();
130  }
131 
132  /* sets antonym this expression
133  * @param expression antonym of this index
134  */
135 // void setAntonym ( const QString & expression ) { m_translation->setAntonym ( expression ); }
136 
137  /* returns antonym of this expression
138  * @return antonym or "" if no string available
139  */
140 // QString antonym() const { return m_translation->antonym(); }
141 
142  /*
143  * Set a irregular plural form.
144  * @param plural plural of the word
145  */
146 // void setIrregularPlural ( const QString& plural ) { m_translation->setIrregularPlural( plural ); }
147 
148  /*
149  * Get a irregular plural form.
150  * @return plural of the word
151  */
152 // QString irregularPlural() const { return m_translation->irregularPlural(); }
153 
154  /* sets the word type of this expression
155  * @param type type of this expression ("" = none)
156  */
157  void setWordType(KEduVocWordType* wordType) {
158  m_translation->setWordType(wordType);
159  }
160 
161  /* returns the leitner box of this translation
162  * @return the box
163  */
164 // KEduVocLeitnerBox* leitnerBox() const;
165 
166  /* sets the leitner box of this translation
167  * @param leitnerBox the box
168  */
169 // void setLeitnerBox ( KEduVocLeitnerBox* leitnerBox );
170 
171  /*
172  * Bad, only used for tense entry page, will be deleted later. Deprecated.
173  * @param conjugation
174  */
175 // void setConjugations ( const QMap<QString, KEduVocConjugation>& conjugations );
176 
177 
178 
179  /*
180  * Bad, only compatibility. Deprecated.
181  * @return
182  */
183 // QMap <QString, KEduVocConjugation> conjugations() const;
184 
185  /*
186  * Comparison forms of adjectives/adverbs.
187  */
188  QString comparative() const {
189  return m_translation->comparative();
190  }
191  void setComparative(const QString& comparative) {
192  m_translation->setComparative(comparative);
193  }
194  QString superlative() const {
195  return m_translation->superlative();
196  }
197  void setSuperlative(const QString& superlative) {
198  m_translation->setSuperlative(superlative);
199  }
200 
201  /* sets multiple choice
202  * @param mc multiple choice block
203  */
204 //@note commented out in keduvoctranslation.h
205 // void setMultipleChoice( const QStringList &mc );
206 
207  /* get the sound url for this translation if it exists */
208  QString soundUrl() {
209  return m_translation->soundUrl().path();
210  }
211 
212  /* set the sound url for this translation
213  * @param url url of the sound file */
214  void setSoundUrl(const QString &url) {
215  m_translation->setSoundUrl(url);
216  }
217 
218  /* get the image url for this translation if it exists */
219  QString imageUrl() {
220  return m_translation->soundUrl().path();
221  }
222 
223  /* set the image url for this translation
224  * @param url url of the image
225  */
226  void setImageUrl(const QString &url) {
227  m_translation->setImageUrl(url);
228  }
229 
230  /*
231  * Equal operator to assing a translation to another one.
232  * @param translation translation to be copied
233  * @return reference to the new translation
234  */
235 // KEduVocTranslation& operator= ( const KEduVocTranslation &translation );
236 
237  /*
238  * Compare two translations, including word type etc.
239  * @param translation
240  * @return true if equal
241  */
242 // bool operator== ( const KEduVocTranslation &translation ) const;
243 
244 // void fromKVTML2 ( QDomElement& parent );
245 // void toKVTML2 ( QDomElement& parent );
246 public slots:
251  void addFalseFriend(Translation* falseFriend) {
252  m_translation->addFalseFriend(falseFriend->kEduVocTranslation());
253  }
254 
259  void removeFalseFriend(Translation* falseFriend) {
260  m_translation->removeFalseFriend(falseFriend->kEduVocTranslation());
261  }
262 
267  void addSynonym(Translation* synonym) {
268  m_translation->addSynonym(synonym->kEduVocTranslation());
269  }
270 
275  void removeSynonym(Translation* synonym) {
276  m_translation->removeSynonym(synonym->kEduVocTranslation());
277  }
278 
283  void addAntonym(Translation* antonym) {
284  m_translation->addAntonym(antonym->kEduVocTranslation());
285  }
286 
291  void removeAntonym(Translation* antonym) {
292  m_translation->removeAntonym(antonym->kEduVocTranslation());
293  }
294 
299  QVariantList falseFriends() const {
300  return toVariantList<KEduVocTranslation, Translation> (m_translation->falseFriends());
301  }
302 
307  QVariantList synonyms() const {
308  return toVariantList<KEduVocTranslation, Translation> (m_translation->synonyms());
309  }
310 
315  QVariantList antonyms() const {
316  return toVariantList<KEduVocTranslation, Translation> (m_translation->antonyms());
317  }
318 
320  QString wordType() const;
321 
323  QStringList multipleChoice() {
324  return m_translation->multipleChoice();
325  }
326 
328  QStringList conjugationTenses() const {
329  return m_translation->conjugationTenses();
330  }
331 
355  void setConjugationText(const QString& conjugation, const QString& tense, const KEduVocWordFlags& flags);
356 
364  void setConjugation(QObject * conjugation, const QString& tense, const KEduVocWordFlags& flags);
365 
366 
374  QObject * conjugation(const QString & tense, const KEduVocWordFlags& flags);
375 
381  QStringList conjugationTexts(const QString& tense);
382 
389  QStringList conjugationTexts(const QString& tense, const KEduVocWordFlags& flags);
390 
391 
392  /*
393  * Returns a pointer to the declension object of this translation.
394  * Returns 0 if no declension object exists!
395  * @return the declension
396  */
397 // KEduVocDeclension* declension();
398 //weird bug with QMap with this function
399 // QObject * declension(KEduVocWordFlag::DeclensionNumber number, KEduVocWordFlag::DeclensionCase decCase);
400 
401  /*
402  * Set a new declension for a translation
403  * @param declension
404  */
405 // void setDeclension ( KEduVocDeclension* declension );
406 // void setDeclension(const QString& declension, KEduVocWordFlag::DeclensionNumber number, KEduVocWordFlag::DeclensionCase decCase);
407 
408 
409 
410 private:
411  KEduVocTranslation * m_translation;
412 
413 };
414 
415 //Template functions should not be separated from their definition (must be in the header file)
416 template <class T, class S>
417 QVariantList Translation::toVariantList(QList<T*> objList) const
418 {
419  QVariantList list;
420  foreach(T * t, objList) {
421  QObject * obj = new S(t);
422  list.push_back(qVariantFromValue(obj));
423  }
424  return list;
425 }
426 
427 
428 }
429 
430 #endif
Scripting::Translation::pronunciation
QString pronunciation() const
Definition: translation.h:89
Scripting::Translation::falseFriends
QVariantList falseFriends() const
Returns false friends of this expression.
Definition: translation.h:299
Scripting::Translation::example
QString example() const
Definition: translation.h:109
Scripting::Translation::setComparative
void setComparative(const QString &comparative)
Definition: translation.h:191
Scripting::Translation::setWordType
void setWordType(KEduVocWordType *wordType)
Definition: translation.h:157
Scripting::Translation::addSynonym
void addSynonym(Translation *synonym)
Add a synonym.
Definition: translation.h:267
Scripting::Translation::setConjugation
void setConjugation(QObject *conjugation, const QString &tense, const KEduVocWordFlags &flags)
Sets the conjugation of the verb in the given tense, number and person.
Definition: translation.cpp:60
Scripting::Translation::comment
QString comment() const
Definition: translation.h:98
text.h
Scripting::Translation::conjugationTenses
QStringList conjugationTenses() const
returns a string list with the available conjugation tenses
Definition: translation.h:328
Scripting::Translation::conjugationTexts
QStringList conjugationTexts(const QString &tense)
Returns all the possible conjugations of the given tense.
Definition: translation.cpp:71
Scripting::Translation
KEduVocTranslation wrapper class for scripting with Kross.
Definition: translation.h:36
Scripting::Translation::setSuperlative
void setSuperlative(const QString &superlative)
Definition: translation.h:197
Scripting::Translation::removeSynonym
void removeSynonym(Translation *synonym)
Remove a synonym.
Definition: translation.h:275
Scripting::Translation::paraphrase
QString paraphrase() const
Definition: translation.h:128
Scripting::Translation::removeFalseFriend
void removeFalseFriend(Translation *falseFriend)
Remove a false friend.
Definition: translation.h:259
Scripting::Translation::setConjugationText
void setConjugationText(const QString &conjugation, const QString &tense, const KEduVocWordFlags &flags)
Sets the conjugation of the verb in the given tense, number and person.
Definition: translation.cpp:47
Scripting::Translation::multipleChoice
QStringList multipleChoice()
returns multiple choice if available
Definition: translation.h:323
Scripting::Translation::imageUrl
QString imageUrl()
Definition: translation.h:219
QObject
expression.h
Scripting::Translation::kEduVocTranslation
KEduVocTranslation * kEduVocTranslation()
Definition: translation.h:77
Scripting::Translation::setParaphrase
void setParaphrase(const QString &expression)
Definition: translation.h:121
Scripting::Translation::toVariantList
QVariantList toVariantList(QList< T * > objList) const
Definition: translation.h:417
Scripting::Translation::setSoundUrl
void setSoundUrl(const QString &url)
Definition: translation.h:214
Scripting::Translation::setImageUrl
void setImageUrl(const QString &url)
Definition: translation.h:226
QString
QList
QStringList
Scripting::Translation::addAntonym
void addAntonym(Translation *antonym)
Add a antonym.
Definition: translation.h:283
Scripting::Text
Scripting::Text class object provides methods and properties for accessing Parley text's value and gr...
Definition: text.h:39
Scripting::Translation::synonyms
QVariantList synonyms() const
Returns synonyms of this expression.
Definition: translation.h:307
Scripting::Translation::comparative
QString comparative() const
Definition: translation.h:188
Scripting::Translation::setExample
void setExample(const QString &expression)
Definition: translation.h:114
Scripting::Translation::setComment
void setComment(const QString &expr)
Definition: translation.h:102
Scripting::Translation::conjugation
QObject * conjugation(const QString &tense, const KEduVocWordFlags &flags)
returns the conjugation of the verb in the given tense, number and person
Definition: translation.cpp:54
Scripting::Translation::setPronunciation
void setPronunciation(const QString &expression)
Definition: translation.h:93
Scripting::Translation::superlative
QString superlative() const
Definition: translation.h:194
Scripting::Expression
This class represents.
Definition: expression.h:35
Scripting::Translation::antonyms
QVariantList antonyms() const
Returns antonyms of this expression.
Definition: translation.h:315
Scripting::Translation::soundUrl
QString soundUrl()
Definition: translation.h:208
Scripting::Translation::addFalseFriend
void addFalseFriend(Translation *falseFriend)
Add a false friend.
Definition: translation.h:251
Scripting::Translation::removeAntonym
void removeAntonym(Translation *antonym)
Remove a antonym.
Definition: translation.h:291
Scripting::Translation::wordType
QString wordType() const
returns the word type of this expression
Definition: translation.cpp:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:56 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal