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

parley

translation.h

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003     Copyright 2008 Avgoustinos Kadis <avgoustinos.kadis@kdemail.net>
00004 
00005  ***************************************************************************/
00006 
00007 /***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  ***************************************************************************/
00015 #ifndef SCRIPTINGSCRIPTOBJECTTRANSLATION_H
00016 #define SCRIPTINGSCRIPTOBJECTTRANSLATION_H
00017 
00018 #include <keduvocdeclension.h>
00019 #include <keduvocconjugation.h>
00020 
00021 #include "keduvoctranslation.h"
00022 #include "keduvocwordtype.h"
00023 #include "expression.h"
00024 #include "text.h"
00025 
00026 #include <QObject>
00027 
00028 namespace Scripting
00029 {
00030 
00036     class Translation : public Text
00037     {
00038             Q_OBJECT
00040             Q_PROPERTY ( QString pronunciation READ pronunciation WRITE setPronunciation )
00042             Q_PROPERTY ( QString comment READ comment WRITE setComment )
00044             Q_PROPERTY ( QString example READ example WRITE setExample )
00046             Q_PROPERTY ( QString paraphrase READ paraphrase WRITE setParaphrase )
00047 //             Q_PROPERTY ( QString antonym READ antonym WRITE setAntonym )
00048 //             Q_PROPERTY ( QString irregularPlural READ irregularPlural WRITE setIrregularPlural )
00050             Q_PROPERTY ( QString comparative READ comparative WRITE setComparative )
00052             Q_PROPERTY ( QString superlative READ superlative WRITE setSuperlative )
00054             Q_PROPERTY ( QString soundUrl READ soundUrl WRITE setSoundUrl )
00056             Q_PROPERTY ( QString imageUrl READ soundUrl WRITE setImageUrl )
00057         public:
00058             /*
00059              * Default constructor for an empty translation.
00060              */
00061             Translation ( Expression * entry );
00062 
00063             /*
00064              * Constructor
00065              * @param translation is used as translation
00066              */
00067             Translation ( Expression * entry, const QString & translation );
00068 
00069             /*
00070              * Constructor from KEduVocTranslation (not used by scripts)
00071              * @param translation KEduVocTranslation to initialize Scripting::Translation
00072              */
00073             Translation ( KEduVocTranslation * translation );
00074 
00075             ~Translation();
00076 
00077             KEduVocTranslation* kEduVocTranslation() { return m_translation; }
00078 
00079             template <class T, class S>
00080             QVariantList toVariantList ( QList<T*> objList ) const;
00081 
00082 //             static QMap<QString,KEduVocConjugation::ConjugationNumber> & getConjNumberMap ();
00083 
00084 //             static QMap<QString,KEduVocConjugation::ConjugationPerson> & getConjPersonMap ();
00085 
00086             /* returns the pronunciation of this translation */
00087             QString pronunciation() const { return m_translation->pronunciation(); }
00088             /* sets the pronunciation of this expression */
00089             void setPronunciation ( const QString & expression ) { m_translation->setPronunciation ( expression ); }
00090 
00091             /* returns the translation commment */
00092             QString comment() const { return m_translation->comment(); }
00093             /* sets the translation commment */
00094             void setComment ( const QString & expr ) { m_translation->setComment ( expr ); }
00095 
00096             /* returns example of this expression
00097             * @return                 example or "" if no string available
00098             */
00099             QString example() const { return m_translation->example(); }
00100 
00101             /* sets example of this expression */
00102             void setExample ( const QString & expression ) { m_translation->setExample ( expression ); }
00103 
00104             /* sets paraphrase of this expression
00105             * @param expression       paraphrase of this index
00106             */
00107             void setParaphrase ( const QString & expression ) { m_translation->setParaphrase ( expression ); }
00108 
00109             /* returns paraphrase of this expression
00110             * @return                 paraphrase or "" if no string available
00111             */
00112             QString paraphrase() const { return m_translation->paraphrase(); }
00113 
00114             /* sets antonym this expression
00115             * @param expression       antonym of this index
00116             */
00117 //             void setAntonym ( const QString & expression ) { m_translation->setAntonym ( expression ); }
00118 
00119             /* returns antonym of this expression
00120             * @return                 antonym or "" if no string available
00121             */
00122 //             QString antonym() const { return m_translation->antonym(); }
00123 
00124             /*
00125              * Set a irregular plural form.
00126              * @param plural plural of the word
00127              */
00128 //             void setIrregularPlural ( const QString& plural ) { m_translation->setIrregularPlural( plural ); }
00129 
00130             /*
00131              * Get a irregular plural form.
00132              * @return plural of the word
00133              */
00134 //             QString irregularPlural() const { return m_translation->irregularPlural(); }
00135 
00136             /* sets the word type of this expression
00137             * @param type             type of this expression ("" = none)
00138             */
00139             void setWordType ( KEduVocWordType* wordType ) { m_translation->setWordType ( wordType ); }
00140 
00141             /* returns the leitner box of this translation
00142              * @return the box
00143              */
00144 //             KEduVocLeitnerBox* leitnerBox() const;
00145 
00146             /* sets the leitner box of this translation
00147              * @param leitnerBox the box
00148              */
00149 //             void setLeitnerBox ( KEduVocLeitnerBox* leitnerBox );
00150 
00151             /*
00152              * Bad, only used for tense entry page, will be deleted later. Deprecated.
00153              * @param conjugation
00154              */
00155 //             void setConjugations ( const QMap<QString, KEduVocConjugation>& conjugations );
00156 
00157 
00158 
00159             /*
00160              * Bad, only compatibility. Deprecated.
00161              * @return
00162              */
00163 //             QMap <QString, KEduVocConjugation> conjugations() const;
00164 
00165             /*
00166              * Comparison forms of adjectives/adverbs.
00167              */
00168             QString comparative() const { return m_translation->comparative(); }
00169             void setComparative ( const QString& comparative ) { m_translation->setComparative ( comparative ); }
00170             QString superlative() const { return m_translation->superlative(); }
00171             void setSuperlative ( const QString& superlative ) { m_translation->setSuperlative ( superlative ); }
00172 
00173             /* sets multiple choice
00174              * @param mc               multiple choice block
00175               */
00176 //@note commented out in keduvoctranslation.h
00177 //     void setMultipleChoice( const QStringList &mc );
00178 
00179             /* get the sound url for this translation if it exists */
00180             QString soundUrl() { return m_translation->soundUrl().path(); }
00181 
00182             /* set the sound url for this translation
00183              * @param url               url of the sound file */
00184             void setSoundUrl ( const QString &url ) { m_translation->setSoundUrl ( url ); }
00185 
00186             /* get the image url for this translation if it exists */
00187             QString imageUrl() { return m_translation->soundUrl().path(); }
00188 
00189             /* set the image url for this translation
00190              * @param url               url of the image
00191              */
00192             void setImageUrl ( const QString &url ) { m_translation->setImageUrl ( url ); }
00193 
00194             /*
00195              * Equal operator to assing a translation to another one.
00196              * @param translation translation to be copied
00197              * @return reference to the new translation
00198              */
00199 //             KEduVocTranslation& operator= ( const KEduVocTranslation &translation );
00200 
00201             /*
00202              * Compare two translations, including word type etc.
00203              * @param translation
00204              * @return true if equal
00205              */
00206 //             bool operator== ( const KEduVocTranslation &translation ) const;
00207 
00208 //             void fromKVTML2 ( QDomElement& parent );
00209 //             void toKVTML2 ( QDomElement& parent );
00210         public slots:
00215             void addFalseFriend ( Translation* falseFriend ) { m_translation->addFalseFriend ( falseFriend->kEduVocTranslation() ); }
00216 
00221             void removeFalseFriend ( Translation* falseFriend ) { m_translation->removeFalseFriend ( falseFriend->kEduVocTranslation() ); }
00222 
00227             void addSynonym ( Translation* synonym ) { m_translation->addSynonym ( synonym->kEduVocTranslation() ); }
00228 
00233             void removeSynonym ( Translation* synonym ) { m_translation->removeSynonym ( synonym->kEduVocTranslation() ); }
00234 
00239             void addAntonym ( Translation* antonym ) { m_translation->addAntonym ( antonym->kEduVocTranslation() ); }
00240 
00245             void removeAntonym ( Translation* antonym ) { m_translation->removeAntonym ( antonym->kEduVocTranslation() ); }
00246 
00251             QVariantList falseFriends() const { return toVariantList<KEduVocTranslation,Translation> ( m_translation->falseFriends() ); }
00252 
00257             QVariantList synonyms() const { return toVariantList<KEduVocTranslation,Translation> ( m_translation->synonyms() ); }
00258 
00263             QVariantList antonyms() const { return toVariantList<KEduVocTranslation,Translation> ( m_translation->antonyms() ); }
00264 
00266             QString wordType() const;
00267 
00269             QStringList multipleChoice() { return m_translation->multipleChoice(); }
00270 
00272             QStringList conjugationTenses() const { return m_translation->conjugationTenses(); }
00273 
00297             void setConjugationText ( const QString& conjugation, const QString& tense, const KEduVocWordFlags& flags );
00298 
00306             void setConjugation ( QObject * conjugation, const QString& tense, const KEduVocWordFlags& flags );
00307 
00308 
00316             QObject * conjugation ( const QString & tense, const KEduVocWordFlags& flags );
00317 
00323             QStringList conjugationTexts ( const QString& tense );
00324 
00331             QStringList conjugationTexts ( const QString& tense, const KEduVocWordFlags& flags );
00332 
00333 
00334             /*
00335              * Returns a pointer to the declension object of this translation.
00336              * Returns 0 if no declension object exists!
00337              * @return the declension
00338              */
00339 //             KEduVocDeclension* declension();
00340 //weird bug with QMap with this function
00341 //             QObject * declension(KEduVocWordFlag::DeclensionNumber number, KEduVocWordFlag::DeclensionCase decCase);
00342 
00343             /*
00344              * Set a new declension for a translation
00345              * @param declension
00346              */
00347 //             void setDeclension ( KEduVocDeclension* declension );
00348 //             void setDeclension(const QString& declension, KEduVocWordFlag::DeclensionNumber number, KEduVocWordFlag::DeclensionCase decCase);
00349 
00350 
00351 
00352         private:
00353             KEduVocTranslation * m_translation;
00354 
00355     };
00356 
00357     //Template functions should not be separated from their definition (must be in the header file)
00358     template <class T, class S>
00359     QVariantList Translation::toVariantList ( QList<T*> objList ) const
00360     {
00361         QVariantList list;
00362         foreach ( T * t, objList )
00363         {
00364             QObject * obj = new S ( t );
00365             list.push_back ( qVariantFromValue ( obj ) );
00366         }
00367         return list;
00368     }
00369 
00370 
00371 }
00372 
00373 #endif

parley

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

kdeedu

Skip menu "kdeedu"
  •     lib
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal