Rename TranslationTextEdit to TranslationView
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Wed, 15 Sep 2010 09:40:07 +0000 (11:40 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Wed, 15 Sep 2010 09:40:07 +0000 (11:40 +0200)
src/mdictionary/gui/TranslationTextEdit.cpp [deleted file]
src/mdictionary/gui/TranslationTextEdit.h [deleted file]
src/mdictionary/gui/TranslationView.cpp [new file with mode: 0644]
src/mdictionary/gui/TranslationView.h [new file with mode: 0644]
src/mdictionary/gui/TranslationWidget.cpp
src/mdictionary/gui/TranslationWidget.h
src/mdictionary/mdictionary.pro

diff --git a/src/mdictionary/gui/TranslationTextEdit.cpp b/src/mdictionary/gui/TranslationTextEdit.cpp
deleted file mode 100644 (file)
index 41d5aaa..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
-
-    This file is part of mDictionary.
-
-    mDictionary is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    mDictionary is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
-
-    Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-//! \file TranslationTextEdit.cpp
-//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
-
-#include <QtGui>
-#include "TranslationTextEdit.h"
-#include "TranslationWidget.h"
-
-TranslationTextEdit::TranslationTextEdit(QWidget *parent) :
-    QWebView(parent)
-{
-    realParent = qobject_cast<TranslationWidget*>(parent);
-    searchSelectedAction = new QAction(tr("Search"), this);
-    copySelectedAction = new QAction(tr("Copy"), this);
-    selectAllAction = new QAction(tr("Select All"), this);
-    setAcceptDrops(false);
-
-    #ifdef Q_WS_MAEMO_5
-        installEventFilter(this);
-        property("kineticScroller").value<QAbstractKineticScroller*>()->
-                setEnabled(true);
-    #endif
-
-
-    connect(searchSelectedAction, SIGNAL(triggered()),
-            this, SIGNAL(search()));
-    connect(page(), SIGNAL(selectionChanged()), this, SLOT(selection()));
-}
-
-void TranslationTextEdit::wheelEvent(QWheelEvent *e) {
-    if(e->modifiers() & Qt::ControlModifier) {
-        if(e->delta()>0) {
-            zoomIn();
-        }
-        else {
-            zoomOut();
-        }
-        e->ignore();
-    }
-    else {
-        QWebView::wheelEvent(e);
-    }
-}
-
-bool TranslationTextEdit::eventFilter(QObject *, QEvent *e) {
-    switch (e->type()) {
-    case QEvent::MouseButtonPress:
-        if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
-            mousePressed = true;
-        break;
-    case QEvent::MouseButtonRelease:
-        if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
-            mousePressed = false;
-        break;
-    case QEvent::MouseMove:
-        if (mousePressed)
-            return true;
-    default:
-        break;
-    }
-    return false;
-}
-
-
-void TranslationTextEdit::contextMenuEvent(QContextMenuEvent *e) {
-    QMenu *menu = new QMenu;
-    if(selectedText().isEmpty())
-        searchSelectedAction->setEnabled(false);
-    else
-        searchSelectedAction->setEnabled(true);
-
-    menu->addAction(searchSelectedAction);
-    menu->addSeparator();
-    menu->addAction(pageAction(QWebPage::Copy));
-    menu->addAction(pageAction(QWebPage::SelectAll));
-
-    menu->exec(e->globalPos());
-    delete menu;
-
-    e->ignore();
-}
-
-
-void TranslationTextEdit::zoomIn() {
-    if(zoomFactor() >= 3)
-        return;
-    setZoomFactor(zoomFactor()*1.05);
-    realParent->updateZoom(zoomFactor());
-
-}
-
-void TranslationTextEdit::zoomOut() {
-    if(zoomFactor() <= 0.5)
-        return;
-    setZoomFactor(zoomFactor()*0.95);
-    realParent->updateZoom(zoomFactor());
-}
-
-void TranslationTextEdit::copy() {
-      pageAction(QWebPage::Copy)->trigger();
-}
-
-void TranslationTextEdit::selection() {
-    if(selectedText().size())
-        Q_EMIT copyAvailable(true);
-    else
-        Q_EMIT copyAvailable(false);
-}
-
-
-void TranslationTextEdit::selectAll() {
-    pageAction(QWebPage::SelectAll)->trigger();
-}
-
-
-
diff --git a/src/mdictionary/gui/TranslationTextEdit.h b/src/mdictionary/gui/TranslationTextEdit.h
deleted file mode 100644 (file)
index 917105a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
-
-    This file is part of mDictionary.
-
-    mDictionary is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    mDictionary is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
-
-    Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-//! \file TranslationTextEdit.h
-//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
-
-#ifndef TRANSLATIONTEXTEDIT_H
-#define TRANSLATIONTEXTEDIT_H
-
-#include <QTextEdit>
-#include <QAction>
-#include <QWebView>
-#include <QEvent>
-
-class TranslationWidget;
-
-class TranslationTextEdit : public QWebView
-{
-    Q_OBJECT
-public:
-    explicit TranslationTextEdit(QWidget *parent = 0);
-
-public Q_SLOTS:
-    void zoomIn();
-    void zoomOut();
-    void copy();
-    void selection();
-    void selectAll();
-
-Q_SIGNALS:
-    void search();
-    void copyAvailable(bool);
-
-protected:
-    void contextMenuEvent(QContextMenuEvent *);
-    void wheelEvent(QWheelEvent *);
-
-private:
-    QAction* searchSelectedAction;
-    QAction* copySelectedAction;
-    QAction* selectAllAction;
-    TranslationWidget* realParent;
-    bool mousePressed;
-    bool eventFilter(QObject *, QEvent *);
-
-};
-
-#endif // TRANSLATIONTEXTEDIT_H
diff --git a/src/mdictionary/gui/TranslationView.cpp b/src/mdictionary/gui/TranslationView.cpp
new file mode 100644 (file)
index 0000000..79a6c14
--- /dev/null
@@ -0,0 +1,136 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//! \file TranslationView.cpp
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+
+#include <QtGui>
+#include "TranslationView.h"
+#include "TranslationWidget.h"
+
+TranslationView::TranslationView(QWidget *parent) :
+    QWebView(parent)
+{
+    realParent = qobject_cast<TranslationWidget*>(parent);
+    searchSelectedAction = new QAction(tr("Search"), this);
+    copySelectedAction = new QAction(tr("Copy"), this);
+    selectAllAction = new QAction(tr("Select All"), this);
+    setAcceptDrops(false);
+
+    #ifdef Q_WS_MAEMO_5
+        installEventFilter(this);
+        property("kineticScroller").value<QAbstractKineticScroller*>()->
+                setEnabled(true);
+    #endif
+
+
+    connect(searchSelectedAction, SIGNAL(triggered()),
+            this, SIGNAL(search()));
+    connect(page(), SIGNAL(selectionChanged()), this, SLOT(selection()));
+}
+
+void TranslationView::wheelEvent(QWheelEvent *e) {
+    if(e->modifiers() & Qt::ControlModifier) {
+        if(e->delta()>0) {
+            zoomIn();
+        }
+        else {
+            zoomOut();
+        }
+        e->ignore();
+    }
+    else {
+        QWebView::wheelEvent(e);
+    }
+}
+
+bool TranslationView::eventFilter(QObject *, QEvent *e) {
+    switch (e->type()) {
+    case QEvent::MouseButtonPress:
+        if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
+            mousePressed = true;
+        break;
+    case QEvent::MouseButtonRelease:
+        if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
+            mousePressed = false;
+        break;
+    case QEvent::MouseMove:
+        if (mousePressed)
+            return true;
+    default:
+        break;
+    }
+    return false;
+}
+
+
+void TranslationView::contextMenuEvent(QContextMenuEvent *e) {
+    QMenu *menu = new QMenu;
+    if(selectedText().isEmpty())
+        searchSelectedAction->setEnabled(false);
+    else
+        searchSelectedAction->setEnabled(true);
+
+    menu->addAction(searchSelectedAction);
+    menu->addSeparator();
+    menu->addAction(pageAction(QWebPage::Copy));
+    menu->addAction(pageAction(QWebPage::SelectAll));
+
+    menu->exec(e->globalPos());
+    delete menu;
+
+    e->ignore();
+}
+
+
+void TranslationView::zoomIn() {
+    if(zoomFactor() >= 3)
+        return;
+    setZoomFactor(zoomFactor()*1.05);
+    realParent->updateZoom(zoomFactor());
+
+}
+
+void TranslationView::zoomOut() {
+    if(zoomFactor() <= 0.5)
+        return;
+    setZoomFactor(zoomFactor()*0.95);
+    realParent->updateZoom(zoomFactor());
+}
+
+void TranslationView::copy() {
+      pageAction(QWebPage::Copy)->trigger();
+}
+
+void TranslationView::selection() {
+    if(selectedText().size())
+        Q_EMIT copyAvailable(true);
+    else
+        Q_EMIT copyAvailable(false);
+}
+
+
+void TranslationView::selectAll() {
+    pageAction(QWebPage::SelectAll)->trigger();
+}
+
+
+
diff --git a/src/mdictionary/gui/TranslationView.h b/src/mdictionary/gui/TranslationView.h
new file mode 100644 (file)
index 0000000..1ea9d12
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//! \file TranslationView.h
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+
+#ifndef TRANSLATIONVIEW_H
+#define TRANSLATIONVIEW_H
+
+#include <QTextEdit>
+#include <QAction>
+#include <QWebView>
+#include <QEvent>
+
+class TranslationWidget;
+
+class TranslationView : public QWebView
+{
+    Q_OBJECT
+public:
+    explicit TranslationView(QWidget *parent = 0);
+
+public Q_SLOTS:
+    void zoomIn();
+    void zoomOut();
+    void copy();
+    void selection();
+    void selectAll();
+
+Q_SIGNALS:
+    void search();
+    void copyAvailable(bool);
+
+protected:
+    void contextMenuEvent(QContextMenuEvent *);
+    void wheelEvent(QWheelEvent *);
+
+private:
+    QAction* searchSelectedAction;
+    QAction* copySelectedAction;
+    QAction* selectAllAction;
+    TranslationWidget* realParent;
+    bool mousePressed;
+    bool eventFilter(QObject *, QEvent *);
+
+};
+
+#endif // TRANSLATIONVIEW_H
index 404ca2f..a7bf713 100644 (file)
@@ -214,7 +214,7 @@ void TranslationWidget::initButtons() {
 
 void TranslationWidget::initializeUI() {
 
-    webkit = new TranslationTextEdit(this);
+    webkit = new TranslationView(this);
     Settings* set = guiinterface->settings();
     qreal fac = set->value("zoom").toFloat();
     if(!fac)
index 9e3e36c..5907f97 100644 (file)
@@ -30,7 +30,7 @@
 #include "../backbone/backbone.h"
 #include <QtXml>
 #include <QXmlQuery>
-#include "TranslationTextEdit.h"
+#include "TranslationView.h"
 #include <QPropertyAnimation>
 #include "../../include/GUIInterface.h"
 
@@ -72,7 +72,7 @@ private:
     QString XslConversion(QString translation);
     QToolButton* zoomInToolButton;
     QToolButton* zoomOutToolButton;
-    TranslationTextEdit *webkit;
+    TranslationView *webkit;
     QString xslt;
 
     #ifdef Q_WS_MAEMO_5
index 8e3195b..0025ded 100644 (file)
@@ -34,7 +34,7 @@ SOURCES += gui/main.cpp \
     gui/BookmarksWidget.cpp \
     gui/WelcomeScreenWidget.cpp \
     gui/AboutWidget.cpp \
-    gui/TranslationTextEdit.cpp \
+    gui/TranslationView.cpp \
     gui/DBusAdapter.cpp \
     gui/NotifyManager.cpp \
     gui/SpinBox.cpp
@@ -63,7 +63,7 @@ HEADERS += gui/MainWindow.h \
     gui/BookmarksWidget.h \
     gui/WelcomeScreenWidget.h \
     ../include/Notify.h \
-    gui/TranslationTextEdit.h \
+    gui/TranslationView.h \
     ../include/AccentsNormalizer.h \
     ../include/DictDialog.h \
     gui/DBusAdapter.h \