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
25 #ifndef STARDICTPLUGIN_H
26 #define STARDICTPLUGIN_H
34 #include <QSqlDatabase>
37 #include <QXmlStreamReader>
42 #include "../../include/CommonDictInterface.h"
43 #include "../../include/settings.h"
44 #include "StarDictDialog.h"
45 #include "TranslationStarDict.h"
47 class TranslationXdxf;
49 class StarDictPlugin : public CommonDictInterface
52 Q_INTERFACES(CommonDictInterface)
54 StarDictPlugin(QObject *parent=0);
58 //! \returns source language code iso 639-2
59 QString langFrom() const;
61 //! \returns destination language code iso 639-2
62 QString langTo() const;
64 //! \returns dictionary name (like "old English" or so)
67 //! \returns dictionary type (xdxf, google translate, etc)
70 //! returns information about dictionary in xml (name, authors, etc)
71 QString infoNote() const;
73 /*! \returns DictDialog object that creates dialogs
74 for adding a new dictionary and changing plugin settings
76 DictDialog* dictDialog();
78 //! \returns new, clean copy of plugin with settings set as in Settings*
79 CommonDictInterface* getNew(const Settings*) const;
81 //! \returns whether plugin can start searching
82 bool isAvailable() const;
84 //! \returns a description of a word given by a QString
85 QString search(QString key);
87 //! \returns current plugin settings
90 //! \returns words count in a dictionary
94 bool setSettings(const Settings*);
96 //! \return object containing data parsed from .ifo file
99 //! \returns plugin icon
102 /*! plugin should delete any files (eg. cache) that have been created and are ready
110 /*! performs search in a dictionary
111 \param word word to search for in a dictionary
112 \param limit limit on number of results
114 After finishing search it has to emit
115 \see CommonDictInterface:finalTranslation finalTranslation
117 QList<Translation*> searchWordList(QString word, int limit=0);
119 //! stops current operation
122 //! loads translations for each plugin only once
128 /*! \returns true or false depending on whether the dictionary is cached
132 /*! searches for a list of words similar to a word in a database file
133 \param word key compared with keys in a database
134 \param limit limits the number of translations in returned list,
136 \returns list of translations
138 QList<Translation*> searchWordListCache(QString word, int limit=0);
140 /*! searches for a list of words similar to a word in a xdxf file
141 \param word key compared with keys in a xdxf file
142 \param limit limits the number of translations in returned list,
144 \returns list of translations
146 QList<Translation*> searchWordListFile(QString word, int limit=0);
148 /*! searches for a translation of a word which is exactly like a key
150 QString searchFile(QString key);
152 //! scans dictionary file to get information about it
153 bool getDictionaryInfo();
155 //! counts the keys in a xdxf file
159 //! language from which we translate
161 //! language to which we translate
163 //! name of a dictionary
165 //! information about dictionary
168 QString _dictionaryInfo;
170 //! icon displayed during translations and when a dictionary is chosen
173 //! number of words in a dictionary
175 //! indicates if search is stopped
176 volatile bool stopped;
178 StarDictDialog* _dictDialog;
179 Settings* _ifoFileSettings;
182 #endif // XDXFPLUGIN_H