parley
expression.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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
00043 public:
00044
00045
00046 Expression ();
00047
00048
00049
00050
00051
00052 Expression ( const QString & expression );
00053
00054
00055
00056
00057
00058 Expression ( const QStringList & translations );
00059
00060 Expression ( const Expression & other );
00061
00062
00063
00064
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
00076 QObject * lesson() const { return new Lesson ( m_expression->lesson() ); }
00077
00078
00079 bool isActive() const { return m_expression->isActive(); }
00080
00081 void setActive ( bool flag = true ) { m_expression->setActive ( flag ); }
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 public slots:
00092
00096 void resetGrades ( int index ) { m_expression->resetGrades ( index ); }
00097
00098
00099
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
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