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
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
27 #ifndef GUIINTERFACE_H
28 #define GUIINTERFACE_H
29 #include <QMainWindow>
32 #include "translation.h"
33 #include "CommonDictInterface.h"
37 //! Interface for different GUIs
39 Default base class for all GUIs is QMainWindow
41 class GUIInterface : public QMainWindow {
45 GUIInterface(QWidget *parent = 0) :QMainWindow(parent) {}
46 virtual ~GUIInterface() {}
48 //! Returns all loaded dictionaries with information if they are
51 \return Hash of pointers to a dictionary and boolean flag indicating if
52 a dictionary is active
54 virtual QHash<CommonDictInterface*, bool> getDictionaries() = 0;
57 //! Returns all loaded plugins
59 \return List of pointers to plugins
61 virtual QList<CommonDictInterface*> getPlugins() = 0;
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
69 \returns flag indicating if GUI is in exact search mode
73 //! Sets GUI exact search mode.
74 /*! \sa exactSearch() */
75 void setExactSearch(bool exactSearch);
77 virtual Settings* settings() = 0;
79 virtual void setSettings(Settings*) = 0;
83 //! Searches in exact mode for a given word
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
89 virtual void searchExact(QString word) = 0;
91 //! Adds key words from given translations to history
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();
99 virtual void addToHistory(QList<Translation*>) = 0;
101 //! Shows history dialog
102 virtual void showHistory(QPoint) = 0;
104 //! Shows translation of next word in history
106 It will work only if there is next word available in history.
107 Translation of a word is searched for with searchExact() function
110 virtual void historyNext() = 0;
112 //! Shows translation of previous word in history
114 It will work only if there is previous word available in history.
115 Translation of a word is searched for with searchExact() function
118 virtual void historyPrev() = 0;
120 //! Gets words list from backbone and prepares received list to display
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.
128 \sa showTranslation()
130 virtual void wordListReady() = 0;
132 //! Gets translation strings from backbone and emits signal to display them
133 virtual void translationsReady() = 0;
136 //! Should be emitted when user wants to close application to stop
137 //! all ongoing searches
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
143 void searchWordList(QString word);
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
150 void searchTranslations(QList<Translation*>);
152 //! Emitted when starting search, will disable GUI components
153 //! and show progress bars
156 //! Emitted when searching ends, will enable GUI components
159 //! Emitted when user wants to break search
160 void stopSearching();
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
167 void showWordList(QHash<QString, QList<Translation*> >);
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
174 void showTranslation(QStringList);
176 //! Emitted when user wants to add a new dictionary
177 /*! \param new dictionary returned by specific plugin dialog
179 void addNewDictionary(CommonDictInterface*);
181 //! Emitted when user wants to remove a dictionary
182 /*! \param dictionary which will be removed
184 void removeDictionary(CommonDictInterface*);
186 //! Emitted when user changes dictionaries active/inactive states
187 /*! \param list of only active dictionaries
189 void selectedDictionaries(QList<CommonDictInterface* >);
191 void addToBookmarks(QList<Translation*>);
194 #endif // GUIINTERFACE_H