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

parley

Scripting::Lesson

Scripting::Lesson Class Reference

KEduVocLesson wrapping class for Kross scripts. More...

#include <lesson.h>

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

List of all members.

Public Slots

void appendChildLesson (Lesson *child)
void appendEntry (Expression *entry)
void appendNewEntry (QStringList translations)
QObject * childLesson (const QString &name)
QObject * childLesson (int row)
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 (QStringList translations)
QObject * newEntry ()
void removeChildLesson (int row)
void removeEntry (QObject *entry)
void setEntries (QVariantList entries)

Public Member Functions

 Lesson (const QString &name)
 Lesson (KEduVocContainer *container)
 Lesson (KEduVocLesson *lesson)
 ~Lesson ()

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 <avgoustinos.kadis@kdemail.net>

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  )  [inline, slot]

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:
entry The 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:
translations A string list with the translations (in same order as their identifiers)

Definition at line 141 of file lesson.cpp.

QObject* Scripting::Lesson::childLesson ( const QString &  name  )  [inline, slot]

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

Parameters:
name lesson name
Returns:
the child lesson

Definition at line 201 of file lesson.h.

QObject* Scripting::Lesson::childLesson ( int  row  )  [inline, slot]

Return the child lesson with the corresponding row.

Definition at line 193 of file lesson.h.

int Scripting::Lesson::childLessonCount (  )  const [inline, slot]

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:
recursive If 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:
recursive If 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:
name Name 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 
) [inline, slot]

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:
index Index where the entry will be added
entry The entry to add (can be created by newEntry() function)

Definition at line 99 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:
translations A 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.

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.

void Scripting::Lesson::removeChildLesson ( int  row  )  [inline, slot]

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:
entry A 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

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