1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
23 /*! \file xdxfplugin.h
34 #include <QSqlDatabase>
37 #include <QXmlStreamReader>
40 #include "../../../includes/CommonDictInterface.h"
41 #include "../../../includes/settings.h"
42 #include "XdxfDictDialog.h"
43 #include "XdxfCachingDialog.h"
44 #include "TranslationXdxf.h"
46 class TranslationXdxf;
48 class XdxfPlugin : public CommonDictInterface
51 Q_INTERFACES(CommonDictInterface)
53 XdxfPlugin(QObject *parent=0);
56 //! returns source language code iso 639-2
57 QString langFrom() const;
59 //! returns destination language code iso 639-2
60 QString langTo() const;
62 //! returns dictionary name (like "old english" or so)
65 //! returns dictionary type (xdxf, google translate, etc)
68 //! returns information about dictionary in html (name, authors, etc)
69 QString infoNote() const;
71 /*! returns DictDialog object that creates dialogs
72 for adding new dictionary and change plugin tings
74 DictDialog* dictDialog();
76 //! returns new, clean copy of plugin with setting set as in Settings*
77 CommonDictInterface* getNew(const Settings*) const;
79 //! returns whether plugin can start searching
80 bool isAvailable() const;
82 //! returns a description of a word given by a QString
83 QString search(QString key);
85 //! returns a unique hash for a dictionary
88 //! set unique value (unique for every dictionary not plugin)
91 //! returns current plugin settings
94 //! returns words count in dictionary
98 void setSettings(Settings*);
100 //! returns plugin icon
101 virtual QIcon* icon();
104 /*! performs search in dictionary
105 \param word word to search in dictionary
106 \param limit limit on number of results
108 After finishing search it has to emit
109 \see CommonDictInterface:finalTranslation finalTranslation
111 QList<Translation*> searchWordList(QString word, int limit=0);
113 //! stop current operation
117 //! emited with percent count of caching progress, and time elapsed from
119 void updateCachingProgress(int, int);
123 QString removeAccents(QString);
126 /*! returns true or false depending on whether the dictionary is cached
127 or not, not implemented yet
131 //! sets the path to dictionary file and adds it to settings
132 void setPath(QString);
134 QList<Translation*> searchWordListCache(QString word, int limit=0);
135 QList<Translation*> searchWordListFile(QString word, int limit=0);
136 QString searchFile(QString key);
137 QString searchCache(QString key);
138 //! scan dictionary file to get information about it
139 void getDictionaryInfo();
142 bool makeCache(QString dir);
145 //! language from which we translate
147 //! language to which we translate
149 //! name of a dictionary
151 //! type of a dictionary
153 //! information about dictionary
155 //! path to dictionary file
162 //! number of words in dicrionary
166 volatile bool stopped;
168 XdxfDictDialog* _dictDialog;
169 XdxfCachingDialog* cachingDialog;
171 QMap<QChar, QRegExp> letters;
176 #endif // XDXFPLUGIN_H