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

parley

  • Scripting
  • Parley
Public Types | Public Slots | Signals | Public Member Functions | Properties | List of all members
Scripting::Parley Class Reference

#include <parley.h>

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

Public Types

enum  Flags {
  NoInformation = 0x0, Masculine = 0x1, Feminine = 0x2, Neuter = 0x4,
  Singular = 0x10, Dual = 0x20, Plural = 0x40, Verb = 0x100,
  Noun = 0x200, Pronoun = 0x400, Adjective = 0x800, Adverb = 0x1000,
  Article = 0x2000, Conjunction = 0x4000, First = 0x10000, Second = 0x20000,
  Third = 0x40000, Nominative = 0x80000, Genitive = 0x100000, Dative = 0x200000,
  Accusative = 0x400000, Ablative = 0x800000, Locative = 0x1000000, Vocative = 0x2000000,
  Definite = 0x4000000, Indefinite = 0x8000000, Regular = 0x10000000, Irregular = 0x20000000
}
 

Public Slots

void addTranslation (QString word, QString fromLanguage, QString toLanguage, QString translation)
 
QStringList dataDirs ()
 
QString localeName (QString locale)
 
QStringList locales ()
 
QObject * newAction (const QString &name, const QString &text=QString())
 
QObject * newDocument ()
 
void open (QString filename)
 
QStringList pluginDirs ()
 
QVariantList selectedEntries ()
 
QVariantList selectedTranslations ()
 

Signals

void translateWord (const QString &word, const QString &fromLanguage, const QString &toLanguage)
 
void translationFinished (const QString &word, const QString &fromLanguage, const QString &toLanguage)
 
void translationStarted (const QString &word, const QString &fromLanguage, const QString &toLanguage)
 

Public Member Functions

 Parley (Editor::EditorWindow *editor)
 
 ~Parley ()
 
QObject * activeLesson ()
 
void callTranslateWord (const QString &word, const QString &fromLanguage, const QString &toLanguage)
 
QObject * getDocument ()
 
Translator * translator ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 

Properties

QObject activeLesson
 
QObject doc
 
QObject document
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 

Detailed Description

Parley scripting class (main entry point of a Parley Kross script)

Parley class is the main entry point of Parley scripting classes. Through it you can access the Document class (Parley.doc or Parley.document) which provides functionality for viewing/modifying a Parley document (KEduVocDocument), that means access lessons, entries, document languages etc.

The Parley class has to do more with the active Parley application. Here it follows a list of possible usages of Parley class:

  • Add a new Action to the script menu (see Parley::newAction() function)
  • Add a new translation script (see Parley::translateWord() signal)
  • Have direct access to the active lesson (see Parley::activeLesson property)
  • Have access to various enumerations (see Parley::Number, Parley::Case, Parley::Person, Parley::Gender and Parley::Definiteness enumerations)
  • Create a new Parley Document (see Parley::newDocument() function)

Signals and Slots: To connect a script function (slot) to a signal you just define a function with the same name as the signal or use the Parley.connect function:

#how to connect a function to a signal (example with Parley::translateWord() signal)
def translateFromInternet(word,fromLang,toLang):
print "Translating from Internet!!.."
Parley.connect("translateWord(const QString &,const QString &,const QString &)",translateFromInternet)
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 152 of file parley.h.

Member Enumeration Documentation

enum Scripting::Parley::Flags
Enumerator
NoInformation 
Masculine 
Feminine 
Neuter 
Singular 
Dual 
Plural 
Verb 
Noun 
Pronoun 
Adjective 
Adverb 
Article 
Conjunction 
First 
Second 
Third 
Nominative 
Genitive 
Dative 
Accusative 
Ablative 
Locative 
Vocative 
Definite 
Indefinite 
Regular 
Irregular 

Definition at line 167 of file parley.h.

Constructor & Destructor Documentation

Scripting::Parley::Parley ( Editor::EditorWindow *  editor)

Definition at line 42 of file parley.cpp.

Scripting::Parley::~Parley ( )

Definition at line 48 of file parley.cpp.

Member Function Documentation

QObject* Scripting::Parley::activeLesson ( )
void Scripting::Parley::addTranslation ( QString  word,
QString  fromLanguage,
QString  toLanguage,
QString  translation 
)
slot

Adds the found translation of the word from language fromLanguage to language toLanguage to Parley translations to be used for translating lesson entries (or anything else).

This function is ment to be used by scripts to add a translation of a word by parsing either online or offline dictionaries.

#example usage of addTranslation function
import Parley
#function called by Parley whenever a translation of a word is needed
def translateWord(word,fromLang,toLang):
<<look for the word translation>>
Parley.addTranslation(word,fromLang,toLang,foundWord)
<<look for more translations>>
Parameters
wordTranslated word
fromLanguageFrom language
toLanguageTo language
translationTranslation of word

Definition at line 61 of file parley.cpp.

void Scripting::Parley::callTranslateWord ( const QString &  word,
const QString &  fromLanguage,
const QString &  toLanguage 
)

Definition at line 54 of file parley.cpp.

