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

parley

  • Scripting
  • Lesson
Public Slots | Public Member Functions | List of all members
Scripting::Lesson Class Reference

#include <lesson.h>

Inheritance diagram for Scripting::Lesson:
Inheritance graph
[legend]

Public Slots

void appendChildLesson (Lesson *child)
 
void appendEntry (Expression *entry)
 
void appendNewEntry (QStringList translations)
 
QObject * childLesson (int row)
 
QObject * childLesson (const QString &name)
 
int childLessonCount () const
 
QVariantList childLessons (bool recursive=false)
 
void clearEntries ()
 
QVariantList entries (bool recursive=false) const
 
QObject * entry (int row, bool recursive=false)
 
int entryCount (bool recursive=false)
 
QObject * findChildLesson (const QString &name)
 
void insertChildLesson (int row, Lesson *child)
 
void insertEntry (int index, Expression *entry)
 
QObject * newEntry ()
 
QObject * newEntry (QStringList translations)
 
void removeChildLesson (int row)
 
void removeEntry (QObject *entry)
 
void setEntries (QVariantList entries)
 
- Public Slots inherited from Scripting::Container
double averageGrade (int translation, bool recursive)
 
int expressionsOfGrade (int translation, unsigned int grade, bool recursive)
 
void resetGrades (int translation, bool recursive)
 
int row () const
 

Public Member Functions

 Lesson (KEduVocLesson *lesson)
 
 Lesson (KEduVocContainer *container)
 
 Lesson (const QString &name)
 
 ~Lesson ()
 
- Public Member Functions inherited from Scripting::Container
 Container (KEduVocContainer *container=0)
 
 ~Container ()
 
void appendChildContainer (Container *child)
 
Container * childContainer (int row)
 
Container * childContainer (const QString &name)
 
int childContainerCount () const
 
QVariantList childContainers ()
 
KEduVocContainer * findContainer (const QString &name)
 
QString imageUrl ()
 
bool inPractice ()
 
void insertChildContainer (int row, Container *child)
 
KEduVocContainer * kEduVocContainer ()
 
QString name ()
 
void removeChildContainer (int row)
 
void removeTranslation (int translation)
 
void setImageUrl (const QString &url)
 
void setInPractice (bool inPractice)
 
void setName (const QString &name)
 
template<class T , class S >
QVariantList toVariantList (QList< T * > objList) const
 

Additional Inherited Members

- Static Public Member Functions inherited from Scripting::Container
static
KEduVocContainer::EnumEntriesRecursive 
boolToEnum (bool recursive)
 
static bool enumToBool (KEduVocContainer::EnumEntriesRecursive recursive)
 
static QList< KEduVocContainer * > flattenContainer (KEduVocContainer *root)
 
- Protected Attributes inherited from Scripting::Container
KEduVocContainer * m_container
 
- Properties inherited from Scripting::Container
QString imageUrl
 
bool inPractice
 
QString name
 

Detailed Description

KEduVocLesson wrapping class for Kross scripts.

The Lesson class gives access to lesson properties, entries and child-lessons. The lesson properties documentation can be found in Container class as well as few function's documentation.

The main way of accessing the lesson entries is with the entries() function which allows you to iterate through all the lesson entries (recursively also) and access their properties and modifiy them (see entries() function example code). For individual entry access use the entry(int) function.

To add new entries to a lesson you can use the following ways:

  • newEntry() or newEntry(QStringList) with appendEntry() or insertEntry() function
  • appendNewEntry() function [easiest way]

To remove an entry use the removeEntry() function

Author
Avgoustinos Kadis avgou.nosp@m.stin.nosp@m.os.ka.nosp@m.dis@.nosp@m.kdema.nosp@m.il.n.nosp@m.et

Definition at line 47 of file lesson.h.

Constructor & Destructor Documentation

Scripting::Lesson::Lesson ( KEduVocLesson *  lesson)

Definition at line 24 of file lesson.cpp.

Scripting::Lesson::Lesson ( KEduVocContainer *  container)

Definition at line 29 of file lesson.cpp.

Scripting::Lesson::Lesson ( const QString &  name)

Definition at line 35 of file lesson.cpp.

Scripting::Lesson::~Lesson ( )

Definition at line 42 of file lesson.cpp.

Member Function Documentation

void Scripting::Lesson::appendChildLesson ( Lesson *  child)
inlineslot

Appends a child lesson under the current lesson.

Definition at line 177 of file lesson.h.

void Scripting::Lesson::appendEntry ( Expression *  entry)
slot

Appends an entry at the end of the lesson.

import Parley
lesson = Parley.doc.findLesson("Lesson 2")
if lesson != None:
new_entry = lesson.newEntry(["hello","bonjour"])
lesson.appendEntry(new_entry)
Parameters
entryThe entry to add the lesson

Definition at line 94 of file lesson.cpp.

void Scripting::Lesson::appendNewEntry ( QStringList  translations)
slot

Creates and appends a new entry with the given translations.

