Clean and order documentation in source files. Source ready to beta 2 release
[mdictionary] / src / plugins / stardict / StarDictPlugin.h
index 632ecdc..5937b3a 100644 (file)
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
+/*!
+     \file StarDictPlugin.h
+     \brief Implementation of stardict plugin's main class.
 
-
-/*! \file xdxfplugin.h
+     \author Jakub Jaszczynski
 */
+
 #ifndef STARDICTPLUGIN_H
 #define STARDICTPLUGIN_H
 
 #include <QDialog>
 #include <QRegExp>
 #include <QTime>
-#include <QSqlQuery>
-#include <QSqlDatabase>
-#include <QSqlError>
 #include <QFile>
-#include <QXmlStreamReader>
+//#include <QXmlStreamReader>
 #include <QtPlugin>
 #include <QHash>
 #include <QIcon>
@@ -65,7 +65,7 @@ public:
     //! \returns dictionary name (like "old English" or so)
     QString name() const;
 
-    //! \returns dictionary type (xdxf, google translate, etc)
+    //! \returns dictionary type (xdxf, google,starDict translate, etc)
     QString type() const;
 
     //! returns information about dictionary in xml (name, authors, etc)
@@ -73,7 +73,7 @@ public:
 
     /*! \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*
@@ -87,38 +87,38 @@ public:
         return search(key, 0, 0);
     }
 
-    /*! \return a description of a word given by a QString
+    /*!
+        \return a description of a word given by a QString
         \param offset offset of translation to be cut out
         \param len lenght of translation to be cut out
-        */
+    */
     QString search(QString key, qint64 offset, qint32 len);
 
     //! \returns current plugin settings
     Settings* settings();
 
-    //! \returns words count in a dictionary
-    long wordsCount();
-
     //! Sets new settings
     bool setSettings(const Settings*);
 
     //! \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();
+    */
+    void clean() {;}
 
 
 
 public Q_SLOTS:
-    /*! performs search in a dictionary
-      \param  word word to search for in a 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);
 
@@ -131,84 +131,75 @@ public Q_SLOTS:
 
 private:
 
-    /*! \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 file
+        \param word key compared with keys in a file
+        \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 starDict file
+        \param word key compared with keys in a starDict 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 a xdxf file */
+    /*!
+        searches for a translation of a word which is exactly like a key
+        in a starDict file
+    */
     QString searchFile(QString key);
 
     //! scans dictionary file to get information about it
     bool getDictionaryInfo();
 
-    //! counts the keys in a xdxf file
-    int countWords();
-
-
-    //! language from which we translate
-    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 a dictionary is chosen
-    QIcon _icon;
-
-    //! number of words in a dictionary
-    long _wordsCount;
-    //! indicates if search is stopped
-    volatile bool stopped;
-    Settings *_settings;
-    StarDictDialog* _dictDialog;
-    Settings* _ifoFileSettings;
-    StarDictReader * dictReader;
-
-    /*! Reads and process (converting to qstring) data from StarDict dictionary
+    /*!
+        Reads and process (converting to qstring) data from StarDict dictionary
         file (*.dict[.dz])
         \return converted translation
         \param QByteArray raw data to process
-        \param mode StarDict parametr "sametypesequence" */
-    QString format(QByteArray, QString mode);
+        \param mode StarDict parametr "sametypesequence"
+    */
+    QString format(QByteArray, QString mode,QString key);
 
-    /*! Reads bytes bytes of data or reads until \0
+    /*!
+        Reads bytes bytes of data or reads until \0
         \param it iterator to given data
         \param end end of data
         \param bytes to read
-        \return readed data chunk*/
+        \return readed data chunk
+    */
     QByteArray read(QByteArray::iterator it, QByteArray::iterator end,
            int bytes = 0);
 
-    /*! Interpret data basis on mode (StarDict dict data type)
+    /*!
+        Interpret data basis on mode (StarDict dict data type)
         \param it iterator on given data set
         \param end iterator pointing to the data end
         \param mode stardict dict data type
         \param last used to interpret sametypesequence field last letter (see
-                StarDict format description)
-        \return QSting containing interpreted data chunk */
+        StarDict format description)
+        \return QSting containing interpreted data chunk
+    */
     QString interpret(QByteArray::iterator it, QByteArray::iterator end,
-            QChar mode, bool last = false);
+            QChar mode,QString key, bool last = false);
+
+    QString _langFrom;
+    QString _langTo;
+    QString _name;
+    QString _infoNote;
+    QIcon _icon;
+    volatile bool stopped;
+    Settings *_settings;
+    StarDictDialog* _dictDialog;
+    Settings* _ifoFileSettings;
+
+    friend class StarDictTests;
 };
 
 #endif // XDXFPLUGIN_H