QStringList Scripting::Parley::dataDirs ( )
inlineslot

Definition at line 239 of file parley.h.

QObject* Scripting::Parley::getDocument ( )
inline

Definition at line 230 of file parley.h.

QString Scripting::Parley::localeName ( QString  locale)
slot

Gives the language name of the given locale.

Parameters
localeLanguage locale
Returns
Language name

Definition at line 73 of file parley.cpp.

QStringList Scripting::Parley::locales ( )
slot

Returns a list of all available locales (to be used by the scripts)

Returns
Todo:
Change it into a QMap property (Parley.languageCodes)

Definition at line 67 of file parley.cpp.

QObject * Scripting::Parley::newAction ( const QString &  name,
const QString &  text = QString() 
)
slot

Creates and adds to the Scripts menu a new KAction (see KAction documentation)

#how to add two new Scripts menu entries
import Parley
def convertLessonToPDF():
print "Converting lesson to PDF.."
def convertLessonToHTML():
print "Converting lesson to HTML.."
#one way of creating a new action
newaction_pdf = Parley.newAction("convert_lesson_pdf")
newaction_pdf.text="Convert Lesson to PDF"
Parley.connect(newaction_pdf,"triggered()",convertLessonToPDF)
#second way of creating a new action (short)
newaction_html = Parley.newAction("convert_lesson_html","Convert Lesson to HTML")
Parley.connect(newaction_html,"triggered()",convertLessonToHTML)
Parameters
nameUnique action name
textAction's text (what text appears in the scripts menu)
Returns
A reference to a KAction object (accessible by scripts)

Definition at line 145 of file parley.cpp.

QObject* Scripting::Parley::newDocument ( )
inlineslot

Creates a new document and returns a reference to it.

#how to create a new document, add lessons, add entries and save it to a kvtml file
import Parley
#create new document
doc = Parley.newDocument()
doc.title = "New document"
#set identifiers
doc.appendNewIdentifier("English","en_US")
doc.appendNewIdentifier("French","fr")
#lessons
l1 = doc.newLesson("Lesson1")
doc.rootLesson.appendChildLesson(l1)
#add a new entry (first way)
e = l1.newEntry()
e.setTranslation(0,"dog")
e.setTranslation(1,"chien")
l1.appendEntry(e)
#add a new entry (second way)
ee = l1.newEntry(["glass","verre"])
l1.appendEntry(ee)
#third way
ee = l1.appendNewEntry(["book","livre"])
#add a new lesson (fast way)
l2 = doc.appendNewLesson("Lesson 2")
#add a new child lesson under "Lesson 2"
l3 = doc.appendNewLesson("Lesson 3",l2)
#add a new entry (third way)
l2.appendNewEntry(["I","je"]);
l3.appendNewEntry(["good morning","bonjour"])
#save document
doc.saveAs("/home/kde-devel/test_new_document.kvtml")
Returns
A Document object, the newly created lesson

Definition at line 344 of file parley.h.

void Scripting::Parley::open ( QString  filename)
slot
Todo:
Make this function working (not very important function)

Definition at line 78 of file parley.cpp.

QStringList Scripting::Parley::pluginDirs ( )
inlineslot

Definition at line 243 of file parley.h.

QVariantList Scripting::Parley::selectedEntries ( )
slot

Returns a list of Expression objects (the selected entries of the active lesson)

Definition at line 90 of file parley.cpp.

QVariantList Scripting::Parley::selectedTranslations ( )
slot

Returns a list of Translation objects (the selected translations of the active lesson)

Definition at line 116 of file parley.cpp.

void Scripting::Parley::translateWord ( const QString &  word,
const QString &  fromLanguage,
const QString &  toLanguage 
)
signal

Slots (script functions) connected to this signal are called when a translation of word is requested.

Note that a script function with the same name as a signal will be automatically connected to that signal when the script is activated.

#example usage of translateWord signal
import Parley
#function called by Parley whenever a translation of a word is needed
def translateWord(word,fromLang,toLang):
<<look for the word translation>>
Parley.addTranslation(word,fromLang,toLang,foundWord)
<<look for more translations>>
Parameters
wordWord to translate
fromLanguageThe language of word to translate from
toLanguageThe language you want to translate to
void Scripting::Parley::translationFinished ( const QString &  word,
const QString &  fromLanguage,
const QString &  toLanguage 
)
signal
void Scripting::Parley::translationStarted ( const QString &  word,
const QString &  fromLanguage,
const QString &  toLanguage 
)
signal
Translator* Scripting::Parley::translator ( )
inline

Definition at line 225 of file parley.h.

Property Documentation

QObject * Scripting::Parley::activeLesson
read

Currently active lesson.

Definition at line 160 of file parley.h.

QObject Scripting::Parley::doc
read

Abreviation of document property (same as Parley.document)

Definition at line 158 of file parley.h.

QObject Scripting::Parley::document
read

Read-only property of the active document.

Definition at line 156 of file parley.h.


The documentation for this class was generated from the following files:
  • parley.h
  • parley.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:57 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