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) {}
47 virtual ~GUIInterface() {}
49 //! Returns all loaded dictionaries with information about that they are
52 \return Hash of pointers to dictionary and boolean flag indicating if
55 virtual QHash<CommonDictInterface*, bool> getDictionaries() = 0;
58 //! Returns all loaded plugins
60 \return List of pointers to plugins
62 virtual QList<CommonDictInterface*> getPlugins() = 0;
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
70 \returns flag indicating if GUI is in exact search mode
74 //! Sets GUI exact search mode.
75 /*! \sa exactSearch() */
76 void setExactSearch(bool exactSearch);
78 virtual Settings* settings() = 0;
80 virtual void setSettings(Settings*) = 0;
84 //! Searches in exact mode for given word
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
90 virtual void searchExact(QString word) = 0;
92 //! Adds key words from given translations to history
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();
100 virtual void addToHistory(QList<Translation*>) = 0;
102 //! Shows history dialog
103 virtual void showHistory(QPoint) = 0;
105 //! Shows translation of next word in history
107 It will work only if there is next word available in history.
108 Translation of word is searched with searchExact() function
111 virtual void historyNext() = 0;
113 //! Shows translation of previous word in history
115 It will work only if there is previous word available in history.
116 Translation of word is searched with searchExact() function
119 virtual void historyPrev() = 0;
121 //! Gets words list from backbone and prepares received list to display
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.
129 \sa showTranslation()
131 virtual void wordListReady() = 0;
133 //! Gets translation strings from backbone and emits signal to display them
134 virtual void translationsReady() = 0;
137 //! Should be emitted when user wants to close application to stop
138 //! all ongoing searches
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
144 void searchWordList(QString word);
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
151 void searchTranslations(QList<Translation*>);
153 //! Emitted when starting search, will disable GUI components
154 //! and show progress bars
157 //! Emitted when searching ends, will enable GUI components
160 //! Emitted when user wants to break search
161 void stopSearching();
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
168 void showWordList(QHash<QString, QList<Translation*> >);
170 //! Emitted after receiving translation strings in translationsReady() slot,
171 //! will display translation of given word
172 /*! \param list of translations from different dictionaries
175 void showTranslation(QStringList);
177 //! Emitted when user wants to add new dictionary
178 /*! \param new dictionary returned by specific plugin dialog
180 void addNewDictionary(CommonDictInterface*);
182 //! Emitted when user wants to remove dictionary
183 /*! \param dictionary which will be removed
185 void removeDictionary(CommonDictInterface*);
187 //! Emitted when user changes dictionaries active/inactive states
188 /*! \param list of only active dictionaries
190 void selectedDictionaries(QList<CommonDictInterface* >);
192 void addToBookmarks(QList<Translation*>);
195 #endif // GUIINTERFACE_H