272afd955ba0e13d263424109d7a8bfd573122d2
[mdictionary] / trunk / src / plugins / google / src / GooglePlugin.h
1 /*******************************************************************************
2
3     This file is part of mDictionary.
4
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.
9
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.
14
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/>.
17
18     Copyright 2010 Comarch S.A.
19
20 *******************************************************************************/
21
22
23 /*! \file GooglePlugin.h
24 */
25 #ifndef GOOGLEPLUGIN_H
26 #define GOOGLEPLUGIN_H
27
28
29 #include <QObject>
30 #include <QDialog>
31 #include <QtPlugin>
32 #include <QIcon>
33
34 #include "../../../includes/CommonDictInterface.h"
35 #include "../../../includes/settings.h"
36
37
38 class GooglePlugin : public CommonDictInterface
39 {
40     Q_OBJECT
41     Q_INTERFACES(CommonDictInterface)
42 public:
43     GooglePlugin(QObject *parent=0);
44     ~GooglePlugin();
45
46     //! returns source language code iso 639-2
47     QString langFrom() const;
48
49     //! returns destination language code iso 639-2
50     QString langTo() const;
51
52     //! returns dictionary name (like "old english" or so)
53     QString name() const;
54
55     //! returns dictionary type (xdxf, google translate, etc)
56     QString type() const;
57
58     //! returns information about dictionary in html (name, authors, etc)
59     QString infoNote() const;
60
61     /*! returns DictDialog object that creates dialogs
62         for adding new dictionary and change plugin tings
63       */
64     DictDialog* dictDialog();
65
66     //! returns new, clean copy of plugin with setting set as in Settings*
67     CommonDictInterface* getNew(const Settings*) const;
68
69     //! returns whether plugin can start searching
70     bool isAvailable() const;
71
72     //! returns a description of a word given by a QString
73     QString search(QString key);
74
75     //! returns a unique hash for a dictionary
76     uint hash() const;
77
78     //! set unique value (unique for every dictionary not plugin)
79     void setHash(uint);
80
81     //! returns current plugin settings
82     Settings* settings();
83
84     //! Sets new settings
85     void setSettings(Settings*);
86
87     //! returns plugin icon
88     QIcon* icon();
89
90
91 public Q_SLOTS:
92     /*! performs search in dictionary
93       \param  word word to search in dictionary
94       \param limit limit on number of results
95
96       After finishing search it has to emit
97       \see CommonDictInterface:finalTranslation  finalTranslation
98     */
99     QList<Translation*> searchWordList(QString word, int limit=0);
100
101     //! stop current operation
102     void stop();
103
104 private:
105     void initLanguages();
106     QMap<QString, QString> languages;
107
108     //! language from which we translate
109     QString _langFrom;
110     //! language to which we translate
111     QString _langTo;
112     //! name of a dictionary
113     QString _name;
114     //! type of a dictionary
115     QString _type;
116     //! information about dictionary
117     QString _infoNote;
118     //! path to dictionary file
119     QString path;
120     uint _hash;
121     QIcon _icon;
122     Settings *_settings;
123     bool stopped;
124 };
125
126 #endif // GOOGLEPLUGIN_H
127
128