Merge branch 'qml' of ssh://drop.maemo.org/git/mdictionary into qml
[mdictionary] / src / plugins / google / GooglePlugin.h
index 87c709a..f62603c 100644 (file)
@@ -18,8 +18,9 @@
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
-
-/*! \file GooglePlugin.h
+/*!
+    \file GooglePlugin.h
+    \brief Implementation of google plugin's main class.
 
     \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
 */
@@ -34,9 +35,9 @@
 #include <QIcon>
 #include <QtNetwork>
 
-#include "../../common/CommonDictInterface.h"
-#include "../../common/settings.h"
-#include "../../common/DictDialog.h"
+#include "../../include/CommonDictInterface.h"
+#include "../../include/settings.h"
+#include "../../include/DictDialog.h"
 #include "TranslationGoogle.h"
 #include "GoogleDictDialog.h"
 
@@ -50,65 +51,71 @@ public:
     GooglePlugin(QObject *parent=0);
     ~GooglePlugin();
 
-    //! returns source language code iso 639-2
+    //! \returns source language code iso 639-2
     QString langFrom() const;
 
-    //! returns destination language code iso 639-2
+    //! \returns destination language code iso 639-2
     QString langTo() const;
 
-    //! returns dictionary name (like "old English" or so)
+    //! \returns dictionary name (like "old English" or so)
     QString name() const;
 
-    //! returns dictionary type (xdxf, google translate, etc)
+    //! \returns dictionary type (xdxf, google translate, etc)
     QString type() const;
 
-    //! returns information about dictionary in html (name, authors, etc)
+    //! returns information about dictionary (name, authors, etc)
     QString infoNote() const;
 
+    //! sets the language to which the translation is done
     void setLangTo(QString langTo);
 
+    //! sets the language from which the translation is done
     void setLangFrom(QString langFrom);
 
-    /*! returns DictDialog object that creates dialogs
+    /*!
+        \returns DictDialog object that creates dialogs
         for adding new dictionaries and changing plugin things
-      */
+    */
     DictDialog* dictDialog();
 
-    //! returns new, clean copy of plugin with settings set as in Settings*
+    //! \returns new, clean copy of plugin with settings set as in Settings*
     CommonDictInterface* getNew(const Settings*) const;
 
-    //! returns whether plugin can start searching
+    //! \returns whether plugin can start searching
     bool isAvailable() const;
 
+    //! sets if connection with Internet is possible
     void setConnectionAccept(QString connectionAcepted);
 
+    //! \returns the value of "connection_accepted" from settings
     bool isConnectionAccept() const;
 
-    //! returns a description of a word given by a QString
+    //! \returns a description of a word given by a QString
     QString search(QString key);
 
-    //! returns a unique hash for a dictionary
-    uint hash() const;
-
-    //! sets unique value (unique for every dictionary, not plugin)
-    void setHash(uint);
-
-    //! returns current plugin settings
+    //! \returns current plugin settings
     Settings* settings();
 
     //! Sets new settings
     void setSettings(const Settings*);
 
-    //! returns plugin icon
+    //! \returns plugin icon
     QIcon* icon();
 
+    //! \returns plugin icon's resource path
+    QString iconPath();
+
+    //! \returns empty translation object (to be fetched later) for a given key
     Translation* getTranslationFor(QString key);
 
-    static QMap<QString, QString> initLanguages();
+    //! initializes the list of available languages in Google translator
+    static void initLanguages();
+
+    static QMap<QString, QString> languages;
 
 public slots:
-    /*! performs search in dictionary
-      \param  word word to search in dictionary
+    /*! performs search in a dictionary
+      \param  word word to search for in a dictionary
       \param limit limit on number of results
 
       After finishing search it has to emit
@@ -116,29 +123,44 @@ public slots:
     */
     QList<Translation*> searchWordList(QString word, int limit=0);
 
-    //! stop current operation
+    //! stops current operation
     void stop();
 
+    //! function called after the request from Google is returned
     void done();
 
+    //! transforms Google format to String with translation
     QString jsonParse(QString result);
+
+    //! sets information about dictionary
     void getDictionaryInfo();
 
+    //! loads translations for each plugin only once
+    void retranslate();
+protected:
+    static bool noNetworkErrorShowed;
+
 private:
-    QMap<QString, QString> languages;
+    //! name of a dictionary
     QString _name;
     //! type of a dictionary
     QString _type;
     //! information about dictionary
     QString _infoNote;
-    uint _hash;
+
+    //! icon displayed during translations and when a dictionary is chosen
     QIcon _icon;
+    //! Path to icon
+    QString _iconPath;
     Settings *_settings;
+    //! indicates if search is stopped
     bool stopped;
     bool _connectionAccept;
+    //! indicates if response from Google appeared
     volatile bool wait;
     QHttp *http;
     GoogleDictDialog *_dictDialog;
+    QThread *threa;
 };
 
 #endif // GOOGLEPLUGIN_H