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

parley

  • sources
  • kde-4.12
  • 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() { return m_translation; }
78 
79  template <class T, class S>
80  QVariantList toVariantList ( QList<T*> objList ) const;
81 
82 // static QMap<QString,KEduVocConjugation::ConjugationNumber> & getConjNumberMap ();
83 
84 // static QMap<QString,KEduVocConjugation::ConjugationPerson> & getConjPersonMap ();
85 
86  /* returns the pronunciation of this translation */
87  QString pronunciation() const { return m_translation->pronunciation(); }
88  /* sets the pronunciation of this expression */
89  void setPronunciation ( const QString & expression ) { m_translation->setPronunciation ( expression ); }
90 
91  /* returns the translation commment */
92  QString comment() const { return m_translation->comment(); }
93  /* sets the translation commment */
94  void setComment ( const QString & expr ) { m_translation->setComment ( expr ); }
95 
96  /* returns example of this expression
97  * @return example or "" if no string available
98  */
99  QString example() const { return m_translation->example(); }
100 
101  /* sets example of this expression */
102  void setExample ( const QString & expression ) { m_translation->setExample ( expression ); }
103 
104  /* sets paraphrase of this expression
105  * @param expression paraphrase of this index
106  */
107  void setParaphrase ( const QString & expression ) { m_translation->setParaphrase ( expression ); }
108 
109  /* returns paraphrase of this expression
110  * @return paraphrase or "" if no string available
111  */
112  QString paraphrase() const { return m_translation->paraphrase(); }
113 
114  /* sets antonym this expression
115  * @param expression antonym of this index
116  */
117 // void setAntonym ( const QString & expression ) { m_translation->setAntonym ( expression ); }
118 
119  /* returns antonym of this expression
120  * @return antonym or "" if no string available
121  */
122 // QString antonym() const { return m_translation->antonym(); }
123 
124  /*
125  * Set a irregular plural form.
126  * @param plural plural of the word
127  */
128 // void setIrregularPlural ( const QString& plural ) { m_translation->setIrregularPlural( plural ); }
129 
130  /*
131  * Get a irregular plural form.
132  * @return plural of the word
133  */
134 // QString irregularPlural() const { return m_translation->irregularPlural(); }
135 
136  /* sets the word type of this expression
137  * @param type type of this expression ("" = none)
138  */
139  void setWordType ( KEduVocWordType* wordType ) { m_translation->setWordType ( wordType ); }
140 
141  /* returns the leitner box of this translation
142  * @return the box
143  */
144 // KEduVocLeitnerBox* leitnerBox() const;
145 
146  /* sets the leitner box of this translation
147  * @param leitnerBox the box
148  */
149 // void setLeitnerBox ( KEduVocLeitnerBox* leitnerBox );
150 
151  /*
152  * Bad, only used for tense entry page, will be deleted later. Deprecated.
153  * @param conjugation
154  */
155 // void setConjugations ( const QMap<QString, KEduVocConjugation>& conjugations );
156 
157 
158 
159  /*
160  * Bad, only compatibility. Deprecated.
161  * @return
162  */
163 // QMap <QString, KEduVocConjugation> conjugations() const;
164 
165  /*
166  * Comparison forms of adjectives/adverbs.
167  */
168  QString comparative() const { return m_translation->comparative(); }
169  void setComparative ( const QString& comparative ) { m_translation->setComparative ( comparative ); }
170  QString superlative() const { return m_translation->superlative(); }
171  void setSuperlative ( const QString& superlative ) { m_translation->setSuperlative ( superlative ); }
172 
173  /* sets multiple choice
174  * @param mc multiple choice block
175  */
176 //@note commented out in keduvoctranslation.h
177 // void setMultipleChoice( const QStringList &mc );
178 
179  /* get the sound url for this translation if it exists */
180  QString soundUrl() { return m_translation->soundUrl().path(); }
181 
182  /* set the sound url for this translation
183  * @param url url of the sound file */
184  void setSoundUrl ( const QString &url ) { m_translation->setSoundUrl ( url ); }
185 
186  /* get the image url for this translation if it exists */
187  QString imageUrl() { return m_translation->soundUrl().path(); }
188 
189  /* set the image url for this translation
190  * @param url url of the image
191  */
192  void setImageUrl ( const QString &url ) { m_translation->setImageUrl ( url ); }
193 
194  /*
195  * Equal operator to assing a translation to another one.
196  * @param translation translation to be copied
197  * @return reference to the new translation
198  */
199 // KEduVocTranslation& operator= ( const KEduVocTranslation &translation );
200 
201  /*
202  * Compare two translations, including word type etc.
203  * @param translation
204  * @return true if equal
205  */
206 // bool operator== ( const KEduVocTranslation &translation ) const;
207 
208 // void fromKVTML2 ( QDomElement& parent );
209 // void toKVTML2 ( QDomElement& parent );
210  public slots:
215  void addFalseFriend ( Translation* falseFriend ) { m_translation->addFalseFriend ( falseFriend->kEduVocTranslation() ); }
216 
221  void removeFalseFriend ( Translation* falseFriend ) { m_translation->removeFalseFriend ( falseFriend->kEduVocTranslation() ); }
222 
227  void addSynonym ( Translation* synonym ) { m_translation->addSynonym ( synonym->kEduVocTranslation() ); }
228 
233  void removeSynonym ( Translation* synonym ) { m_translation->removeSynonym ( synonym->kEduVocTranslation() ); }
234 
239  void addAntonym ( Translation* antonym ) { m_translation->addAntonym ( antonym->kEduVocTranslation() ); }
240 
245  void removeAntonym ( Translation* antonym ) { m_translation->removeAntonym ( antonym->kEduVocTranslation() ); }
246 
251  QVariantList falseFriends() const { return toVariantList<KEduVocTranslation,Translation> ( m_translation->falseFriends() ); }
252 
257  QVariantList synonyms() const { return toVariantList<KEduVocTranslation,Translation> ( m_translation->synonyms() ); }
258 
263  QVariantList antonyms() const { return toVariantList<KEduVocTranslation,Translation> ( m_translation->antonyms() ); }
264 
266  QString wordType() const;
267 
269  QStringList multipleChoice() { return m_translation->multipleChoice(); }
270 
272  QStringList conjugationTenses() const { return m_translation->conjugationTenses(); }
273 
297  void setConjugationText ( const QString& conjugation, const QString& tense, const KEduVocWordFlags& flags );
298 
306  void setConjugation ( QObject * conjugation, const QString& tense, const KEduVocWordFlags& flags );
307 
308 
316  QObject * conjugation ( const QString & tense, const KEduVocWordFlags& flags );
317 
323  QStringList conjugationTexts ( const QString& tense );
324 
331  QStringList conjugationTexts ( const QString& tense, const KEduVocWordFlags& flags );
332 
333 
334  /*
335  * Returns a pointer to the declension object of this translation.
336  * Returns 0 if no declension object exists!
337  * @return the declension
338  */
339 // KEduVocDeclension* declension();
340 //weird bug with QMap with this function
341 // QObject * declension(KEduVocWordFlag::DeclensionNumber number, KEduVocWordFlag::DeclensionCase decCase);
342 
343  /*
344  * Set a new declension for a translation
345  * @param declension
346  */
347 // void setDeclension ( KEduVocDeclension* declension );
348 // void setDeclension(const QString& declension, KEduVocWordFlag::DeclensionNumber number, KEduVocWordFlag::DeclensionCase decCase);
349 
350 
351 
352  private:
353  KEduVocTranslation * m_translation;
354 
355  };
356 
357  //Template functions should not be separated from their definition (must be in the header file)
358  template <class T, class S>
359  QVariantList Translation::toVariantList ( QList<T*> objList ) const
360  {
361  QVariantList list;
362  foreach ( T * t, objList )
363  {
364  QObject * obj = new S ( t );
365  list.push_back ( qVariantFromValue ( obj ) );
366  }
367  return list;
368  }
369 
370 
371 }
372 
373 #endif
Scripting::Translation::pronunciation
QString pronunciation() const
Definition: translation.h:87
Scripting::Translation::falseFriends
QVariantList falseFriends() const
Returns false friends of this expression.
Definition: translation.h:251
Scripting::Translation::example
QString example() const
Definition: translation.h:99
Scripting::Translation::setComparative
void setComparative(const QString &comparative)
Definition: translation.h:169
Scripting::Translation::setWordType
void setWordType(KEduVocWordType *wordType)
Definition: translation.h:139
Scripting::Translation::addSynonym
void addSynonym(Translation *synonym)
Add a synonym.
Definition: translation.h:227
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:92
text.h
Scripting::Translation::conjugationTenses
QStringList conjugationTenses() const
returns a string list with the available conjugation tenses
Definition: translation.h:272
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:171
QObject
Scripting::Translation::removeSynonym
void removeSynonym(Translation *synonym)
Remove a synonym.
Definition: translation.h:233
Scripting::Translation::paraphrase
QString paraphrase() const
Definition: translation.h:112
Scripting::Translation::removeFalseFriend
void removeFalseFriend(Translation *falseFriend)
Remove a false friend.
Definition: translation.h:221
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:269
Scripting::Translation::imageUrl
QString imageUrl()
Definition: translation.h:187
expression.h
Scripting::Translation::kEduVocTranslation
KEduVocTranslation * kEduVocTranslation()
Definition: translation.h:77
Scripting::Translation::setParaphrase
void setParaphrase(const QString &expression)
Definition: translation.h:107
Scripting::Translation::toVariantList
QVariantList toVariantList(QList< T * > objList) const
Definition: translation.h:359
Scripting::Translation::setSoundUrl
void setSoundUrl(const QString &url)
Definition: translation.h:184
Scripting::Translation::setImageUrl
void setImageUrl(const QString &url)
Definition: translation.h:192
Scripting::Translation::addAntonym
void addAntonym(Translation *antonym)
Add a antonym.
Definition: translation.h:239
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:257
Scripting::Translation::comparative
QString comparative() const
Definition: translation.h:168
Scripting::Translation::setExample
void setExample(const QString &expression)
Definition: translation.h:102
Scripting::Translation::setComment
void setComment(const QString &expr)
Definition: translation.h:94
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:89
Scripting::Translation::superlative
QString superlative() const
Definition: translation.h:170
Scripting::Expression
This class represents.
Definition: expression.h:35
Scripting::Translation::antonyms
QVariantList antonyms() const
Returns antonyms of this expression.
Definition: translation.h:263
Scripting::Translation::soundUrl
QString soundUrl()
Definition: translation.h:180
Scripting::Translation::addFalseFriend
void addFalseFriend(Translation *falseFriend)
Add a false friend.
Definition: translation.h:215
Scripting::Translation::removeAntonym
void removeAntonym(Translation *antonym)
Remove a antonym.
Definition: translation.h:245
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-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:06 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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