• 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)
 

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 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 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)
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 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
lessonLesson 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
nameLanguage description ex. "American English"
localeLanguage locale ex. "en_US"

Definition at line 100 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 114 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 121 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)
inlinestaticslot

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)
inlinestaticslot

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
nameName 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)
inlineslot

Returns the identifier of translation index.

Parameters
indexnumber 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
inlineslot
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 
)
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 360 of file document.h.

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

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)
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 247 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 481 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 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" ) 
)
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 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
trTranslation object to set it's word type
wordtypeWord 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
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-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