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

parley

  • sources
  • kde-4.12
  • kdeedu
  • parley
  • src
  • scripts
  • scripting
document.h
Go to the documentation of this file.
1 /***************************************************************************
2 
3  Copyright 2008 Avgoustinos Kadis <avgoustinos.kadis@kdemail.net>
4 
5  ***************************************************************************/
6 
7 /***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef SCRIPTOBJECTDOCUMENT_H
16 #define SCRIPTOBJECTDOCUMENT_H
17 
18 #include <keduvocdocument.h>
19 
20 #include "lesson.h"
21 #include "identifier.h"
22 
23 #include <QObject>
24 
25 namespace Scripting
26 {
27  class Translation;
28 
66  class Document : public QObject
67  {
68  Q_OBJECT
70  Q_PROPERTY ( QObject * rootLesson READ rootLesson )
72  Q_PROPERTY ( QString title READ title WRITE setTitle )
74  Q_PROPERTY ( QString author READ author WRITE setAuthor )
76  Q_PROPERTY ( QString authorContact READ authorContact WRITE setAuthorContact )
78  Q_PROPERTY ( QString license READ license WRITE setLicense )
80  Q_PROPERTY ( QString documentComment READ documentComment WRITE setDocumentComment )
82  Q_PROPERTY ( QString category READ category WRITE setCategory )
84  Q_PROPERTY ( QString generator READ generator WRITE setGenerator )
86  Q_PROPERTY ( QString version READ version WRITE setVersion )
88  Q_PROPERTY ( QString csvDelimiter READ csvDelimiter WRITE setCsvDelimiter )
90  Q_PROPERTY ( QString url READ url WRITE setUrl )
91 
92  Q_ENUMS ( FileType )
93  public:
94 
96  enum FileType
97  {
98  KvdNone,
99  Automatic,
100  Kvtml,
101  Wql,
102  Pauker,
103  Vokabeln,
104  Xdxf,
105  Csv,
106  Kvtml1
107  };
108 
110  enum ErrorCode
111  {
112  NoError = 0,
113  Unknown,
114  InvalidXml,
115  FileTypeUnknown,
116  FileCannotWrite,
117  FileWriterFailed,
118  FileCannotRead,
119  FileReaderFailed,
120  FileDoesNotExist
121  };
122 
124  enum FileDialogMode
125  {
126  Reading,
127  Writing
128  };
129 
131  enum LessonDeletion
132  {
133  DeleteEmptyLesson,
134  DeleteEntriesAndLesson
135  };
136 
137  Document ( QObject* parent = 0 );
138 
139  Document ( KEduVocDocument * doc );
140 
141  ~Document();
142 
143  KEduVocDocument * kEduVocDocument() { return m_doc; }
144 
145  //Property: rootLesson (READ)
146  QObject * rootLesson() { return new Lesson ( m_doc->lesson() ); }
147 
148  KEduVocWordType * wordTypeFromString ( const QString & name );
149 
150  //**** Property Methods ****//
151 
152  /* set the title of the file
153  * @param title title to set */
154  void setTitle ( const QString & title ) { m_doc->setTitle ( title ); }
155 
156  /* @returns the title of the file */
157  QString title() const { return m_doc->title(); }
158 
159  /* set the author of the file
160  * @param author author to set */
161  void setAuthor ( const QString & author ) { m_doc->setAuthor ( author ); }
162 
163  /* @returns the author of the file */
164  QString author() const { return m_doc->author(); }
165 
166  /* set the author contact info
167  * @param contact email/contact info to set */
168  void setAuthorContact ( const QString & authorContact ) { m_doc->setAuthorContact ( authorContact ); }
169 
170  /* @returns the author contact information */
171  QString authorContact() const { return m_doc->authorContact(); }
172 
173  /* set the license of the file
174  * @param license license to set */
175  void setLicense ( const QString & license ) { m_doc->setLicense ( license ); }
176 
177  /* @returns the license of the file */
178  QString license() const { return m_doc->license(); }
179 
180  /* set the comment of the file
181  * @param comment comment to set */
182  void setDocumentComment ( const QString & comment ) { m_doc->setDocumentComment ( comment ); }
183 
184  /* @return the comment of the file */
185  QString documentComment() const { return m_doc->documentComment(); }
186 
187  /* set the category of the file
188  * @param category category to set */
189  void setCategory ( const QString & category ) { m_doc->setCategory ( category ); }
190 
191  /* @return the category of the file */
192  QString category() const { return m_doc->category(); }
193 
194  /*
195  * Sets the generator of the file
196  */
197  void setGenerator ( const QString & generator ) { m_doc->setGenerator ( generator ); }
198 
199  /* @returns the generator of the file */
200  QString generator() const { return m_doc->generator(); }
201 
202  /* Sets version of the loaded file
203  * @param ver the new version */
204  void setVersion ( const QString & ver ) { m_doc->setVersion ( ver ); }
205 
206  /* @returns the version of the loaded file */
207  QString version() const { return m_doc->version(); }
208 
209  /*
210  * Returns the delimiter (separator) used for csv import and export.
211  * The default is a single tab character
212  *
213  * @returns the delimiter used
214  */
215  QString csvDelimiter() const { return m_doc->csvDelimiter(); }
216 
217  /*
218  * Sets the delimiter (separator) used for csv import and export
219  *
220  * @param delimiter the delimiter to use
221  */
222  void setCsvDelimiter ( const QString &delimiter ) { m_doc->setCsvDelimiter ( delimiter ); }
223 
224  /*
225  * Sets the URL of the XML file
226  */
227  void setUrl ( const QString& url ) { m_doc->setUrl ( url ); }
228 
229  /* @returns the URL of the XML file */
230  QString url() const { return m_doc->url().path(); }
231 
232  public slots:
233 
247  QObject * newLesson ( const QString & name ) { return new Lesson ( name ); }
248 
261  void appendLesson ( QObject * lesson );
262 
273  QObject * appendNewLesson ( const QString & name );
274 
287  QObject * appendNewLesson ( const QString & name, Lesson * parent );
288 
299  QVariantList allLessons();
300 
316  QObject * findLesson ( const QString& name );
317 
324  void setWordType ( QObject * tr, const QString & wordtype );
325 
329  QStringList wordTypes();
330 
331 // --------------------- copied from KEduVocDocument
332 
333  /*
334  * Open a document file
335  *
336  * @param url url to file to open
337  * @returns ErrorCode
338  */
339 // int open ( const QString & url ) { return m_doc->open ( url ); }
340 
349  int saveAs ( const QString & url, KEduVocDocument::FileType ft = KEduVocDocument::Automatic, const QString & generator = QString ( "Parley" ) ) { return m_doc->saveAs ( url, ft, generator ); }
350 
351 // QByteArray toByteArray ( const QString &generator );
352 
360  void merge ( Document *docToMerge, bool matchIdentifiers ) { m_doc->merge ( docToMerge->kEduVocDocument(),matchIdentifiers ); }
361 
362 // NOT NEEDED
363  /*
364  * Indicates if the document is modified
365  *
366  * @param dirty new state
367  */
368 // void setModified ( bool dirty = true ) { m_doc->setModified ( dirty ); }
369 
370  /* @returns the modification state of the doc */
371 // bool isModified() const { return m_doc->isModified(); }
372 
373  // *** identifier methods ***
374 
378  int identifierCount() const { return m_doc->identifierCount(); }
379 
384  QObject * newIdentifier() { return new Identifier(); }
385 
391  void appendNewIdentifier ( const QString& name, const QString& locale );
392 
399  int appendIdentifier ( Identifier * identifier ) { return m_doc->appendIdentifier ( * ( identifier->kEduVocIdentifier() ) ); }
400 
401  /*
402  * Sets the identifier of translation
403  *
404  * @param index number of translation 0..x
405  * @param lang thr language identifier: en=english, de=german, ...
406  */
407 // void setIdentifier ( int index, Identifier * lang ) { m_doc->setIdentifier ( index,* ( lang->kEduVocIdentifier() ) ); }
408 
415  QObject * identifier ( int index ) { return new Identifier ( m_doc->identifier ( index ) ); }
416 
422  void removeIdentifier ( int index ) { m_doc->removeIdentifier ( index ); }
423 
425  QVariantList identifiers();
426 
427  /*
428  * Determines the index of a given identifier
429  *
430  * @param lang identifier of language
431  * @returns index of identifier, 0 = original, 1..n = translation, -1 = not found
432  */
433 // not implemented in KEduVocDocument
434 // int indexOfIdentifier ( const QString &name ) const { return m_doc->indexOfIdentifier(name); }
435 
436 
437  // *** grade methods ***
438 
439  /*
440  * Retrieves the identifiers for the current query
441  * not written in the new version!
442  *
443  * @param org identifier for original
444  * @param trans identifier for translation
445  */
446 // KDE_DEPRECATED void queryIdentifier ( QString &org, QString &trans ) const;
447 
448  /*
449  * Sets the identifiers for the current query
450  * not written in the new version!
451  *
452  * @param org identifier for original
453  * @param trans identifier for translation
454  */
455 // KDE_DEPRECATED void setQueryIdentifier ( const QString &org, const QString &trans );
456 
457  // *** lesson methods ***
458 
459  /* get the lesson root object
460  * @returns a pointer to the lesson object
461  */
462 // KEduVocLesson * lesson();
463 
464 // KEduVocWordType * wordTypeContainer();
465 
466 // KEduVocLeitnerBox * leitnerContainer();
467 
468  // *** file format specific methods ***
469 
470 
471  static KEduVocDocument::FileType detectFileType ( const QString &fileName ) { return KEduVocDocument::detectFileType ( fileName ); }
472 
481  static QString pattern ( KEduVocDocument::FileDialogMode mode ) { return KEduVocDocument::pattern ( mode ); }
482 
484  static QString errorDescription ( int errorCode ) { return KEduVocDocument::errorDescription ( errorCode ); }
485 
486  private:
487  KEduVocDocument * m_doc;
488  };
489 
490 }
491 #endif
Scripting::Document::Pauker
Definition: document.h:102
identifier.h
Scripting::Document::FileTypeUnknown
Definition: document.h:115
Scripting::Document::generator
QString generator() const
Definition: document.h:200
Scripting::Document::DeleteEntriesAndLesson
Definition: document.h:134
Scripting::Document::detectFileType
static KEduVocDocument::FileType detectFileType(const QString &fileName)
Definition: document.h:471
Scripting::Document::FileWriterFailed
Definition: document.h:117
Scripting::Document::csvDelimiter
QString csvDelimiter() const
Definition: document.h:215
Scripting::Identifier::kEduVocIdentifier
KEduVocIdentifier * kEduVocIdentifier()
Definition: identifier.h:69
Scripting::Document::appendIdentifier
int appendIdentifier(Identifier *identifier)
Appends a new identifier (usually a language)
Definition: document.h:399
Scripting::Document::Csv
Definition: document.h:105
Scripting::Lesson
KEduVocLesson wrapping class for Kross scripts.
Definition: lesson.h:47
Scripting::Document::FileReaderFailed
Definition: document.h:119
Scripting::Document::errorDescription
static QString errorDescription(int errorCode)
Returns a more detailed description of the errorCode given.
Definition: document.h:484
Scripting::Document::pattern
static QString pattern(KEduVocDocument::FileDialogMode mode)
Create a string with the supported document types, that can be used as filter in KFileDialog.
Definition: document.h:481
Scripting::Document::identifier
QObject * identifier(int index)
Returns the identifier of translation index.
Definition: document.h:415
QObject
Scripting::Document::setGenerator
void setGenerator(const QString &generator)
Definition: document.h:197
Scripting::Document::appendLesson
void appendLesson(QObject *lesson)
Appends a lesson to the document.
Definition: document.cpp:108
Scripting::Document::FileDoesNotExist
Definition: document.h:120
Scripting::Document::Writing
Definition: document.h:127
Scripting::Document
KEduVocDocument wrapping class for Kross scripts.
Definition: document.h:66
Scripting::Document::newIdentifier
QObject * newIdentifier()
Creates a new identifier and returns a reference to it.
Definition: document.h:384
Scripting::Document::setAuthor
void setAuthor(const QString &author)
Definition: document.h:161
Scripting::Document::~Document
~Document()
Definition: document.cpp:35
Scripting::Document::setTitle
void setTitle(const QString &title)
Definition: document.h:154
Scripting::Document::setAuthorContact
void setAuthorContact(const QString &authorContact)
Definition: document.h:168
Scripting::Document::setLicense
void setLicense(const QString &license)
Definition: document.h:175
Scripting::Document::newLesson
QObject * newLesson(const QString &name)
Creates and returns a new lesson (doesn't add it as a sublesson to any lesson)
Definition: document.h:247
Scripting::Document::KvdNone
Definition: document.h:98
Scripting::Document::authorContact
QString authorContact() const
Definition: document.h:171
Scripting::Document::documentComment
QString documentComment() const
Definition: document.h:185
Scripting::Document::FileDialogMode
FileDialogMode
used as parameter for pattern
Definition: document.h:124
Scripting::Document::version
QString version() const
Definition: document.h:207
Scripting::Document::saveAs
int saveAs(const QString &url, KEduVocDocument::FileType ft=KEduVocDocument::Automatic, const QString &generator=QString("Parley"))
Saves the data under the given name.
Definition: document.h:349
Scripting::Document::NoError
Definition: document.h:112
Scripting::Document::url
QString url() const
Definition: document.h:230
Scripting::Document::Xdxf
Definition: document.h:104
Scripting::Document::author
QString author() const
Definition: document.h:164
Scripting::Document::Document
Document(QObject *parent=0)
Definition: document.cpp:25
Scripting::Document::removeIdentifier
void removeIdentifier(int index)
Removes identifier and the according translations in all entries.
Definition: document.h:422
Scripting::Document::findLesson
QObject * findLesson(const QString &name)
Searches through all the lessons (recursively) and returns the first lesson the specified name...
Definition: document.cpp:128
Scripting::Document::appendNewLesson
QObject * appendNewLesson(const QString &name)
Creates a new lesson and appends it to the root lesson.
Definition: document.cpp:114
Scripting::Document::wordTypes
QStringList wordTypes()
Returns a string list with all the available word type's names.
Definition: document.cpp:77
Scripting::Document::FileCannotWrite
Definition: document.h:116
Scripting::Identifier
Identifier class can be accessed from Document class and is used for specifying the document language...
Definition: identifier.h:54
Scripting::Document::setWordType
void setWordType(QObject *tr, const QString &wordtype)
Sets the word type (wordtype) of the given tr translation object.
Definition: document.cpp:62
Scripting::Document::Unknown
Definition: document.h:113
lesson.h
Scripting::Document::FileCannotRead
Definition: document.h:118
Scripting::Document::setCsvDelimiter
void setCsvDelimiter(const QString &delimiter)
Definition: document.h:222
Scripting::Document::setDocumentComment
void setDocumentComment(const QString &comment)
Definition: document.h:182
Scripting::Document::setUrl
void setUrl(const QString &url)
Definition: document.h:227
Scripting::Document::InvalidXml
Definition: document.h:114
Scripting::Document::merge
void merge(Document *docToMerge, bool matchIdentifiers)
Merges data from another document.
Definition: document.h:360
Scripting::Document::Wql
Definition: document.h:101
Scripting::Document::appendNewIdentifier
void appendNewIdentifier(const QString &name, const QString &locale)
Append a new identifier by giving the name and locale.
Definition: document.cpp:100
Scripting::Document::identifiers
QVariantList identifiers()
Returns a list of all the identifiers of this document.
Definition: document.cpp:89
Scripting::Document::license
QString license() const
Definition: document.h:178
Scripting::Document::title
QString title() const
Definition: document.h:157
Scripting::Document::wordTypeFromString
KEduVocWordType * wordTypeFromString(const QString &name)
Definition: document.cpp:45
Scripting::Document::setCategory
void setCategory(const QString &category)
Definition: document.h:189
Scripting::Document::FileType
FileType
known vocabulary file types
Definition: document.h:96
Scripting::Document::kEduVocDocument
KEduVocDocument * kEduVocDocument()
Definition: document.h:143
Scripting::Document::Reading
Definition: document.h:126
Scripting::Document::setVersion
void setVersion(const QString &ver)
Definition: document.h:204
Scripting::Document::allLessons
QVariantList allLessons()
Returns all the lessons in the document (including sublessons)
Definition: document.cpp:39
Scripting::Document::rootLesson
QObject * rootLesson()
Definition: document.h:146
Scripting::Document::category
QString category() const
Definition: document.h:192
Scripting::Document::LessonDeletion
LessonDeletion
delete only empty lessons or also if they have entries
Definition: document.h:131
Scripting::Document::identifierCount
int identifierCount() const
Definition: document.h:378
Scripting::Document::DeleteEmptyLesson
Definition: document.h:133
Scripting::Document::Kvtml
Definition: document.h:100
Scripting::Document::Kvtml1
Definition: document.h:106
Scripting::Document::ErrorCode
ErrorCode
the return code when opening/saving
Definition: document.h:110
Scripting::Document::Vokabeln
Definition: document.h:103
Scripting::Document::Automatic
Definition: document.h:99
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:05 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