Clean and order documentation in source files. Source ready to beta 2 release
[mdictionary] / src / mdictionary / gui / TranslationWidget.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 TranslationWidget.h
22     \brief Displays translation of a word found in dictionaries
23
24     \author Mateusz Półrola <mateusz.polrola@comarch.pl>
25 */
26
27 #ifndef TRANSLATIONWIDGET_H
28 #define TRANSLATIONWIDGET_H
29
30 #include <QWidget>
31 #include <QModelIndex>
32 #include <QtGui>
33 #include "../backbone/backbone.h"
34 #include <QtXml>
35 #include <QXmlQuery>
36 #include "TranslationView.h"
37 #include <QPropertyAnimation>
38 #include "../../include/GUIInterface.h"
39
40 /*!
41     Displays many translations of word, formatted as xml.
42 */
43 class TranslationWidget : public QScrollArea {
44     Q_OBJECT
45 public:
46     explicit TranslationWidget(QWidget *parent = 0);
47
48 Q_SIGNALS:
49     void search(QString);
50     void notify(Notify::NotifyType, QString);
51
52 public Q_SLOTS:
53     //! Show widget.
54     void show();
55
56     //! Requests to show a translation of words list passed as parameter.
57     void show(QStringList);
58
59     //! Updates user's zoom preferences and sends its to backbone to be saved
60     void updateZoom(qreal);
61
62 protected:
63     #ifdef Q_WS_MAEMO_5
64         void keyPressEvent(QKeyEvent *);
65         void hideEvent(QHideEvent *);
66     #endif
67
68 private Q_SLOTS:
69     void searchSelected();
70     void copySelected();
71     #ifdef Q_WS_MAEMO_5
72         void showButtons();
73     #endif
74
75 private:
76     QString XslConversion(QString translation);
77     QString checkTranslation(QString trans);
78     QString createTranslation(QStringList translations);
79     QToolButton* zoomInToolButton;
80     QToolButton* zoomOutToolButton;
81     TranslationView *webkit;
82     QString xslt;
83
84     #ifdef Q_WS_MAEMO_5
85         QToolButton* zoomInButton;
86         QToolButton* zoomOutButton;
87         QToolButton* selectAllButton;
88         QToolButton* copyButton;
89         QToolButton* searchButton;
90         QToolButton* showButtonsButton;
91
92         QPropertyAnimation* zoomInButtonAnimation;
93         QPropertyAnimation* zoomOutButtonAnimation;
94         QPropertyAnimation* copyButtonAnimation;
95         QPropertyAnimation* selectAllButtonAnimation;
96         QPropertyAnimation* searchButtonAnimation;
97         QAnimationGroup* buttonsAnimation;
98
99         void initButtons();
100         bool buttonsInitialized;
101         bool buttonsVisible;
102
103         void grabZoomKeys(bool);
104     #endif
105
106     QVBoxLayout *verticalLayout;
107     QHBoxLayout* horizontalLayout;
108     GUIInterface* guiinterface;
109
110     void initializeUI();
111 };
112
113 #endif // TRANSLATIONWIDGET_H