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 "../backbone/backbone.h"
31 #include "TranslationWidget.h"
32 #include "WordListWidget.h"
33 #include "SearchBarWidget.h"
34 #include "MenuWidget.h"
35 #include "DictManagerWidget.h"
36 #include "HistoryListDialog.h"
42 //! Implements interface for GUI
44 Create all of GUI subcomponents, and connects all GUI interface signals with
45 suitable backbone signals and slots. Only this class has direct access to
46 backbone object. It manages all request of subcomponents e. g. searching of
47 given word, displaying history, removing dictionary.
48 It also provide data from backbone to subcomponents e. g. result of search.
50 class MainWindow : public GUIInterface
57 \param backbone object which will doing all searches and returns data
58 \param parent parent widget of this window
61 explicit MainWindow(Backbone* backbone, QWidget *parent = 0);
64 //! Returns all loaded dictionaries with infromation about that they are
67 \return Hash of pointers to dictionary and boolean flag indicating if
70 QHash<CommonDictInterface*, bool> getDictionaries();
72 //! Returns all loaded plugins
74 \return List of pointers to plugins
76 QList<CommonDictInterface*> getPlugins();
78 //! Indicates if GUI is in exact search mode.
79 /*! When GUI is in exact search mode it search for word, and
80 if find exacly matching translation it directly displays it, whithout
81 displaying matching word list. This mode is used for browsing search
82 history and search words from application arguments.
83 \returns flag indicating if GUI is in exact search mode
87 //! Sets GUI exact search mode.
88 /*! When GUI is in exact search mode it search for word, and
89 if find exacly matching translation it directly displays it, whithout
90 displaying matching word list. This mode is used for browsing search
91 history and search words from application arguments.
92 \param exactSearch flag indicating if GUI will be in exact search mode
95 void setExactSearch(bool);
99 //! Search in exact mode for given word
101 GUI will be automaticaly set into exact search mode, and after search or
102 break will be unset from exact search mode.
103 \param word which will be searched in dictionaries
105 void searchExact(QString);
108 //! Gets word list from backbone and prepares received list to display
110 Checks if received list is empty, in that case displays suitable
111 information. If GUI is in exact search mode it will search for exact
112 word in received list, and if word is found it will emit signal to
113 display it's translation. Otherwise it will display list of matching
114 words and show suitable information.
116 \sa showTranslation()
118 void wordListReady();
120 //! Gets translation strings from backbone and emit signal to display them
121 void translationsReady();
123 //! Adds to history key words from given translations
125 By default this slot is connected to signal searchTranslations, and
126 passed translation list contains only translation with the same key, so
127 only one word is added to history.
128 \param list of translations with key words
129 \sa searchTranslations()
131 void addToHistory(QList<Translation*>);
133 //! Shows history dialog
136 //! Shows translation of next word in history
138 It will work only if there is available next word in history.
139 Translation of word is searched with searchExact() function
144 //! Shows translation of previous word in history
146 It will work only if there is available previous word in history.
147 Translation of word is searched with searchExact() function
153 //! Sets string for which current search is ongoing, is used to find exact
154 //! word when GUI is in search exact mode.
155 void setSearchString(QString);
157 //! Disables menu when search is ongoing
163 //! When user break searching it make sure that exact search mode will be
165 void breakSearching();
169 /*! When user wants to close application, we first sends signal to stop all
172 void closeEvent(QCloseEvent *);
182 SearchBarWidget* searchBarWidget;
183 TranslationWidget* translationWidget;
184 WordListWidget* wordListWidget;
185 MenuWidget* menuWidget;
186 DictManagerWidget* dictManagerWidget;
190 QAction* dictionariesAction;
192 // QAction* settingsAction;
193 //QAction* aboutAction;
197 QString searchString;
200 void connectBackbone();
201 void connectSearchBar();
202 void connectWordList();
203 void connectTranslationWidget();
204 void connectDictManager();
208 #endif // MAINWINDOW_H