X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fplugins%2Fgoogle%2FGooglePlugin.cpp;h=3c3ff11e97687a9933d13f682946023b0b8f76f1;hb=0920a54ebc21e26ea44fab232832f45b7882da19;hp=95ae0e4d140a5b1da8cdb969414eaac2d65ff426;hpb=6594c63c9925f07d851cfe99fa8366fb92ddeaae;p=mdictionary diff --git a/src/plugins/google/GooglePlugin.cpp b/src/plugins/google/GooglePlugin.cpp index 95ae0e4..3c3ff11 100644 --- a/src/plugins/google/GooglePlugin.cpp +++ b/src/plugins/google/GooglePlugin.cpp @@ -18,8 +18,10 @@ Copyright 2010 Comarch S.A. *******************************************************************************/ +/*! + \file GooglePlugin.cpp + \brief Implementation of google plugin's main class. -/*! \file GooglePlugin.cpp \author Jakub Jaszczynski */ @@ -28,6 +30,8 @@ #include "GoogleDictDialog.h" QMap GooglePlugin::languages; +bool GooglePlugin::noNetworkErrorShowed = false; + GooglePlugin::GooglePlugin(QObject *parent): CommonDictInterface(parent), _name(""),_infoNote("") { @@ -37,20 +41,22 @@ GooglePlugin::GooglePlugin(QObject *parent): CommonDictInterface(parent), _settings->setValue("type","google"); _settings->setValue("connection_accepted","true"); _dictDialog = new GoogleDictDialog(this,this); - _icon = QIcon("/usr/share/mdictionary/google.png"); + _iconPath = "/usr/share/mdictionary/google.png"; + _icon = QIcon(_iconPath); stopped = false; initLanguages(); - http = new QHttp(this); + http = new QHttp(); connect(http, SIGNAL(done(bool)), this, SLOT(done())); + threa=new QThread(); + http->moveToThread(threa); + threa->start(); } void GooglePlugin::retranslate() { QString locale = QLocale::system().name(); - QTranslator *translator = new QTranslator(this); - if(!translator->load(":/google/translations/" + locale)) { translator->load(":/google/translations/en_US"); } @@ -145,6 +151,10 @@ QIcon* GooglePlugin::icon() { return &_icon; } +QString GooglePlugin::iconPath(){ + return _iconPath; +} + CommonDictInterface* GooglePlugin::getNew(const Settings* settings) const { GooglePlugin *plugin = new GooglePlugin(); @@ -155,7 +165,7 @@ CommonDictInterface* GooglePlugin::getNew(const Settings* settings) const { QString GooglePlugin::search(QString) { - qDebug() << "function is not used in this plugin"; + qDebug() << "function is not used in google plugin"; return QString(""); } @@ -169,8 +179,10 @@ QList GooglePlugin::searchWordList(QString word, int ) { QList translations; if(isAvailable()) { QString error(""); - word.replace("*",""); /*remove wildcard*/ - word.replace("?",""); + char wrongChar[]={"*?&<>"}; + for(unsigned int a=0;avalue("lang_from"), _settings->value("lang_to")); @@ -187,14 +199,22 @@ QList GooglePlugin::searchWordList(QString word, int ) { wait=true; /* bool - change in slot done (initiate by http) */ stopped=false; /* bool - change in slot stop (initiate in gui) */ + int lastState=0; http->request(head, data); - while(wait && (error=="" || error=="Unknown error") && !stopped) + while(wait && (error=="" || error=="Unknown error") && !stopped){ error=http->errorString(); - + if(lastState!=http->state()) { + lastState=http->state(); + if(lastState==0) + done(); + } + } if(error!="" && error!="Unknown error") { - qDebug()<readAll()); @@ -272,9 +292,8 @@ QString GooglePlugin::jsonParse(QString result) { } returnLang=list1.at(index*2+1); if(partOfSpeach.size()==0){ - if(translation.toLower()==original.toLower()){ + if(translation.toLower()==original.toLower()) return QString(""); // word doesn't exist"; - } else return "\""+translation+"\""; }