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