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

parley

  • sources
  • kde-4.12
  • 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 { return m_expression; }
71 
72  template <class T, class S>
73  QVariantList toVariantList ( QList<T*> objList ) const;
74 
75  //Property: lesson [get method - read-only]
76  QObject * lesson() const { return new Lesson ( m_expression->lesson() ); }
77 
78  /* returns flag if entry is activated for queries */
79  bool isActive() const { return m_expression->isActive(); }
80  /* set entry active (enabled for queries) */
81  void setActive ( bool flag = true ) { m_expression->setActive ( flag ); }
82 
83  //Property: sizeHing [get/set methods] (not implemented in KEduVocExpression)
84  //int sizeHint() const { return m_expression->sizeHint(); }
85  //void setSizeHint( int sizeHint ) { m_expression->setSizeHint(sizeHint); }
86 
87  //for assignlable type
88 // Expression & operator= ( const Expression &other );
89 // bool operator== ( const Expression &other ) const;
90 
91  public slots:
92 
96  void resetGrades ( int index ) { m_expression->resetGrades ( index ); }
97 
98  //not implemented in KEduVocExpression
99 // void setTranslation( int index, QObject* translation );
100 
116  void setTranslation ( int index, const QString &expression )
117  {
118  m_expression->setTranslation ( index,expression );
119  }
120 
132  void setTranslations ( QStringList translations );
133 
144  void removeTranslation ( int index ) { m_expression->removeTranslation ( index ); }
145 
151  QObject* translation ( int index ) const;
152 
154  QVariantList translationIndices() const;
155 
166  QVariantList translations() const;
167 
177  QStringList translationTexts() const;
178 
179  private:
180  KEduVocExpression* m_expression;
181  };
182 
183  //Template functions should not be separated from their definition (must be in the header file)
184  template <class T, class S>
185  QVariantList Expression::toVariantList ( QList<T*> objList ) const
186  {
187  QVariantList list;
188  foreach ( T * t, objList )
189  {
190  QObject * obj = new S ( t );
191  list.push_back ( qVariantFromValue ( obj ) );
192  }
193  return list;
194  }
195 
196 
197 }
198 
199 #endif
Scripting::Expression::toVariantList
QVariantList toVariantList(QList< T * > objList) const
Definition: expression.h:185
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:144
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:116
Scripting::Expression::isActive
bool isActive() const
Definition: expression.h:79
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:107
Scripting::Expression::translations
QVariantList translations() const
Returns a list of all the translations of an entry.
Definition: expression.cpp:60
QObject
Scripting::Expression::lesson
QObject * lesson() const
Definition: expression.h:76
Scripting::Expression::setActive
void setActive(bool flag=true)
Definition: expression.h:81
Scripting::Expression::setTranslations
void setTranslations(QStringList translations)
Sets the translations of an entry.
Definition: expression.cpp:101
Scripting::Expression::translationTexts
QStringList translationTexts() const
Returns a list of all the translations texts of an entry.
Definition: expression.cpp:73
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:96
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:05 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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