2f10cc1e4d26ad678e764affd2f5804985e3e9d5
[mdictionary] / src / include / GUIInterface.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 //! \file GUIInterface.h
22 //! \brief Defines interface for GUI
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
24
25
26
27 #ifndef GUIINTERFACE_H
28 #define GUIINTERFACE_H
29 #include <QMainWindow>
30 #include <QMultiHash>
31
32 #include "translation.h"
33 #include "CommonDictInterface.h"
34
35 class Settings;
36
37 //! Interface for different GUIs
38 /*!
39   Default base class for all GUIs is QMainWindow
40   */
41 class GUIInterface : public QMainWindow {
42     Q_OBJECT
43
44 public:
45     GUIInterface(QWidget *parent = 0) :QMainWindow(parent) {}
46
47     virtual ~GUIInterface() {}
48
49     //! Returns all loaded dictionaries with information about that they are
50     //! active/inactive
51     /*!
52         \return Hash of pointers to dictionary and boolean flag indicating if
53         dictionary is active
54      */
55     virtual QHash<CommonDictInterface*, bool> getDictionaries() = 0;
56
57
58     //! Returns all loaded plugins
59     /*!
60         \return List of pointers to plugins
61      */
62     virtual QList<CommonDictInterface*> getPlugins() = 0;
63
64     //! Indicates if GUI is in exact search mode.
65     /*! When GUI is in exact search mode it searches for word, and
66         if it finds exactly matching translation it directly displays it, without
67         displaying matching word list. This mode should be
68         used for browsing search history and searching words from application
69         arguments.
70         \returns flag indicating if GUI is in exact search mode
71     */
72     bool exactSearch();
73
74     //! Sets GUI exact search mode.
75     /*! \sa exactSearch() */
76     void setExactSearch(bool exactSearch);
77
78     virtual Settings* settings() = 0;
79
80     virtual void setSettings(Settings*) = 0;
81
82
83 public Q_SLOTS:
84     //! Searches in exact mode for given word
85     /*!
86       GUI will be automatically set into exact search mode, and after search or
87       break it will be unset from exact search mode.
88       \param word which will be searched in dictionaries
89       */
90     virtual void searchExact(QString word) = 0;
91
92     //! Adds key words from given translations to history
93     /*!
94       By default this slot is connected to searchTranslations signal, and
95       passed translations list contains only translations with the same key, so
96       only one word is added to history.
97       \param list of translations with key words
98       \sa searchTranslations();
99       */
100     virtual void addToHistory(QList<Translation*>) = 0;
101
102     //! Shows history dialog
103     virtual void showHistory(QPoint) = 0;
104
105     //! Shows translation of next word in history
106     /*!
107       It will work only if there is next word available in history.
108       Translation of word is searched with searchExact() function
109       \sa searchExact()
110       */
111     virtual void historyNext() = 0;
112
113     //! Shows translation of previous word in history
114     /*!
115       It will work only if there is previous word available in history.
116       Translation of word is searched with searchExact() function
117       \sa searchExact()
118       */
119     virtual void historyPrev() = 0;
120
121     //! Gets words list from backbone and prepares received list to display
122     /*!
123       Checks if received list is empty, in that case it displays suitable
124       information. If GUI is in exact search mode it will search for exact
125       word in received list, and if word is found it will emit signal to
126       display its translation. Otherwise it will display list of matching
127       words and show suitable information.
128       \sa exactSearch()
129       \sa showTranslation()
130      */
131     virtual void wordListReady() = 0;
132
133     //! Gets translation strings from backbone and emits signal to display them
134     virtual void translationsReady() = 0;
135
136 Q_SIGNALS:
137     //! Should be emitted when user wants to close application to stop
138     //! all ongoing searches
139     void quit();
140
141     //! Emitted when user wants to search for list of words matching given word
142     /*! \param word word which will be matched, it can contain wildcards
143     */
144     void searchWordList(QString word);
145
146     //! Emitted when user wants to see translation of words.
147     /*! \param list of translations for given word which will be received
148         in wordListReady() slot
149         \sa wordListReady()
150     */
151     void searchTranslations(QList<Translation*>);
152
153     //! Emitted when starting search, will disable GUI components
154     //! and show progress bars
155     void setBusy();
156
157     //! Emitted when searching ends, will enable GUI components
158     void setIdle();
159
160     //! Emitted when user wants to break search
161     void stopSearching();
162
163     //! Emitted after receiving word list in wordListReady() slot, will display
164     //! list of matched words
165     /*! \param hash of word and list of translations of this word found
166          in dictionaries
167      */
168     void showWordList(QHash<QString, QList<Translation*> >);
169
170     //! Emitted after receiving translation strings in translationsReady() slot,
171     //! will display translation of given word
172     /*! \param list of translations from different dictionaries
173          in dictionaries
174      */
175     void showTranslation(QStringList);
176
177     //! Emitted when user wants to add new dictionary
178     /*! \param new dictionary returned by specific plugin dialog
179       */
180     void addNewDictionary(CommonDictInterface*);
181
182     //! Emitted when user wants to remove dictionary
183     /*! \param dictionary which will be removed
184       */
185     void removeDictionary(CommonDictInterface*);
186
187     //! Emitted when user changes dictionaries active/inactive states
188     /*! \param list of only active dictionaries
189       */
190     void selectedDictionaries(QList<CommonDictInterface* >);
191
192     void addToBookmarks(QList<Translation*>);
193 };
194
195 #endif // GUIINTERFACE_H