Added icon to xdxf plugin and commonDictInterface
[mdictionary] / trunk / src / plugins / xdxf / src / xdxfplugin.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 #ifndef XDXFPLUGIN_H
23 #define XDXFPLUGIN_H
24
25 #include "../../../includes/CommonDictInterface.h"
26 #include <QObject>
27 #include <QDialog>
28 #include <QRegExp>
29 #include <QTime>
30 #include "XdxfDictDialog.h"
31
32 class TranslationXdxf;
33
34 class XdxfPlugin : public CommonDictInterface
35 {
36     Q_OBJECT
37     Q_INTERFACES(CommonDictInterface)
38 public:
39     XdxfPlugin(QObject *parent=0);
40
41     //! returns source language code iso 639-2
42     QString langFrom() const;
43
44     //! returns destination language code iso 639-2
45     QString langTo() const;
46
47     //! returns dictionary name (like "old english" or so)
48     QString name() const;
49
50     //! returns dictionary type (xdxf, google translate, etc)
51     QString type() const;
52
53     //! returns information about dictionary in html (name, authors, etc)
54     QString infoNote() const;
55
56     /*! returns DictDialog object that creates dialogs
57         for adding new dictionary and change plugin settings
58       */
59     DictDialog* dictDialog();
60
61
62     //! returns new, clean copy of plugin with setting set as in Settings*
63     CommonDictInterface* getNew(const Settings*) const;
64
65     //! returns whether plugin can start searching
66     bool isAvailable() const;
67
68     //! returns a description of a word given by a QString
69     QString search(QString key);
70
71     //! returns a unique hash for a dictionary
72     uint hash() const;
73
74     //! set unique value (unique for every dictionary not plugin)
75     void setHash(uint);
76
77     //! returns current plugin settings
78     Settings* settings();
79
80     //! returns words count in dictionary
81     long wordsCount();
82
83     //! Sets new settings
84     void setSettings(Settings*);
85
86     //! returns plugin icon
87     virtual QIcon icon();
88
89 public Q_SLOTS:
90     /*! performs search in dictionary
91       \param  word word to search in dictionary
92       \param limit limit on number of results
93
94       After finishing search it has to emit
95       \see CommonDictInterface:finalTranslation  finalTranslation
96     */
97     QList<Translation*> searchWordList(QString word, int limit=0);
98
99     //! stop current operation
100     void stop();
101
102
103 protected:
104     QString removeAccents(QString);
105
106 private:
107 /*! returns true or false depending on whether the dictionary is cached
108     or not, not implemented yet
109  */
110     bool isCached();
111
112 //! sets the path to dictionary file and adds it to settings
113     void setPath(QString);
114
115     //! language from which we translate
116     QString _langFrom;
117     //! language to which we translate
118     QString _langTo;
119     //! name of a dictionary
120     QString _name;
121     //! type of a dictionary
122     QString _type;
123     //! information about dictionary
124     QString _infoNote;
125     QDialog *_loadDialog;
126     QDialog *_settingsDialog;
127     //! path to dictionary file
128     QString path;
129     uint _hash;
130     QIcon _icon;
131
132     //! number of words in dicrionary
133     long _wordsCount;
134
135     //! scan dictionary file to get information about it
136     void getDictionaryInfo();
137
138     volatile bool stopped;
139     Settings *_settings;
140     XdxfDictDialog* _dictDialog;
141 };
142
143 #endif // XDXFPLUGIN_H
144
145