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

parley

  • sources
  • kde-4.14
  • kdeedu
  • parley
  • src
  • scripts
  • scripting
expression.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 SCRIPTINGEXPRESSION_H
16 #define SCRIPTINGEXPRESSION_H
17 
18 #include <keduvocexpression.h>
19 
20 #include "lesson.h"
21 
22 #include <QObject>
23 #include <QVariantList>
24 
25 namespace Scripting
26 {
27 
28 class Translation;
29 
35 class Expression : public QObject
36 {
37  Q_OBJECT
39  Q_PROPERTY(QObject * lesson READ lesson)
41  Q_PROPERTY(bool active READ isActive WRITE setActive)
42 // Q_PROPERTY ( int sizeHint READ sizeHint WRITE setSizeHint)
43 public:
44  /* default constructor for an empty vocabulary expression
45  */
46  Expression();
47 
48  /* Constructor for a vocabulary expression with one translation
49  *
50  * @param expression translation
51  */
52  Expression(const QString & expression);
53 
54  /*
55  * Constructor for vocabulary expression with more than one translation
56  * @param translations
57  */
58  Expression(const QStringList & translations);
59 
60  Expression(const Expression & other);
61 
62  /*
63  * Constructor from a KEduVocExpression (doesn't exist in KEduVocExpression)
64  * @param expression KEduVocExpression object
65  */
66  Expression(KEduVocExpression * expression);
67 
68  ~Expression();
69 
70  KEduVocExpression * kEduVocExpression() const {
71  return m_expression;
72  }
73 
74  template <class T, class S>
75  QVariantList toVariantList(QList<T*> objList) const;
76 
77  //Property: lesson [get method - read-only]
78  QObject * lesson() const {
79  return new Lesson(m_expression->lesson());
80  }
81 
82  /* returns flag if entry is activated for queries */
83  bool isActive() const {
84  return m_expression->isActive();
85  }
86  /* set entry active (enabled for queries) */
87  void setActive(bool flag = true) {
88  m_expression->setActive(flag);
89  }
90 
91  //Property: sizeHing [get/set methods] (not implemented in KEduVocExpression)
92  //int sizeHint() const { return m_expression->sizeHint(); }
93  //void setSizeHint( int sizeHint ) { m_expression->setSizeHint(sizeHint); }
94 
95  //for assignlable type
96 // Expression & operator= ( const Expression &other );
97 // bool operator== ( const Expression &other ) const;
98 
99 public slots:
100 
104  void resetGrades(int index) {
105  m_expression->resetGrades(index);
106  }
107 
108  //not implemented in KEduVocExpression
109 // void setTranslation( int index, QObject* translation );
110 
126  void setTranslation(int index, const QString &expression) {
127  m_expression->setTranslation(index, expression);
128  }
129 
141  void setTranslations(QStringList translations);
142 
153  void removeTranslation(int index) {
154  m_expression->removeTranslation(index);
155  }
156 
162  QObject* translation(int index) const;
163 
165  QVariantList translationIndices() const;
166 
177  QVariantList translations() const;
178 
188  QStringList translationTexts() const;
189 
190 private:
191  KEduVocExpression* m_expression;
192 };
193 
194 //Template functions should not be separated from their definition (must be in the header file)
195 template <class T, class S>
196 QVariantList Expression::toVariantList(QList<T*> objList) const
197 {
198  QVariantList list;
199  foreach(T * t, objList) {
200  QObject * obj = new S(t);
201  list.push_back(qVariantFromValue(obj));
202  }
203  return list;
204 }
205 
206 
207 }
208 
209 #endif
Scripting::Expression::toVariantList
QVariantList toVariantList(QList< T * > objList) const
Definition: expression.h:196
Scripting::Expression::active
bool active
Specifies if the entry is active or not (enabled for queries or not)
Definition: expression.h:41
Scripting::Expression::removeTranslation
void removeTranslation(int index)
removes a translation
Definition: expression.h:153
Scripting::Expression::translationIndices
QVariantList translationIndices() const
Returns a list of integers (the translation indices)
Definition: expression.cpp:50
Scripting::Expression::setTranslation
void setTranslation(int index, const QString &expression)
Add a translation to this expression.
Definition: expression.h:126
Scripting::Expression::isActive
bool isActive() const
Definition: expression.h:83
Scripting::Lesson
KEduVocLesson wrapping class for Kross scripts.
Definition: lesson.h:47
Scripting::Expression::translation
QObject * translation(int index) const
Get the translation of a specified index (translation index)
Definition: expression.cpp:104
Scripting::Expression::translations
QVariantList translations() const
Returns a list of all the translations of an entry.
Definition: expression.cpp:59
Scripting::Expression::lesson
QObject * lesson() const
Definition: expression.h:78
QObject
Scripting::Expression::setActive
void setActive(bool flag=true)
Definition: expression.h:87
Scripting::Expression::setTranslations
void setTranslations(QStringList translations)
Sets the translations of an entry.
Definition: expression.cpp:98
QString
QList
Scripting::Expression::translationTexts
QStringList translationTexts() const
Returns a list of all the translations texts of an entry.
Definition: expression.cpp:71
QStringList
lesson.h
Scripting::Expression::kEduVocExpression
KEduVocExpression * kEduVocExpression() const
Definition: expression.h:70
Scripting::Expression
This class represents.
Definition: expression.h:35
Scripting::Expression::resetGrades
void resetGrades(int index)
reset all grades of the entry
Definition: expression.h:104
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:56 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
  • 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