removeAccents refactorized out to the AccentsNormalizer class
[mdictionary] / trunk / src / plugins / xdxf / src / xdxfplugin.h
index ce2dbca..f3cabe6 100644 (file)
 
 *******************************************************************************/
 
+
+/*! \file xdxfplugin.h
+*/
 #ifndef XDXFPLUGIN_H
 #define XDXFPLUGIN_H
 
-#include "../../../includes/CommonDictInterface.h"
+
 #include <QObject>
 #include <QDialog>
 #include <QRegExp>
 #include <QTime>
+#include <QSqlQuery>
+#include <QSqlDatabase>
+#include <QSqlError>
+#include <QFile>
+#include <QXmlStreamReader>
+#include <QtPlugin>
+
+#include "../../../includes/CommonDictInterface.h"
+#include "../../../includes/settings.h"
 #include "XdxfDictDialog.h"
+#include "XdxfCachingDialog.h"
+#include "TranslationXdxf.h"
 
 class TranslationXdxf;
 
@@ -37,6 +51,7 @@ class XdxfPlugin : public CommonDictInterface
     Q_INTERFACES(CommonDictInterface)
 public:
     XdxfPlugin(QObject *parent=0);
+    ~XdxfPlugin();
 
     //! returns source language code iso 639-2
     QString langFrom() const;
@@ -54,11 +69,10 @@ public:
     QString infoNote() const;
 
     /*! returns DictDialog object that creates dialogs
-        for adding new dictionary and change plugin settings
+        for adding new dictionary and change plugin tings
       */
     DictDialog* dictDialog();
 
-
     //! returns new, clean copy of plugin with setting set as in Settings*
     CommonDictInterface* getNew(const Settings*) const;
 
@@ -77,6 +91,15 @@ public:
     //! returns current plugin settings
     Settings* settings();
 
+    //! returns words count in dictionary
+    long wordsCount();
+
+    //! Sets new settings
+    void setSettings(Settings*);
+
+    //! returns plugin icon
+    virtual QIcon* icon();
+
 public Q_SLOTS:
     /*! performs search in dictionary
       \param  word word to search in dictionary
@@ -85,26 +108,65 @@ public Q_SLOTS:
       After finishing search it has to emit
       \see CommonDictInterface:finalTranslation  finalTranslation
     */
-    QList<Translation*> searchWordList(QString word, int limit);
+    QList<Translation*> searchWordList(QString word, int limit=0);
 
     //! stop current operation
     void stop();
 
+Q_SIGNALS:
+    //! emited with percent count of caching progress, and time elapsed from
+    //! last signal emit
+    void updateCachingProgress(int, int);
+
+
+
 private:
+/*! returns true or false depending on whether the dictionary is cached
+    or not, not implemented yet
+ */
     bool isCached();
+
+//! sets the path to dictionary file and adds it to settings
     void setPath(QString);
+
+    QList<Translation*> searchWordListCache(QString word, int limit=0);
+    QList<Translation*> searchWordListFile(QString word, int limit=0);
+    QString searchFile(QString key);
+    QString searchCache(QString key);
+    //! scan dictionary file to get information about it
+    void getDictionaryInfo();
+
+    int countWords();
+    bool makeCache(QString dir);
+
+    //! language from which we translate
     QString _langFrom;
+    //! language to which we translate
     QString _langTo;
+    //! name of a dictionary
     QString _name;
+    //! type of a dictionary
     QString _type;
+    //! information about dictionary
     QString _infoNote;
-    QDialog *_loadDialog;
-    QDialog *_settingsDialog;
+    //! path to dictionary file
     QString path;
     uint _hash;
-    bool stopped;   /*volatile*/
+    QIcon _icon;
+    QSqlDatabase db;
+    QString db_name;
+
+    //! number of words in dicrionary
+    long _wordsCount;
+
+
+    volatile bool stopped;
     Settings *_settings;
     XdxfDictDialog* _dictDialog;
+    XdxfCachingDialog* cachingDialog;
+//    extern void initAccents();
+ //   extern QString removeAccents(QString string);
+
 };
 
 #endif // XDXFPLUGIN_H