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 MainWindow.h
22 //! \brief Implements interface for GUI
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
28 #include <QMainWindow>
29 #include "../../includes/GUIInterface.h"
30 #include "../../includes/settings.h"
31 #include "../backbone/backbone.h"
32 #include "TranslationWidget.h"
33 #include "WordListWidget.h"
34 #include "SearchBarWidget.h"
35 #include "MenuWidget.h"
36 #include "DictManagerWidget.h"
37 #include "SettingsWidget.h"
38 #include "HistoryListDialog.h"
44 //! Implements interface for GUI
46 Create all of GUI subcomponents, and connects all GUI interface signals with
47 suitable backbone signals and slots. Only this class has direct access to
48 backbone object. It manages all request of subcomponents e. g. searching of
49 given word, displaying history, removing dictionary.
50 It also provide data from backbone to subcomponents e. g. result of search.
52 class MainWindow : public GUIInterface
59 \param backbone object which will doing all searches and returns data
60 \param parent parent widget of this window
63 explicit MainWindow(Backbone* backbone, QWidget *parent = 0);
66 //! Returns all loaded dictionaries with infromation about that they are
69 \return Hash of pointers to dictionary and boolean flag indicating if
72 QHash<CommonDictInterface*, bool> getDictionaries();
74 //! Returns all loaded plugins
76 \return List of pointers to plugins
78 QList<CommonDictInterface*> getPlugins();
80 //! Indicates if GUI is in exact search mode.
81 /*! When GUI is in exact search mode it search for word, and
82 if find exacly matching translation it directly displays it, whithout
83 displaying matching word list. This mode is used for browsing search
84 history and search words from application arguments.
85 \returns flag indicating if GUI is in exact search mode
89 //! Sets GUI exact search mode.
90 /*! When GUI is in exact search mode it search for word, and
91 if find exacly matching translation it directly displays it, whithout
92 displaying matching word list. This mode is used for browsing search
93 history and search words from application arguments.
94 \param exactSearch flag indicating if GUI will be in exact search mode
97 void setExactSearch(bool);
101 void setSettings(Settings*);
105 //! Search in exact mode for given word
107 GUI will be automaticaly set into exact search mode, and after search or
108 break will be unset from exact search mode.
109 \param word which will be searched in dictionaries
111 void searchExact(QString);
114 //! Gets word list from backbone and prepares received list to display
116 Checks if received list is empty, in that case displays suitable
117 information. If GUI is in exact search mode it will search for exact
118 word in received list, and if word is found it will emit signal to
119 display it's translation. Otherwise it will display list of matching
120 words and show suitable information.
122 \sa showTranslation()
124 void wordListReady();
126 //! Gets translation strings from backbone and emit signal to display them
127 void translationsReady();
129 //! Adds to history key words from given translations
131 By default this slot is connected to signal searchTranslations, and
132 passed translation list contains only translation with the same key, so
133 only one word is added to history.
134 \param list of translations with key words
135 \sa searchTranslations()
137 void addToHistory(QList<Translation*>);
139 //! Shows history dialog
142 //! Shows translation of next word in history
144 It will work only if there is available next word in history.
145 Translation of word is searched with searchExact() function
150 //! Shows translation of previous word in history
152 It will work only if there is available previous word in history.
153 Translation of word is searched with searchExact() function
159 //! Sets string for which current search is ongoing, is used to find exact
160 //! word when GUI is in search exact mode.
161 void setSearchString(QString);
163 //! Disables menu when search is ongoing
169 //! When user break searching it make sure that exact search mode will be
171 void breakSearching();
175 /*! When user wants to close application, we first sends signal to stop all
178 void closeEvent(QCloseEvent *);
188 SearchBarWidget* searchBarWidget;
189 TranslationWidget* translationWidget;
190 WordListWidget* wordListWidget;
191 MenuWidget* menuWidget;
192 DictManagerWidget* dictManagerWidget;
193 SettingsWidget* settingsWidget;
197 QAction* dictionariesAction;
199 QAction* settingsAction;
200 //QAction* aboutAction;
204 QString searchString;
207 void connectBackbone();
208 void connectSearchBar();
209 void connectWordList();
210 void connectTranslationWidget();
211 void connectDictManager();
215 #endif // MAINWINDOW_H