Merge branch 'master' of ssh://drop.maemo.org/git/mdictionary
[mdictionary] / src / plugins / xdxf / xdxfplugin.h
diff --git a/src/plugins/xdxf/xdxfplugin.h b/src/plugins/xdxf/xdxfplugin.h
new file mode 100644 (file)
index 0000000..a95d542
--- /dev/null
@@ -0,0 +1,187 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+
+/*! \file xdxfplugin.h
+*/
+#ifndef XDXFPLUGIN_H
+#define XDXFPLUGIN_H
+
+
+#include <QObject>
+#include <QDialog>
+#include <QRegExp>
+#include <QTime>
+#include <QSqlQuery>
+#include <QSqlDatabase>
+#include <QSqlError>
+#include <QFile>
+#include <QXmlStreamReader>
+#include <QtPlugin>
+
+#include "../../common/CommonDictInterface.h"
+#include "../../common/settings.h"
+#include "XdxfDictDialog.h"
+#include "XdxfCachingDialog.h"
+#include "TranslationXdxf.h"
+
+class TranslationXdxf;
+
+class XdxfPlugin : public CommonDictInterface
+{
+    Q_OBJECT
+    Q_INTERFACES(CommonDictInterface)
+public:
+    XdxfPlugin(QObject *parent=0);
+
+    ~XdxfPlugin();
+
+    //! returns source language code iso 639-2
+    QString langFrom() const;
+
+    //! returns destination language code iso 639-2
+    QString langTo() const;
+
+    //! returns dictionary name (like "old English" or so)
+    QString name() const;
+
+    //! returns dictionary type (xdxf, google translate, etc)
+    QString type() const;
+
+    //! returns information about dictionary in html (name, authors, etc)
+    QString infoNote() const;
+
+    /*! returns DictDialog object that creates dialogs
+        for adding new dictionary and changing plugin things
+      */
+    DictDialog* dictDialog();
+
+    //! 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;
+
+    //! 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();
+
+    //! returns words count in 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
+        to be deleted
+        */
+    void clean();
+
+
+
+public Q_SLOTS:
+    /*! performs search in dictionary
+      \param  word word to search in dictionary
+      \param limit limit on number of results
+
+      After finishing search it has to emit
+      \see CommonDictInterface:finalTranslation  finalTranslation
+    */
+    QList<Translation*> searchWordList(QString word, int limit=0);
+
+    //! stop current operation
+    void stop();
+
+
+
+Q_SIGNALS:
+    //! emitted 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);
+<<<<<<< HEAD:trunk/src/plugins/xdxf/src/xdxfplugin.h
+
+    //! scan dictionary file to get information about it
+    bool getDictionaryInfo();
+=======
+    //! scans dictionary file to get information about it
+    void getDictionaryInfo();
+>>>>>>> d87efdac5743196dbae222515ab86c6e321c3d98:src/plugins/xdxf/xdxfplugin.h
+
+    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;
+    //! information about dictionary
+    QString _infoNote;
+    //! path to dictionary file
+ //   QString path;
+    uint _hash;
+    QIcon _icon;
+    QSqlDatabase db;
+    QString db_name;
+    //! number of words in dictionary
+    long _wordsCount;
+    volatile bool stopped;
+    Settings *_settings;
+    XdxfDictDialog* _dictDialog;
+    XdxfCachingDialog* cachingDialog;
+
+};
+
+#endif // XDXFPLUGIN_H
+
+