Changed plugin tree schema
authorBartosz Szatkowski <bulislaw@linux.com>
Thu, 5 Aug 2010 13:18:04 +0000 (15:18 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Thu, 5 Aug 2010 13:18:04 +0000 (15:18 +0200)
trunk/src/plugins/xdxf/src/TranslationXdxf.cpp [new file with mode: 0644]
trunk/src/plugins/xdxf/src/TranslationXdxf.h [new file with mode: 0644]
trunk/src/plugins/xdxf/src/XdxfPlugin.pro [new file with mode: 0644]
trunk/src/plugins/xdxf/src/XdxfPlugin/TranslationXdxf.cpp [deleted file]
trunk/src/plugins/xdxf/src/XdxfPlugin/TranslationXdxf.h [deleted file]
trunk/src/plugins/xdxf/src/XdxfPlugin/XdxfPlugin.pro [deleted file]
trunk/src/plugins/xdxf/src/XdxfPlugin/xdxfplugin.cpp [deleted file]
trunk/src/plugins/xdxf/src/XdxfPlugin/xdxfplugin.h [deleted file]
trunk/src/plugins/xdxf/src/xdxfplugin.cpp [new file with mode: 0644]
trunk/src/plugins/xdxf/src/xdxfplugin.h [new file with mode: 0644]

diff --git a/trunk/src/plugins/xdxf/src/TranslationXdxf.cpp b/trunk/src/plugins/xdxf/src/TranslationXdxf.cpp
new file mode 100644 (file)
index 0000000..c2bb1a7
--- /dev/null
@@ -0,0 +1,30 @@
+#include "TranslationXdxf.h"
+
+
+TranslationXdxf::TranslationXdxf() {
+}
+
+TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo, XdxfPlugin *xdxfPlugin): _key(_key),_dictionaryInfo(_dictionaryInfo) {
+    this->xdxfPlugin=xdxfPlugin;
+}
+
+QString TranslationXdxf::key() const {
+    return _key;
+}
+
+QString TranslationXdxf::dictionaryInfo() const {
+    return _dictionaryInfo;
+}
+
+QString TranslationXdxf::toHtml() const {
+    return xdxfPlugin->search(_key);
+}
+
+void TranslationXdxf::setKey(QString _key) {
+    this->_key=_key;
+}
+
+void TranslationXdxf::setDictionaryInfo(QString _dictionaryInfo) {
+    this->_dictionaryInfo=_dictionaryInfo;
+}
+
diff --git a/trunk/src/plugins/xdxf/src/TranslationXdxf.h b/trunk/src/plugins/xdxf/src/TranslationXdxf.h
new file mode 100644 (file)
index 0000000..0c65eb4
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef TRANSLATIONXDXF_H
+#define TRANSLATIONXDXF_H
+
+#include <QString>
+#include "../../../includes/translation.h"
+#include "xdxfplugin.h"
+
+class TranslationXdxf : public Translation
+{
+public:
+    TranslationXdxf();
+    TranslationXdxf(QString _key,QString _dictionaryInfo, XdxfPlugin *xdxfPlugin);
+
+    //! \return word to be translated
+    QString key() const;
+
+    //! \returns dictionary information (plugin name, languages, <logo> etc)\
+    //!    to be displayed in translation table header
+    QString dictionaryInfo() const;
+
+    //! \return parsed raw format into html
+    QString toHtml() const;
+
+    //! sets the word for which we want to find a translation
+    void setKey(QString);
+
+    //! sets information about dictionary
+    void setDictionaryInfo(QString);
+
+
+private:
+    QString _key;
+    QString _dictionaryInfo;
+    XdxfPlugin *xdxfPlugin;
+
+};
+
+#endif // TRANSLATIONXDXF_H
+
diff --git a/trunk/src/plugins/xdxf/src/XdxfPlugin.pro b/trunk/src/plugins/xdxf/src/XdxfPlugin.pro
new file mode 100644 (file)
index 0000000..7e811e3
--- /dev/null
@@ -0,0 +1,23 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-08-03T09:33:52
+#
+#-------------------------------------------------
+
+QT       += core xml gui
+
+
+TARGET = XdxfPlugin
+TEMPLATE = lib
+
+SOURCES +=  \
+    xdxfplugin.cpp \
+    TranslationXdxf.cpp
+
+
+HEADERS += \
+    xdxfplugin.h \
+    ../../../includes/translation.h \
+    ../../../includes/settings.h \
+    ../../../includes/CommonDictInterface.h \
+    TranslationXdxf.h
diff --git a/trunk/src/plugins/xdxf/src/XdxfPlugin/TranslationXdxf.cpp b/trunk/src/plugins/xdxf/src/XdxfPlugin/TranslationXdxf.cpp
deleted file mode 100644 (file)
index c2bb1a7..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "TranslationXdxf.h"
-
-
-TranslationXdxf::TranslationXdxf() {
-}
-
-TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo, XdxfPlugin *xdxfPlugin): _key(_key),_dictionaryInfo(_dictionaryInfo) {
-    this->xdxfPlugin=xdxfPlugin;
-}
-
-QString TranslationXdxf::key() const {
-    return _key;
-}
-
-QString TranslationXdxf::dictionaryInfo() const {
-    return _dictionaryInfo;
-}
-
-QString TranslationXdxf::toHtml() const {
-    return xdxfPlugin->search(_key);
-}
-
-void TranslationXdxf::setKey(QString _key) {
-    this->_key=_key;
-}
-
-void TranslationXdxf::setDictionaryInfo(QString _dictionaryInfo) {
-    this->_dictionaryInfo=_dictionaryInfo;
-}
-
diff --git a/trunk/src/plugins/xdxf/src/XdxfPlugin/TranslationXdxf.h b/trunk/src/plugins/xdxf/src/XdxfPlugin/TranslationXdxf.h
deleted file mode 100644 (file)
index cfb24f4..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef TRANSLATIONXDXF_H
-#define TRANSLATIONXDXF_H
-
-#include <QString>
-#include "../../../../includes/translation.h"
-#include "xdxfplugin.h"
-
-class TranslationXdxf : public Translation
-{
-public:
-    TranslationXdxf();
-    TranslationXdxf(QString _key,QString _dictionaryInfo, XdxfPlugin *xdxfPlugin);
-
-    //! \return word to be translated
-    QString key() const;
-
-    //! \returns dictionary information (plugin name, languages, <logo> etc)\
-    //!    to be displayed in translation table header
-    QString dictionaryInfo() const;
-
-    //! \return parsed raw format into html
-    QString toHtml() const;
-
-    //! sets the word for which we want to find a translation
-    void setKey(QString);
-
-    //! sets information about dictionary
-    void setDictionaryInfo(QString);
-
-
-private:
-    QString _key;
-    QString _dictionaryInfo;
-    XdxfPlugin *xdxfPlugin;
-
-};
-
-#endif // TRANSLATIONXDXF_H
-
diff --git a/trunk/src/plugins/xdxf/src/XdxfPlugin/XdxfPlugin.pro b/trunk/src/plugins/xdxf/src/XdxfPlugin/XdxfPlugin.pro
deleted file mode 100644 (file)
index 3677e33..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2010-08-03T09:33:52
-#
-#-------------------------------------------------
-
-QT       += core xml gui
-
-
-TARGET = XdxfPlugin
-TEMPLATE = lib
-
-SOURCES +=  \
-    xdxfplugin.cpp \
-    TranslationXdxf.cpp
-
-
-HEADERS += \
-    xdxfplugin.h \
-    ../../../../includes/translation.h \
-    ../../../../includes/settings.h \
-    ../../../../includes/CommonDictInterface.h \
-    TranslationXdxf.h
diff --git a/trunk/src/plugins/xdxf/src/XdxfPlugin/xdxfplugin.cpp b/trunk/src/plugins/xdxf/src/XdxfPlugin/xdxfplugin.cpp
deleted file mode 100644 (file)
index 466b7a6..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-#include "xdxfplugin.h"
-#include <QDebug>
-#include <QFile>
-#include <QXmlStreamReader>
-#include <QtPlugin>
-#include "TranslationXdxf.h"
-
-XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
-                    _langFrom(tr("")), _langTo(tr("")),_name(tr("")),
-                    _type(tr("xdxf")), _infoNote(tr("")) {
-    path="dict.xdxf";
-    stopped = false;
-}
-
-QString XdxfPlugin::langFrom() const {
-    return  _langFrom;
-}
-
-QString XdxfPlugin::langTo() const {
-    return  _langTo;
-}
-
-QString XdxfPlugin::name() const {
-    return  _name;
-}
-
-QString XdxfPlugin::type() const {
-    return _type;
-}
-
-QString XdxfPlugin::infoNote() const {
-    return  _infoNote;
-}
-
-QList<Translation*> XdxfPlugin::searchWordList(QString word, int limit) {
-    stopped = false;
-    QRegExp regWord(word);
-    regWord.setCaseSensitivity(Qt::CaseInsensitive);
-    regWord.setPatternSyntax(QRegExp::Wildcard);
-
-    QList<Translation*> translations;
-    QFile dictionaryFile(path);
-    if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
-        qDebug()<<"Error: could not open file";
-        return translations;
-    }
-    QXmlStreamReader dictionaryReader(&dictionaryFile);
-    dictionaryReader.readNextStartElement();
-    if(dictionaryReader.name()=="xdxf") {
-      if(dictionaryReader.attributes().hasAttribute("lang_from"))
-        _langFrom = dictionaryReader.attributes().value("lang_from").toString();
-      if(dictionaryReader.attributes().hasAttribute("lang_to"))
-        _langTo = dictionaryReader.attributes().value("lang_to").toString();
-    }
-    dictionaryReader.readNextStartElement();
-    if(dictionaryReader.name()=="full_name")
-        _name=dictionaryReader.readElementText();
-    dictionaryReader.readNextStartElement();
-    if(dictionaryReader.name()=="description")
-        _infoNote=dictionaryReader.readElementText();
-    QString a;
-    int i=0;
-    while(!dictionaryReader.atEnd() && !stopped){
-        dictionaryReader.readNextStartElement();
-        if(dictionaryReader.name()=="ar"){
-            while(dictionaryReader.name()!="k" && !dictionaryReader.atEnd())
-                dictionaryReader.readNextStartElement();
-           a = dictionaryReader.readElementText();
-           if(regWord.exactMatch(a) && i<limit) {
-                translations.append(new TranslationXdxf(a,_infoNote,this));
-                i++;
-                if(i>=limit)
-                    break;
-            }
-        }
-    }
-    stopped=false;
-    dictionaryFile.close();
-    return translations;
-}
-
-QString XdxfPlugin::search(QString key) {
-    QFile dictionaryFile(path);
-    if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
-        qDebug()<<"Error: could not open file";
-        return "";
-    }
-    QXmlStreamReader dictionaryReader(&dictionaryFile);
-
-    QString a;
-    bool match =false;
-    while (!dictionaryReader.atEnd()) {
-        dictionaryReader.readNext();
-        if(dictionaryReader.tokenType() == QXmlStreamReader::StartElement) {
-            if(dictionaryReader.name()=="k") {
-                a = dictionaryReader.readElementText();
-                if(a==key)
-                    match = true;
-            }
-        }
-        else if(dictionaryReader.tokenType() == QXmlStreamReader::Characters)  {
-            if(match) {
-              QString temp(dictionaryReader.text().toString().replace("\n",""));
-              dictionaryFile.close();
-              return temp;
-            }
-        }
-    }
-    return "";
-}
-
-void XdxfPlugin::stop() {
-    stopped=true;
-}
-
-QDialog* XdxfPlugin::loadDialog() {
-     path="dict.xdxf";
-}
-
-QDialog* XdxfPlugin::settingsDialog() {
-    path="dict.xdxf";
-}
-
-CommonDictInterface* XdxfPlugin::getNew(const Settings*) const {
-  return new XdxfPlugin();
-}
-
-bool XdxfPlugin::isAvailable() const {
-    return true;
-}
-
-void XdxfPlugin::setHash(uint _hash)
-{
-    this->_hash=_hash;
-}
-
-uint XdxfPlugin::hash() const
-{
-   return _hash;
-}
-
-Q_EXPORT_PLUGIN2(xdxf, XdxfPlugin)
diff --git a/trunk/src/plugins/xdxf/src/XdxfPlugin/xdxfplugin.h b/trunk/src/plugins/xdxf/src/XdxfPlugin/xdxfplugin.h
deleted file mode 100644 (file)
index 8f3fbf5..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef XDXFPLUGIN_H
-#define XDXFPLUGIN_H
-
-#include "../../../../includes/CommonDictInterface.h"
-#include <QObject>
-#include <QDialog>
-#include <QRegExp>
-#include <QTime>
-
-class TranslationXdxf;
-
-class XdxfPlugin : public CommonDictInterface
-{
-    Q_OBJECT
-    Q_INTERFACES(CommonDictInterface)
-public:
-    XdxfPlugin(QObject *parent=0);
-
-    //! 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 dialog that creates new dictionary and fills necessary options
-    //! QDialog should return Setting* object after being shown
-    QDialog* loadDialog();
-
-    //! returns dialog with dictionary settings
-    QDialog* settingsDialog();
-
-    //! 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);
-
-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);
-
-    //! stop current operation
-    void stop();
-
-private:
-    bool isCached();
-    QString _langFrom;
-    QString _langTo;
-    QString _name;
-    QString _type;
-    QString _infoNote;
-    QDialog *_loadDialog;
-    QDialog *_settingsDialog;
-    QString path;
-    uint _hash;
-    bool stopped;   /*volatile*/
-};
-
-#endif // XDXFPLUGIN_H
-
-
diff --git a/trunk/src/plugins/xdxf/src/xdxfplugin.cpp b/trunk/src/plugins/xdxf/src/xdxfplugin.cpp
new file mode 100644 (file)
index 0000000..466b7a6
--- /dev/null
@@ -0,0 +1,142 @@
+#include "xdxfplugin.h"
+#include <QDebug>
+#include <QFile>
+#include <QXmlStreamReader>
+#include <QtPlugin>
+#include "TranslationXdxf.h"
+
+XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
+                    _langFrom(tr("")), _langTo(tr("")),_name(tr("")),
+                    _type(tr("xdxf")), _infoNote(tr("")) {
+    path="dict.xdxf";
+    stopped = false;
+}
+
+QString XdxfPlugin::langFrom() const {
+    return  _langFrom;
+}
+
+QString XdxfPlugin::langTo() const {
+    return  _langTo;
+}
+
+QString XdxfPlugin::name() const {
+    return  _name;
+}
+
+QString XdxfPlugin::type() const {
+    return _type;
+}
+
+QString XdxfPlugin::infoNote() const {
+    return  _infoNote;
+}
+
+QList<Translation*> XdxfPlugin::searchWordList(QString word, int limit) {
+    stopped = false;
+    QRegExp regWord(word);
+    regWord.setCaseSensitivity(Qt::CaseInsensitive);
+    regWord.setPatternSyntax(QRegExp::Wildcard);
+
+    QList<Translation*> translations;
+    QFile dictionaryFile(path);
+    if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
+        qDebug()<<"Error: could not open file";
+        return translations;
+    }
+    QXmlStreamReader dictionaryReader(&dictionaryFile);
+    dictionaryReader.readNextStartElement();
+    if(dictionaryReader.name()=="xdxf") {
+      if(dictionaryReader.attributes().hasAttribute("lang_from"))
+        _langFrom = dictionaryReader.attributes().value("lang_from").toString();
+      if(dictionaryReader.attributes().hasAttribute("lang_to"))
+        _langTo = dictionaryReader.attributes().value("lang_to").toString();
+    }
+    dictionaryReader.readNextStartElement();
+    if(dictionaryReader.name()=="full_name")
+        _name=dictionaryReader.readElementText();
+    dictionaryReader.readNextStartElement();
+    if(dictionaryReader.name()=="description")
+        _infoNote=dictionaryReader.readElementText();
+    QString a;
+    int i=0;
+    while(!dictionaryReader.atEnd() && !stopped){
+        dictionaryReader.readNextStartElement();
+        if(dictionaryReader.name()=="ar"){
+            while(dictionaryReader.name()!="k" && !dictionaryReader.atEnd())
+                dictionaryReader.readNextStartElement();
+           a = dictionaryReader.readElementText();
+           if(regWord.exactMatch(a) && i<limit) {
+                translations.append(new TranslationXdxf(a,_infoNote,this));
+                i++;
+                if(i>=limit)
+                    break;
+            }
+        }
+    }
+    stopped=false;
+    dictionaryFile.close();
+    return translations;
+}
+
+QString XdxfPlugin::search(QString key) {
+    QFile dictionaryFile(path);
+    if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
+        qDebug()<<"Error: could not open file";
+        return "";
+    }
+    QXmlStreamReader dictionaryReader(&dictionaryFile);
+
+    QString a;
+    bool match =false;
+    while (!dictionaryReader.atEnd()) {
+        dictionaryReader.readNext();
+        if(dictionaryReader.tokenType() == QXmlStreamReader::StartElement) {
+            if(dictionaryReader.name()=="k") {
+                a = dictionaryReader.readElementText();
+                if(a==key)
+                    match = true;
+            }
+        }
+        else if(dictionaryReader.tokenType() == QXmlStreamReader::Characters)  {
+            if(match) {
+              QString temp(dictionaryReader.text().toString().replace("\n",""));
+              dictionaryFile.close();
+              return temp;
+            }
+        }
+    }
+    return "";
+}
+
+void XdxfPlugin::stop() {
+    stopped=true;
+}
+
+QDialog* XdxfPlugin::loadDialog() {
+     path="dict.xdxf";
+}
+
+QDialog* XdxfPlugin::settingsDialog() {
+    path="dict.xdxf";
+}
+
+CommonDictInterface* XdxfPlugin::getNew(const Settings*) const {
+  return new XdxfPlugin();
+}
+
+bool XdxfPlugin::isAvailable() const {
+    return true;
+}
+
+void XdxfPlugin::setHash(uint _hash)
+{
+    this->_hash=_hash;
+}
+
+uint XdxfPlugin::hash() const
+{
+   return _hash;
+}
+
+Q_EXPORT_PLUGIN2(xdxf, XdxfPlugin)
diff --git a/trunk/src/plugins/xdxf/src/xdxfplugin.h b/trunk/src/plugins/xdxf/src/xdxfplugin.h
new file mode 100644 (file)
index 0000000..88f045a
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef XDXFPLUGIN_H
+#define XDXFPLUGIN_H
+
+#include "../../../includes/CommonDictInterface.h"
+#include <QObject>
+#include <QDialog>
+#include <QRegExp>
+#include <QTime>
+
+class TranslationXdxf;
+
+class XdxfPlugin : public CommonDictInterface
+{
+    Q_OBJECT
+    Q_INTERFACES(CommonDictInterface)
+public:
+    XdxfPlugin(QObject *parent=0);
+
+    //! 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 dialog that creates new dictionary and fills necessary options
+    //! QDialog should return Setting* object after being shown
+    QDialog* loadDialog();
+
+    //! returns dialog with dictionary settings
+    QDialog* settingsDialog();
+
+    //! 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);
+
+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);
+
+    //! stop current operation
+    void stop();
+
+private:
+    bool isCached();
+    QString _langFrom;
+    QString _langTo;
+    QString _name;
+    QString _type;
+    QString _infoNote;
+    QDialog *_loadDialog;
+    QDialog *_settingsDialog;
+    QString path;
+    uint _hash;
+    bool stopped;   /*volatile*/
+};
+
+#endif // XDXFPLUGIN_H
+
+