e094144811a95b08ad602cb929c9aac59298cf86
[mdictionary] / trunk / src / includes / CommonDictInterface.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 // Created by Bartosz Szatkowski
23
24 #ifndef COMMONDICTINTERFACE_H
25 #define COMMONDICTINTERFACE_H
26
27 #include <QString>
28 #include <QDialog>
29 #include <QObject>
30 #include <QList>
31 #include "translation.h"
32 class Settings;
33
34 Q_DECLARE_INTERFACE (CommonDictInterface, "xdxfInterface")
35
36 //! Interface for dict engines plugins
37 class CommonDictInterface : public QObject {
38   Q_OBJECT
39   public:
40     CommonDictInterface(QObject *parent = 0):QObject(parent) {}
41
42     //! returns source language code iso 639-2
43     virtual QString langFrom() const = 0;
44
45     //! returns destination language code iso 639-2
46     virtual QString langTo() const = 0;
47
48     //! returns dictionary name (like "old english" or so
49     virtual QString name() const = 0;
50
51     //! returns dictionary type (xdxf, google translate, etc)
52     virtual QString type() const = 0;
53
54     //! returns information about dictionary in html (name, authors, etc)
55     virtual QString infoNote() const = 0;
56
57     //! return dialog that creates new dictionary and fills necesary options
58     //! QDialog should returns Setting* object after being showed
59     virtual QDialog* loadDialog() = 0;
60
61     //! return dialog with dictionary settings
62     virtual QDialog* settingsDialog() = 0;
63
64     //! return new, clean copy of plugin with setting set as in Settings*
65     virtual CommonDictInterface* getNew(const Settings*) const = 0;
66
67     //! returns whether plugin can start searching
68     virtual bool isAvailable() const = 0;
69
70     //! returns the actual translation of a word given in key
71     virtual QString search(QString key) = 0;
72
73     //! \returns unique value (unique for every dictionary not plugin
74     virtual uint hash() const = 0;
75
76  public Q_SLOTS:
77     /*! performs search in dictionary
78         \param  word word to search in dictionary
79         \param limit limit on number of results
80
81         After finishing search it have to emit
82         \see CommonDictInterface:finalTranslation  finalTranslation
83
84     */
85     virtual void searchWordList(QString word, int limit) = 0;
86
87     //! stop current operation
88     virtual void stop() = 0;
89
90   Q_SIGNALS:
91     //! emit list of found Translations
92     void finalTranslation(QList<Translation*>);
93
94     //! emited after dictionary is ready to use afer being loaded
95     void loaded(CommonDictInterface*);
96 };
97
98 Q_DECLARE_INTERFACE(CommonDictInterface, "CommonDictInterface/0.1");
99
100 #endif