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 infromation 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 search for word, and
66 if find exacly matching translation it directly displays it, whithout
67 displaying matching word list. This mode should be
68 used for browsing search history and search 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 //! Search in exact mode for given word
86 GUI will be automaticaly set into exact search mode, and after search or
87 break 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 to history key words from given translations
94 By default this slot is connected to signal searchTranslations, and
95 passed translation list contains only translation 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() = 0;
105 //! Shows translation of next word in history
107 It will work only if there is available next word 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 available previous word in history.
116 Translation of word is searched with searchExact() function
119 virtual void historyPrev() = 0;
121 //! Gets word list from backbone and prepares received list to display
123 Checks if received list is empty, in that case 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 it's 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 emit signal to display them
134 virtual void translationsReady() = 0;
137 //! Should be emited when user wants to close application to stop
138 //! all ongoing searches
141 //! Emited when user want to search for list of words matching given word
142 /*! \param word word which will be matched, it can contains wildcards
144 void searchWordList(QString word);
146 //! Emited 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 //! Emited when starting search, will disable GUI components
154 //! and shows progress bars
157 //! Emited when searching ends, will enable GUI components
160 //! Emited when user want to break search
161 void stopSearching();
163 //! Emited after received word list in wordListReady() slot, will display
164 //! list of matched words
165 /*! \param hash of word and list of translation of this word found
168 void showWordList(QHash<QString, QList<Translation*> >);
170 //! Emited after received 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 //! Emited when user wants to add new dictionary
178 /*! \param new dictionary returned by specyfic plugin dialog
180 void addNewDictionary(CommonDictInterface*);
182 //! Emited when user wants to remove dictionary
183 /*! \param dictionary which will be removed
185 void removeDictionary(CommonDictInterface*);
187 //! Emited 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