• 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
parley.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 SCRIPTOBJECTPARLEY_H
16 #define SCRIPTOBJECTPARLEY_H
17 
18 #include "document.h"
19 
20 #include <QObject>
21 #include <KAction>
22 #include <KDebug>
23 
24 #include <keduvocdeclension.h>
25 
26 #include <KStandardDirs>
27 
28 namespace Editor
29 {
30 class EditorWindow;
31 }
32 class Translator;
33 
123 namespace Scripting
124 {
125 
126 
152 class Parley : public QObject
153 {
154  Q_OBJECT
156  Q_PROPERTY(QObject * document READ getDocument)
158  Q_PROPERTY(QObject * doc READ getDocument)
160  Q_PROPERTY(QObject * activeLesson READ activeLesson)
161 
162 // Q_ENUMS ( Number Case Person Gender Definiteness )
163  Q_ENUMS(Flags)
164 
165 public:
166 
167  enum Flags {
168  // This is used for both empty flags and to denote no flags of the correct type were set.
169  NoInformation = 0x0,
170 
171  // Gender
172  Masculine = 0x1,
173  Feminine = 0x2,
174  Neuter = 0x4,
175 
176  // Plurality
177  Singular = 0x10,
178  Dual = 0x20,
179  Plural = 0x40,
180 
181  // Part of Speech
182  Verb = 0x100,
183  Noun = 0x200,
184  Pronoun = 0x400,
185  Adjective = 0x800,
186  Adverb = 0x1000,
187  Article = 0x2000,
188  Conjunction = 0x4000,
189 
190  // Person
191  First = 0x10000,
192  Second = 0x20000,
193  Third = 0x40000,
194 
195  // Declension Case
196  Nominative = 0x80000,
197  Genitive = 0x100000,
198  Dative = 0x200000,
199  Accusative = 0x400000,
200  Ablative = 0x800000,
201  Locative = 0x1000000,
202  Vocative = 0x2000000,
203 
204  // Other assorted flags
205  Definite = 0x4000000, // The article is definite
206  Indefinite = 0x8000000, // The article is indefinite
207  Regular = 0x10000000,
208  Irregular = 0x20000000
209  };
210 
211  Parley(Editor::EditorWindow * editor);
212 
213  ~Parley();
214 
215  /*
216  * Emits translateWord signal so the script function connected to it translate the @p word
217  * @param word Word to translate
218  * @param fromLanguage The language of @p word to translate from
219  * @param toLanguage The language you want to translate to
220  */
221  void callTranslateWord(const QString & word, const QString& fromLanguage, const QString& toLanguage);
222 
223  //sets the translator object
224 // void setTranslator ( Translator* translator ) { m_translator = translator; }
225  Translator * translator() {
226  return m_translator;
227  }
228 
229  //Returns the active document
230  QObject* getDocument() {
231  return m_doc;
232  }
233 
234  //Returns the active lesson
235  QObject* activeLesson();
236 
237 public Q_SLOTS:
238 
239  QStringList dataDirs() {
240  return KGlobal::dirs()->findDirs("data", "parley");
241  }
242 
243  QStringList pluginDirs() {
244  return KGlobal::dirs()->findDirs("data", "parley/plugins");
245  }
246 
248  QVariantList selectedEntries();
249 
251  QVariantList selectedTranslations();
252 
271  void addTranslation(QString word, QString fromLanguage, QString toLanguage, QString translation);
276  QStringList locales();
277 
283  QString localeName(QString locale);
284 
286  /*
287  * Open the Parley Document @p file
288  * Usage:
289  * @code
290  * import Parley
291  * Parley.open("Vocab/MyVocab.kvtml")
292  * @endcode
293  * @param file Parley Document file path (ex. /home/kde-user/MyVocab.kvtml)
294  */
295  void open(QString filename);
296 
344  QObject * newDocument() {
345  return new Document();
346  }
347 
375  QObject * newAction(const QString & name, const QString & text = QString());
376 
377 Q_SIGNALS:
395  void translateWord(const QString & word, const QString& fromLanguage, const QString& toLanguage);
396  /* Emits when the translation of a word is finished (from all the scripts) [not to be used by scripts] */
397  void translationFinished(const QString & word, const QString& fromLanguage, const QString& toLanguage);
398  /* Emits when the translation of a word starts [not to be used by scripts] */
399  void translationStarted(const QString & word, const QString& fromLanguage, const QString& toLanguage);
400 
401 private:
402  Translator* m_translator;
403  Document* m_doc;
404  Editor::EditorWindow * m_editor;
405 };
406 
407 }
408 #endif
Scripting::Parley::getDocument
QObject * getDocument()
Definition: parley.h:230
Scripting::Parley::newAction
QObject * newAction(const QString &name, const QString &text=QString())
Creates and adds to the Scripts menu a new KAction (see KAction documentation)
Definition: parley.cpp:145
Scripting::Parley::Indefinite
Definition: parley.h:206
Scripting::Parley::addTranslation
void addTranslation(QString word, QString fromLanguage, QString toLanguage, QString translation)
Adds the found translation of the word from language fromLanguage to language toLanguage to Parley tr...
Definition: parley.cpp:61
Scripting::Parley::selectedEntries
QVariantList selectedEntries()
Returns a list of Expression objects (the selected entries of the active lesson)
Definition: parley.cpp:90
Scripting::Parley::First
Definition: parley.h:191
Scripting::Parley::Second
Definition: parley.h:192
Scripting::Parley::Ablative
Definition: parley.h:200
Scripting::Parley::pluginDirs
QStringList pluginDirs()
Definition: parley.h:243
Scripting::Parley::callTranslateWord
void callTranslateWord(const QString &word, const QString &fromLanguage, const QString &toLanguage)
Definition: parley.cpp:54
Scripting::Parley::translationStarted
void translationStarted(const QString &word, const QString &fromLanguage, const QString &toLanguage)
Scripting::Parley::Dative
Definition: parley.h:198
Scripting::Parley::translateWord
void translateWord(const QString &word, const QString &fromLanguage, const QString &toLanguage)
Slots (script functions) connected to this signal are called when a translation of word is requested...
Scripting::Parley::Genitive
Definition: parley.h:197
Scripting::Parley::NoInformation
Definition: parley.h:169
Scripting::Parley::Regular
Definition: parley.h:207
Scripting::Parley::Locative
Definition: parley.h:201
Scripting::Parley::Third
Definition: parley.h:193
QObject::name
const char * name() const
Scripting::Parley::open
void open(QString filename)
Definition: parley.cpp:78
Scripting::Document
KEduVocDocument wrapping class for Kross scripts.
Definition: document.h:66
Scripting::Parley::Flags
Flags
Definition: parley.h:167
QObject
Scripting::Parley::Pronoun
Definition: parley.h:184
Scripting::Parley::doc
QObject doc
Abreviation of document property (same as Parley.document)
Definition: parley.h:158
Scripting::Parley::Irregular
Definition: parley.h:208
Scripting::Parley::dataDirs
QStringList dataDirs()
Definition: parley.h:239
document.h
Scripting::Parley::Neuter
Definition: parley.h:174
Scripting::Parley::locales
QStringList locales()
Returns a list of all available locales (to be used by the scripts)
Definition: parley.cpp:67
QString
Scripting::Parley::Masculine
Definition: parley.h:172
QStringList
Scripting::Parley::Vocative
Definition: parley.h:202
Scripting::Parley::Adjective
Definition: parley.h:185
Scripting::Parley::activeLesson
QObject * activeLesson()
Scripting::Parley::Feminine
Definition: parley.h:173
Translator
Keeps the translated words.
Definition: translator.h:74
Scripting::Parley::selectedTranslations
QVariantList selectedTranslations()
Returns a list of Translation objects (the selected translations of the active lesson) ...
Definition: parley.cpp:116
Scripting::Parley
Parley scripting class (main entry point of a Parley Kross script)
Definition: parley.h:152
Scripting::Parley::Article
Definition: parley.h:187
Scripting::Parley::Parley
Parley(Editor::EditorWindow *editor)
Definition: parley.cpp:42
Scripting::Parley::translationFinished
void translationFinished(const QString &word, const QString &fromLanguage, const QString &toLanguage)
Scripting::Parley::Conjunction
Definition: parley.h:188
Scripting::Parley::Noun
Definition: parley.h:183
Scripting::Parley::Accusative
Definition: parley.h:199
Scripting::Parley::Plural
Definition: parley.h:179
Editor::EditorWindow
Definition: editor.h:50
Scripting::Parley::document
QObject document
Read-only property of the active document.
Definition: parley.h:156
Scripting::Parley::localeName
QString localeName(QString locale)
Gives the language name of the given locale.
Definition: parley.cpp:73
Scripting::Parley::Nominative
Definition: parley.h:196
Scripting::Parley::Adverb
Definition: parley.h:186
Scripting::Parley::Verb
Definition: parley.h:182
Scripting::Parley::Definite
Definition: parley.h:205
Scripting::Parley::~Parley
~Parley()
Definition: parley.cpp:48
Scripting::Parley::Dual
Definition: parley.h:178
Scripting::Parley::translator
Translator * translator()
Definition: parley.h:225
Scripting::Parley::newDocument
QObject * newDocument()
Creates a new document and returns a reference to it.
Definition: parley.h:344
Scripting::Parley::Singular
Definition: parley.h:177
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