QWidgetAction(parent) {
//creating custom tab widget, and sets style sheet to have centered tabs
- tabWidget = new MenuTabWidget(this);
- //creates custom tab widget, and sets style sheet to have centered tabs
tabWidget = new MenuTabWidget();
tabWidget->setStyleSheet("QTabWidget::tab-bar {alignment: center;}");
//! returns plugin icon
virtual QIcon* icon() = 0;
+ virtual Translation* getTranslationFor(QString key) {return 0;}
+
public Q_SLOTS:
/*! performs search in dictionary
\param word word to search in dictionary
--- /dev/null
+TEMPLATE=subdirs
+SUBDIRS=src
+
+check.target = check
+check.CONFIG = recursive
+check.recurse = tests
+QMAKE_EXTRA_TARGETS += check
--- /dev/null
+#include "GoogleDictDialog.h"
+
+GoogleDictDialog::GoogleDictDialog(GooglePlugin *plugin, QObject *parent) :
+ DictDialog(parent) {
+ this->plugin = plugin;
+}
+
+
+Settings* GoogleDictDialog::addNewDictionary(QWidget *parent) {
+ Settings *settings = new Settings();
+ settings->setValue("langTo","pl");
+ settings->setValue("langFrom","en");
+ return settings;
+ //return GoogleLoadDialog::getSettings(parent);
+}
+
+void GoogleDictDialog::changeSettings(QWidget * parent) {
+
+ Settings* settings = new Settings;
+ foreach(QString key, plugin->settings()->keys())
+ settings->setValue(key, plugin->settings()->value(key));
+ plugin->setSettings(settings);
+ delete settings;
+}
--- /dev/null
+#ifndef GOOGLEDICTDIALOG_H
+#define GOOGLEDICTDIALOG_H
+
+#include "../../../includes/DictDialog.h"
+#include "GooglePlugin.h"
+
+class GooglePlugin;
+
+class GoogleDictDialog : public DictDialog
+{
+ Q_OBJECT
+public:
+ explicit GoogleDictDialog(GooglePlugin* plugin, QObject *parent = 0);
+ /*!
+ Shows add new xdxf dictionary dialog and returns settings of new dict
+ \param parent parent widget on which will be displayed dialog
+ */
+ Settings* addNewDictionary(QWidget *parent);
+
+ /*!
+ Shows settings dialog and save new settings in plugin
+ \param parent parent widget on which will be displayed dialog
+ */
+ void changeSettings(QWidget *parent);
+
+private:
+ GooglePlugin* plugin;
+};
+
+#endif // GOOGLEDICTDIALOG_H
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file GooglePlugin.cpp
+*/
+
+#include "GooglePlugin.h"
+#include <QDebug>
+#include "GoogleDictDialog.h"
+
+
+GooglePlugin::GooglePlugin(QObject *parent): CommonDictInterface(parent),
+ _langFrom(tr("")), _langTo(tr("")),_name(tr("")),
+ _type(tr("google")), _infoNote(tr("")) {
+
+ stopped = false;
+ _settings = new Settings();
+ _dictDialog = new GoogleDictDialog(this,this);
+
+ //_icon = QIcon(":/icon/google.png");
+ initLanguages();
+ _settings->setValue("type","google");
+
+ http = new QHttp(this);
+ connect(http, SIGNAL(done(bool)), this, SLOT(done()));
+}
+
+GooglePlugin::~GooglePlugin() {
+ delete _settings;
+}
+
+QString GooglePlugin::langFrom() const {
+ return _langFrom;
+}
+
+QString GooglePlugin::langTo() const {
+ return _langTo;
+}
+
+QString GooglePlugin::name() const {
+ return _name;
+}
+
+QString GooglePlugin::type() const {
+ return _type;
+}
+
+QString GooglePlugin::infoNote() const {
+ return _infoNote;
+}
+
+void GooglePlugin::setLangTo(QString langTo){
+ _langTo=langTo;
+}
+
+void GooglePlugin::setLangFrom(QString langFrom){
+ _langFrom=langFrom;
+}
+
+DictDialog* GooglePlugin::dictDialog() {
+ return _dictDialog;
+}
+
+bool GooglePlugin::isAvailable() const {
+ return true;
+}
+
+QString GooglePlugin::search(QString key) {
+ /*function is not used on this plagin */
+ return QString("");
+}
+
+uint GooglePlugin::hash() const {
+ return _hash;
+}
+
+void GooglePlugin::setHash(uint) {
+ this->_hash=_hash;
+}
+
+Settings* GooglePlugin::settings() {
+ return _settings;
+}
+
+QIcon* GooglePlugin::icon() {
+ return &_icon;
+}
+
+CommonDictInterface* GooglePlugin::getNew(const Settings* settings) const
+{
+ GooglePlugin *plugin = new GooglePlugin();
+ if(settings) {
+ plugin->setLangFrom(settings->value("langFrom"));
+ plugin->setLangTo(settings->value("langTo"));
+ QStringList list = settings->keys();
+ foreach(QString key, list)
+ plugin->settings()->setValue(key, settings->value(key));
+ }
+ delete settings;
+ return plugin;
+}
+
+void GooglePlugin::setSettings(Settings* settings) {
+ _langFrom=settings->value("langFrom");
+ _langTo=settings->value("langTo");
+ QStringList list = settings->keys();
+ foreach(QString key, list)
+ _settings->setValue(key, settings->value(key));
+ delete settings;
+}
+
+Translation* GooglePlugin::getTranslationFor(QString key) {
+ QList<Translation*> translations = searchWordList(key);
+ if(translations.size()>0)
+ return translations.at(0);
+ else
+ return new TranslationGoogle();
+}
+
+QList<Translation*> GooglePlugin::searchWordList(QString word, int limit) {
+ QList<Translation*> translations;
+ QString url = QString("/translate_a/t?client=t&sl=%1+&tl=%2").arg(_langFrom,_langTo);
+ qDebug()<<url;
+ QHttpRequestHeader head = QHttpRequestHeader("POST", url, 1,1);
+ head.setValue("Host", "www.google.pl");
+ head.setValue("User-Agent", "Mozilla/5.0");
+ head.setValue("Accept-Encoding", "deflate");
+ head.setContentLength(word.length());
+ head.setValue("Connection", "Close");
+
+ QByteArray data("text=");
+ data.append(word.toUtf8());
+ http->setHost("www.google.pl");
+ wait=true;
+ http->request(head, data);
+ while(wait);
+
+ QString text = QString::fromUtf8(http->readAll());
+
+ text=jsonParse(text);
+ if(text!=""){
+ text=tr("<key>") + word + tr("</key>") + tr("<t>") + text + tr("</t>");
+ translations<<(new TranslationGoogle(word,text,_infoNote,this));
+ }
+ return translations;
+}
+
+QString GooglePlugin::jsonParse(QString result) {
+ int pos=0,pos2=0;
+ int index=0;
+ int size=0;
+
+ QString returnLang;
+ QString translation;
+ QString original;
+ QList<QString> partOfSpeach;
+ QList<QList<QString>* > words;
+
+ QStringList list1 = result.split("\"");
+ size=(list1.size()-1)/2;
+ if(size<=2)
+ return QString("");
+ translation=list1.at(1);
+ original=list1.at(3);
+ pos=result.indexOf("]");
+ pos=result.indexOf("]",pos+1);
+ pos++;
+ index=3;
+ if(result.at(pos+1)==QChar(','))
+ returnLang=list1.at(index*2+1);
+ while(result.indexOf("[",pos+1)!=-1){
+ partOfSpeach.append(list1.at(index*2+1));
+ pos2=result.indexOf("]",pos+1);
+ pos=result.indexOf("\"",pos+1);
+ pos=result.indexOf("\"",pos+1);
+ pos=result.indexOf("\"",pos+1);
+ pos=result.indexOf("\"",pos+1);
+ while(pos2>pos && pos2!=-1 && pos!= -1) {
+ index++;
+ if(size==index)
+ return QString("");
+ QList<QString> *list=new QList<QString>;
+ list->append(list1.at(index*2+1));
+ words.append(list);
+ pos=result.indexOf("\"",pos+1);
+ pos=result.indexOf("\"",pos+1);
+ }
+ index++;
+ if(size==index)
+ return QString("");
+ pos=pos2+2;
+ }
+ returnLang=list1.at(index*2+1);
+
+ if(returnLang!=_langFrom)
+ return QString("");
+
+ //result=translation;
+
+ return result;
+}
+
+void GooglePlugin::done() {
+ wait=false;
+}
+
+void GooglePlugin::started(int a) {
+ qDebug()<<"test";
+}
+
+void GooglePlugin::stop() {
+ stopped=true;
+}
+
+void GooglePlugin::initLanguages() {
+ languages["AFRIKAANS"] = "af";
+ languages["ALBANIAN"] = "sq";
+ languages["AMHARIC"] = "am";
+ languages["ARABIC"] = "ar";
+ languages["ARMENIAN"] = "hy";
+ languages["AZERBAIJANI"] = "az";
+ languages["BASQUE"] = "eu";
+ languages["BELARUSIAN"] = "be";
+ languages["BENGALI"] = "bn";
+ languages["BIHARI"] = "bh";
+ languages["BRETON"] = "br";
+ languages["BULGARIAN"] = "bg";
+ languages["BURMESE"] = "my";
+ languages["CATALAN"] = "ca";
+ languages["CHEROKEE"] = "chr";
+ languages["CHINESE"] = "zh";
+ languages["CHINESE_SIMPLIFIED"] = "zh-CN";
+ languages["CHINESE_TRADITIONAL"] = "zh-TW";
+ languages["CORSICAN"] = "co";
+ languages["CROATIAN"] = "hr";
+ languages["CZECH"] = "cs";
+ languages["DANISH"] = "da";
+ languages["DHIVEHI"] = "dv";
+ languages["DUTCH"] = "nl";
+ languages["ENGLISH"] = "en";
+ languages["ESPERANTO"] = "eo";
+ languages["ESTONIAN"] = "et";
+ languages["FAROESE"] = "fo";
+ languages["FILIPINO"] = "tl";
+ languages["FINNISH"] = "fi";
+ languages["FRENCH"] = "fr";
+ languages["FRISIAN"] = "fy";
+ languages["GALICIAN"] = "gl";
+ languages["GEORGIAN"] = "ka";
+ languages["GERMAN"] = "de";
+ languages["GREEK"] = "el";
+ languages["GUJARATI"] = "gu";
+ languages["HAITIAN_CREOLE"] = "ht";
+ languages["HEBREW"] = "iw";
+ languages["HINDI"] = "hi";
+ languages["HUNGARIAN"] = "hu";
+ languages["ICELANDIC"] = "is";
+ languages["INDONESIAN"] = "id";
+ languages["INUKTITUT"] = "iu";
+ languages["IRISH"] = "ga";
+ languages["ITALIAN"] = "it";
+ languages["JAPANESE"] = "ja";
+ languages["JAVANESE"] = "jw";
+ languages["KANNADA"] = "kn";
+ languages["KAZAKH"] = "kk";
+ languages["KHMER"] = "km";
+ languages["KOREAN"] = "ko";
+ languages["KURDISH"] = "ku";
+ languages["KYRGYZ"] = "ky";
+ languages["LAO"] = "lo";
+ languages["LATIN"] = "la";
+ languages["LATVIAN"] = "lv";
+ languages["LITHUANIAN"] = "lt";
+ languages["LUXEMBOURGISH"] = "lb";
+ languages["MACEDONIAN"] = "mk";
+ languages["MALAY"] = "ms";
+ languages["MALAYALAM"] = "ml";
+ languages["MALTESE"] = "mt";
+ languages["MAORI"] = "mi";
+ languages["MARATHI"] = "mr";
+ languages["MONGOLIAN"] = "mn";
+ languages["NEPALI"] = "ne";
+ languages["NORWEGIAN"] = "no";
+ languages["OCCITAN"] = "oc";
+ languages["ORIYA"] = "or";
+ languages["PASHTO"] = "ps";
+ languages["PERSIAN"] = "fa";
+ languages["POLISH"] = "pl";
+ languages["PORTUGUESE"] = "pt";
+ languages["PORTUGUESE_PORTUGAL"] = "pt-PT";
+ languages["PUNJABI"] = "pa";
+ languages["QUECHUA"] = "qu";
+ languages["ROMANIAN"] = "ro";
+ languages["RUSSIAN"] = "ru";
+ languages["SANSKRIT"] = "sa";
+ languages["SCOTS_GAELIC"] = "gd";
+ languages["SERBIAN"] = "sr";
+ languages["SINDHI"] = "sd";
+ languages["SINHALESE"] = "si";
+ languages["SLOVAK"] = "sk";
+ languages["SLOVENIAN"] = "sl";
+ languages["SPANISH"] = "es";
+ languages["SUNDANESE"] = "su";
+ languages["SWAHILI"] = "sw";
+ languages["SWEDISH"] = "sv";
+ languages["SYRIAC"] = "syr";
+ languages["TAJIK"] = "tg";
+ languages["TAMIL"] = "ta";
+ languages["TATAR"] = "tt";
+ languages["TELUGU"] = "te";
+ languages["THAI"] = "th";
+ languages["TIBETAN"] = "bo";
+ languages["TONGA"] = "to";
+ languages["TURKISH"] = "tr";
+ languages["UKRAINIAN"] = "uk";
+ languages["URDU"] = "ur";
+ languages["UZBEK"] = "uz";
+ languages["UIGHUR"] = "ug";
+ languages["VIETNAMESE"] = "vi";
+ languages["WELSH"] = "cy";
+ languages["YIDDISH"] = "yi";
+ languages["YORUBA"] = "yo";
+ languages["UNKNOWN"] = "";
+}
+
+Q_EXPORT_PLUGIN2(google, GooglePlugin)
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+
+/*! \file GooglePlugin.h
+*/
+#ifndef GOOGLEPLUGIN_H
+#define GOOGLEPLUGIN_H
+
+
+#include <QObject>
+#include <QDialog>
+#include <QtPlugin>
+#include <QIcon>
+#include <QtNetwork>
+
+#include "../../../includes/CommonDictInterface.h"
+#include "../../../includes/settings.h"
+#include "../../../includes/DictDialog.h"
+#include "TranslationGoogle.h"
+#include "GoogleDictDialog.h"
+
+class GoogleDictDialog;
+
+class GooglePlugin : public CommonDictInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(CommonDictInterface)
+public:
+ GooglePlugin(QObject *parent=0);
+ ~GooglePlugin();
+
+ //! returns source language code iso 639-2
+ QString langFrom() const;
+
+ //! returns destination language code iso 639-2
+ QString langTo() const;
+
+ //! returns dictionary name (like "old english" or so)
+ QString name() const;
+
+ //! returns dictionary type (xdxf, google translate, etc)
+ QString type() const;
+
+ //! returns information about dictionary in html (name, authors, etc)
+ QString infoNote() const;
+
+ void setLangTo(QString langTo);
+
+ void setLangFrom(QString langFrom);
+
+ /*! returns DictDialog object that creates dialogs
+ for adding new dictionary and change plugin tings
+ */
+ DictDialog* dictDialog();
+
+ //! returns new, clean copy of plugin with setting set as in Settings*
+ CommonDictInterface* getNew(const Settings*) const;
+
+ //! returns whether plugin can start searching
+ bool isAvailable() const;
+
+ //! returns a description of a word given by a QString
+ QString search(QString key);
+
+ //! returns a unique hash for a dictionary
+ uint hash() const;
+
+ //! set unique value (unique for every dictionary not plugin)
+ void setHash(uint);
+
+ //! returns current plugin settings
+ Settings* settings();
+
+ //! Sets new settings
+ void setSettings(Settings*);
+
+ //! returns plugin icon
+ QIcon* icon();
+
+ Translation* getTranslationFor(QString key);
+
+public slots:
+ /*! performs search in dictionary
+ \param word word to search in dictionary
+ \param limit limit on number of results
+
+ After finishing search it has to emit
+ \see CommonDictInterface:finalTranslation finalTranslation
+ */
+ QList<Translation*> searchWordList(QString word, int limit=0);
+
+ //! stop current operation
+ void stop();
+
+ void done();
+ void started(int);
+
+private:
+ void initLanguages();
+ QString jsonParse(QString result);
+ QMap<QString, QString> languages;
+
+ //! language from which we translate
+ QString _langFrom;
+ //! language to which we translate
+ QString _langTo;
+ //! name of a dictionary
+ QString _name;
+ //! type of a dictionary
+ QString _type;
+ //! information about dictionary
+ QString _infoNote;
+ //! path to dictionary file
+ QString path;
+ uint _hash;
+ QIcon _icon;
+ Settings *_settings;
+ bool stopped;
+ volatile bool wait;
+ QHttp *http;
+ GoogleDictDialog *_dictDialog;
+};
+
+#endif // GOOGLEPLUGIN_H
+
+
--- /dev/null
+#include "TranslationGoogle.h"
+
+TranslationGoogle::TranslationGoogle():_key(""),_trans(""),_dictionaryInfo("") {
+ googlePlugin=0;
+}
+
+TranslationGoogle::TranslationGoogle(QString _key,QString _trans,
+ QString _dictionaryInfo,GooglePlugin *googlePlugin):
+ _key(_key),_trans(_trans),_dictionaryInfo(_dictionaryInfo) {
+ this->googlePlugin=googlePlugin;
+ if(googlePlugin)
+ _dictHash = googlePlugin->hash();
+ _bookmark=0;
+}
+
+QString TranslationGoogle::key() const{
+ return _key;
+}
+
+QString TranslationGoogle::dictionaryInfo() const {
+ return _dictionaryInfo;
+}
+
+QString TranslationGoogle::toHtml() const {
+ QString result("");
+ if(googlePlugin) {
+ result+="<dict> <info bookmark=\"false\">GOOGLE TRANSLATOR </info>";
+ result+=_trans +"</dict>";
+ }
+ qDebug()<<"test"+result;
+ return result;
+}
+
+void TranslationGoogle::setKey(QString) {
+ this->_key=_key;
+}
+
+void TranslationGoogle::setDictionaryInfo(QString){
+ this->_dictionaryInfo=_dictionaryInfo;
+}
--- /dev/null
+#ifndef TRANSLATIONGOOGLE_H
+#define TRANSLATIONGOOGLE_H
+
+#include "../../../includes/translation.h"
+#include "GooglePlugin.h"
+
+class GooglePlugin;
+
+class TranslationGoogle : public Translation
+{
+public:
+ TranslationGoogle();
+
+ TranslationGoogle(QString _key,QString _trans,QString _dictionaryInfo, GooglePlugin *googlePlugin);
+
+ //! \return word to be translated
+ QString key() const;
+
+ /*! \returns dictionary information (plugin name, languages, <logo> etc)\
+ to be displayed in translation table header*/
+ QString dictionaryInfo() const;
+
+ //! \return parsed raw format into html
+ QString toHtml() const;
+
+ /*! sets the word for which we want to find a translation
+ \param word for which we want to find a translation */
+ void setKey(QString);
+
+ //! sets information about dictionary
+ void setDictionaryInfo(QString);
+
+ //! \retrun whether given translation is taken from bookmarks
+ bool isBookmark() const {
+ return _bookmark;
+ }
+
+ //! returns coresponding dict object
+ uint dict() const {return _dictHash;}
+
+private:
+ QString _key;
+ QString _dictionaryInfo;
+ QString _trans;
+ GooglePlugin *googlePlugin;
+ int _dictHash;
+ bool error;
+
+};
+
+#endif // TRANSLATIONGOOGLE_H
--- /dev/null
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-08-03T09:33:52
+#
+#-------------------------------------------------
+
+QT += core xml gui network
+
+
+TARGET = GooglePlugin
+TEMPLATE = lib
+
+MDICT_PLUGINSDIR = $$[MDICT_PLUGINSDIR]
+
+isEmpty(MDICT_PLUGINSDIR) {
+ MDICT_PLUGINSDIR = .
+}
+
+MDICT_APPNAME = $$[MDICT_APPNAME]
+
+isEmpty(MDICT_APPNAME) {
+ MDICT_APPNAME = mdictionary
+}
+
+
+DESTDIR = $${MDICT_PLUGINSDIR}/$${MDICT_APPNAME}
+
+
+
+SOURCES += \
+ GooglePlugin.cpp \
+ TranslationGoogle.cpp \
+ GoogleDictDialog.cpp
+
+HEADERS += \
+ GooglePlugin.h \
+ ../../../includes/DictDialog.h \
+ ../../../includes/translation.h \
+ ../../../includes/settings.h \
+ ../../../includes/CommonDictInterface.h \
+ TranslationGoogle.h \
+ GoogleDictDialog.h
+
+
+
+
+unix {
+ #VARIABLES
+ isEmpty(PREFIX) {
+ PREFIX = /usr
+ }
+
+ BINDIR = $$PREFIX/bin
+ LIBDIR = $$PREFIX/lib/$${MDICT_APPNAME}
+ DATADIR =$$PREFIX/share
+
+ DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\"
+
+ #MAKE INSTALL
+
+ INSTALLS += target dicts
+
+ target.path = $$LIBDIR
+
+ dicts.path = $$LIBDIR
+
+}
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+#include "test.h"
+#include <QSignalSpy>
+
+void GoogleTest::getNew() {
+
+ GooglePlugin googlePlugin(this);
+ Settings *settings=new Settings;
+ settings->setValue("langFrom","pl");
+ settings->setValue("langTo","en");
+
+
+jsonParse(QString result)
+
+
+
+ while(1)
+ qDebug()<<signa.count();
+}
+
+QTEST_MAIN(GoogleTest)
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+#ifndef TEST_H
+#define TEST_H
+
+#include <QtTest/QtTest>
+#include "../src/GooglePlugin.h"
+
+
+ class GoogleTest: public QObject
+ {
+ Q_OBJECT
+
+
+ private slots:
+ void getNew();
+
+ };
+
+
+#endif // TEST_H
--- /dev/null
+######################################################################
+# Automatically generated by qmake (1.07a) Wed Aug 4 11:35:12 2010
+######################################################################
+
+CONFIG += qtestlib
+QT += core gui network
+TARGET = GooglrPluginTests
+TEMPLATE = app
+INCLUDEPATH += .
+
+# Input
+HEADERS += test.h \
+ ../src/GooglePlugin.h \
+ ../../../includes/translation.h \
+ ../../../includes/settings.h \
+ ../../../includes/DictDialog.h \
+ ../../../includes/CommonDictInterface.h \
+ ../src/TranslationGoogle.h
+
+SOURCES += test.cpp \
+ ../src/GooglePlugin.cpp \
+ ../src/TranslationGoogle.cpp
+
+check.target = check
+check.commands = ./GooglePluginTests
+QMAKE_EXTRA_TARGETS += check
TEMPLATE = subdirs
-SUBDIRS = xdxf
+SUBDIRS = xdxf google
check.target = check
check.CONFIG = recursive
#include "TranslationXdxf.h"
#include <QDebug>
-TranslationXdxf::TranslationXdxf() {
+TranslationXdxf::TranslationXdxf():_key(""),_dictionaryInfo("") {
+ xdxfPlugin=0;
}
TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo,
this->xdxfPlugin=xdxfPlugin;
if(xdxfPlugin)
_dictHash = xdxfPlugin->hash();
+ _bookmark=0;
}
QString TranslationXdxf::key() const {
QString _dictionaryInfo;
XdxfPlugin *xdxfPlugin;
int _dictHash;
-
};
#endif // TRANSLATIONXDXF_H
CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
XdxfPlugin *plugin = new XdxfPlugin();
- static int a=0;
if(settings){
plugin->setPath(settings->value("path"));
QStringList list = settings->keys();
foreach(QString key, list)
plugin->settings()->setValue(key, settings->value(key));
- a=a+1;
plugin->db_name = plugin->_settings->value("type")
+ plugin->_settings->value("path");
plugin->db = QSqlDatabase::addDatabase("QSQLITE", plugin->db_name);