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

parley

Scripting::Document

Scripting::Document Class Reference

KEduVocDocument wrapping class for Kross scripts. More...

#include <document.h>

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

List of all members.

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, Lesson *parent)
QObject * appendNewLesson (const QString &name)
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 (KEduVocDocument *doc)
 Document (QObject *parent=0)
 ~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)

Properties

QString author
QString authorContact
QString category
QString csvDelimiter
QString documentComment
QString generator
QString license
QObject rootLesson
QString title
QString url
QString version

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

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

enum Scripting::Document::FileDialogMode

used as parameter for pattern

Enumerator:
Reading 
Writing 

Definition at line 124 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 131 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  )  [inline, slot]

Appends a new identifier (usually a language).

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

Definition at line 399 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:
lesson Lesson object (the lesson to be added)

Definition at line 108 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:
name Language description ex. "American English"
locale Language locale ex. "en_US"

Definition at line 100 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:
name Lesson name
parent Parent lesson
Returns:
A reference to the new lesson

Definition at line 121 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:
name Lesson name
Returns:
A reference to the new lesson

Definition at line 114 of file document.cpp.

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

Definition at line 164 of file document.h.

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

Definition at line 171 of file document.h.

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

Definition at line 192 of file document.h.

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

Definition at line 215 of file document.h.

static KEduVocDocument::FileType Scripting::Document::detectFileType ( const QString &  fileName  )  [inline, static, slot]

Definition at line 471 of file document.h.

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

Definition at line 185 of file document.h.

static QString Scripting::Document::errorDescription ( int  errorCode  )  [inline, static, slot]

Returns a more detailed description of the errorCode given.

Definition at line 484 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:
name Name of the lesson to look for
Returns:
A reference to a lesson if found. 0 otherwise

Definition at line 128 of file document.cpp.

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

Definition at line 200 of file document.h.

QObject* Scripting::Document::identifier ( int  index  )  [inline, slot]

Returns the identifier of translation index.

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

Definition at line 415 of file document.h.

int Scripting::Document::identifierCount (  )  const [inline, slot]
Returns:
the number of different identifiers (usually languages)

Definition at line 378 of file document.h.

QVariantList Scripting::Document::identifiers (  )  [slot]

Returns a list of all the identifiers of this document.

Definition at line 89 of file document.cpp.

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

Definition at line 143 of file document.h.

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

Definition at line 178 of file document.h.

void Scripting::Document::merge ( Document *  docToMerge,
bool  matchIdentifiers 
) [inline, slot]

Merges data from another document.

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

Definition at line 360 of file document.h.

QObject* Scripting::Document::newIdentifier (  )  [inline, slot]

Creates a new identifier and returns a reference to it.

Returns:

Definition at line 384 of file document.h.

QObject* Scripting::Document::newLesson ( const QString &  name  )  [inline, slot]

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:
name Name of the lesson
Returns:
Lesson object (the new lesson)

Definition at line 247 of file document.h.

static QString Scripting::Document::pattern ( KEduVocDocument::FileDialogMode  mode  )  [inline, static, slot]

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:
mode the mode for the supported document types. See FileDialogMode enum
Returns:
the filter string

Definition at line 481 of file document.h.

void Scripting::Document::removeIdentifier ( int  index  )  [inline, slot]

Removes identifier and the according translations in all entries.

Parameters:
index number of translation 0..x

Definition at line 422 of file document.h.

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

Definition at line 146 of file document.h.

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

Saves the data under the given name.

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

Definition at line 349 of file document.h.

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

Definition at line 161 of file document.h.

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

Definition at line 168 of file document.h.

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

Definition at line 189 of file document.h.

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

Definition at line 222 of file document.h.

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

Definition at line 182 of file document.h.

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

Definition at line 197 of file document.h.

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

Definition at line 175 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 227 of file document.h.

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

Definition at line 204 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:
tr Translation object to set it's word type
wordtype Word type name

Definition at line 62 of file document.cpp.

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

Definition at line 157 of file document.h.

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

Definition at line 230 of file document.h.

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

Definition at line 207 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 77 of file document.cpp.


Property Documentation

QString Scripting::Document::author [read, write]

Document author's name.

Definition at line 74 of file document.h.

QString Scripting::Document::authorContact [read, write]

Author contact info (email).

Definition at line 76 of file document.h.

QString Scripting::Document::category [read, write]

Category that the lesson belongs.

Definition at line 82 of file document.h.

QString Scripting::Document::csvDelimiter [read, write]

Delimiter (separator) used for csv import and export.

Definition at line 88 of file document.h.

QString Scripting::Document::documentComment [read, write]

Comment about the document.

Definition at line 80 of file document.h.

QString Scripting::Document::generator [read, write]

Generator program (which program generates this file).

Definition at line 84 of file document.h.

QString Scripting::Document::license [read, write]

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 [read, write]

Document's title.

Definition at line 72 of file document.h.

QString Scripting::Document::url [read, write]

URL of the XML file.

Definition at line 90 of file document.h.

QString Scripting::Document::version [read, write]

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

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