add draft of google translation
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Mon, 23 Aug 2010 13:55:23 +0000 (15:55 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Mon, 23 Aug 2010 13:55:23 +0000 (15:55 +0200)
trunk/src/base/gui/MenuWidget.cpp
trunk/src/plugins/google/google.pro [new file with mode: 0644]
trunk/src/plugins/google/src/GooglePlugin.cpp [new file with mode: 0644]
trunk/src/plugins/google/src/GooglePlugin.h [new file with mode: 0644]
trunk/src/plugins/google/src/src.pro [new file with mode: 0644]
trunk/src/plugins/google/tests/test.cpp [new file with mode: 0644]
trunk/src/plugins/google/tests/test.h [new file with mode: 0644]
trunk/src/plugins/google/tests/tests.pro [new file with mode: 0644]
trunk/src/plugins/plugins.pro

index 7dd6475..fa6210b 100644 (file)
@@ -29,7 +29,7 @@ MenuWidget::MenuWidget(QWidget *parent) :
     QWidgetAction(parent) {
 
     //creating custom tab widget, and sets style sheet to have centered tabs
-    tabWidget = new MenuTabWidget(this);
+    tabWidget = new MenuTabWidget();
     tabWidget->setStyleSheet("QTabWidget::tab-bar {alignment: center;}");
 
 }
diff --git a/trunk/src/plugins/google/google.pro b/trunk/src/plugins/google/google.pro
new file mode 100644 (file)
index 0000000..70fcdea
--- /dev/null
@@ -0,0 +1,7 @@
+TEMPLATE=subdirs
+SUBDIRS=src
+
+check.target = check
+check.CONFIG = recursive
+check.recurse = tests
+QMAKE_EXTRA_TARGETS += check
diff --git a/trunk/src/plugins/google/src/GooglePlugin.cpp b/trunk/src/plugins/google/src/GooglePlugin.cpp
new file mode 100644 (file)
index 0000000..1136f4e
--- /dev/null
@@ -0,0 +1,106 @@
+/*******************************************************************************
+
+    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 GooglePlugin.cpp
+*/
+
+#include "GooglePlugin.h"
+#include <QDebug>
+
+
+GooglePlugin::GooglePlugin(QObject *parent): CommonDictInterface(parent),
+                    _langFrom(tr("")), _langTo(tr("")),_name(tr("")),
+                    _type(tr("google")), _infoNote(tr("")) {
+
+stopped = false;
+//_icon = QIcon(":/icon/google.png");
+}
+
+GooglePlugin::~GooglePlugin()
+{
+}
+
+QString GooglePlugin::langFrom() const {
+    return _langFrom;
+}
+
+QString GooglePlugin::langTo() const {
+    return _langTo;
+}
+
+QString GooglePlugin::name() const {
+    return _name;
+}
+
+QString GooglePlugin::type() const {
+    return _type;
+}
+
+QString GooglePlugin::infoNote() const {
+    return _infoNote;
+}
+
+DictDialog* GooglePlugin::dictDialog()
+{
+}
+
+CommonDictInterface* GooglePlugin::getNew(const Settings*) const
+{
+}
+
+bool GooglePlugin::isAvailable() const {
+   return true;
+}
+
+QString GooglePlugin::search(QString key)
+{
+}
+
+uint GooglePlugin::hash() const {
+    return _hash;
+}
+
+void GooglePlugin::setHash(uint) {
+    this->_hash=_hash;
+}
+
+Settings* GooglePlugin::settings() {
+    return _settings;
+}
+
+void GooglePlugin::setSettings(Settings*)
+{
+}
+
+QIcon* GooglePlugin::icon() {
+    return &_icon;
+}
+
+QList<Translation*> GooglePlugin::searchWordList(QString word, int limit)
+{
+}
+
+void GooglePlugin::stop() {
+    stopped=true;
+}
+
+
+Q_EXPORT_PLUGIN2(google, GooglePlugin)
diff --git a/trunk/src/plugins/google/src/GooglePlugin.h b/trunk/src/plugins/google/src/GooglePlugin.h
new file mode 100644 (file)
index 0000000..a5e325e
--- /dev/null
@@ -0,0 +1,124 @@
+/*******************************************************************************
+
+    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 GooglePlugin.h
+*/
+#ifndef GOOGLEPLUGIN_H
+#define GOOGLEPLUGIN_H
+
+
+#include <QObject>
+#include <QDialog>
+#include <QtPlugin>
+#include <QIcon>
+
+#include "../../../includes/CommonDictInterface.h"
+#include "../../../includes/settings.h"
+
+
+class GooglePlugin : public CommonDictInterface
+{
+    Q_OBJECT
+    Q_INTERFACES(CommonDictInterface)
+public:
+    GooglePlugin(QObject *parent=0);
+    ~GooglePlugin();
+
+    //! returns source language code iso 639-2
+    QString langFrom() const;
+
+    //! returns destination language code iso 639-2
+    QString langTo() const;
+
+    //! returns dictionary name (like "old english" or so)
+    QString name() const;
+
+    //! returns dictionary type (xdxf, google translate, etc)
+    QString type() const;
+
+    //! returns information about dictionary in html (name, authors, etc)
+    QString infoNote() const;
+
+    /*! returns DictDialog object that creates dialogs
+        for adding new dictionary and change plugin tings
+      */
+    DictDialog* dictDialog();
+
+    //! returns new, clean copy of plugin with setting set as in Settings*
+    CommonDictInterface* getNew(const Settings*) const;
+
+    //! returns whether plugin can start searching
+    bool isAvailable() const;
+
+    //! returns a description of a word given by a QString
+    QString search(QString key);
+
+    //! returns a unique hash for a dictionary
+    uint hash() const;
+
+    //! set unique value (unique for every dictionary not plugin)
+    void setHash(uint);
+
+    //! returns current plugin settings
+    Settings* settings();
+
+    //! Sets new settings
+    void setSettings(Settings*);
+
+    //! returns plugin icon
+    QIcon* icon();
+
+public Q_SLOTS:
+    /*! performs search in dictionary
+      \param  word word to search in dictionary
+      \param limit limit on number of results
+
+      After finishing search it has to emit
+      \see CommonDictInterface:finalTranslation  finalTranslation
+    */
+    QList<Translation*> searchWordList(QString word, int limit=0);
+
+    //! stop current operation
+    void stop();
+
+private:
+    //! language from which we translate
+    QString _langFrom;
+    //! language to which we translate
+    QString _langTo;
+    //! name of a dictionary
+    QString _name;
+    //! type of a dictionary
+    QString _type;
+    //! information about dictionary
+    QString _infoNote;
+    //! path to dictionary file
+    QString path;
+    uint _hash;
+    QIcon _icon;
+    Settings *_settings;
+    bool stopped;
+};
+
+#endif // GOOGLEPLUGIN_H
+
+
diff --git a/trunk/src/plugins/google/src/src.pro b/trunk/src/plugins/google/src/src.pro
new file mode 100644 (file)
index 0000000..985b5e5
--- /dev/null
@@ -0,0 +1,64 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-08-03T09:33:52
+#
+#-------------------------------------------------
+
+QT       += core xml gui sql
+
+
+TARGET = GooglePlugin
+TEMPLATE = lib
+
+MDICT_PLUGINSDIR = $$[MDICT_PLUGINSDIR]
+
+isEmpty(MDICT_PLUGINSDIR) {
+  MDICT_PLUGINSDIR = .
+}
+
+MDICT_APPNAME = $$[MDICT_APPNAME]
+
+isEmpty(MDICT_APPNAME) {
+  MDICT_APPNAME = mdictionary
+}
+
+
+DESTDIR = $${MDICT_PLUGINSDIR}/$${MDICT_APPNAME}
+
+
+
+SOURCES +=  \
+    GooglePlugin.cpp \
+
+HEADERS += \
+    GooglePlugin.h \
+    ../../../includes/DictDialog.h \
+    ../../../includes/translation.h \
+    ../../../includes/settings.h \
+    ../../../includes/CommonDictInterface.h \
+
+
+
+    
+unix {
+  #VARIABLES
+  isEmpty(PREFIX) {
+    PREFIX = /usr
+  }
+  
+  BINDIR = $$PREFIX/bin
+  LIBDIR = $$PREFIX/lib/$${MDICT_APPNAME}
+  DATADIR =$$PREFIX/share
+
+  DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\"
+
+  #MAKE INSTALL
+
+  INSTALLS += target dicts
+
+  target.path = $$LIBDIR
+
+  dicts.path = $$LIBDIR
+
+}
+
diff --git a/trunk/src/plugins/google/tests/test.cpp b/trunk/src/plugins/google/tests/test.cpp
new file mode 100644 (file)
index 0000000..d558d93
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+
+    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.
+
+*******************************************************************************/
+
+#include "test.h"
+#include <QSignalSpy>
+
+void GoogleTest::getNew() {
+
+GooglePlugin test;
+}
+
+QTEST_MAIN(GoogleTest)
diff --git a/trunk/src/plugins/google/tests/test.h b/trunk/src/plugins/google/tests/test.h
new file mode 100644 (file)
index 0000000..70a8bcf
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+
+    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.
+
+*******************************************************************************/
+
+#ifndef TEST_H
+#define TEST_H
+
+#include <QtTest/QtTest>
+#include "../src/GooglePlugin.h"
+
+
+ class GoogleTest: public QObject
+ {
+     Q_OBJECT
+
+
+ private slots:
+     void getNew();
+
+ };
+
+
+#endif // TEST_H
diff --git a/trunk/src/plugins/google/tests/tests.pro b/trunk/src/plugins/google/tests/tests.pro
new file mode 100644 (file)
index 0000000..7a823d0
--- /dev/null
@@ -0,0 +1,24 @@
+######################################################################
+# Automatically generated by qmake (1.07a) Wed Aug 4 11:35:12 2010
+######################################################################
+
+CONFIG += qtestlib
+QT += sql
+TARGET = GooglrPluginTests
+TEMPLATE = app
+INCLUDEPATH += .
+
+# Input
+HEADERS += test.h \
+    ../src/GooglePlugin.h \
+    ../../../includes/translation.h \
+    ../../../includes/settings.h \
+    ../../../includes/DictDialog.h \
+    ../../../includes/CommonDictInterface.h \
+
+SOURCES += test.cpp \
+    ../src/GooglePlugin.cpp \
+
+check.target = check
+check.commands = ./GooglePluginTests
+QMAKE_EXTRA_TARGETS += check
index 512061a..d465f5f 100644 (file)
@@ -1,5 +1,5 @@
 TEMPLATE = subdirs
-SUBDIRS = xdxf
+SUBDIRS = xdxf google
 
 check.target = check
 check.CONFIG = recursive