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

parley

expression.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 SCRIPTINGEXPRESSION_H
00016 #define SCRIPTINGEXPRESSION_H
00017 
00018 #include <keduvocexpression.h>
00019 
00020 #include "lesson.h"
00021 
00022 #include <QObject>
00023 #include <QVariantList>
00024 
00025 namespace Scripting
00026 {
00027 
00028     class Translation;
00029 
00035     class Expression : public QObject
00036     {
00037             Q_OBJECT
00039             Q_PROPERTY ( QObject * lesson READ lesson )
00041             Q_PROPERTY ( bool active READ isActive WRITE setActive )
00042 //             Q_PROPERTY ( int sizeHint READ sizeHint WRITE setSizeHint)
00043         public:
00044             /* default constructor for an empty vocabulary expression
00045              */
00046             Expression ();
00047 
00048             /* Constructor for a vocabulary expression with one translation
00049              *
00050              * @param expression       translation
00051              */
00052             Expression ( const QString & expression );
00053 
00054             /*
00055              * Constructor for vocabulary expression with more than one translation
00056              * @param translations
00057              */
00058             Expression ( const QStringList & translations );
00059 
00060             Expression ( const Expression & other );
00061 
00062             /*
00063              * Constructor from a KEduVocExpression (doesn't exist in KEduVocExpression)
00064              * @param expression KEduVocExpression object
00065              */
00066             Expression ( KEduVocExpression * expression );
00067 
00068             ~Expression();
00069 
00070             KEduVocExpression * kEduVocExpression() const { return m_expression; }
00071 
00072             template <class T, class S>
00073             QVariantList toVariantList ( QList<T*> objList ) const;
00074 
00075             //Property: lesson [get method - read-only]
00076             QObject * lesson() const { return new Lesson ( m_expression->lesson() ); }
00077 
00078             /* returns flag if entry is activated for queries */
00079             bool isActive() const { return m_expression->isActive(); }
00080             /* set entry active (enabled for queries) */
00081             void setActive ( bool flag = true ) { m_expression->setActive ( flag ); }
00082 
00083             //Property: sizeHing [get/set methods] (not implemented in KEduVocExpression)
00084             //int sizeHint() const { return m_expression->sizeHint(); }
00085             //void setSizeHint( int sizeHint ) { m_expression->setSizeHint(sizeHint); }
00086 
00087             //for assignlable type
00088 //             Expression & operator= ( const Expression &other );
00089 //             bool operator== ( const Expression &other ) const;
00090 
00091         public slots:
00092 
00096             void resetGrades ( int index ) { m_expression->resetGrades ( index ); }
00097 
00098             //not implemented in KEduVocExpression
00099 //             void setTranslation( int index, QObject* translation );
00100 
00116             void setTranslation ( int index, const QString &expression )
00117             {
00118                 m_expression->setTranslation ( index,expression );
00119             }
00120 
00132             void setTranslations ( QStringList translations );
00133 
00144             void removeTranslation ( int index ) { m_expression->removeTranslation ( index ); }
00145 
00151             QObject* translation ( int index ) const;
00152 
00154             QVariantList translationIndices() const;
00155 
00166             QVariantList translations() const;
00167 
00177             QStringList translationTexts() const;
00178 
00179         private:
00180             KEduVocExpression* m_expression;
00181     };
00182 
00183     //Template functions should not be separated from their definition (must be in the header file)
00184     template <class T, class S>
00185     QVariantList Expression::toVariantList ( QList<T*> objList ) const
00186     {
00187         QVariantList list;
00188         foreach ( T * t, objList )
00189         {
00190             QObject * obj = new S ( t );
00191             list.push_back ( qVariantFromValue ( obj ) );
00192         }
00193         return list;
00194     }
00195 
00196 
00197 }
00198 
00199 #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