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

parley

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

#include <document.h>

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

Public Types

enum  ErrorCode {
  NoError = 0, Unknown, InvalidXml, FileTypeUnknown,
  FileCannotWrite, FileWriterFailed, FileCannotRead, FileReaderFailed,
  FileDoesNotExist
}
 
enum  FileDialogMode { Reading, Writing }
 
enum  FileType {
  KvdNone, Automatic, Kvtml, Wql,
  Pauker, Vokabeln, Xdxf, Csv,
  Kvtml1
}
 
enum  LessonDeletion { DeleteEmptyLesson, DeleteEntriesAndLesson }
 

Public Slots

QVariantList allLessons ()
 
int appendIdentifier (Identifier *identifier)
 
void appendLesson (QObject *lesson)
 
void appendNewIdentifier (const QString &name, const QString &locale)
 
QObject * appendNewLesson (const QString &name)
 
QObject * appendNewLesson (const QString &name, Lesson *parent)
 
static KEduVocDocument::FileType detectFileType (const QString &fileName)
 
static QString errorDescription (int errorCode)
 
QObject * findLesson (const QString &name)
 
QObject * identifier (int index)
 
int identifierCount () const
 
QVariantList identifiers ()
 
void merge (Document *docToMerge, bool matchIdentifiers)
 
QObject * newIdentifier ()
 
QObject * newLesson (const QString &name)
 
static QString pattern (KEduVocDocument::FileDialogMode mode)
 
void removeIdentifier (int index)
 
int saveAs (const QString &url, KEduVocDocument::FileType ft=KEduVocDocument::Automatic, const QString &generator=QString("Parley"))
 
void setWordType (QObject *tr, const QString &wordtype)
 
QStringList wordTypes ()
 

Public Member Functions

 Document (QObject *parent=0)
 
 Document (KEduVocDocument *doc)
 
 ~Document ()
 
QString author () const
 
QString authorContact () const
 
QString category () const
 
QString csvDelimiter () const
 
QString documentComment () const
 
QString generator () const
 
KEduVocDocument * kEduVocDocument ()
 
QString license () const
 
QObject * rootLesson ()
 
void setAuthor (const QString &author)
 
void setAuthorContact (const QString &authorContact)
 
void setCategory (const QString &category)
 
void setCsvDelimiter (const QString &delimiter)
 
void setDocumentComment (const QString &comment)
 
void setGenerator (const QString &generator)
 
void setLicense (const QString &license)
 
void setTitle (const QString &title)
 
void setUrl (const QString &url)
 
void setVersion (const QString &ver)
 
QString title () const
 
QString url () const
 
QString version () const
 
KEduVocWordType * wordTypeFromString (const QString &name)
 
- 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

QString author
 
QString authorContact
 
QString category
 
QString csvDelimiter
 
QString documentComment
 
QString generator
 
QString license
 
QObject rootLesson
 
QString title
 
QString url
 
QString version
 
- 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

KEduVocDocument wrapping class for Kross scripts.

The Document class provides methods and properties for accessing the document lessons, entries, languages, word types and general document parameters. The easiest way of accessing this class is through the Parley.document (Parley.doc) property like in the example.

#how to get a reference to the Parley's active document
import Parley
doc = Parley.doc
print doc.title, doc.author, doc.authorContact

You can access document lessons with the following ways:

  • Document::rootLesson property
  • allLessons() function
  • findLesson() function

and add a new lesson with

  • newLesson() and appendLesson() function
  • Document::appendNewLesson(const QString &) function
  • Document::appendNewLesson(const QString &,Lesson*) function

The document identifiers (see Identifier class) can be set by these functions:

  • newIdentifier() and appendIdentifier() functions
  • appendNewIdentifier() function
  • removeIdentifier() function (for removing a language)

and be accessed by:

  • as a list with identifiers() function
  • individually by identifier() function
  • and get how many identifiers exist with identifierCount() function

The saveAs() function can be used to save into a file a newly created document, or the active document. See Parley::newDocument().

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 66 of file document.h.

Member Enumeration Documentation

enum Scripting::Document::ErrorCode

the return code when opening/saving

Enumerator
NoError 
Unknown 
InvalidXml 
FileTypeUnknown 
FileCannotWrite 
FileWriterFailed 
FileCannotRead 
FileReaderFailed 
FileDoesNotExist 

Definition at line 109 of file document.h.

enum Scripting::Document::FileDialogMode

used as parameter for pattern

Enumerator
Reading 
Writing 

Definition at line 122 of file document.h.

enum Scripting::Document::FileType

known vocabulary file types

Enumerator
KvdNone 
Automatic 
Kvtml 
Wql 
Pauker 
Vokabeln 
Xdxf 
Csv 
Kvtml1 

Definition at line 96 of file document.h.

enum Scripting::Document::LessonDeletion

delete only empty lessons or also if they have entries

