Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-//Created by Mateusz Półrola
+//! \file MainWindow.h
+//! \brief Implements interface for GUI
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
+#include "../../includes/GUIInterface.h"
+#include "../../includes/settings.h"
#include "../backbone/backbone.h"
#include "TranslationWidget.h"
#include "WordListWidget.h"
#include "SearchBarWidget.h"
#include "MenuWidget.h"
+#include "DictManagerWidget.h"
+#include "SettingsWidget.h"
+#include "HistoryListDialog.h"
+#include "AboutWidget.h"
namespace Ui {
class MainWindow;
}
-class MainWindow : public QMainWindow
+//! Implements interface for GUI
+/*!
+ Create all of GUI subcomponents, and connects all GUI interface signals with
+ suitable backbone signals and slots. Only this class has direct access to
+ backbone object. It manages all request of subcomponents e. g. searching of
+ given word, displaying history, removing dictionary.
+ It also provide data from backbone to subcomponents e. g. result of search.
+*/
+class MainWindow : public GUIInterface
{
Q_OBJECT
public:
+ //! Constructor
+ /*!
+ \param backbone object which will doing all searches and returns data
+ \param parent parent widget of this window
+ */
+
explicit MainWindow(Backbone* backbone, QWidget *parent = 0);
~MainWindow();
- void searchExactWord(QString);
+ //! Returns all loaded dictionaries with infromation about that they are
+ //! active/inactive
+ /*!
+ \return Hash of pointers to dictionary and boolean flag indicating if
+ dictionary is active
+ */
+ QHash<CommonDictInterface*, bool> getDictionaries();
+
+ //! Returns all loaded plugins
+ /*!
+ \return List of pointers to plugins
+ */
+ QList<CommonDictInterface*> getPlugins();
+
+ //! Indicates if GUI is in exact search mode.
+ /*! When GUI is in exact search mode it search for word, and
+ if find exacly matching translation it directly displays it, whithout
+ displaying matching word list. This mode is used for browsing search
+ history and search words from application arguments.
+ \returns flag indicating if GUI is in exact search mode
+ */
+ bool exactSearch();
+
+ //! Sets GUI exact search mode.
+ /*! When GUI is in exact search mode it search for word, and
+ if find exacly matching translation it directly displays it, whithout
+ displaying matching word list. This mode is used for browsing search
+ history and search words from application arguments.
+ \param exactSearch flag indicating if GUI will be in exact search mode
+ \sa exactSearch()
+ */
+ void setExactSearch(bool);
+
+ Settings* settings();
+
+ void setSettings(Settings*);
+
+
+ public Q_SLOTS:
+ //! Search in exact mode for given word
+ /*!
+ GUI will be automaticaly set into exact search mode, and after search or
+ break will be unset from exact search mode.
+ \param word which will be searched in dictionaries
+ */
+ void searchExact(QString);
+
+
+ //! Gets word list from backbone and prepares received list to display
+ /*!
+ Checks if received list is empty, in that case displays suitable
+ information. If GUI is in exact search mode it will search for exact
+ word in received list, and if word is found it will emit signal to
+ display it's translation. Otherwise it will display list of matching
+ words and show suitable information.
+ \sa exactSearch()
+ \sa showTranslation()
+ */
+ void wordListReady();
+
+ //! Gets translation strings from backbone and emit signal to display them
+ void translationsReady();
+
+ //! Adds to history key words from given translations
+ /*!
+ By default this slot is connected to signal searchTranslations, and
+ passed translation list contains only translation with the same key, so
+ only one word is added to history.
+ \param list of translations with key words
+ \sa searchTranslations()
+ */
+ void addToHistory(QList<Translation*>);
+
+ //! Shows history dialog
+ void showHistory();
+
+ //! Shows translation of next word in history
+ /*!
+ It will work only if there is available next word in history.
+ Translation of word is searched with searchExact() function
+ \sa searchExact()
+ */
+ void historyNext();
+
+ //! Shows translation of previous word in history
+ /*!
+ It will work only if there is available previous word in history.
+ Translation of word is searched with searchExact() function
+ \sa searchExact()
+ */
+ void historyPrev();
-public Q_SLOTS:
- //! Confirmation from backbone that we can close program
- void closeOk();
+private Q_SLOTS:
+ //! Sets string for which current search is ongoing, is used to find exact
+ //! word when GUI is in search exact mode.
+ void setSearchString(QString);
+
+ //! Disables menu when search is ongoing
+ void disableMenu();
+
+ //! Enables menu
+ void enableMenu();
+
+ //! When user break searching it make sure that exact search mode will be
+ //! disabled
+ void breakSearching();
-Q_SIGNALS:
- //! Request to backbone to stop all it's activities
- void quit();
- void search(QString);
protected:
/*! When user wants to close application, we first sends signal to stop all
*/
void closeEvent(QCloseEvent *);
-private Q_SLOTS:
- void enableMenu();
-
- void disableMenu();
private:
Backbone* backbone;
Ui::MainWindow *ui;
+
+ void initializeUI();
+
+
SearchBarWidget* searchBarWidget;
TranslationWidget* translationWidget;
WordListWidget* wordListWidget;
MenuWidget* menuWidget;
- bool closingApplication;
+ DictManagerWidget* dictManagerWidget;
+ SettingsWidget* settingsWidget;
+ AboutWidget* aboutWidget;
+
+ #ifndef Q_WS_MAEMO_5
+ QSplitter* splitter;
+ QAction* dictionariesAction;
+ //QAction* edit;
+ QAction* settingsAction;
+ QAction* aboutAction;
+ #endif
+
+ bool _exactSearch;
+ QString searchString;
+
+
+ void connectBackbone();
+ void connectSearchBar();
+ void connectWordList();
+ void connectTranslationWidget();
+ void connectDictManager();
+ void connectMenu();
};
#endif // MAINWINDOW_H