• 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
  • scripts_test
translationscript.cpp
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 #include "translationscript.h"
16 
17 #include <KDebug>
18 #include <QVariant>
19 
20 TranslationScript::TranslationScript(QString filename)
21 {
22  action = new Kross::Action(this, "Action");
23  action->setFile(filename);
24 }
25 
26 
27 TranslationScript::~TranslationScript()
28 {
29 }
30 
34 void TranslationScript::getLanguagePairs()
35 {
36  QVariant script_result = action->callFunction("getLanguagePairs");
37 
38  foreach(const QVariant & langpair, script_result.toList()) {
39  QVariantList pair = langpair.toList();
40  QString from = pair[0].toString();
41  QString to = pair[1].toString();
42 // kDebug() << from << " -> " << to;
43  }
44 }
45 
49 QStringList TranslationScript::translateWord(QString word, QString from, QString to)
50 {
51  QVariantList args;
52  args << word << from << to;
53  QVariant script_result = action->callFunction("fetchTranslation", args);
54  QList<QVariant> translations = script_result.toList();
55 
56  QStringList result;
57 
58  for (int i = 0; i < translations.size(); i++) {
59 // kDebug() << translations[i].toString() << " " << translations[i].toString().length();
60  result.push_back(translations[i].toString());
61  }
62 
63  return result;
64 }
QList::push_back
void push_back(const T &value)
QVariant::toList
QList< QVariant > toList() const
QList::size
int size() const
translationscript.h
QString
QList
QStringList
TranslationScript::translateWord
QStringList translateWord(QString word, QString from, QString to)
Definition: translationscript.cpp:49
TranslationScript::~TranslationScript
~TranslationScript()
Definition: translationscript.cpp:27
TranslationScript::getLanguagePairs
void getLanguagePairs()
Definition: translationscript.cpp:34
TranslationScript::TranslationScript
TranslationScript(QString filename)
Definition: translationscript.cpp:20
QVariant
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