Fixed gui: search progress bar, result list
[mdictionary] / trunk / src / base / 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 Implements translation widget
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
24
25 #ifndef TRANSLATIONWIDGET_H
26 #define TRANSLATIONWIDGET_H
27
28 #include <QWidget>
29 #include <QModelIndex>
30 #include <QtGui>
31 #include "../backbone/backbone.h"
32 #include "TranslationWidgetAutoResizer.h"
33 #include <QtXml>
34 #include <QXmlQuery>
35 #include "TranslationTextEdit.h"
36 #include <QPropertyAnimation>
37
38 //! Displays translation of word found in dictionaries
39 /*!
40     Display many translation of word, formatted as html.
41 */
42 class TranslationWidget : public QScrollArea {
43     Q_OBJECT
44 public:
45     explicit TranslationWidget(QWidget *parent = 0);
46
47 Q_SIGNALS:
48     void updateSize();
49
50     void search(QString);
51
52 public Q_SLOTS:
53     //! Show widget.
54     void show();
55
56     //! Request to show translation of word list passed as parameter.
57     void show(QStringList);
58
59 protected:
60     #ifdef Q_WS_MAEMO_5
61         void keyPressEvent(QKeyEvent *);
62         void hideEvent(QHideEvent *);
63     #endif
64
65 private Q_SLOTS:
66     void searchSelected();
67     #ifdef Q_WS_MAEMO_5
68         void showButtons();
69     #endif
70
71 private:
72     QString XslConversion(QString translation);
73     QToolButton* zoomInToolButton;
74     QToolButton* zoomOutToolButton;
75     TranslationTextEdit *textEdit;
76     #ifdef Q_WS_MAEMO_5
77         QToolButton* zoomInButton;
78         QToolButton* zoomOutButton;
79         QToolButton* selectAllButton;
80         QToolButton* copyButton;
81         QToolButton* searchButton;
82         QToolButton* showButtonsButton;
83
84         QPropertyAnimation* zoomInButtonAnimation;
85         QPropertyAnimation* zoomOutButtonAnimation;
86         QPropertyAnimation* copyButtonAnimation;
87         QPropertyAnimation* selectAllButtonAnimation;
88         QPropertyAnimation* searchButtonAnimation;
89         QAnimationGroup* buttonsAnimation;
90
91         void initButtons();
92         bool buttonsInitialized;
93         bool buttonsVisible;
94
95         void grabZoomKeys(bool);
96     #endif
97     QVBoxLayout *verticalLayout;
98     QHBoxLayout* horizontalLayout;
99     TranslationWidgetAutoResizer* resizer;
100
101     void initializeUI();
102 };
103
104 #endif // TRANSLATIONWIDGET_H