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

parley

  • sources
  • kde-4.14
  • 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  KvdNone,
98  Automatic,
99  Kvtml,
100  Wql,
101  Pauker,
102  Vokabeln,
103  Xdxf,
104  Csv,
105  Kvtml1
106  };
107 
109  enum ErrorCode {
110  NoError = 0,
111  Unknown,
112  InvalidXml,
113  FileTypeUnknown,
114  FileCannotWrite,
115  FileWriterFailed,
116  FileCannotRead,
117  FileReaderFailed,
118  FileDoesNotExist
119  };
120 
122  enum FileDialogMode {
123  Reading,
124  Writing
125  };
126 
128  enum LessonDeletion {
129  DeleteEmptyLesson,
130  DeleteEntriesAndLesson
131  };
132 
133  Document(QObject* parent = 0);
134 
135  Document(KEduVocDocument * doc);
136 
137  ~Document();
138 
139  KEduVocDocument * kEduVocDocument() {
140  return m_doc;
141  }
142 
143  //Property: rootLesson (READ)
144  QObject * rootLesson() {
145  return new Lesson(m_doc->lesson());
146  }
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) {
155  m_doc->setTitle(title);
156  }
157 
158  /* @returns the title of the file */
159  QString title() const {
160  return m_doc->title();
161  }
162 
163  /* set the author of the file
164  * @param author author to set */
165  void setAuthor(const QString & author) {
166  m_doc->setAuthor(author);
167  }
168 
169  /* @returns the author of the file */
170  QString author() const {
171  return m_doc->author();
172  }
173 
174  /* set the author contact info
175  * @param contact email/contact info to set */
176  void setAuthorContact(const QString & authorContact) {
177  m_doc->setAuthorContact(authorContact);
178  }
179 
180  /* @returns the author contact information */
181  QString authorContact() const {
182  return m_doc->authorContact();
183  }
184 
185  /* set the license of the file
186  * @param license license to set */
187  void setLicense(const QString & license) {
188  m_doc->setLicense(license);
189  }
190 
191  /* @returns the license of the file */
192  QString license() const {
193  return m_doc->license();
194  }
195 
196  /* set the comment of the file
197  * @param comment comment to set */
198  void setDocumentComment(const QString & comment) {
199  m_doc->setDocumentComment(comment);
200  }
201 
202  /* @return the comment of the file */
203  QString documentComment() const {
204  return m_doc->documentComment();
205  }
206 
207  /* set the category of the file
208  * @param category category to set */
209  void setCategory(const QString & category) {
210  m_doc->setCategory(category);
211  }
212 
213  /* @return the category of the file */
214  QString category() const {
215  return m_doc->category();
216  }
217 
218  /*
219  * Sets the generator of the file
220  */
221  void setGenerator(const QString & generator) {
222  m_doc->setGenerator(generator);
223  }
224 
225  /* @returns the generator of the file */
226  QString generator() const {
227  return m_doc->generator();
228  }
229 
230  /* Sets version of the loaded file
231  * @param ver the new version */
232  void setVersion(const QString & ver) {
233  m_doc->setVersion(ver);
234  }
235 
236  /* @returns the version of the loaded file */
237  QString version() const {
238  return m_doc->version();
239  }
240 
241  /*
242  * Returns the delimiter (separator) used for csv import and export.
243  * The default is a single tab character
244  *
245  * @returns the delimiter used
246  */
247  QString csvDelimiter() const {
248  return m_doc->csvDelimiter();
249  }
250 
251  /*
252  * Sets the delimiter (separator) used for csv import and export
253  *
254  * @param delimiter the delimiter to use
255  */
256  void setCsvDelimiter(const QString &delimiter) {
257  m_doc->setCsvDelimiter(delimiter);
258  }
259 
260  /*
261  * Sets the URL of the XML file
262  */
263  void setUrl(const QString& url) {
264  m_doc->setUrl(url);
265  }
266 
267  /* @returns the URL of the XML file */
268  QString url() const {
269  return m_doc->url().path();
270  }
271 
272 public slots:
273 
287  QObject * newLesson(const QString & name) {
288  return new Lesson(name);
289  }
290 
303  void appendLesson(QObject * lesson);
304 
315  QObject * appendNewLesson(const QString & name);
316 
329  QObject * appendNewLesson(const QString & name, Lesson * parent);
330 
341  QVariantList allLessons();
342 
358  QObject * findLesson(const QString& name);
359 
366  void setWordType(QObject * tr, const QString & wordtype);
367 
371  QStringList wordTypes();
372 
373 // --------------------- copied from KEduVocDocument
374 
375  /*
376  * Open a document file
377  *
378  * @param url url to file to open
379  * @returns ErrorCode
380  */
381 // int open ( const QString & url ) { return m_doc->open ( url ); }
382 
391  int saveAs(const QString & url, KEduVocDocument::FileType ft = KEduVocDocument::Automatic, const QString & generator = QString("Parley")) {
392  return m_doc->saveAs(url, ft, generator);
393  }
394 
395 // QByteArray toByteArray ( const QString &generator );
396 
404  void merge(Document *docToMerge, bool matchIdentifiers) {
405  m_doc->merge(docToMerge->kEduVocDocument(), matchIdentifiers);
406  }
407 
408 // NOT NEEDED
409  /*
410  * Indicates if the document is modified
411  *
412  * @param dirty new state
413  */
414 // void setModified ( bool dirty = true ) { m_doc->setModified ( dirty ); }
415 
416  /* @returns the modification state of the doc */
417 // bool isModified() const { return m_doc->isModified(); }
418 
419  // *** identifier methods ***
420 
424  int identifierCount() const {
425  return m_doc->identifierCount();
426  }
427 
432  QObject * newIdentifier() {
433  return new Identifier();
434  }
435 
441  void appendNewIdentifier(const QString& name, const QString& locale);
442 
449  int appendIdentifier(Identifier * identifier) {
450  return m_doc->appendIdentifier(* (identifier->kEduVocIdentifier()));
451  }
452 
453  /*
454  * Sets the identifier of translation
455  *
456  * @param index number of translation 0..x
457  * @param lang thr language identifier: en=english, de=german, ...
458  */
459 // void setIdentifier ( int index, Identifier * lang ) { m_doc->setIdentifier ( index,* ( lang->kEduVocIdentifier() ) ); }
460 
467  QObject * identifier(int index) {
468  return new Identifier(m_doc->identifier(index));
469  }
470 
476  void removeIdentifier(int index) {
477  m_doc->removeIdentifier(index);
478  }
479 
481  QVariantList identifiers();
482 
483  /*
484  * Determines the index of a given identifier
485  *
486  * @param lang identifier of language
487  * @returns index of identifier, 0 = original, 1..n = translation, -1 = not found
488  */
489 // not implemented in KEduVocDocument
490 // int indexOfIdentifier ( const QString &name ) const { return m_doc->indexOfIdentifier(name); }
491 
492 
493  // *** grade methods ***
494 
495  /*
496  * Retrieves the identifiers for the current query
497  * not written in the new version!
498  *
499  * @param org identifier for original
500  * @param trans identifier for translation
501  */
502 // KDE_DEPRECATED void queryIdentifier ( QString &org, QString &trans ) const;
503 
504  /*
505  * Sets the identifiers for the current query
506  * not written in the new version!
507  *
508  * @param org identifier for original
509  * @param trans identifier for translation
510  */
511 // KDE_DEPRECATED void setQueryIdentifier ( const QString &org, const QString &trans );
512 
513  // *** lesson methods ***
514 
515  /* get the lesson root object
516  * @returns a pointer to the lesson object
517  */
518 // KEduVocLesson * lesson();
519 
520 // KEduVocWordType * wordTypeContainer();
521 
522 // KEduVocLeitnerBox * leitnerContainer();
523 
524  // *** file format specific methods ***
525 
526 
527  static KEduVocDocument::FileType detectFileType(const QString &fileName) {
528  return KEduVocDocument::detectFileType(fileName);
529  }
530 
539  static QString pattern(KEduVocDocument::FileDialogMode mode) {
540  return KEduVocDocument::pattern(mode);
541  }
542 
544  static QString errorDescription(int errorCode) {
545  return KEduVocDocument::errorDescription(errorCode);
546  }
547 
548 private:
549  KEduVocDocument * m_doc;
550 };
551 
552 }
553 #endif
Scripting::Document::Pauker
Definition: document.h:101
identifier.h
Scripting::Document::FileTypeUnknown
Definition: document.h:113
Scripting::Document::generator
QString generator() const
Definition: document.h:226
Scripting::Document::DeleteEntriesAndLesson
Definition: document.h:130
Scripting::Document::detectFileType
static KEduVocDocument::FileType detectFileType(const QString &fileName)
Definition: document.h:527
Scripting::Document::FileWriterFailed
Definition: document.h:115
Scripting::Document::csvDelimiter
QString csvDelimiter() const
Definition: document.h:247
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:449
Scripting::Document::Csv
Definition: document.h:104
Scripting::Lesson
KEduVocLesson wrapping class for Kross scripts.
Definition: lesson.h:47
Scripting::Document::FileReaderFailed
Definition: document.h:117
Scripting::Document::errorDescription
static QString errorDescription(int errorCode)
Returns a more detailed description of the errorCode given.
Definition: document.h:544
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:539
Scripting::Document::identifier
QObject * identifier(int index)
Returns the identifier of translation index.
Definition: document.h:467
QObject::tr
QString tr(const char *sourceText, const char *disambiguation, int n)
Scripting::Document::setGenerator
void setGenerator(const QString &generator)
Definition: document.h:221
Scripting::Document::appendLesson
void appendLesson(QObject *lesson)
Appends a lesson to the document.
Definition: document.cpp:104
QObject::name
const char * name() const
Scripting::Document::FileDoesNotExist
Definition: document.h:118
Scripting::Document::Writing
Definition: document.h:124
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:432
Scripting::Document::setAuthor
void setAuthor(const QString &author)
Definition: document.h:165
QObject
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:176
Scripting::Document::setLicense
void setLicense(const QString &license)
Definition: document.h:187
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:287
Scripting::Document::KvdNone
Definition: document.h:97
Scripting::Document::authorContact
QString authorContact() const
Definition: document.h:181
Scripting::Document::documentComment
QString documentComment() const
Definition: document.h:203
Scripting::Document::FileDialogMode
FileDialogMode
used as parameter for pattern
Definition: document.h:122
QString
Scripting::Document::version
QString version() const
Definition: document.h:237
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:391
Scripting::Document::NoError
Definition: document.h:110
QStringList
Scripting::Document::url
QString url() const
Definition: document.h:268
Scripting::Document::Xdxf
Definition: document.h:103
Scripting::Document::author
QString author() const
Definition: document.h:170
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:476
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:125
Scripting::Document::appendNewLesson
QObject * appendNewLesson(const QString &name)
Creates a new lesson and appends it to the root lesson.
Definition: document.cpp:111
Scripting::Document::wordTypes
QStringList wordTypes()
Returns a string list with all the available word type's names.
Definition: document.cpp:75
Scripting::Document::FileCannotWrite
Definition: document.h:114
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:61
Scripting::Document::Unknown
Definition: document.h:111
lesson.h
Scripting::Document::FileCannotRead
Definition: document.h:116
Scripting::Document::setCsvDelimiter
void setCsvDelimiter(const QString &delimiter)
Definition: document.h:256
Scripting::Document::setDocumentComment
void setDocumentComment(const QString &comment)
Definition: document.h:198
Scripting::Document::setUrl
void setUrl(const QString &url)
Definition: document.h:263
Scripting::Document::InvalidXml
Definition: document.h:112
Scripting::Document::merge
void merge(Document *docToMerge, bool matchIdentifiers)
Merges data from another document.
Definition: document.h:404
Scripting::Document::Wql
Definition: document.h:100
Scripting::Document::appendNewIdentifier
void appendNewIdentifier(const QString &name, const QString &locale)
Append a new identifier by giving the name and locale.
Definition: document.cpp:96
Scripting::Document::identifiers
QVariantList identifiers()
Returns a list of all the identifiers of this document.
Definition: document.cpp:86
Scripting::Document::license
QString license() const
Definition: document.h:192
Scripting::Document::title
QString title() const
Definition: document.h:159
Scripting::Document::wordTypeFromString
KEduVocWordType * wordTypeFromString(const QString &name)
Definition: document.cpp:45
Scripting::Document::setCategory
void setCategory(const QString &category)
Definition: document.h:209
Scripting::Document::FileType
FileType
known vocabulary file types
Definition: document.h:96
Scripting::Document::kEduVocDocument
KEduVocDocument * kEduVocDocument()
Definition: document.h:139
Scripting::Document::Reading
Definition: document.h:123
Scripting::Document::setVersion
void setVersion(const QString &ver)
Definition: document.h:232
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:144
Scripting::Document::category
QString category() const
Definition: document.h:214
Scripting::Document::LessonDeletion
LessonDeletion
delete only empty lessons or also if they have entries
Definition: document.h:128
QObject::parent
QObject * parent() const
Scripting::Document::identifierCount
int identifierCount() const
Definition: document.h:424
Scripting::Document::DeleteEmptyLesson
Definition: document.h:129
Scripting::Document::Kvtml
Definition: document.h:99
Scripting::Document::Kvtml1
Definition: document.h:105
Scripting::Document::ErrorCode
ErrorCode
the return code when opening/saving
Definition: document.h:109
Scripting::Document::Vokabeln
Definition: document.h:102
Scripting::Document::Automatic
Definition: document.h:98
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:56 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