Enumerator
DeleteEmptyLesson 
DeleteEntriesAndLesson 

Definition at line 128 of file document.h.

Constructor & Destructor Documentation

Scripting::Document::Document ( QObject *  parent = 0)

Definition at line 25 of file document.cpp.

Scripting::Document::Document ( KEduVocDocument *  doc)

Definition at line 30 of file document.cpp.

Scripting::Document::~Document ( )

Definition at line 35 of file document.cpp.

Member Function Documentation

QVariantList Scripting::Document::allLessons ( )
slot

Returns all the lessons in the document (including sublessons)

#how to print the names of all the lessons
import Parley
for lesson in Parley.document.allLessons():
print lesson.name
Returns
A list of all the lessons in the document

Definition at line 39 of file document.cpp.

int Scripting::Document::appendIdentifier ( Identifier *  identifier)
inlineslot

Appends a new identifier (usually a language)

Parameters
identifierthe identifier to append. If empty default names are used.
Returns
the identifier number

Definition at line 449 of file document.h.

void Scripting::Document::appendLesson ( QObject *  lesson)
slot

Appends a lesson to the document.

#how to add a new lesson with appendLesson() function
import Parley
newlesson = Parley.doc.newLesson("My New Lesson")
Parley.doc.appendLesson(newlesson)
Parameters
lessonLesson object (the lesson to be added)

Definition at line 104 of file document.cpp.

void Scripting::Document::appendNewIdentifier ( const QString &  name,
const QString &  locale 
)
slot

Append a new identifier by giving the name and locale.

Parameters
nameLanguage description ex. "American English"
localeLanguage locale ex. "en_US"

Definition at line 96 of file document.cpp.

QObject * Scripting::Document::appendNewLesson ( const QString &  name)
slot

Creates a new lesson and appends it to the root lesson.

#how to add a new lesson to the root lesson
import Parley
newlesson = Parley.doc.appendNewLesson("My New Lesson")
Parameters
nameLesson name
Returns
A reference to the new lesson

Definition at line 111 of file document.cpp.

QObject * Scripting::Document::appendNewLesson ( const QString &  name,
Lesson *  parent 
)
slot

Creates a new lesson and appends it to the parent lesson.

#how to add a new lesson under another lesson
import Parley
parentLesson = Parley.doc.appendNewLesson("My Parent Lesson")
childLesson = Parley.doc.appendNewLesson("My new child lesson",parentLesson)
Parameters
nameLesson name
parentParent lesson
Returns
A reference to the new lesson

Definition at line 118 of file document.cpp.

QString Scripting::Document::author ( ) const
inline

Definition at line 170 of file document.h.

QString Scripting::Document::authorContact ( ) const
inline

Definition at line 181 of file document.h.

QString Scripting::Document::category ( ) const
inline

Definition at line 214 of file document.h.

QString Scripting::Document::csvDelimiter ( ) const
inline

Definition at line 247 of file document.h.

static KEduVocDocument::FileType Scripting::Document::detectFileType ( const QString &  fileName)
inlinestaticslot

Definition at line 527 of file document.h.

QString Scripting::Document::documentComment ( ) const
inline

Definition at line 203 of file document.h.

static QString Scripting::Document::errorDescription ( int  errorCode)
inlinestaticslot

Returns a more detailed description of the errorCode given.

Definition at line 544 of file document.h.

QObject * Scripting::Document::findLesson ( const QString &  name)
slot

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

#how to search for a lesson
import Parley
lesson = Parley.doc.findLesson("Lesson 2")
if lesson != None:
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 125 of file document.cpp.

QString Scripting::Document::generator ( ) const
inline

Definition at line 226 of file document.h.

QObject* Scripting::Document::identifier ( int  index)
inlineslot

Returns the identifier of translation index.

Parameters
indexnumber of translation 0..x
Returns
the language identifier: en=english, de=german, ...

Definition at line 467 of file document.h.

int Scripting::Document::identifierCount ( ) const
inlineslot
Returns
the number of different identifiers (usually languages)

Definition at line 424 of file document.h.

QVariantList Scripting::Document::identifiers ( )
slot

Returns a list of all the identifiers of this document.

Definition at line 86 of file document.cpp.

KEduVocDocument* Scripting::Document::kEduVocDocument ( )
inline

Definition at line 139 of file document.h.

QString Scripting::Document::license ( ) const
inline

Definition at line 192 of file document.h.

void Scripting::Document::merge ( Document *  docToMerge,
bool  matchIdentifiers 
)
inlineslot

Merges data from another document.

Parameters
docToMergedocument containing the data to be merged
matchIdentifiersif true only entries having identifiers present in the current document will be mergedurl is empty (or NULL) actual name is preserved

Definition at line 404 of file document.h.

QObject* Scripting::Document::newIdentifier ( )
inlineslot

Creates a new identifier and returns a reference to it.

