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 *******************************************************************************/
22 /*! \file GooglePlugin.h
24 \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
27 #ifndef GOOGLEPLUGIN_H
28 #define GOOGLEPLUGIN_H
37 #include "../../include/CommonDictInterface.h"
38 #include "../../include/settings.h"
39 #include "../../include/DictDialog.h"
40 #include "TranslationGoogle.h"
41 #include "GoogleDictDialog.h"
43 class GoogleDictDialog;
45 class GooglePlugin : public CommonDictInterface
48 Q_INTERFACES(CommonDictInterface)
50 GooglePlugin(QObject *parent=0);
53 //! returns source language code iso 639-2
54 QString langFrom() const;
56 //! returns destination language code iso 639-2
57 QString langTo() const;
59 //! returns dictionary name (like "old English" or so)
62 //! returns dictionary type (xdxf, google translate, etc)
65 //! returns information about dictionary (name, authors, etc)
66 QString infoNote() const;
68 //! sets the language to which the translation is done
69 void setLangTo(QString langTo);
71 //! sets the language from which the translation is done
72 void setLangFrom(QString langFrom);
74 /*! returns DictDialog object that creates dialogs
75 for adding new dictionaries and changing plugin things
77 DictDialog* dictDialog();
79 //! returns new, clean copy of plugin with settings set as in Settings*
80 CommonDictInterface* getNew(const Settings*) const;
82 //! returns whether plugin can start searching
83 bool isAvailable() const;
85 //! sets if connection with Internet is possible
86 void setConnectionAccept(QString connectionAcepted);
88 //! returns the value of "connection_accepted" from settings
89 bool isConnectionAccept() const;
91 //! returns a description of a word given by a QString
92 QString search(QString key);
94 //! returns current plugin settings
98 void setSettings(const Settings*);
100 //! returns plugin icon
103 //! returns empty translation object (to be fetched later) for given key
104 Translation* getTranslationFor(QString key);
106 //! initializes the list of available languages in Google translator
107 static void initLanguages();
109 static QMap<QString, QString> languages;
112 /*! performs search in a dictionary
113 \param word word to search for in a dictionary
114 \param limit limit on number of results
116 After finishing search it has to emit
117 \see CommonDictInterface:finalTranslation finalTranslation
119 QList<Translation*> searchWordList(QString word, int limit=0);
121 //! stop current operation
124 //! function called after the request from Google is returned
127 //! transforms Google format to String with translation
128 QString jsonParse(QString result);
130 //! sets information about dictionary
131 void getDictionaryInfo();
133 //! loads translations for each plugin only once
137 //! name of a dictionary
139 //! type of a dictionary
141 //! information about dictionary
144 //! icon displayed during translations and when the dictionary is chosen
147 //! indicates if search is stopped
149 bool _connectionAccept;
150 //! indicates if response from Google appeared
153 GoogleDictDialog *_dictDialog;
156 #endif // GOOGLEPLUGIN_H