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

parley

document.h

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003     Copyright 2008 Avgoustinos Kadis <avgoustinos.kadis@kdemail.net>
00004 
00005  ***************************************************************************/
00006 
00007 /***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  ***************************************************************************/
00015 #ifndef SCRIPTOBJECTDOCUMENT_H
00016 #define SCRIPTOBJECTDOCUMENT_H
00017 
00018 #include <keduvocdocument.h>
00019 
00020 #include "lesson.h"
00021 #include "identifier.h"
00022 
00023 #include <QObject>
00024 
00025 namespace Scripting
00026 {
00027     class Translation;
00028 
00066     class Document : public QObject
00067     {
00068             Q_OBJECT
00070             Q_PROPERTY ( QObject * rootLesson READ rootLesson )
00072             Q_PROPERTY ( QString title READ title WRITE setTitle )
00074             Q_PROPERTY ( QString author READ author WRITE setAuthor )
00076             Q_PROPERTY ( QString authorContact READ authorContact WRITE setAuthorContact )
00078             Q_PROPERTY ( QString license READ license WRITE setLicense )
00080             Q_PROPERTY ( QString documentComment READ documentComment WRITE setDocumentComment )
00082             Q_PROPERTY ( QString category READ category WRITE setCategory )
00084             Q_PROPERTY ( QString generator READ generator WRITE setGenerator )
00086             Q_PROPERTY ( QString version READ version WRITE setVersion )
00088             Q_PROPERTY ( QString csvDelimiter READ csvDelimiter WRITE setCsvDelimiter )
00090             Q_PROPERTY ( QString url READ url WRITE setUrl )
00091 
00092             Q_ENUMS ( FileType )
00093         public:
00094 
00096             enum FileType
00097             {
00098                 KvdNone,
00099                 Automatic,
00100                 Kvtml,
00101                 Wql,
00102                 Pauker,
00103                 Vokabeln,
00104                 Xdxf,
00105                 Csv,
00106                 Kvtml1
00107             };
00108 
00110             enum ErrorCode
00111             {
00112                 NoError = 0,
00113                 Unknown,
00114                 InvalidXml,
00115                 FileTypeUnknown,
00116                 FileCannotWrite,
00117                 FileWriterFailed,
00118                 FileCannotRead,
00119                 FileReaderFailed,
00120                 FileDoesNotExist
00121             };
00122 
00124             enum FileDialogMode
00125             {
00126                 Reading,
00127                 Writing
00128             };
00129 
00131             enum LessonDeletion
00132             {
00133                 DeleteEmptyLesson,
00134                 DeleteEntriesAndLesson
00135             };
00136 
00137             Document ( QObject* parent = 0 );
00138 
00139             Document ( KEduVocDocument * doc );
00140 
00141             ~Document();
00142 
00143             KEduVocDocument * kEduVocDocument() { return m_doc; }
00144 
00145             //Property: rootLesson (READ)
00146             QObject * rootLesson() { return new Lesson ( m_doc->lesson() ); }
00147 
00148             KEduVocWordType * wordTypeFromString ( const QString & name );
00149 
00150             //**** Property Methods ****//
00151 
00152             /* set the title of the file
00153              * @param title title to set */
00154             void setTitle ( const QString & title ) { m_doc->setTitle ( title ); }
00155 
00156             /* @returns the title of the file */
00157             QString title() const { return m_doc->title(); }
00158 
00159             /* set the author of the file
00160              * @param author author to set */
00161             void setAuthor ( const QString & author ) { m_doc->setAuthor ( author ); }
00162 
00163             /* @returns the author of the file */
00164             QString author() const { return m_doc->author(); }
00165 
00166             /* set the author contact info
00167              * @param contact email/contact info to set */
00168             void setAuthorContact ( const QString & authorContact ) { m_doc->setAuthorContact ( authorContact ); }
00169 
00170             /* @returns the author contact information */
00171             QString authorContact() const { return m_doc->authorContact(); }
00172 
00173             /* set the license of the file
00174              * @param license license to set */
00175             void setLicense ( const QString & license ) { m_doc->setLicense ( license ); }
00176 
00177             /* @returns the license of the file */
00178             QString license() const { return m_doc->license(); }
00179 
00180             /* set the comment of the file
00181              * @param comment comment to set */
00182             void setDocumentComment ( const QString & comment ) { m_doc->setDocumentComment ( comment ); }
00183 
00184             /* @return the comment of the file */
00185             QString documentComment() const { return m_doc->documentComment(); }
00186 
00187             /* set the category of the file
00188              * @param category category to set */
00189             void setCategory ( const QString & category ) { m_doc->setCategory ( category ); }
00190 
00191             /* @return the category of the file */
00192             QString category() const { return m_doc->category(); }
00193 
00194             /*
00195              * Sets the generator of the file
00196              */
00197             void setGenerator ( const QString & generator ) { m_doc->setGenerator ( generator ); }
00198 
00199             /* @returns the generator of the file */
00200             QString generator() const { return m_doc->generator(); }
00201 
00202             /* Sets version of the loaded file
00203              * @param ver the new version */
00204             void setVersion ( const QString & ver ) { m_doc->setVersion ( ver ); }
00205 
00206             /* @returns the version of the loaded file */
00207             QString version() const { return m_doc->version(); }
00208 
00209             /*
00210              * Returns the delimiter (separator) used for csv import and export.
00211              * The default is a single tab character
00212              *
00213              * @returns                the delimiter used
00214              */
00215             QString csvDelimiter() const { return m_doc->csvDelimiter(); }
00216 
00217             /*
00218              * Sets the delimiter (separator) used for csv import and export
00219              *
00220              * @param delimiter        the delimiter to use
00221              */
00222             void setCsvDelimiter ( const QString &delimiter ) { m_doc->setCsvDelimiter ( delimiter ); }
00223 
00224             /*
00225              * Sets the URL of the XML file
00226              */
00227             void setUrl ( const QString& url ) { m_doc->setUrl ( url ); }
00228 
00229             /* @returns the URL of the XML file */
00230             QString url() const { return m_doc->url().path(); }
00231 
00232         public slots:
00233 
00247             QObject * newLesson ( const QString & name ) { return new Lesson ( name ); }
00248 
00261             void appendLesson ( QObject * lesson );
00262 
00273             QObject * appendNewLesson ( const QString & name );
00274 
00287             QObject * appendNewLesson ( const QString & name, Lesson * parent );
00288 
00299             QVariantList allLessons();
00300 
00316             QObject * findLesson ( const QString& name );
00317 
00324             void setWordType ( QObject * tr, const QString & wordtype );
00325 
00329             QStringList wordTypes();
00330 
00331 // ---------------------  copied from KEduVocDocument
00332 
00333             /*
00334              * Open a document file
00335              *
00336              * @param url      url to file to open
00337              * @returns        ErrorCode
00338              */
00339 //             int open ( const QString & url ) { return m_doc->open ( url ); }
00340 
00349             int saveAs ( const QString & url, KEduVocDocument::FileType ft = KEduVocDocument::Automatic, const QString & generator = QString ( "Parley" ) ) { return m_doc->saveAs ( url, ft, generator ); }
00350 
00351 //             QByteArray toByteArray ( const QString &generator );
00352 
00360             void merge ( Document *docToMerge, bool matchIdentifiers ) { m_doc->merge ( docToMerge->kEduVocDocument(),matchIdentifiers ); }
00361 
00362 // NOT NEEDED
00363             /*
00364              * Indicates if the document is modified
00365              *
00366              * @param dirty   new state
00367              */
00368 //             void setModified ( bool dirty = true ) { m_doc->setModified ( dirty ); }
00369 
00370             /* @returns the modification state of the doc */
00371 //             bool isModified() const { return m_doc->isModified(); }
00372 
00373             // *** identifier methods ***
00374 
00378             int identifierCount() const { return m_doc->identifierCount(); }
00379 
00384             QObject * newIdentifier() { return new Identifier(); }
00385 
00391             void appendNewIdentifier ( const QString& name, const QString& locale );
00392 
00399             int appendIdentifier ( Identifier * identifier ) { return m_doc->appendIdentifier ( * ( identifier->kEduVocIdentifier() ) ); }
00400 
00401             /*
00402              * Sets the identifier of translation
00403              *
00404              * @param index            number of translation 0..x
00405              * @param lang             thr language identifier: en=english, de=german, ...
00406              */
00407 //             void setIdentifier ( int index, Identifier * lang ) { m_doc->setIdentifier ( index,* ( lang->kEduVocIdentifier() ) ); }
00408 
00415             QObject * identifier ( int index ) { return new Identifier ( m_doc->identifier ( index ) ); }
00416 
00422             void removeIdentifier ( int index ) { m_doc->removeIdentifier ( index ); }
00423 
00425             QVariantList identifiers();
00426 
00427             /*
00428              * Determines the index of a given identifier
00429              *
00430              * @param lang             identifier of language
00431              * @returns                index of identifier, 0 = original, 1..n = translation, -1 = not found
00432              */
00433 // not implemented in KEduVocDocument
00434 //             int indexOfIdentifier ( const QString &name ) const { return m_doc->indexOfIdentifier(name); }
00435 
00436 
00437             // *** grade methods ***
00438 
00439             /*
00440              * Retrieves the identifiers for the current query
00441              * not written in the new version!
00442              *
00443              * @param org        identifier for original
00444              * @param trans      identifier for translation
00445              */
00446 //             KDE_DEPRECATED void queryIdentifier ( QString &org, QString &trans ) const;
00447 
00448             /*
00449              * Sets the identifiers for the current query
00450              * not written in the new version!
00451              *
00452              * @param org        identifier for original
00453              * @param trans      identifier for translation
00454              */
00455 //             KDE_DEPRECATED void setQueryIdentifier ( const QString &org, const QString &trans );
00456 
00457             // *** lesson methods ***
00458 
00459             /* get the lesson root object
00460              * @returns a pointer to the lesson object
00461              */
00462 //             KEduVocLesson * lesson();
00463 
00464 //             KEduVocWordType * wordTypeContainer();
00465 
00466 //             KEduVocLeitnerBox * leitnerContainer();
00467 
00468             // *** file format specific methods ***
00469 
00470 
00471             static KEduVocDocument::FileType detectFileType ( const QString &fileName ) { return KEduVocDocument::detectFileType ( fileName ); }
00472 
00481             static QString pattern ( KEduVocDocument::FileDialogMode mode ) { return KEduVocDocument::pattern ( mode ); }
00482 
00484             static QString errorDescription ( int errorCode ) { return KEduVocDocument::errorDescription ( errorCode ); }
00485 
00486         private:
00487             KEduVocDocument * m_doc;
00488     };
00489 
00490 }
00491 #endif

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