Merge branch 'master' into cache
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Thu, 19 Aug 2010 10:51:54 +0000 (12:51 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Thu, 19 Aug 2010 10:51:54 +0000 (12:51 +0200)
Conflicts:
trunk/src/base/gui/TranslationWidget.cpp
trunk/src/base/gui/TranslationWidget.h

17 files changed:
trunk/src/base/base.pro
trunk/src/base/gui/BookmarksWidget.cpp
trunk/src/base/gui/BookmarksWidget.h
trunk/src/base/gui/DictManagerWidget.cpp
trunk/src/base/gui/MainWindow.cpp
trunk/src/base/gui/MainWindow.h
trunk/src/base/gui/MenuWidget.h
trunk/src/base/gui/SearchBarWidget.cpp
trunk/src/base/gui/SettingsWidget.cpp
trunk/src/base/gui/SettingsWidget.h
trunk/src/base/gui/TranslationWidget.cpp
trunk/src/base/gui/TranslationWidget.h
trunk/src/base/gui/WelcomeScreenWidget.h
trunk/src/base/gui/WordListProxyStyle.cpp
trunk/src/base/gui/WordListProxyStyle.h
trunk/src/base/gui/WordListWidget.cpp
trunk/src/base/gui/WordListWidget.h

index 03940d0..e440e9c 100644 (file)
@@ -33,7 +33,8 @@ SOURCES += gui/main.cpp \
     gui/SettingsWidget.cpp \
     gui/BookmarksWidget.cpp \
     gui/WelcomeScreenWidget.cpp \ 
-    gui/AboutWidget.cpp
+    gui/AboutWidget.cpp \
+    gui/TranslationTextEdit.cpp
 
 HEADERS  += gui/MainWindow.h \
     gui/AboutWidget.h \
@@ -57,7 +58,8 @@ HEADERS  += gui/MainWindow.h \
     backbone/BookmarkTranslations.h \
     gui/SettingsWidget.h \
     gui/BookmarksWidget.h \
-    gui/WelcomeScreenWidget.h
+    gui/WelcomeScreenWidget.h \
+    gui/TranslationTextEdit.h
 
 FORMS    += gui/MainWindow.ui
 RESOURCES += gui/gui.qrc
index 7bbe036..047bad7 100644 (file)
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
-
-//Created by Mateusz Półrola
+//! \file BookmarksWidget.cpp
+//! \brief Bookmarks management widget
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 #include "BookmarksWidget.h"
 
+
 BookmarksWidget::BookmarksWidget(GUIInterface *parent) :
     QDialog(parent)
 {
index 87b909c..fcc0c97 100644 (file)
@@ -19,7 +19,9 @@
 
 *******************************************************************************/
 
-//Created by Mateusz Półrola
+//! \file BookmarksWidget.h
+//! \brief Bookmarks management widget
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 #ifndef BOOKMARKSWIDGET_H
 #define BOOKMARKSWIDGET_H
 #include <QtGui>
 #include "../../includes/GUIInterface.h"
 
+//! Implements bookmarks management widget
+/*!
+  Allow user to show all or remove all bookmarks
+  */
 class BookmarksWidget : public QDialog
 {
     Q_OBJECT
index 236aa35..6209364 100644 (file)
@@ -19,7 +19,9 @@
 
 *******************************************************************************/
 
-//Created by Mateusz Półrola
+//! \file DictManagerWidget.cpp
+//! \brief Dicrionaries management widget
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 #include "DictManagerWidget.h"
 #include "DictTypeSelectDialog.h"
index 8dc1f47..fac9d25 100644 (file)
@@ -33,10 +33,6 @@ MainWindow::MainWindow(Backbone *backbone, QWidget *parent):
     GUIInterface(parent),
     ui(new Ui::MainWindow) {
 
-    #ifdef Q_WS_MAEMO_5
-        setAttribute(Qt::WA_Maemo5StackedWindow);
-    #endif
-
     this->backbone = backbone;
 
     initializeUI();
@@ -65,10 +61,9 @@ MainWindow::~MainWindow() {
 void MainWindow::initializeUI() {
     ui->setupUi(this);
 
-    //showFullScreen();
-    //sets attribute to maemo's stacked window
-
-
+    #ifdef Q_WS_MAEMO_5
+        setAttribute(Qt::WA_Maemo5StackedWindow);
+    #endif
 
     searchBarWidget = new SearchBarWidget;
 
@@ -80,12 +75,15 @@ void MainWindow::initializeUI() {
 
     welcomeScreenWidget = new WelcomeScreenWidget;
 
+
     #ifdef Q_WS_MAEMO_5
+    //At start we set widget as welcome screen widget
         ui->centralWidget->layout()->addWidget(welcomeScreenWidget);
         QVBoxLayout* vl = (QVBoxLayout*)(ui->centralWidget->layout());
         vl->addWidget(searchBarWidget, 0, Qt::AlignBottom);
     #else
         translationWidget->hide();
+        //we add to splitter word list and welcome screen
         splitter = new QSplitter(Qt::Horizontal);
         splitter->addWidget(wordListWidget);
         splitter->addWidget(welcomeScreenWidget);
@@ -109,6 +107,7 @@ void MainWindow::initializeUI() {
     aboutWidget->hide();
 
 
+    //creating menus
 
     #ifdef Q_WS_MAEMO_5
         menuWidget = new MenuWidget(this);
@@ -165,13 +164,13 @@ void MainWindow::wordListReady() {
     QHash<QString, QList<Translation*> > searchResult;
 
     #ifdef Q_WS_MAEMO_5
+    //switch welcome screen with word list
     if(!wordListWidget->isVisible()) {
         int i = ui->centralWidget->layout()->indexOf(welcomeScreenWidget);
         QBoxLayout* l = (QBoxLayout*)(ui->centralWidget->layout());
         l->removeWidget(welcomeScreenWidget);
         welcomeScreenWidget->deleteLater();
         l->insertWidget(0, wordListWidget);
-        qDebug()<<"changed";
     }
     #endif
 
@@ -198,6 +197,7 @@ void MainWindow::wordListReady() {
         }
         else {
             #ifndef Q_WS_MAEMO_5
+            //on desktop we show word list in exact search
                 emit showWordList(searchResult);
             #endif
             bool foundExactMatch = false;
@@ -227,6 +227,7 @@ void MainWindow::wordListReady() {
 
 void MainWindow::translationsReady() {
     #ifndef Q_WS_MAEMO_5
+    //switch welcome screen with translation widget
     if(!translationWidget->isVisible()) {
         int i = ui->centralWidget->layout()->indexOf(welcomeScreenWidget);
         QBoxLayout* l = (QBoxLayout*)(ui->centralWidget->layout());
@@ -234,7 +235,6 @@ void MainWindow::translationsReady() {
         s->insertWidget(1,translationWidget);
         s->setStretchFactor(1, 150);
         welcomeScreenWidget->deleteLater();
-        qDebug()<<"changed";
     }
     #endif
 
@@ -249,6 +249,12 @@ QHash<CommonDictInterface*, bool> MainWindow::getDictionaries() {
     return backbone->getDictionaries();
 }
 
+
+void MainWindow::search(QString word) {
+    setExactSearch(false);
+    searchBarWidget->search(word);
+}
+
 void MainWindow::searchExact(QString word) {
     setExactSearch(true);
     //searching with searchBar, not directly by emiting searchWordList(),
@@ -448,6 +454,15 @@ void MainWindow::connectTranslationWidget() {
     connect(this, SIGNAL(showTranslation(QStringList)),
             translationWidget, SLOT(show(QStringList)));
 
+     #ifdef Q_WS_MAEMO_5
+        connect(translationWidget, SIGNAL(search(QString)),
+                this, SLOT(search(QString)));
+    #else
+        connect(translationWidget, SIGNAL(search(QString)),
+                this, SLOT(searchExact(QString)));
+    #endif
+
+
 }
 
 void MainWindow::connectDictManager() {
@@ -471,23 +486,23 @@ void MainWindow::connectMenu() {
 }
 
 
-void MainWindow::showAllBookmarks() {
-    #ifdef Q_WS_MAEMO_5
-        menuWidget->hideMenu();
-    #endif
-    backbone->fetchBookmarks();
-}
-
 void MainWindow::connectBookmarksWidget() {
     #ifdef Q_WS_MAEMO_5
+        //after removing bookmarks we search for it once again to clear word list
         connect(bookmarksWidget, SIGNAL(removeAllBookmarks()),
                 backbone, SLOT(removeAllBookmark()));
 
+        connect(bookmarksWidget, SIGNAL(removeAllBookmarks()),
+                backbone, SLOT(fetchBookmarks()));
+
+
         connect(bookmarksWidget, SIGNAL(showAllBookmarks()),
-                this, SLOT(showAllBookmarks()));
+                menuWidget, SLOT(hideMenu()));
 
-        connect(bookmarksWidget, SIGNAL(removeAllBookmarks()),
+        connect(bookmarksWidget, SIGNAL(showAllBookmarks()),
                 backbone, SLOT(fetchBookmarks()));
+
+
     #else
         connect(bookmarksShowAllAction, SIGNAL(triggered()),
                 backbone, SLOT(fetchBookmarks()));
index 6032269..d475ad6 100644 (file)
@@ -99,8 +99,18 @@ public:
     */
     void setExactSearch(bool);
 
+
+    //! Returns current settings.
+    /*!
+       \returns Settings object containing curren application settings
+      */
     Settings* settings();
 
+
+    //! Sets new settings.
+    /*!
+       \param Settings object containing new application settings
+      */
     void setSettings(Settings*);
 
 
@@ -114,6 +124,14 @@ public:
     void searchExact(QString);
 
 
+    //! Search for given word
+    /*!
+      \param word which will be searched in dictionaries
+      */
+    void search(QString);
+
+
+
     //! Gets word list from backbone and prepares received list to display
     /*!
       Checks if received list is empty, in that case displays suitable
@@ -174,9 +192,6 @@ private Q_SLOTS:
     void breakSearching();
 
 
-    void showAllBookmarks();
-
-
 protected:
     /*! When user wants to close application, we first sends signal to stop all
         ongoing searches.
index fafc63b..37ec77b 100644 (file)
@@ -52,6 +52,9 @@ public:
     void removeSubMenu(QString title);
 
 public Q_SLOTS:
+    /*!
+      Hides menu
+      */
     void hideMenu();
 
 protected:
index 4731d6e..82ccd2e 100644 (file)
@@ -81,10 +81,10 @@ QIcon SearchBarWidget::generateIcon(QIcon oryginal, qreal rotation) {
         p = p.transformed(m);
     }
 
-
     QIcon newIcon;
     newIcon.addPixmap(p);
 
+
     #ifdef Q_WS_MAEMO_5
         QPainter painter(&p);
         painter.fillRect(p.rect(), QColor(0,0,0,192));
index 5b34ee5..937aee1 100644 (file)
@@ -65,7 +65,6 @@ SettingsWidget::SettingsWidget(GUIInterface *parent) :
     verticalLayout->addWidget(searchInBookmarksCheckBox);
 
 
-
     #ifndef Q_WS_MAEMO_5
         setMinimumWidth(250);
         setMaximumWidth(250);
@@ -112,6 +111,7 @@ void SettingsWidget::hideEvent(QHideEvent *e) {
     else
         newSettings->setValue("search_bookmarks", "false");
 
+    //setting new settings only if their are different that old ones
     QString key;
     foreach(key, newSettings->keys()) {
         if(settings->value(key) != newSettings->value(key)) {
index defb521..f7ed38d 100644 (file)
@@ -19,7 +19,9 @@
 
 *******************************************************************************/
 
-//Created by Mateusz Półrola
+//! \file DictManagerWidget.h
+//! \brief Settings widget
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 #ifndef SETTINGSWIDGET_H
 #define SETTINGSWIDGET_H
 #include "../../includes/GUIInterface.h"
 #include "../../includes/settings.h"
 
+//! Implements applications settings widget
+/*!
+  Shows settings that user can change.
+  It allow to change limit of searches and limit of history.
+  Also it allow to select if application have to search in dictionaries or in
+  bookmarks or in both of them. All changes are saved automatically after
+  hiding of this widget.
+  */
 class SettingsWidget : public QDialog
 {
     Q_OBJECT
 public:
+    //! Constructor
+    /*!
+      \param parent parent of this widget, which must be subclass of
+      GUIInterface, because it will use it to get current settings and
+      sets new ones.
+      */
     explicit SettingsWidget(GUIInterface *parent = 0);
 
 protected:
index d7d2b5c..8b2e564 100644 (file)
 #include "TranslationWidget.h"
 #include "TranslationWidgetAutoResizer.h"
 #include <QDebug>
+#ifdef Q_WS_MAEMO_5
+    #include <QtGui/QX11Info>
+    #include <X11/Xlib.h>
+    #include <X11/Xatom.h>
+#endif
 
 TranslationWidget::TranslationWidget(QWidget *parent):
     QScrollArea(parent) {
@@ -36,6 +41,10 @@ TranslationWidget::TranslationWidget(QWidget *parent):
     initializeUI();
     //Q_INIT_RESOURCE(xslt);
     setWindowTitle(tr("Translation"));
+
+    connect(textEdit, SIGNAL(search()),
+            this, SLOT(searchSelected()));
+
 }
 
 
@@ -45,7 +54,12 @@ void TranslationWidget::show() {
 
 void TranslationWidget::show(QStringList translations) {
 
-    show();
+    showMaximized();
+
+    #ifdef Q_WS_MAEMO_5
+        if(!buttonsInitialized)
+            initButtons();
+    #endif
 
     textEdit->clear();
 
@@ -94,12 +108,98 @@ void TranslationWidget::initializeUI() {
 
     zoomOutToolButton = new QToolButton;
     zoomOutToolButton->setIcon(QIcon::fromTheme("pdf_zoomout"));
+#ifdef Q_WS_MAEMO_5
+void TranslationWidget::initButtons() {
+
+        int x = width() - showButtonsButton->sizeHint().width();
+        int y = height() - showButtonsButton->sizeHint().height();
+
+        showButtonsButton->move(QPoint(x,y));
+        showButtonsButton->show();
+        showButtonsButton->setCheckable(true);
+//==================================================================
+
+        x = width() - zoomOutButton->sizeHint().width();
+        y = height() - 2*zoomOutButton->sizeHint().height();
+        zoomOutButton->move(QPoint(x, height()));
+
+        zoomOutButtonAnimation =
+                new QPropertyAnimation(zoomOutButton, "pos", this);
+
+        zoomOutButtonAnimation->setStartValue(QPoint(x, height()));
+        zoomOutButtonAnimation->setEndValue(QPoint(x,y));
+        zoomOutButtonAnimation->setDuration(200);
+        zoomOutButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
+//==================================================================
+        x = width() - zoomInButton->sizeHint().width();
+        y = height() - 3*zoomInButton->sizeHint().height();
+        zoomInButton->move(QPoint(x, height()));
+
+        zoomInButtonAnimation =
+                new QPropertyAnimation(zoomInButton, "pos", this);
+
+        zoomInButtonAnimation->setStartValue(QPoint(x, height()));
+        zoomInButtonAnimation->setEndValue(QPoint(x,y));
+        zoomInButtonAnimation->setDuration(400);
+        zoomInButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
+//==================================================================
+        x = 0;
+        y = height() - copyButton->sizeHint().height();
+
+        copyButton->move(QPoint(x, height()));
+
+        copyButtonAnimation =
+                new QPropertyAnimation(copyButton, "pos", this);
+
+        copyButtonAnimation->setStartValue(QPoint(x, height()));
+        copyButtonAnimation->setEndValue(QPoint(x,y));
+        copyButtonAnimation->setDuration(200);
+        copyButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
+//==================================================================
+        x = 0;
+        y = height() - 2*copyButton->sizeHint().height();
+
+        selectAllButton->move(QPoint(x, height()));
+
+        selectAllButtonAnimation =
+                new QPropertyAnimation(selectAllButton, "pos", this);
+
+        selectAllButtonAnimation->setStartValue(QPoint(x, height()));
+        selectAllButtonAnimation->setEndValue(QPoint(x,y));
+        selectAllButtonAnimation->setDuration(400);
+        selectAllButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
+//==================================================================
+        x = 0;
+        y = height() - 3*copyButton->sizeHint().height();
+
+        searchButton->move(QPoint(x, height()));
+
+        searchButtonAnimation =
+                new QPropertyAnimation(searchButton, "pos", this);
+
+        searchButtonAnimation->setStartValue(QPoint(x, height()));
+        searchButtonAnimation->setEndValue(QPoint(x,y));
+        searchButtonAnimation->setDuration(600);
+        searchButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
+//==================================================================
+
+        buttonsAnimation = new QParallelAnimationGroup(this);
+        buttonsAnimation->addAnimation(zoomInButtonAnimation);
+        buttonsAnimation->addAnimation(zoomOutButtonAnimation);
+        buttonsAnimation->addAnimation(selectAllButtonAnimation);
+        buttonsAnimation->addAnimation(copyButtonAnimation);
+        buttonsAnimation->addAnimation(searchButtonAnimation);
+        buttonsInitialized = true;
+        buttonsVisible = false;
+
+        connect(showButtonsButton, SIGNAL(toggled(bool)),
+                this, SLOT(showButtons(bool)));
+}
+#endif
 
-   // horizontalLayout = new QHBoxLayout;
-    //horizontalLayout->addWidget(zoomInToolButton);
-   // horizontalLayout->addWidget(zoomOutToolButton);
+void TranslationWidget::initializeUI() {
 
-    textEdit = new QTextEdit;
+    textEdit = new TranslationTextEdit;
     textEdit->setReadOnly(true);
 
     resizer = new TranslationWidgetAutoResizer(textEdit);
@@ -117,43 +217,122 @@ void TranslationWidget::initializeUI() {
     this->setWidget(w);
     this->setWidgetResizable(true);
 
-    connect(zoomInToolButton, SIGNAL(clicked()),
-            textEdit, SLOT(zoomIn()));
-
-    connect(zoomInToolButton, SIGNAL(clicked()),
-            this, SIGNAL(updateSize()));
-
-    connect(zoomOutToolButton, SIGNAL(clicked()),
-            textEdit, SLOT(zoomOut()));
-
-    connect(zoomInToolButton, SIGNAL(clicked()),
-            this, SIGNAL(updateSize()));
-
-   /* #ifdef Q_WS_MAEMO_5
-        fullScreenButton = new QToolButton(this);
-        fullScreenButton->setIcon(QIcon::fromTheme("general_fullsize"));
-        fullScreenButton->setMinimumSize(fullScreenButton->sizeHint());
-        int x = QApplication::desktop()->screenGeometry(this).width()  -
-                fullScreenButton->sizeHint().width();
-        int y = QApplication::desktop()->screenGeometry(this).height() -
-                fullScreenButton->sizeHint().height();
-        fullScreenButton->move(QPoint(x,y));
-        fullScreenButton->show();
-        fullScreenButton->setWindowOpacity(0.5);
-
-
-        backButton = new QToolButton(this);
-        backButton->setIcon(QIcon::fromTheme("general_overlay_back"));
-        backButton->setMinimumSize(fullScreenButton->sizeHint());
-        x = QApplication::desktop()->screenGeometry(this).width()  -
-                backButton->sizeHint().width();
-        y = 0;
-        backButton->move(QPoint(x,y));
-        backButton->show();
-        backButton->setWindowOpacity(0.5);
-
-        connect(backButton, SIGNAL(clicked()),
-                this, SLOT(hide()));
-    #endif*/
+
+    #ifdef Q_WS_MAEMO_5
+        zoomInButton = new QToolButton(this);
+        zoomInButton->setIcon(QIcon::fromTheme("pdf_zoomin"));
+        zoomInButton->setMinimumSize(zoomInButton->sizeHint());
+
+        zoomOutButton = new QToolButton(this);
+        zoomOutButton->setIcon(QIcon::fromTheme("pdf_zoomout"));
+        zoomOutButton->setMinimumSize(zoomOutButton->sizeHint());
+
+        selectAllButton = new QToolButton(this);
+        selectAllButton->setIcon(QIcon::fromTheme("pdf_zoomout"));
+        selectAllButton->setMinimumSize(selectAllButton->sizeHint());
+
+        copyButton = new QToolButton(this);
+        copyButton->setIcon(QIcon::fromTheme("general_notes"));
+        copyButton->setMinimumSize(copyButton->sizeHint());
+        copyButton->setEnabled(false);
+
+        searchButton = new QToolButton(this);
+        searchButton->setIcon(QIcon::fromTheme("general_search"));
+        searchButton->setMinimumSize(searchButton->sizeHint());
+        searchButton->setEnabled(false);
+
+        showButtonsButton = new QToolButton(this);
+        showButtonsButton->setIcon(QIcon::fromTheme("general_search"));
+        showButtonsButton->setMinimumSize(searchButton->sizeHint());
+
+        connect(zoomInButton, SIGNAL(clicked()),
+                textEdit, SLOT(zoomIn()));
+
+        connect(zoomOutButton, SIGNAL(clicked()),
+                textEdit, SLOT(zoomOut()));
+
+
+        connect(searchButton, SIGNAL(clicked()),
+                this, SLOT(searchSelected()));
+
+        connect(copyButton, SIGNAL(clicked()),
+                textEdit, SLOT(copy()));
+
+        connect(textEdit, SIGNAL(copyAvailable(bool)),
+                searchButton, SLOT(setEnabled(bool)));
+
+        connect(textEdit, SIGNAL(copyAvailable(bool)),
+                copyButton, SLOT(setEnabled(bool)));
+
+        connect(selectAllButton, SIGNAL(clicked()),
+                textEdit, SLOT(selectAll()));
+
+        buttonsInitialized = false;
+
+
+
+        grabZoomKeys(true);
+    #endif
+}
+
+void TranslationWidget::searchSelected() {
+    #ifdef Q_WS_MAEMO_5
+        hide();
+    #endif
+    emit search(textEdit->textCursor().selectedText());
+}
+
+#ifdef Q_WS_MAEMO_5
+void TranslationWidget::showButtons(bool show) {
+    if(show && !buttonsVisible) {
+        buttonsAnimation->setDirection(QAbstractAnimation::Forward);
+        buttonsAnimation->start();
+        buttonsVisible = true;
+    }
+    else if(!show && buttonsVisible) {
+        buttonsAnimation->setDirection(QAbstractAnimation::Backward);
+        buttonsAnimation->start();
+        buttonsVisible = false;
+    }
+}
+
+void TranslationWidget::grabZoomKeys(bool grab) {
+     if (!winId()) {
+         return;
+     }
+
+    unsigned long val = (grab) ? 1 : 0;
+    Atom atom = XInternAtom(QX11Info::display(),
+                            "_HILDON_ZOOM_KEY_ATOM", False);
+    if (!atom) {
+        return;
+    }
+
+    XChangeProperty (QX11Info::display(),
+         winId(),
+         atom,
+         XA_INTEGER,
+         32,
+         PropModeReplace,
+         reinterpret_cast<unsigned char *>(&val),
+         1);
 }
 
+void TranslationWidget::keyPressEvent(QKeyEvent* event) {
+    switch (event->key()) {
+        case Qt::Key_F7:
+        textEdit->zoomIn();
+        event->accept();
+        break;
+
+        case Qt::Key_F8:
+        textEdit->zoomOut();
+        event->accept();
+        break;
+    }
+    QWidget::keyPressEvent(event);
+}
+#endif
+
+
+
index f087f00..05f61ec 100644 (file)
@@ -32,6 +32,8 @@
 #include "TranslationWidgetAutoResizer.h"
 #include <QtXml>
 #include <QXmlQuery>
+#include "TranslationTextEdit.h"
+#include <QPropertyAnimation>
 
 //! Displays translation of word found in dictionaries
 /*!
@@ -45,6 +47,8 @@ public:
 Q_SIGNALS:
     void updateSize();
 
+    void search(QString);
+
 public Q_SLOTS:
     //! Show widget.
     void show();
@@ -52,22 +56,48 @@ public Q_SLOTS:
     //! Request to show translation of word list passed as parameter.
     void show(QStringList);
 
+protected:
+    #ifdef Q_WS_MAEMO_5
+        void keyPressEvent(QKeyEvent *);
+    #endif
+
+private Q_SLOTS:
+    void searchSelected();
+    #ifdef Q_WS_MAEMO_5
+        void showButtons(bool);
+    #endif
 
 private:
     QString XslConversion(QString translation);
-    QTextEdit *textEdit;
     QToolButton* zoomInToolButton;
     QToolButton* zoomOutToolButton;
+    TranslationTextEdit *textEdit;
     #ifdef Q_WS_MAEMO_5
-        QToolButton* fullScreenButton;
-        QToolButton* backButton;
+        QToolButton* zoomInButton;
+        QToolButton* zoomOutButton;
+        QToolButton* selectAllButton;
+        QToolButton* copyButton;
+        QToolButton* searchButton;
+        QToolButton* showButtonsButton;
+
+        QPropertyAnimation* zoomInButtonAnimation;
+        QPropertyAnimation* zoomOutButtonAnimation;
+        QPropertyAnimation* copyButtonAnimation;
+        QPropertyAnimation* selectAllButtonAnimation;
+        QPropertyAnimation* searchButtonAnimation;
+        QAnimationGroup* buttonsAnimation;
+
+        void initButtons();
+        bool buttonsInitialized;
+        bool buttonsVisible;
+
+        void grabZoomKeys(bool);
     #endif
     QVBoxLayout *verticalLayout;
     QHBoxLayout* horizontalLayout;
     TranslationWidgetAutoResizer* resizer;
 
     void initializeUI();
-
 };
 
 #endif // TRANSLATIONWIDGET_H
index 8a06634..463d979 100644 (file)
@@ -18,8 +18,9 @@
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
-
-//Created by Mateusz Półrola
+//! \file WelcomeScreenWidget.h
+//! \brief Implements widget that display welcome screen to user
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 #ifndef WELCOMESCREENWIDGET_H
 #define WELCOMESCREENWIDGET_H
@@ -28,6 +29,7 @@
 #include <QScrollArea>
 #include <QtGui>
 
+//! Displays wlecome screen with logo and name of application
 class WelcomeScreenWidget : public QScrollArea
 {
     Q_OBJECT
index 57d03c4..571ba9b 100644 (file)
@@ -27,6 +27,7 @@
 WordListProxyStyle::WordListProxyStyle() :
     QProxyStyle()
 {
+    //load pixmap from resources
     starPixmapOn = QPixmap(":/icons/staron.png");
     starPixmapOff = QPixmap(":/icons/staroff.png");
 }
index dd76e73..4a1647c 100644 (file)
@@ -1,5 +1,6 @@
 /*******************************************************************************
 
+
     This file is part of mDictionary.
 
     mDictionary is free software: you can redistribute it and/or modify
@@ -18,8 +19,9 @@
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
-
-//Created by Mateusz Półrola
+//! \file WordListProxyStyle.h
+//! \brief Implements custom style which draw checkboxes as stars
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 #ifndef WORDLISTPROXYSTYLE_H
 #define WORDLISTPROXYSTYLE_H
 #include <QProxyStyle>
 #include <QtGui>
 
+//! Custom proxy style that draw checkboxes as stars.
+//! It will automatically wrap setted style and change only
+//! checkboxes drawing.
 class WordListProxyStyle : public QProxyStyle
 {
 public:
     WordListProxyStyle();
+    //! Reimplemented drawPrimitive method which only draw different
+    //! PE_IndicatorCheckBox elements
+    //! \sa QProxyStyle::drawPrimitive()
     void drawPrimitive(PrimitiveElement element,
                        const QStyleOption *option,
                        QPainter *painter,
index 60cf791..f44af27 100644 (file)
 WordListWidget::WordListWidget(QWidget *parent):
     QTreeView(parent) {
 
+    //creating new model to store words and stars
     model = new QStandardItemModel(this);
     setModel(model);
     setHeaderHidden(true);
     setRootIsDecorated(false);
     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
+    //set our custom style to draw checkboxes as stars
     setStyle(new WordListProxyStyle);
 
+    //setting size of star in pixels, on maemo checboxes are much bigger
     #ifdef Q_WS_MAEMO_5
         checkBoxWidth = 70;
     #else
@@ -53,11 +56,18 @@ WordListWidget::WordListWidget(QWidget *parent):
 
 void WordListWidget::addWord(QString word, int row) {
     QStandardItem* item = new QStandardItem(word);
+
+    //we don't want to allow user to edit word
     item->setFlags(item->flags() ^ Qt::ItemIsEditable);
+
     QStandardItem* itemCheckBox = new QStandardItem();
+    //creating checkbox item
     itemCheckBox->setFlags(itemCheckBox->flags() ^ Qt::ItemIsEditable |
                            Qt::ItemIsUserCheckable);
 
+    /*checking if word is already in bookmarks, information about that is
+    stored in it's translation object (not all translation have to be in
+    bookmarks)*/
     bool bookmark = false;
     Translation* t;
     foreach(t, searchResult[word]) {
@@ -72,6 +82,7 @@ void WordListWidget::addWord(QString word, int row) {
     else
         itemCheckBox->setCheckState(Qt::Unchecked);
 
+    //add item to model
     model->setItem(row,0, item);
     model->setItem(row,1, itemCheckBox);
 }
@@ -79,6 +90,7 @@ void WordListWidget::addWord(QString word, int row) {
 
 void WordListWidget::showSearchResults(
         QHash<QString, QList<Translation *> > result) {
+
     model->clear();
     searchResult.clear();
 
@@ -97,20 +109,28 @@ void WordListWidget::showSearchResults(
 }
 
 void WordListWidget::wordClicked(QModelIndex index) {
+    //we're getting translation based on data in index
     emit showTranslation(
             searchResult[index.data().toString()]);
 }
 
 void WordListWidget::wordChecked(QModelIndex index) {
+
+    //save new item state
     Qt::CheckState state =
             Qt::CheckState(index.data(Qt::CheckStateRole).toInt());
 
-    if(selectedIndexes().count()==0) return;
+
+
+    //getting index of item which contains word which should be added/removed
+    //from bookmarks
     QModelIndex item = selectedIndexes().at(0);
     if(!item.isValid()) return;
 
+    //to shorten lag between clicking on star and it's change
     repaint();
 
+    //depending on new state emit suitable signal
     if(state == Qt::Checked) {
         emit addBookmark(searchResult[item.data().toString()]);
     }
@@ -121,20 +141,29 @@ void WordListWidget::wordChecked(QModelIndex index) {
 
 
 void WordListWidget::mouseReleaseEvent(QMouseEvent *event) {
-    QTreeView::mouseReleaseEvent(event);
 
+    //firstly we normally handle this event
+    QTreeView::mouseReleaseEvent(event);
 
+    //then we checking at which item user clicked
     QModelIndex index = indexAt(event->pos());
     if(!index.isValid()) return;
+
+    /*if there are no selected items we return, that occurs sometimes
+    on maemo, when user is scrolling list and click to stop the scroll,
+    system don't select item but emitting mouseReleaseEvent*/
     if(selectedIndexes().count() == 0) return;
 
+    //if user don't click on word either on star return
     if(selectedIndexes().at(0) != index && selectedIndexes().at(1) != index)
         return;
 
     int c = index.column();
     if(c==0)
+        //if column is 0 user clicked word
         wordClicked(index);
     else
+        //else user clicked star
         wordChecked(index);
 }
 
index 7ad634d..9dc011f 100644 (file)
 
 //! Displays list of words found in dictionaries
 /*!
-    It allow user to select word to see it's translation or to mark it as "star"
+    It allow user to select word to see it's translation or to mark or unmark
+    it as "star" (add/remove from bookmarks). It inherit from QTreeView
+    to allow display two columns, one with words and second with stars.
+    Star is normal checkable item. To get effect of star we need to set
+    style (WordListProxyStyle) for this widget.
   */
 class WordListWidget : public QTreeView {
     Q_OBJECT
@@ -68,19 +72,35 @@ public Q_SLOTS:
     void unlockList();
 
 protected:
+    //! Reimplemented standard mouseReleaseEvent to check if user clicked on
+    //! word on it's star to emit suitable signal
     void mouseReleaseEvent(QMouseEvent *event);
+
+    //! Resize the size of columns to assure that stars are always on right
+    //! side next to scroll bar
     void resizeEvent(QResizeEvent *event);
 
 private Q_SLOTS:
+    //! Emits signal to show translation of clicked item. Signal is emitted
+    //! only when word was clicked.
     void wordClicked(QModelIndex index);
+
+    //! Emits signal to show add or remove word from bookmarks.
+    //! Signal is emitted only when star was clicked.
     void wordChecked(QModelIndex index);
 
 private:
+    //! Adds word to model. Row is row in the model
     void addWord(QString word, int row);
+
     QStandardItemModel* model;
+    //! Describes width of star checkbox in pixels
     int checkBoxWidth;
+
+    //! Resizes sizes of colums after adding new words or after resize event.
     void resizeColumns();
 
+    //! Association between words and their's translations
     QHash<QString, QList<Translation*> > searchResult;
 };