add draft of google translation
[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 public Q_SLOTS:
91     /*! performs search in dictionary
92       \param  word word to search in dictionary
93       \param limit limit on number of results
94
95       After finishing search it has to emit
96       \see CommonDictInterface:finalTranslation  finalTranslation
97     */
98     QList<Translation*> searchWordList(QString word, int limit=0);
99
100     //! stop current operation
101     void stop();
102
103 private:
104     //! language from which we translate
105     QString _langFrom;
106     //! language to which we translate
107     QString _langTo;
108     //! name of a dictionary
109     QString _name;
110     //! type of a dictionary
111     QString _type;
112     //! information about dictionary
113     QString _infoNote;
114     //! path to dictionary file
115     QString path;
116     uint _hash;
117     QIcon _icon;
118     Settings *_settings;
119     bool stopped;
120 };
121
122 #endif // GOOGLEPLUGIN_H
123
124