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

parley

expression.cpp

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 #include "expression.h"
00016 #include "translation.h"
00017 
00018 namespace Scripting
00019 {
00020 
00021     Expression::Expression()
00022     {
00023         m_expression = new KEduVocExpression();
00024     }
00025 
00026     Expression::Expression ( const QString & expression )
00027     {
00028         m_expression = new KEduVocExpression ( expression );
00029     }
00030 
00031     Expression::Expression ( const QStringList & translations )
00032     {
00033         m_expression = new KEduVocExpression ( translations );
00034     }
00035 
00036     Expression::Expression ( KEduVocExpression * expression )
00037             : QObject(), m_expression ( expression )
00038     {
00039     }
00040 
00041     Expression::Expression ( const Expression & other ) : QObject()
00042     {
00043         m_expression = other.kEduVocExpression();
00044     }
00045 
00046     Expression::~Expression()
00047     {
00048     }
00049 
00050     QVariantList Expression::translationIndices() const
00051     {
00052         QVariantList vlist;
00053         foreach ( int k, m_expression->translationIndices() )
00054         {
00055             vlist.push_back ( QVariant ( k ) );
00056         }
00057         return vlist;
00058     }
00059 
00060     QVariantList Expression::translations() const
00061     {
00062         //build a list of all the translations
00063         QList<KEduVocTranslation *> translations;
00064         foreach ( int k, m_expression->translationIndices() )
00065         {
00066             if ( m_expression->translation ( k ) )
00067                 translations.push_back ( m_expression->translation ( k ) );
00068         }
00069         //convert it to QVariantList and return it
00070         return toVariantList<KEduVocTranslation,Translation> ( translations );
00071     }
00072 
00073     QStringList Expression::translationTexts() const
00074     {
00075         //build a list of all the translation texts
00076         QStringList list;
00077         foreach ( int k, m_expression->translationIndices() )
00078         {
00079             if ( m_expression->translation ( k ) )
00080                 list << m_expression->translation(k)->text();
00081         }
00082         return list;
00083     }
00084 
00085 //     Expression & Expression::operator= ( const Expression &other )
00086 //     {
00087 //         m_expression = other.kEduVocEntry();
00088 //         return ( *this );
00089 //     }
00090 
00091 //     bool Expression::operator== ( const Expression &other ) const
00092 //     {
00093 //         return m_expression == other.kEduVocEntry();
00094 //     }
00095 
00096 //     void Expression::setTranslation( int index, QObject* translation ) {
00097 //         Translation * t = dynamic_cast<Translation*>(translation);
00098 //         m_expression->setTranslation(index,t->kEduVocTranslation());
00099 //     }
00100 
00101     void Expression::setTranslations ( QStringList translations )
00102     {
00103         if ( m_expression ) delete m_expression;
00104         m_expression = new KEduVocExpression ( translations );
00105     }
00106 
00107     QObject* Expression::translation ( int index ) const
00108     {
00109         return new Translation ( m_expression->translation ( index ) );
00110     }
00111 }
00112 
00113 

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