1 /*******************************************************************************
3 This file is part of mDictionary.
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.
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.
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/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
21 /*! \file GUIInterface.h
22 \brief Defines interface for GUI
24 \author Mateusz Półrola <mateusz.polrola@comarch.pl>
29 #ifndef GUIINTERFACE_H
30 #define GUIINTERFACE_H
31 #include <QMainWindow>
34 #include "translation.h"
35 #include "CommonDictInterface.h"
39 //! Interface for different GUIs
41 Default base class for all GUIs is QMainWindow
43 class GUIInterface : public QMainWindow {
47 GUIInterface(QWidget *parent = 0) :QMainWindow(parent) {}
48 virtual ~GUIInterface() {}
50 //! Returns all loaded dictionaries with information if they are
53 \return Hash of pointers to a dictionary and boolean flag indicating if
54 a dictionary is active
56 virtual QHash<CommonDictInterface*, bool> getDictionaries() = 0;
59 //! Returns all loaded plugins
61 \return List of pointers to plugins
63 virtual QList<CommonDictInterface*> getPlugins() = 0;
65 //! Indicates if GUI is in exact search mode.
66 /*! When GUI is in exact search mode it searches for a word, and
67 if it finds exactly matching translation it directly displays it, without
68 displaying matching words list. This mode should be
69 used for browsing search history and searching for words from application
71 \returns flag indicating if GUI is in exact search mode
75 //! Sets GUI exact search mode.
76 /*! \sa exactSearch() */
77 void setExactSearch(bool exactSearch);
79 virtual Settings* settings() = 0;
81 virtual void setSettings(Settings*) = 0;
85 //! Searches in exact mode for a given word
87 GUI will be automatically set into exact search mode, and after search or
88 break it will be unset from exact search mode.
89 \param word word which will be searched for in dictionaries
91 virtual void searchExact(QString word) = 0;
93 //! Adds key words from given translations to history
95 By default this slot is connected to searchTranslations signal, and
96 passed translations list contains only translations with the same key, so
97 only one word is added to history.
98 \param list of translations with key words
99 \sa searchTranslations();
101 virtual void addToHistory(QList<Translation*>) = 0;
103 //! Shows history dialog
104 virtual void showHistory(QPoint) = 0;
106 //! Shows translation of next word in history
108 It will work only if there is next word available in history.
109 Translation of a word is searched for with searchExact() function
112 virtual void historyNext() = 0;
114 //! Shows translation of previous word in history
116 It will work only if there is previous word available in history.
117 Translation of a word is searched for with searchExact() function
120 virtual void historyPrev() = 0;
122 //! Gets words list from backbone and prepares received list to display
124 Checks if received list is empty, in that case it displays suitable
125 information. If GUI is in exact search mode it will search for exact
126 word in received list, and if the word is found it will emit signal to
127 display its translation. Otherwise it will display list of matching
128 words and show suitable information.
130 \sa showTranslation()
132 virtual void wordListReady() = 0;
134 //! Gets translation strings from backbone and emits signal to display them
135 virtual void translationsReady() = 0;
138 //! Should be emitted when user wants to close application to stop
139 //! all ongoing searches
142 //! Emitted when user wants to search for a list of words matching a given word
143 /*! \param word word which will be matched, it can contain wildcards
145 void searchWordList(QString word);
147 //! Emitted when user wants to see translation of words.
148 /*! \param list of translations for a given word which will be received
149 in wordListReady() slot
152 void searchTranslations(QList<Translation*>);
154 //! Emitted when starting search, will disable GUI components
155 //! and show progress bars
158 //! Emitted when searching ends, will enable GUI components
161 //! Emitted when user wants to break search
162 void stopSearching();
164 //! Emitted after receiving words list in wordListReady() slot, will display
165 //! list of matched words
166 /*! \param hash of a word and list of translations of this word found
169 void showWordList(QHash<QString, QList<Translation*> >);
171 //! Emitted after receiving translation strings in translationsReady() slot,
172 //! will display translation of a given word
173 /*! \param list of translations from different dictionaries
176 void showTranslation(QStringList);
178 //! Emitted when user wants to add a new dictionary
179 /*! \param new dictionary returned by specific plugin dialog
181 void addNewDictionary(CommonDictInterface*);
183 //! Emitted when user wants to remove a dictionary
184 /*! \param dictionary which will be removed
186 void removeDictionary(CommonDictInterface*);
188 //! Emitted when user changes dictionaries active/inactive states
189 /*! \param list of only active dictionaries
191 void selectedDictionaries(QList<CommonDictInterface* >);
193 void addToBookmarks(QList<Translation*>);
198 #endif // GUIINTERFACE_H