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"
35 //! Interface for different GUIs
37 Default base class for all GUIs is QMainWindow
39 class GUIInterface : public QMainWindow {
43 GUIInterface(QWidget *parent = 0) :QMainWindow(parent) {}
45 virtual ~GUIInterface() {}
47 //! Returns all loaded dictionaries with infromation about that they are
50 \return Hash of pointers to dictionary and boolean flag indicating if
53 virtual QHash<CommonDictInterface*, bool> getDictionaries() = 0;
56 //! Returns all loaded plugins
58 \return List of pointers to plugins
60 virtual QList<CommonDictInterface*> getPlugins() = 0;
62 //! Indicates if GUI is in exact search mode.
63 /*! When GUI is in exact search mode it search for word, and
64 if find exacly matching translation it directly displays it, whithout
65 displaying matching word list. This mode should be
66 used for browsing search history and search words from application
68 \returns flag indicating if GUI is in exact search mode
72 //! Sets GUI exact search mode.
73 /*! \sa exactSearch() */
74 void setExactSearch(bool exactSearch);
78 //! Search in exact mode for given word
80 GUI will be automaticaly set into exact search mode, and after search or
81 break will be unset from exact search mode.
82 \param word which will be searched in dictionaries
84 virtual void searchExact(QString word) = 0;
86 //! Adds to history key words from given translations
88 By default this slot is connected to signal searchTranslations, and
89 passed translation list contains only translation with the same key, so
90 only one word is added to history.
91 \param list of translations with key words
92 \sa searchTranslations();
94 virtual void addToHistory(QList<Translation*>) = 0;
96 //! Shows history dialog
97 virtual void showHistory() = 0;
99 //! Shows translation of next word in history
101 It will work only if there is available next word in history.
102 Translation of word is searched with searchExact() function
105 virtual void historyNext() = 0;
107 //! Shows translation of previous word in history
109 It will work only if there is available previous word in history.
110 Translation of word is searched with searchExact() function
113 virtual void historyPrev() = 0;
115 //! Gets word list from backbone and prepares received list to display
117 Checks if received list is empty, in that case displays suitable
118 information. If GUI is in exact search mode it will search for exact
119 word in received list, and if word is found it will emit signal to
120 display it's translation. Otherwise it will display list of matching
121 words and show suitable information.
123 \sa showTranslation()
125 virtual void wordListReady() = 0;
127 //! Gets translation strings from backbone and emit signal to display them
128 virtual void translationsReady() = 0;
131 //! Should be emited when user wants to close application to stop
132 //! all ongoing searches
135 //! Emited when user want to search for list of words matching given word
136 /*! \param word word which will be matched, it can contains wildcards
138 void searchWordList(QString word);
140 //! Emited when user wants to see translation of words.
141 /*! \param list of translations for given word which will be received
142 in wordListReady() slot
145 void searchTranslations(QList<Translation*>);
147 //! Emited when starting search, will disable GUI components
148 //! and shows progress bars
151 //! Emited when searching ends, will enable GUI components
154 //! Emited when user want to break search
155 void stopSearching();
157 //! Emited after received word list in wordListReady() slot, will display
158 //! list of matched words
159 /*! \param hash of word and list of translation of this word found
162 void showWordList(QHash<QString, QList<Translation*> >);
164 //! Emited after received translation strings in translationsReady() slot,
165 //! will display translation of given word
166 /*! \param list of translations from different dictionaries
169 void showTranslation(QStringList);
171 //! Emited when user wants to add new dictionary
172 /*! \param new dictionary returned by specyfic plugin dialog
174 void addNewDictionary(CommonDictInterface*);
176 //! Emited when user wants to remove dictionary
177 /*! \param dictionary which will be removed
179 void removeDictionary(CommonDictInterface*);
181 //! Emited when user changes dictionaries active/inactive states
182 /*! \param list of only active dictionaries
184 void selectedDictionaries(QList<CommonDictInterface* >);
186 void addToBookmarks(QList<Translation*>);
189 #endif // GUIINTERFACE_H