#how to add a new entry with appendNewEntry()
import Parley
lesson = Parley.doc.rootLesson
lesson.appendNewEntry(["good morning","bonjour"])
lesson.appendNewEntry(["play","jouer"])
Parameters
translationsA string list with the translations (in same order as their identifiers)

Definition at line 141 of file lesson.cpp.

QObject* Scripting::Lesson::childLesson ( int  row)
inlineslot

Return the child lesson with the corresponding row.

Definition at line 193 of file lesson.h.

QObject* Scripting::Lesson::childLesson ( const QString &  name)
inlineslot

Retrieve a child container by its name Returns 0 if no container is found.

Parameters
namelesson name
Returns
the child lesson

Definition at line 201 of file lesson.h.

int Scripting::Lesson::childLessonCount ( ) const
inlineslot

Returns how many child lessons exist under this lesson.

Definition at line 236 of file lesson.h.

QVariantList Scripting::Lesson::childLessons ( bool  recursive = false)
slot

Returns a list of all the child lessons.

#how to access the all the lessons
import Parley
for lesson in Parley.doc.rootLesson.childLessons(True):
print lesson.name
Parameters
recursiveIf true, then will return the child lessons recursively
Returns
A List with Lesson objects (child lessons)

Definition at line 58 of file lesson.cpp.

void Scripting::Lesson::clearEntries ( )
slot

Removes all the lesson entries (not recursively)

Definition at line 118 of file lesson.cpp.

QVariantList Scripting::Lesson::entries ( bool  recursive = false) const
slot

Returns a list of all the entries of a lesson.

import Parley
entries = Parley.doc.rootLesson.entries(True)
for entry in entries
print entry.translationTexts()
Parameters
recursiveIf true, then will return recursively all the entries below this lesson
Returns
A list of Expression objects (entries)

Definition at line 65 of file lesson.cpp.

QObject * Scripting::Lesson::entry ( int  row,
bool  recursive = false 
)
slot

Returns the entry of the given row.

If recursive is true then it considers all the entries of the sublessons too.

Definition at line 84 of file lesson.cpp.

int Scripting::Lesson::entryCount ( bool  recursive = false)
slot

Returns how many entries are in this lesson (or with sublessons if recursive is true)

Definition at line 89 of file lesson.cpp.

QObject * Scripting::Lesson::findChildLesson ( const QString &  name)
slot

Searches through all the child lessons (recursively) and returns the first lesson the specified name.

#how to search for a lesson
import Parley
lesson = Parley.doc.rootLesson.findChildLesson("Lesson 5")
if lesson != None:
print "found"
print lesson.name
else:
print "not found"
Parameters
nameName of the lesson to look for
Returns
A reference to a lesson if found. 0 otherwise

Definition at line 147 of file lesson.cpp.

void Scripting::Lesson::insertChildLesson ( int  row,
Lesson *  child 
)
inlineslot

Inserts a child lesson (child) on the specified row.

Definition at line 181 of file lesson.h.

void Scripting::Lesson::insertEntry ( int  index,
Expression *  entry 
)
slot

Insert an entry on a specific index.

Parameters
indexIndex where the entry will be added
entryThe entry to add (can be created by newEntry() function)

Definition at line 99 of file lesson.cpp.

QObject * Scripting::Lesson::newEntry ( )
slot

Creates and returns a new Expression Object.

#how to add a new entry
import Parley
lesson = Parley.doc.findLesson("Lesson 2")
if lesson != None:
new_entry = lesson.newEntry()
new_entry.setTranslation(0,"day")
new_entry.setTranslation(0,"jour")
lesson.appendEntry(new_entry)

Definition at line 126 of file lesson.cpp.

QObject * Scripting::Lesson::newEntry ( QStringList  translations)
slot

Creates and returns a new Expression Object.

import Parley
lesson = Parley.doc.findLesson("Lesson 2")
if lesson != None:
new_entry = lesson.newEntry(["hello","bonjour"])
lesson.appendEntry(new_entry)
Parameters
translationsA list with the translations of this entry (must be in correct order)
Returns
A new Expression object

Definition at line 136 of file lesson.cpp.

void Scripting::Lesson::removeChildLesson ( int  row)
inlineslot

Remove child lesson of the specified row.

Definition at line 189 of file lesson.h.

void Scripting::Lesson::removeEntry ( QObject *  entry)
slot

Removes an entry from this lesson.

#how to remove all the entries with the word "play" (from all lessons)
import Parley
for lesson in Parley.doc.allLessons():
for entry in lesson.entries():
for tr in entry.translations():
if tr.text == "play":
lesson.remove(entry)
Parameters
entryA reference to the entry to remove
Note
parameter has to be QObject (tried with Expression * entry but didn't work)

Definition at line 104 of file lesson.cpp.

void Scripting::Lesson::setEntries ( QVariantList  entries)
slot

Definition at line 70 of file lesson.cpp.


The documentation for this class was generated from the following files:
  • lesson.h
  • lesson.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:06 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