Fixed dictionary hashing
[mdictionary] / src / plugins / google / GooglePlugin.h
index 596eaaa..3738664 100644 (file)
@@ -34,9 +34,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"
 
@@ -65,8 +65,10 @@ public:
     //! returns information about dictionary in html (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
@@ -74,25 +76,21 @@ public:
       */
     DictDialog* dictDialog();
 
-    //! returns new, clean copy of plugin with setting 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
     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
     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
     Settings* settings();
 
@@ -102,9 +100,13 @@ public:
     //! returns plugin icon
     QIcon* icon();
 
+    //! returns empty translation object (to be fetched later) for 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
@@ -119,23 +121,33 @@ public slots:
     //! stop 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();
+
 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 the dictionary is chosen
     QIcon _icon;
     Settings *_settings;
+    //! indicates if search is stopped
     bool stopped;
     bool _connectionAccept;
+    //! indicates if response from Google appeared
     volatile bool wait;
     QHttp *http;
     GoogleDictDialog *_dictDialog;