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 "../../include/CommonDictInterface.h"
41 #include "../../include/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);
57 //! \returns source language code iso 639-2
58 QString langFrom() const;
60 //! \returns destination language code iso 639-2
61 QString langTo() const;
63 //! \returns dictionary name (like "old English" or so)
66 //! \returns dictionary type (xdxf, google translate, etc)
69 //! returns information about dictionary in xml (name, authors, etc)
70 QString infoNote() const;
72 /*! \returns DictDialog object that creates dialogs
73 for adding a new dictionary and changing plugin settings
75 DictDialog* dictDialog();
77 //! \returns new, clean copy of plugin with settings set as in Settings*
78 CommonDictInterface* getNew(const Settings*) const;
80 //! \returns whether plugin can start searching
81 bool isAvailable() const;
83 //! \returns a description of a word given by a QString
84 QString search(QString key);
86 //! \returns current plugin settings
89 //! \returns words count in a dictionary
93 bool setSettings(const Settings*);
95 //! \returns plugin icon
98 /*! plugin should delete any files (eg. cache) that have been created and are ready
106 /*! performs search in a dictionary
107 \param word word to search for in a dictionary
108 \param limit limit on number of results
110 After finishing search it has to emit
111 \see CommonDictInterface:finalTranslation finalTranslation
113 QList<Translation*> searchWordList(QString word, int limit=0);
115 //! stops current operation
118 //! loads translations for each plugin only once
122 //! emitted with percent count of caching progress, and time elapsed from
124 void updateCachingProgress(int, int);
129 /*! \returns true or false depending on whether the dictionary is cached
133 /*! searches for a list of words similar to a word in a database file
134 \param word key compared with keys in a database
135 \param limit limits the number of translations in returned list,
137 \returns list of translations
139 QList<Translation*> searchWordListCache(QString word, int limit=0);
141 /*! searches for a list of words similar to a word in a xdxf file
142 \param word key compared with keys in a xdxf file
143 \param limit limits the number of translations in returned list,
145 \returns list of translations
147 QList<Translation*> searchWordListFile(QString word, int limit=0);
149 /*! searches for a translation of a word which is exactly like a key
151 QString searchFile(QString key);
153 /*! searches for a translation of a word which is exactly like a key
154 in a database file */
155 QString searchCache(QString key);
157 //! scans dictionary file to get information about it
158 bool getDictionaryInfo();
160 //! counts the keys in a xdxf file
163 /*! transforms xdxf files to database files (caching operation)
164 \returns true on success, false on failure */
165 bool makeCache(QString dir);
167 //! language from which we translate
169 //! language to which we translate
171 //! name of a dictionary
173 //! information about dictionary
176 QString _dictionaryInfo;
178 //! icon displayed during translations and when a dictionary is chosen
182 //! number of words in a dictionary
184 //! indicates if search is stopped
185 volatile bool stopped;
187 XdxfDictDialog* _dictDialog;
188 XdxfCachingDialog* cachingDialog;
191 #endif // XDXFPLUGIN_H