Make program compilable
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Tue, 5 Oct 2010 10:38:53 +0000 (12:38 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Tue, 5 Oct 2010 10:38:53 +0000 (12:38 +0200)
src/plugins/stardict/StarDialog.cpp
src/plugins/stardict/StarDialog.h
src/plugins/stardict/StarDictDialog.cpp
src/plugins/stardict/StarDictDialog.h
src/plugins/stardict/StarDictPlugin.cpp
src/plugins/stardict/StarDictPlugin.h
src/plugins/stardict/TranslationStarDict.cpp
src/plugins/stardict/TranslationStarDict.h

index e4ca1bf..3874fba 100644 (file)
 
 //Created by Mateusz Półrola
 
-#include "XdxfDialog.h"
+#include "StarDialog.h"
 #include <QDebug>
 
-XdxfDialog::XdxfDialog(XdxfPlugin *plugin,
-                       XdxfDialogType type,
+StarDialog::StarDialog(StarDictPlugin *plugin,
+                       StarDialogType type,
                        QWidget *parent) :
     QDialog(parent) {
     this->plugin = plugin;
@@ -62,7 +62,7 @@ XdxfDialog::XdxfDialog(XdxfPlugin *plugin,
 }
 
 
-void XdxfDialog::initializeUI() {
+void StarDialog::initializeUI() {
     mainVerticalLayout = new QVBoxLayout;
     widget = new QWidget;
     widget->setLayout(mainVerticalLayout);
@@ -188,24 +188,12 @@ void XdxfDialog::initializeUI() {
 }
 
 
-void XdxfDialog::setAccents(bool accents) {
+void StarDialog::setAccents(bool accents) {
     _accents = accents;
 }
 
-void XdxfDialog::setGenerateCache(bool generate) {
-    _generateCache = generate;
 
-    if(generate) {
-        _lastAccents = _accents;
-        accentsCheckBox->setChecked(true);
-    }
-    else
-        accentsCheckBox->setChecked(_lastAccents);
-
-    accentsCheckBox->setEnabled(!generate);
-}
-
-void XdxfDialog::selectFile() {
+void StarDialog::selectFile() {
     QString fileName = QFileDialog::getOpenFileName(this,
                                      tr("Select dictionary file"),
                                      _dictionaryFilePath,
@@ -220,7 +208,7 @@ void XdxfDialog::selectFile() {
     }
 }
 
-void XdxfDialog::saveSettings() {
+void StarDialog::saveSettings() {
     _settings = new Settings;
     if(plugin) {
         foreach(QString key, plugin->settings()->keys())
@@ -241,7 +229,7 @@ void XdxfDialog::saveSettings() {
         _settings->setValue("strip_accents", "false");
 }
 
-void XdxfDialog::accept() {
+void StarDialog::accept() {
     if(type == New && _dictionaryFilePath.isEmpty()) {
         Q_EMIT notify(Notify::Warning, tr("File path is not set"));
 
@@ -252,16 +240,12 @@ void XdxfDialog::accept() {
     QDialog::accept();
 }
 
-Settings* XdxfDialog::getSettings() {
+Settings* StarDialog::getSettings() {
     return _settings;
 }
 
 #ifdef Q_WS_MAEMO_5
-    void XdxfDialog::showCacheInfo() {
-        Q_EMIT notify(Notify::Warning, cacheToolTip);
-    }
-
-    void XdxfDialog::showAccentsInfo() {
+    void StarDialog::showAccentsInfo() {
         Q_EMIT notify(Notify::Warning, accentsToolTip);
     }
 #endif
index ec50274..85a08cc 100644 (file)
     \author Mateusz Półrola <mateusz.polrola@gmail.com>
 */
 
-#ifndef XDXFDIALOG_H
-#define XDXFDIALOG_H
+#ifndef STARDIALOG_H
+#define STARDIALOG_H
 
 #include <QDialog>
 #include "../../include/settings.h"
 #include <QtGui>
-#include "xdxfplugin.h"
+#include "StarDictPlugin.h"
 
 
 //! Implementation of xdxf plugin's dialogs.
@@ -46,7 +46,7 @@
      displayed as a tool tip.
     All contents of a dialog are in a scroll area.
 */
-class XdxfDialog : public QDialog
+class StarDialog : public QDialog
 {
     Q_OBJECT
 public:
@@ -57,7 +57,7 @@ public:
       In both types dialog provides widgets to create or delete cache and remove
      or keep accents.
     */
-    enum XdxfDialogType {New, Change};
+    enum StarDialogType {New, Change};
 
     //! Constructor
     /*!
@@ -67,8 +67,8 @@ public:
         \param type describes type of created dialog
         \param parent parent widget of created dialog
     */
-    explicit XdxfDialog(XdxfPlugin* plugin = 0,
-                        XdxfDialogType type = New,
+    explicit StarDialog(StarDictPlugin* plugin = 0,
+                        StarDialogType type = New,
                         QWidget* parent = 0);
 
     //! \returns settings of plugin
@@ -91,12 +91,10 @@ public Q_SLOTS:
 private Q_SLOTS:
     //! displays dialog to browse and select file
     void selectFile();
-    void setGenerateCache(bool);
     void setAccents(bool);
 
     #ifdef Q_WS_MAEMO_5
         //! on maemo shows information about checkboxes
-        void showCacheInfo();
         void showAccentsInfo();
     #endif
 
@@ -142,8 +140,8 @@ private:
 
     Settings* _settings;
 
-    XdxfPlugin* plugin;
-    XdxfDialogType type;
+    StarDictPlugin* plugin;
+    StarDialogType type;
 };
 
-#endif // XDXFDIALOG_H
+#endif // STARDIALOG_H
index 62e1f3d..d6dd535 100644 (file)
 */
 //Created by Mateusz Półrola
 
-#include "XdxfDictDialog.h"
-#include "xdxfplugin.h"
-#include "XdxfDialog.h"
+#include "StarDictDialog.h"
+#include "StarDictPlugin.h"
+#include "StarDialog.h"
 #include <QDebug>
 
-XdxfDictDialog::XdxfDictDialog(XdxfPlugin *plugin, QObject *parent) :
+StarDictDialog::StarDictDialog(StarDictPlugin *plugin, QObject *parent) :
     DictDialog(parent) {
     this->plugin = plugin;
     _lastDialogParent=0;
 }
 
-QWidget* XdxfDictDialog::lastDialogParent() {
+QWidget* StarDictDialog::lastDialogParent() {
     return _lastDialogParent;
 }
 
-void XdxfDictDialog::setLastDialogParent(QWidget *w) {
+void StarDictDialog::setLastDialogParent(QWidget *w) {
     _lastDialogParent = w;
 }
 
-Settings* XdxfDictDialog::addNewDictionary(QWidget *parent) {
-    XdxfDialog d(0, XdxfDialog::New, parent);
+Settings* StarDictDialog::addNewDictionary(QWidget *parent) {
+    StarDialog d(0, StarDialog::New, parent);
 
     setLastDialogParent(parent);
 
@@ -56,8 +56,8 @@ Settings* XdxfDictDialog::addNewDictionary(QWidget *parent) {
     return 0;
 }
 
-void XdxfDictDialog::changeSettings(QWidget * parent) {
-    XdxfDialog d(plugin, XdxfDialog::Change, parent);
+void StarDictDialog::changeSettings(QWidget * parent) {
+    StarDialog d(plugin, StarDialog::Change, parent);
 
     setLastDialogParent(parent);
 
index 50b8ac3..f4a33e1 100644 (file)
 */
 //Created by Mateusz Półrola
 
-#ifndef XDXFDICTDIALOG_H
-#define XDXFDICTDIALOG_H
+#ifndef STARDICTDIALOG_H
+#define STARDICTDIALOG_H
 
 #include "../../include/DictDialog.h"
 
-class XdxfPlugin;
+class StarDictPlugin;
 
 
 //! Implementation of DictDialog interface for xdxf plugin
-class XdxfDictDialog : public DictDialog {
+class StarDictDialog : public DictDialog {
     Q_OBJECT
 public:
-    explicit XdxfDictDialog(XdxfPlugin* plugin, QObject *parent = 0);
+    explicit StarDictDialog(StarDictPlugin* plugin, QObject *parent = 0);
     /*!
       Shows "add new xdxf dictionary" dialog and returns settings of a new dict
       \param parent parent widget on which dialog will be displayed
@@ -52,8 +52,8 @@ public:
     void setLastDialogParent(QWidget*);
 
 private:
-    XdxfPlugin* plugin;
+    StarDictPlugin* plugin;
     QWidget* _lastDialogParent;
 };
 
-#endif // XDXFDICTDIALOG_H
+#endif // STARDICTDIALOG_H
index ee8ee03..88acba9 100644 (file)
 \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
 */
 
-#include "xdxfplugin.h"
+#include "StarDictPlugin.h"
 #include <QDebug>
 #include "../../include/Notify.h"
+#include <QTranslator>
+#include <QCoreApplication>
+#include <QThread>
 
-XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
+StarDictPlugin::StarDictPlugin(QObject *parent) : CommonDictInterface(parent),
                     _langFrom(""), _langTo(""),_name(""), _infoNote("") {
     _settings = new Settings();
-    _dictDialog = new XdxfDictDialog(this, this);
+    _dictDialog = new StarDictDialog(this, this);
 
     connect(_dictDialog, SIGNAL(notify(Notify::NotifyType,QString)),
             this, SIGNAL(notify(Notify::NotifyType,QString)));
@@ -44,7 +47,7 @@ XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
     initAccents();
 }
 
-void XdxfPlugin::retranslate() {
+void StarDictPlugin::retranslate() {
     QString locale = QLocale::system().name();
 
     QTranslator *translator = new QTranslator(this);
@@ -56,38 +59,38 @@ void XdxfPlugin::retranslate() {
 }
 
 
-XdxfPlugin::~XdxfPlugin() {
+StarDictPlugin::~StarDictPlugin() {
     delete _settings;
     delete _dictDialog;
 }
 
 
-QString XdxfPlugin::langFrom() const {   
+QString StarDictPlugin::langFrom() const {
     return _langFrom;
 }
 
 
-QString XdxfPlugin::langTo() const {
+QString StarDictPlugin::langTo() const {
     return  _langTo;
 }
 
 
-QString XdxfPlugin::name() const {
+QString StarDictPlugin::name() const {
     return  _name;
 }
 
 
-QString XdxfPlugin::type() const {
-    return QString("xdxf");
+QString StarDictPlugin::type() const {
+    return QString("stardict");
 }
 
 
-QString XdxfPlugin::infoNote() const {
+QString StarDictPlugin::infoNote() const {
     return _infoNote;
 }
 
 
-QList<Translation*> XdxfPlugin::searchWordList(QString word, int limit) {
+QList<Translation*> StarDictPlugin::searchWordList(QString word, int limit) {
     if( word.indexOf("*")==-1 && word.indexOf("?")==-1 &&
         word.indexOf("_")==-1 && word.indexOf("%")==-1)
         word+="*";
@@ -98,48 +101,8 @@ QList<Translation*> XdxfPlugin::searchWordList(QString word, int limit) {
 }
 
 
-QList<Translation*> XdxfPlugin::searchWordListCache(QString word, int limit) {
-    QSet<Translation*> translations;
-    QString cacheFilePath = _settings->value("cache_path");
-
-    db.setDatabaseName(cacheFilePath);
-    if(!QFile::exists(cacheFilePath) || !db.open()) {
-        qDebug() << "Database error" << db.lastError().text() << endl;
-        Q_EMIT notify(Notify::Warning, QString(tr("Cache database cannot be "
-                "opened for %1 dictionary. Searching in XDXF file. "
-                "You may want to recache.").arg(name())));
-        _settings->setValue("cached","false");
-        return searchWordListFile(word, limit);
-    }
-    stopped = false;
-    word = word.toLower();
-    word = word.replace("*", "%");
-    word = word.replace("?", "_");
-
-    QSqlQuery cur(db);
-    if(limit !=0)
-        cur.prepare("select word from dict where word like ? or normalized "
-                    "like ? limit ?");
-    else
-        cur.prepare("select word from dict where word like ? or normalized "
-                    "like ?");
-    cur.addBindValue(word);
-    cur.addBindValue(word);
-    if(limit !=0)
-        cur.addBindValue(limit);
-    cur.exec();
-
-    while(cur.next() && (translations.size()<limit || limit==0)) {
-       translations.insert(new TranslationXdxf(
-            cur.value(0).toString(),
-            _dictionaryInfo, this));
-    }
-    db.close();
-    return translations.toList();
-}
-
 
-QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
+QList<Translation*> StarDictPlugin::searchWordListFile(QString word, int limit) {
     QSet<Translation*> translations;
     QFile dictionaryFile(_settings->value("path"));
     word = word.toLower();
@@ -174,7 +137,7 @@ QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
                     || regWord.exactMatch(removeAccents(readKey)))
                     && (i<limit || limit==0) && !reader.atEnd())  {
  //               qDebug()<<readKey;
-                translations<<(new TranslationXdxf(readKey.toLower(),
+                translations<<(new TranslationStarDict(readKey.toLower(),
                                _dictionaryInfo,this));
                 if(translations.size()==limit && limit!=0)
                     break;
@@ -188,44 +151,13 @@ QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
 }
 
 
-QString XdxfPlugin::search(QString key) {
-    if(isCached())
-        return searchCache(key);
+QString StarDictPlugin::search(QString key) {
     return searchFile(key);
 }
 
 
-QString XdxfPlugin::searchCache(QString key) {
-    QString result("");
-    QString cacheFilePath = _settings->value("cache_path");
-    db.setDatabaseName(cacheFilePath);
-    key = key.toLower();
-
-    if(!QFile::exists(cacheFilePath) || !db.open()) {
-        qDebug() << "Database error" << db.lastError().text() << endl;
-        Q_EMIT notify(Notify::Warning, QString(tr("Cache database cannot be "
-                "opened for %1 dictionary. Searching in XDXF file. "
-                "You may want to recache.").arg(name())));
-        _settings->setValue("cached","false");
-        return searchFile(key);
-    }
-
-    QSqlQuery cur(db);
-
-    cur.prepare("select translation from dict where word like ?");
-    cur.addBindValue(key);
-    cur.exec();
-    while(cur.next())
-        result += cur.value(0).toString();
-
-    db.close();
-
-    return result;
-
-}
-
 
-QString XdxfPlugin::searchFile(QString key) {
+QString StarDictPlugin::searchFile(QString key) {
     QFile dictionaryFile(_settings->value("path"));
     QString resultString("");
     key = key.toLower();
@@ -287,24 +219,24 @@ QString XdxfPlugin::searchFile(QString key) {
 }
 
 
-void XdxfPlugin::stop() {
+void StarDictPlugin::stop() {
    //qDebug()<<"stop";
     stopped=true;
 }
 
 
-DictDialog* XdxfPlugin::dictDialog() {
+DictDialog* StarDictPlugin::dictDialog() {
      return _dictDialog;
 }
 
 
-CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
-    XdxfPlugin *plugin = new XdxfPlugin();
+CommonDictInterface* StarDictPlugin::getNew(const Settings *settings) const {
+    StarDictPlugin *plugin = new StarDictPlugin();
 
     connect(plugin, SIGNAL(notify(Notify::NotifyType,QString)),
             this, SIGNAL(notify(Notify::NotifyType,QString)));
 
-    ((XdxfDictDialog*)plugin->dictDialog())->setLastDialogParent(_dictDialog->lastDialogParent());
+    ((StarDictDialog*)plugin->dictDialog())->setLastDialogParent(_dictDialog->lastDialogParent());
 
 
 
@@ -323,24 +255,24 @@ CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
 }
 
 
-bool XdxfPlugin::isAvailable() const {
+bool StarDictPlugin::isAvailable() const {
     return true;
 }
 
 
-Settings* XdxfPlugin::settings() {
+Settings* StarDictPlugin::settings() {
     return _settings;
 }
 
 
-bool XdxfPlugin::isCached() {
+bool StarDictPlugin::isCached() {
     if(_settings->value("cached") == "true")
         return true;
     return false;
 }
 
 
-bool XdxfPlugin::setSettings(const Settings *settings) {
+bool StarDictPlugin::setSettings(const Settings *settings) {
     if(settings) {
         bool isPathChange=false;
         QString oldPath = _settings->value("path");
@@ -373,19 +305,12 @@ bool XdxfPlugin::setSettings(const Settings *settings) {
             _wordsCount=0;
             if(oldPath!="")
                 _settings->setValue("cached","false");
-            if(_settings->value("cached")=="true"
-                    && _settings->value("cache_path")!="") {
-                db_name = _settings->value("type")
-                        + _settings->value("cache_path");
-                db = QSqlDatabase::addDatabase("QSQLITE",db_name);
-            }
         }
 
         if((_settings->value("cached") == "false" ||
             _settings->value("cached").isEmpty()) &&
             settings->value("generateCache") == "true") {
             clean();
-            makeCache("");
         }
 
         else if (settings->value("generateCache") == "false") {
@@ -399,7 +324,7 @@ bool XdxfPlugin::setSettings(const Settings *settings) {
 }
 
 
-bool XdxfPlugin::getDictionaryInfo() {
+bool StarDictPlugin::getDictionaryInfo() {
     QFile dictionaryFile(_settings->value("path"));
     if(!QFile::exists(_settings->value("path"))
                 || !dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
@@ -440,12 +365,12 @@ bool XdxfPlugin::getDictionaryInfo() {
 }
 
 
-QIcon* XdxfPlugin::icon() {
+QIcon* StarDictPlugin::icon() {
     return &_icon;
 }
 
 
-int XdxfPlugin::countWords() {
+int StarDictPlugin::countWords() {
     if(_wordsCount>0)
         return _wordsCount;
     QFile dictionaryFile(_settings->value("path"));
@@ -475,159 +400,10 @@ int XdxfPlugin::countWords() {
 }
 
 
-bool XdxfPlugin::makeCache(QString) {
-
-    XdxfCachingDialog d(_dictDialog->lastDialogParent());
-
-//    qDebug()<<_dictDialog->lastDialogParent();
 
-    connect(&d, SIGNAL(cancelCaching()),
-            this, SLOT(stop()));
-    connect(this, SIGNAL(updateCachingProgress(int,int)),
-            &d, SLOT(updateCachingProgress(int,int)));
-
-    d.show();
-
-    QCoreApplication::processEvents();
-    QFileInfo dictFileN(_settings->value("path"));
-    QString cachePathN;
-    stopped = false;
-
-    /*create cache file name*/
-    int i=0;
-    do {
-        cachePathN = QDir::homePath() + "/.mdictionary/"
-                                      + dictFileN.completeBaseName()+"."
-                                      +QString::number(i) + ".cache";
-        i++;
-    } while(QFile::exists(cachePathN));
-
-    db_name = _settings->value("type") + cachePathN;
-    db = QSqlDatabase::addDatabase("QSQLITE",db_name);
-
-    /*checke errors (File open and db open)*/
-    QFile dictionaryFile(dictFileN.filePath());
-    if (!QFile::exists(_settings->value("path"))
-                || !dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
-        Q_EMIT updateCachingProgress(100, 0);
-        Q_EMIT notify(Notify::Warning,
-                QString(tr("XDXF file cannot be read for %1 dictionary")
-                .arg(name())));
-        return 0;
-    }
-    QXmlStreamReader reader(&dictionaryFile);
-    db.setDatabaseName(cachePathN);
-    if(!db.open()) {
-        qDebug() << "Database error" << db.lastError().text() << endl;
-        Q_EMIT updateCachingProgress(100, 0);
-        Q_EMIT notify(Notify::Warning, QString(tr("Cache database cannot be "
-                "opened for %1 dictionary. Searching in XDXF file. "
-                "You may want to recache.").arg(name())));
-        return false;
-    }
+void StarDictPlugin::clean() {
 
-    /*inicial sqlQuery*/
-    QCoreApplication::processEvents();
-    QSqlQuery cur(db);
-    cur.exec("PRAGMA synchronous = 0");
-    cur.exec("drop table dict");
-    QCoreApplication::processEvents();
-    cur.exec("create table dict(word text, normalized text ,translation text)");
-    int counter = 0;
-    cur.exec("BEGIN;");
-
-    QString readKey;
-    bool match = false;
-    QTime timer;
-    timer.start();
-    countWords();
-    int lastProg = -1;
-    _settings->setValue("strip_accents", "true");
-    counter=0;
-
-    /*add all words to db*/
-    while (!reader.atEnd() && !stopped) {
-
-        QCoreApplication::processEvents();
-        reader.readNext();
-        if(reader.tokenType() == QXmlStreamReader::StartElement) {
-            if(reader.name()=="k"){
-                readKey = reader.readElementText();
-                match = true;
-            }
-        }
-        if(match) {
-            QString temp("");
-            while(reader.name()!="ar" && !reader.atEnd()) {
-                if(reader.name()!="" && reader.name()!="k") {
-                    if(reader.tokenType()==QXmlStreamReader::EndElement)
-                        temp+="</";
-                    if(reader.tokenType()==QXmlStreamReader::StartElement)
-                        temp+="<";
-                    temp+=reader.name().toString();
-                    if(reader.name().toString()=="c"
-                        && reader.tokenType()==QXmlStreamReader::StartElement) {
-                        temp= temp + " c=\""
-                                   + reader.attributes().value("c").toString()
-                                   + "\"";
-                    }
-                    temp+=">";
-                }
-                temp+= reader.text().toString().replace("<","&lt;").replace(">"
-                              ,"&gt;");
-                reader.readNext();
-            }
-            if(temp.at(0)==QChar('\n'))
-                temp.remove(0,1);
-            temp="<key>" + readKey + "</key>" + "<t>" + temp+ "</t>";
-            match=false;
-            cur.prepare("insert into dict values(?,?,?)");
-            cur.addBindValue(readKey.toLower());
-            cur.addBindValue(removeAccents(readKey).toLower());
-            cur.addBindValue(temp);
-            cur.exec();
-            counter++;
-            int prog = counter*100/_wordsCount;
-            if(prog % 2 == 0 && lastProg != prog) {
-                Q_EMIT updateCachingProgress(prog,timer.restart());
-                lastProg = prog;
-            }
-        }
-    }
-    cur.exec("END;");
-    cur.exec("select count(*) from dict");
-
-    /*checke errors (wrong number of added words)*/
-    countWords();
-    if(!cur.next() || countWords() != cur.value(0).toInt()) {
-        Q_EMIT updateCachingProgress(100, timer.restart());
-        Q_EMIT notify(Notify::Warning,
-                QString(tr("Database caching error, please try again.")));
-        db.close();
-        _settings->setValue("cache_path", cachePathN);
-        if(stopped)
-            clean();
-        _settings->setValue("cache_path","");
-        return false;
-    }
-
-    _settings->setValue("cache_path", cachePathN);
-    _settings->setValue("cached", "true");
-
-    disconnect(&d, SIGNAL(cancelCaching()),
-            this, SLOT(stop()));
-    disconnect(this, SIGNAL(updateCachingProgress(int,int)),
-            &d, SLOT(updateCachingProgress(int,int)));
-    db.close();
-    return true;
-}
-
-void XdxfPlugin::clean() {
-    if(QFile::exists(_settings->value("cache_path"))) {
-        QFile(_settings->value("cache_path")).remove();
-        QSqlDatabase::removeDatabase(db_name);
-    }
 }
 
 
-Q_EXPORT_PLUGIN2(xdxf, XdxfPlugin)
+Q_EXPORT_PLUGIN2(stardict, StarDictPlugin)
index 334a506..f371153 100644 (file)
@@ -22,8 +22,8 @@
 
 /*! \file xdxfplugin.h
 */
-#ifndef XDXFPLUGIN_H
-#define XDXFPLUGIN_H
+#ifndef STARDICTPLUGIN_H
+#define STARDICTPLUGIN_H
 
 
 #include <QObject>
 #include <QXmlStreamReader>
 #include <QtPlugin>
 #include <QHash>
+#include <QIcon>
 
 #include "../../include/CommonDictInterface.h"
 #include "../../include/settings.h"
-#include "XdxfDictDialog.h"
-#include "XdxfCachingDialog.h"
-#include "TranslationXdxf.h"
+#include "StarDictDialog.h"
+#include "TranslationStarDict.h"
 
 class TranslationXdxf;
 
-class XdxfPlugin : public CommonDictInterface
+class StarDictPlugin : public CommonDictInterface
 {
     Q_OBJECT
     Q_INTERFACES(CommonDictInterface)
 public:
-    XdxfPlugin(QObject *parent=0);
+    StarDictPlugin(QObject *parent=0);
 
-    ~XdxfPlugin();
+    ~StarDictPlugin();
 
     //! \returns source language code iso 639-2
     QString langFrom() const;
@@ -119,11 +119,6 @@ public Q_SLOTS:
     //! loads translations for each plugin only once
     void retranslate();
 
-Q_SIGNALS:
-    //! emitted with percent count of caching progress, and time elapsed from
-    //! last signal emit
-    void updateCachingProgress(int, int);
-
 
 private:
 
@@ -151,19 +146,12 @@ private:
         in a xdxf file */
     QString searchFile(QString key);
 
-    /*! searches for a translation of a word which is exactly like a key
-        in a database file */
-    QString searchCache(QString key);
-
     //! scans dictionary file to get information about it
     bool getDictionaryInfo();
 
     //! counts the keys in a xdxf file
     int countWords();
 
-    /*! transforms xdxf files to database files (caching operation)
-        \returns true on success, false on failure */
-    bool makeCache(QString dir);
 
     //! language from which we translate
     QString _langFrom;
@@ -178,15 +166,13 @@ private:
 
     //! icon displayed during translations and when a dictionary is chosen
     QIcon _icon;
-    QSqlDatabase db;
-    QString db_name;
+
     //! number of words in a dictionary
     long _wordsCount;
     //! indicates if search is stopped
     volatile bool stopped;
     Settings *_settings;
-    XdxfDictDialog* _dictDialog;
-    XdxfCachingDialog* cachingDialog;
+    StarDictDialog* _dictDialog;
 };
 
 #endif // XDXFPLUGIN_H
index fe228b5..942b21e 100644 (file)
 */
 
 
-#include "TranslationXdxf.h"
+#include "TranslationStarDict.h"
 #include <QDebug>
 
-TranslationXdxf::TranslationXdxf():_key(""),_dictionaryInfo("") {
-    xdxfPlugin=0;
+TranslationStarDict::TranslationStarDict():_key(""),_dictionaryInfo("") {
+    starDictPlugin=0;
 }
 
-TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo,
-         XdxfPlugin *xdxfPlugin): _key(_key),_dictionaryInfo(_dictionaryInfo) {
-    this->xdxfPlugin=xdxfPlugin;
-    if(xdxfPlugin)
-        _dictHash = xdxfPlugin->hash();
+TranslationStarDict::TranslationStarDict(QString _key, QString _dictionaryInfo,
+         StarDictPlugin *starDictPlugin): _key(_key),_dictionaryInfo(_dictionaryInfo) {
+    this->starDictPlugin=starDictPlugin;
+    if(starDictPlugin)
+        _dictHash = starDictPlugin->hash();
     _bookmark=0;
 }
 
 
-QString TranslationXdxf::key() const {
+QString TranslationStarDict::key() const {
     return _key;
 }
 
-QString TranslationXdxf::toXml() const { 
+QString TranslationStarDict::toXml() const {
     QString result("");
-    if(!xdxfPlugin)
+    if(!starDictPlugin)
         return result;
 
     result=result + "<dict> <info path=\"/usr/share/mdictionary/xdxf.png\" ";
@@ -53,15 +53,15 @@ QString TranslationXdxf::toXml() const {
         result+= " bookmark=\"true\" > \n";
     else
         result+= " bookmark=\"false\" > \n";
-    result+= _dictionaryInfo + "</info>" + xdxfPlugin->search(_key) + "</dict>";
+    result+= _dictionaryInfo + "</info>" + starDictPlugin->search(_key) + "</dict>";
     return result.replace("&","&amp;");
 }
 
-void TranslationXdxf::setKey(QString _key) {
+void TranslationStarDict::setKey(QString _key) {
     this->_key=_key;
 }
 
-void TranslationXdxf::setDictionaryInfo(QString _dictionaryInfo) {
+void TranslationStarDict::setDictionaryInfo(QString _dictionaryInfo) {
     this->_dictionaryInfo=_dictionaryInfo;
 }
 
index e438bbc..6a18cf8 100644 (file)
 *******************************************************************************/
 /*! \file TranslationXdxf.h
 */
-#ifndef TRANSLATIONXDXF_H
-#define TRANSLATIONXDXF_H
+#ifndef TRANSLATIONSTARDICT_H
+#define TRANSLATIONSTARDICT_H
 
 #include <QString>
 #include "../../include/translation.h"
-#include "xdxfplugin.h"
+#include "StarDictPlugin.h"
 
-class TranslationXdxf : public Translation
+class TranslationStarDict : public Translation
 {
 public:
-    TranslationXdxf();
-    TranslationXdxf(QString _key,
+    TranslationStarDict();
+    TranslationStarDict(QString _key,
                     QString _dictionaryInfo,
-                    XdxfPlugin *xdxfPlugin);
+                    StarDictPlugin *starDictPlugin);
 
     //! \return word to be translated
     QString key() const;
@@ -59,9 +59,9 @@ public:
 private:
     QString _key;
     QString _dictionaryInfo;
-    XdxfPlugin *xdxfPlugin;
+    StarDictPlugin *starDictPlugin;
     int _dictHash;
 };
 
-#endif // TRANSLATIONXDXF_H
+#endif // TRANSLATIONSTARDICT_H