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