Clean and order documentation in source files. Source ready to beta 2 release
[mdictionary] / src / plugins / xdxf / xdxfplugin.h
index c81d47a..858fd49 100644 (file)
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
+/*!
+    \file xdxfplugin.h
+    \brief Implementation of xdxf plugin's main class.
 
-
-/*! \file xdxfplugin.h
+    \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
 */
+
 #ifndef XDXFPLUGIN_H
 #define XDXFPLUGIN_H
 
-
 #include <QObject>
 #include <QDialog>
 #include <QRegExp>
 #include <QFile>
 #include <QXmlStreamReader>
 #include <QtPlugin>
+#include <QHash>
 
 #include "../../include/CommonDictInterface.h"
 #include "../../include/settings.h"
 #include "XdxfDictDialog.h"
 #include "XdxfCachingDialog.h"
 #include "TranslationXdxf.h"
+#include "XdxfDictDownloader.h"
 
 class TranslationXdxf;
 
@@ -51,68 +55,70 @@ class XdxfPlugin : public CommonDictInterface
     Q_INTERFACES(CommonDictInterface)
 public:
     XdxfPlugin(QObject *parent=0);
-
     ~XdxfPlugin();
 
-    //! 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 in xml (name, authors, etc)
     QString infoNote() const;
 
-    /*! returns DictDialog object that creates dialogs
-        for adding new dictionary and changing plugin settings
-      */
+    /*!
+        \returns DictDialog object that creates dialogs
+        for adding a new dictionary and changing plugin settings
+    */
     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;
 
-    //! 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 current plugin settings
+    //! \returns current plugin settings
     Settings* settings();
 
-    //! returns words count in dictionary
+    //! \returns words count in a dictionary
     long wordsCount();
 
     //! Sets new settings
     bool setSettings(const Settings*);
 
-    //! returns plugin icon
+    //! \returns plugin icon
     QIcon* icon();
 
-    /*! plugin should delete any files (eg. cache) that have been created and are ready
+    /*!
+        plugin should delete any files (eg. cache) that have been created and are ready
         to be deleted
-        */
+    */
     void clean();
 
-
+    static XdxfDictDownloader dictDownloader;
 
 public Q_SLOTS:
-    /*! performs search in dictionary
-      \param  word word to search in dictionary
-      \param limit limit on number of results
+    /*!
+        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
-      \see CommonDictInterface:finalTranslation  finalTranslation
+        After finishing search it has to emit
+        \see CommonDictInterface:finalTranslation  finalTranslation
     */
     QList<Translation*> searchWordList(QString word, int limit=0);
 
-    //! stop current operation
+    //! stops current operation
     void stop();
 
     //! loads translations for each plugin only once
@@ -123,65 +129,65 @@ Q_SIGNALS:
     //! last signal emit
     void updateCachingProgress(int, int);
 
-
 private:
-
-    /*! returns true or false depending on whether the dictionary is cached
-        or not, not implemented yet
-     */
+    /*!
+        \returns true or false depending on whether the dictionary is cached
+        or not
+    */
     bool isCached();
-    /*! searches for a list of words similar to a word in a database file
-    \param word key compared with keys in a database
-    \param limit limits the number of translations in returned list,
-           0 means unlimited
-    \returns list of translations
+    /*!
+        searches for a list of words similar to a word in a database file
+        \param word key compared with keys in a database
+        \param limit limits the number of translations in returned list,
+        0 means unlimited
+        \returns list of translations
     */
     QList<Translation*> searchWordListCache(QString word, int limit=0);
 
-    /*! searches for a list of words similar to a word in a xdxf file
-    \param word key compared with keys in a xdxf file
-    \param limit limits the number of translations in returned list,
-           0 means unlimited
-    \returns list of translations
+    /*!
+        searches for a list of words similar to a word in a xdxf file
+        \param word key compared with keys in a xdxf file
+        \param limit limits the number of translations in returned list,
+        0 means unlimited
+        \returns list of translations
     */
     QList<Translation*> searchWordListFile(QString word, int limit=0);
 
-    /*! searches for a translation of a word which is exactly like a key
-        in xdxf file */
+    /*!
+        searches for a translation of a word which is exactly like a key
+        in a xdxf file
+    */
     QString searchFile(QString key);
 
-    /*! searches for a translation of a word which is exactly like a key
-        in database file */
+    /*!
+        searches for a translation of a word which is exactly like a key
+        in a database file
+    */
     QString searchCache(QString key);
 
     //! scans dictionary file to get information about it
     bool getDictionaryInfo();
 
-    //! counts the keys in xdxf file
+    //! counts the keys in a xdxf file
     int countWords();
 
-    /*! transforms xdxf files to database files (caching operation)
-        \returns true on success, false on failure */
+    /*!
+        transforms xdxf files to database files (caching operation)
+        \returns true on success, false on failure
+    */
     bool makeCache(QString dir);
 
-    //! language from which we translate
+    static bool dictDownloaderInitialized;
+
     QString _langFrom;
-    //! language to which we translate
     QString _langTo;
-    //! name of a dictionary
     QString _name;
-    //! information about dictionary
     QString _infoNote;
-
     QString _dictionaryInfo;
-
-    //! icon displayed during translations and when the dictionary is chosen
     QIcon _icon;
     QSqlDatabase db;
     QString db_name;
-    //! number of words in dictionary
     long _wordsCount;
-    //! indicates if search is stopped
     volatile bool stopped;
     Settings *_settings;
     XdxfDictDialog* _dictDialog;