Returns

Definition at line 432 of file document.h.

QObject* Scripting::Document::newLesson ( const QString &  name)
inlineslot

Creates and returns a new lesson (doesn't add it as a sublesson to any lesson)

#how to add a new lesson to the root lesson
import Parley
newlesson = Parley.doc.newLesson("My New Lesson")
Parley.doc.rootLesson.appendChildLesson(newlesson)
Parameters
nameName of the lesson
Returns
Lesson object (the new lesson)

Definition at line 287 of file document.h.

static QString Scripting::Document::pattern ( KEduVocDocument::FileDialogMode  mode)
inlinestaticslot

Create a string with the supported document types, that can be used as filter in KFileDialog.

It includes also an entry to match all the supported types.

Parameters
modethe mode for the supported document types. See FileDialogMode enum
Returns
the filter string

Definition at line 539 of file document.h.

void Scripting::Document::removeIdentifier ( int  index)
inlineslot

Removes identifier and the according translations in all entries.

Parameters
indexnumber of translation 0..x

Definition at line 476 of file document.h.

QObject* Scripting::Document::rootLesson ( )
inline

Definition at line 144 of file document.h.

int Scripting::Document::saveAs ( const QString &  url,
KEduVocDocument::FileType  ft = KEduVocDocument::Automatic,
const QString &  generator = QString("Parley") 
)
inlineslot

Saves the data under the given name.

Parameters
urlif url is empty (or NULL) actual name is preserved
ftthe filetype to be used when saving the document (default value: Automatic). See enum FileType.
generatorthe name of the application saving the document (default value: "Parley")
Returns
ErrorCode

Definition at line 391 of file document.h.

void Scripting::Document::setAuthor ( const QString &  author)
inline

Definition at line 165 of file document.h.

void Scripting::Document::setAuthorContact ( const QString &  authorContact)
inline

Definition at line 176 of file document.h.

void Scripting::Document::setCategory ( const QString &  category)
inline

Definition at line 209 of file document.h.

void Scripting::Document::setCsvDelimiter ( const QString &  delimiter)
inline

Definition at line 256 of file document.h.

void Scripting::Document::setDocumentComment ( const QString &  comment)
inline

Definition at line 198 of file document.h.

void Scripting::Document::setGenerator ( const QString &  generator)
inline

Definition at line 221 of file document.h.

void Scripting::Document::setLicense ( const QString &  license)
inline

Definition at line 187 of file document.h.

void Scripting::Document::setTitle ( const QString &  title)
inline

Definition at line 154 of file document.h.

void Scripting::Document::setUrl ( const QString &  url)
inline

Definition at line 263 of file document.h.

void Scripting::Document::setVersion ( const QString &  ver)
inline

Definition at line 232 of file document.h.

void Scripting::Document::setWordType ( QObject *  tr,
const QString &  wordtype 
)
slot

Sets the word type (wordtype) of the given tr translation object.

If the wordtype is not valid, no changes are made to the translation object

Parameters
trTranslation object to set it's word type
wordtypeWord type name

Definition at line 61 of file document.cpp.

QString Scripting::Document::title ( ) const
inline

Definition at line 159 of file document.h.

QString Scripting::Document::url ( ) const
inline

Definition at line 268 of file document.h.

QString Scripting::Document::version ( ) const
inline

Definition at line 237 of file document.h.

KEduVocWordType * Scripting::Document::wordTypeFromString ( const QString &  name)

Definition at line 45 of file document.cpp.

QStringList Scripting::Document::wordTypes ( )
slot

Returns a string list with all the available word type's names.

Definition at line 75 of file document.cpp.

Property Documentation

QString Scripting::Document::author
readwrite

Document author's name.

Definition at line 74 of file document.h.

QString Scripting::Document::authorContact
readwrite

Author contact info (email)

Definition at line 76 of file document.h.

QString Scripting::Document::category
readwrite

Category that the lesson belongs.

Definition at line 82 of file document.h.

QString Scripting::Document::csvDelimiter
readwrite

Delimiter (separator) used for csv import and export.

Definition at line 88 of file document.h.

QString Scripting::Document::documentComment
readwrite

Comment about the document.

Definition at line 80 of file document.h.

QString Scripting::Document::generator
readwrite

Generator program (which program generates this file)

Definition at line 84 of file document.h.

QString Scripting::Document::license
readwrite

Document license.

Definition at line 78 of file document.h.

QObject Scripting::Document::rootLesson
read

Document's root lesson.

Definition at line 70 of file document.h.

QString Scripting::Document::title
readwrite

Document's title.

Definition at line 72 of file document.h.

QString Scripting::Document::url
readwrite

URL of the XML file.

Definition at line 90 of file document.h.

QString Scripting::Document::version
readwrite

Document version.

Definition at line 86 of file document.h.


The documentation for this class was generated from the following files:
  • document.h
  • document.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