Added strip accent search for bookmarks
[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 /*! /file CommonDictInterface.h
23 \brief Common interface for all dicts and plugins \see CommonDictInterface
24
25 \author Bartosz Szatkowski <bulislaw@linux.com>
26 */
27
28 #ifndef COMMONDICTINTERFACE_H
29 #define COMMONDICTINTERFACE_H
30
31 #include <QString>
32 #include <QDialog>
33 #include <QObject>
34 #include <QList>
35 #include "translation.h"
36 #include "Notify.h"
37
38 class DictDialog;
39 class Settings;
40
41
42 //! Interface for dict engines plugins
43 class CommonDictInterface : public QObject {
44   Q_OBJECT
45   public:
46     CommonDictInterface(QObject *parent = 0):QObject(parent) {}
47
48     virtual ~CommonDictInterface() {}
49
50     //! returns source language code iso 639-2
51     virtual QString langFrom() const = 0;
52
53     //! returns destination language code iso 639-2
54     virtual QString langTo() const = 0;
55
56     //! returns dictionary name (like "old english" or so
57     virtual QString name() const = 0;
58
59     //! returns dictionary type (xdxf, google translate, etc)
60     virtual QString type() const = 0;
61
62     //! returns information about dictionary in html (name, authors, etc)
63     virtual QString infoNote() const = 0;
64
65     /*! returns DictDialog object that creates dialogs
66         for adding new dictionary and change plugin settings*/
67     virtual DictDialog* dictDialog() = 0;
68
69
70     //! returns new, clean copy of plugin with setting set as in Settings*
71     virtual CommonDictInterface* getNew(const Settings*) const = 0;
72
73     //! returns whether plugin can start searching
74     virtual bool isAvailable() const = 0;
75
76     //! returns the actual translation of a word given in key
77     virtual QString search(QString key) = 0;
78
79     //! \returns unique value (unique for every dictionary not plugin
80     virtual uint hash() const = 0;
81
82     //! sets unique value (unique for every dictionary not plugin)
83     virtual void setHash(uint) = 0;
84
85     //! returns current plugin settings
86     virtual Settings* settings() = 0;
87
88     //! returns plugin icon
89     virtual QIcon* icon() = 0;
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                 if limit=0 all matching words are returned
96
97         After finishing search it have to emit
98         \see CommonDictInterface:finalTranslation  finalTranslation
99     */
100     virtual QList<Translation*> searchWordList(QString word, int limit=0) = 0;
101
102     //! stops current operation
103     virtual void stop() = 0;
104
105   Q_SIGNALS:
106
107     //! emited after dictionary is ready to use afer being loaded
108     void loaded(CommonDictInterface*);
109
110     //! emited after change dictionary settings
111     void settingsChanged();
112
113     /*! emmited to backbone when needed to inform user about something
114         \param Backbone::NotifyType gui my dacide to show different typet in
115             different ways
116         \param QString text of the notification
117     */
118     void notify(Notify::NotifyType, QString);
119 };
120
121 Q_DECLARE_INTERFACE(CommonDictInterface, "CommonDictInterface/0.1");
122
123 #endif