1d8e9fb0f7b5e48b73066023fd2f88092e4a984f
[mdictionary] / trunk / src / includes / GUIInterface.h
1 /*******************************************************************************
2
3     This file is part of mDictionary.
4
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.
9
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.
14
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/>.
17
18     Copyright 2010 Comarch S.A.
19
20 *******************************************************************************/
21 //! \file GUIInterface.h
22 //! \brief Defines interface for GUI
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
24
25
26
27 #ifndef GUIINTERFACE_H
28 #define GUIINTERFACE_H
29 #include <QMainWindow>
30 #include <QMultiHash>
31
32 #include "translation.h"
33 #include "CommonDictInterface.h"
34
35 //! Interface for different GUIs
36 /*!
37   Default base class for all GUIs is QMainWindow
38   */
39 class GUIInterface : public QMainWindow {
40     Q_OBJECT
41
42 public:
43     GUIInterface(QWidget *parent = 0) :QMainWindow(parent) {}
44
45     virtual ~GUIInterface() {}
46
47     //! Returns all loaded dictionaries with infromation about that they are
48     //! active/inactive
49     /*!
50         \return Hash of pointers to dictionary and boolean flag indicating if
51         dictionary is active
52      */
53     virtual QHash<CommonDictInterface*, bool> getDictionaries() = 0;
54
55
56     //! Returns all loaded plugins
57     /*!
58         \return List of pointers to plugins
59      */
60     virtual QList<CommonDictInterface*> getPlugins() = 0;
61
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
67         arguments.
68         \returns flag indicating if GUI is in exact search mode
69     */
70     bool exactSearch();
71
72     //! Sets GUI exact search mode.
73     /*! \sa exactSearch() */
74     void setExactSearch(bool exactSearch);
75
76
77 public Q_SLOTS:
78     //! Search in exact mode for given word
79     /*!
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
83       */
84     virtual void searchExact(QString word) = 0;
85
86     //! Adds to history key words from given translations
87     /*!
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();
93       */
94     virtual void addToHistory(QList<Translation*>) = 0;
95
96     //! Shows history dialog
97     virtual void showHistory() = 0;
98
99     //! Shows translation of next word in history
100     /*!
101       It will work only if there is available next word in history.
102       Translation of word is searched with searchExact() function
103       \sa searchExact()
104       */
105     virtual void historyNext() = 0;
106
107     //! Shows translation of previous word in history
108     /*!
109       It will work only if there is available previous word in history.
110       Translation of word is searched with searchExact() function
111       \sa searchExact()
112       */
113     virtual void historyPrev() = 0;
114
115     //! Gets word list from backbone and prepares received list to display
116     /*!
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.
122       \sa exactSearch()
123       \sa showTranslation()
124      */
125     virtual void wordListReady() = 0;
126
127     //! Gets translation strings from backbone and emit signal to display them
128     virtual void translationsReady() = 0;
129
130 Q_SIGNALS:
131     //! Should be emited when user wants to close application to stop
132     //! all ongoing searches
133     void quit();
134
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
137     */
138     void searchWordList(QString word);
139
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
143         \sa wordListReady()
144     */
145     void searchTranslations(QList<Translation*>);
146
147     //! Emited when starting search, will disable GUI components
148     //! and shows progress bars
149     void setBusy();
150
151     //! Emited when searching ends, will enable GUI components
152     void setIdle();
153
154     //! Emited when user want to break search
155     void stopSearching();
156
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
160          in dictionaries
161      */
162     void showWordList(QHash<QString, QList<Translation*> >);
163
164     //! Emited after received translation strings in translationsReady() slot,
165     //! will display translation of given word
166     /*! \param list of translations from different dictionaries
167          in dictionaries
168      */
169     void showTranslation(QStringList);
170
171     //! Emited when user wants to add new dictionary
172     /*! \param new dictionary returned by specyfic plugin dialog
173       */
174     void addNewDictionary(CommonDictInterface*);
175
176     //! Emited when user wants to remove dictionary
177     /*! \param dictionary which will be removed
178       */
179     void removeDictionary(CommonDictInterface*);
180
181     //! Emited when user changes dictionaries active/inactive states
182     /*! \param list of only active dictionaries
183       */
184     void selectedDictionaries(QList<CommonDictInterface* >);
185
186     void addToBookmarks(QList<Translation*>);
187 };
188
189 #endif // GUIINTERFACE_H