From d360b725ed07f75fd80c78cb2de9148ddaee5e80 Mon Sep 17 00:00:00 2001 From: Jakub Jaszczynski Date: Fri, 20 Aug 2010 10:30:20 +0200 Subject: [PATCH] changed the format of translation display --- data/dicts/eng-thai.xdxf | 2 -- data/dicts/eng-us.xdxf | 4 +-- trunk/src/base/gui/TranslationWidget.cpp | 4 +-- trunk/src/base/xsl.xsl | 32 +++++++++++++++--------- trunk/src/includes/CommonDictInterface.h | 2 ++ trunk/src/plugins/xdxf/src/TranslationXdxf.cpp | 5 +--- trunk/src/plugins/xdxf/src/xdxfplugin.cpp | 28 ++++++++++++--------- trunk/src/plugins/xdxf/src/xdxfplugin.h | 4 ++- trunk/src/plugins/xdxf/tests/test.cpp | 22 +++++++++++----- 9 files changed, 61 insertions(+), 42 deletions(-) diff --git a/data/dicts/eng-thai.xdxf b/data/dicts/eng-thai.xdxf index 353129f..d519da3 100644 --- a/data/dicts/eng-thai.xdxf +++ b/data/dicts/eng-thai.xdxf @@ -19,8 +19,6 @@ sib nueng-muen 100 nueng-roy -Aluminum -Aluminium to kolejne tlumaczenie z innego slownika 100,000 nueng-saen 101 diff --git a/data/dicts/eng-us.xdxf b/data/dicts/eng-us.xdxf index 5b1a879..220c3e3 100644 --- a/data/dicts/eng-us.xdxf +++ b/data/dicts/eng-us.xdxf @@ -10,7 +10,7 @@ Medium Wave Airplane Aeroplane Aluminum -Aluminium wymowa przyklad test koloru i pogrobienia +Aluminium Apartment Flatlane Appetizer @@ -302,7 +302,7 @@ Tartlane airplane Aeroplane aluminum -Aluminium to ala ma kota a kot ma ale Aluminium to ala ma kota a kot ma alAluminium to ala ma kota a kot ma alAluminium to ala ma kota a kot ma al +Aluminium amrtment Medium Wave anesthesia diff --git a/trunk/src/base/gui/TranslationWidget.cpp b/trunk/src/base/gui/TranslationWidget.cpp index f1a4d8b..3b76c75 100644 --- a/trunk/src/base/gui/TranslationWidget.cpp +++ b/trunk/src/base/gui/TranslationWidget.cpp @@ -69,12 +69,10 @@ void TranslationWidget::show(QStringList translations) { trans += t + "\n"; } + qDebug()<") + tr("\n ") + trans + tr("\n "); -// trans.replace("&","&"); trans=XslConversion(trans); - qDebug()<insertHtml(trans); // textEdit->setPlainText(trans); diff --git a/trunk/src/base/xsl.xsl b/trunk/src/base/xsl.xsl index ce50c46..3972b6b 100644 --- a/trunk/src/base/xsl.xsl +++ b/trunk/src/base/xsl.xsl @@ -5,25 +5,33 @@ - - - - - - - - - - - - +
+ + + + + + + + + + + + + + + + + + + [] diff --git a/trunk/src/includes/CommonDictInterface.h b/trunk/src/includes/CommonDictInterface.h index d52a21f..6c2b46f 100644 --- a/trunk/src/includes/CommonDictInterface.h +++ b/trunk/src/includes/CommonDictInterface.h @@ -45,6 +45,8 @@ class CommonDictInterface : public QObject { public: CommonDictInterface(QObject *parent = 0):QObject(parent) {} + virtual ~CommonDictInterface() {} + //! returns source language code iso 639-2 virtual QString langFrom() const = 0; diff --git a/trunk/src/plugins/xdxf/src/TranslationXdxf.cpp b/trunk/src/plugins/xdxf/src/TranslationXdxf.cpp index 190e255..ec28e52 100644 --- a/trunk/src/plugins/xdxf/src/TranslationXdxf.cpp +++ b/trunk/src/plugins/xdxf/src/TranslationXdxf.cpp @@ -39,11 +39,8 @@ QString TranslationXdxf::dictionaryInfo() const { QString TranslationXdxf::toHtml() const { QString result(""); -// qDebug()<search(_key); - result+="" + _dictionaryInfo + "" + _key + "" +xdxfPlugin->search(_key) + ""; + result+="" + _dictionaryInfo + xdxfPlugin->search(_key) + ""; result.replace("&","&"); - -// qDebug()<") + temp + tr(""); //.replace("\n","") + resultString+=tr("") + a +tr(""); + resultString+=tr("") + temp + tr(""); match=false; } this->thread()->yieldCurrentThread(); @@ -269,17 +272,17 @@ void XdxfPlugin::setPath(QString path){ CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const { XdxfPlugin *plugin = new XdxfPlugin(); + static int a=0; if(settings){ plugin->setPath(settings->value("path")); - QStringList list = settings->keys(); foreach(QString key, list) plugin->settings()->setValue(key, settings->value(key)); - + a=a+1; plugin->db_name = plugin->_settings->value("type") + plugin->_settings->value("path"); - // if(!plugin->db.connectionName().isEmpty() || settings->value("generateCache")=="true") +// if(!plugin->db.connectionName().isEmpty() || settings->value("generateCache")=="true") plugin->db = QSqlDatabase::addDatabase("QSQLITE", plugin->db_name); if(settings->value("cached").isEmpty() && @@ -287,7 +290,6 @@ CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const { plugin->makeCache(""); } } - plugin->getDictionaryInfo(); return plugin; } @@ -357,10 +359,12 @@ void XdxfPlugin::getDictionaryInfo() { QString format = "png"; QString initialPath = QDir::currentPath() + tr("/xdxf.") + format; -// qDebug()<"+"\n" + _name + "(" + _type + ")" + ""; + _infoNote=""+"\n" + _name + " [" + _langFrom + "-" + _langTo + "] "+ "(" + _type + ")" + ""; @@ -486,7 +490,7 @@ bool XdxfPlugin::makeCache(QString dir) { } if(temp.at(0)==QChar('\n')) temp.remove(0,1); - temp=tr("") + temp+ tr(""); //.replace("\n","") + temp=tr("") + a + tr("") + tr("") + temp+ tr(""); match=false; cur.prepare("insert into dict values(?,?)"); cur.addBindValue(a); diff --git a/trunk/src/plugins/xdxf/src/xdxfplugin.h b/trunk/src/plugins/xdxf/src/xdxfplugin.h index 38cd88a..f964251 100644 --- a/trunk/src/plugins/xdxf/src/xdxfplugin.h +++ b/trunk/src/plugins/xdxf/src/xdxfplugin.h @@ -42,6 +42,8 @@ class XdxfPlugin : public CommonDictInterface public: XdxfPlugin(QObject *parent=0); + virtual ~XdxfPlugin(); + //! returns source language code iso 639-2 QString langFrom() const; @@ -58,7 +60,7 @@ public: QString infoNote() const; /*! returns DictDialog object that creates dialogs - for adding new dictionary and change plugin settings + for adding new dictionary and change plugin tings */ DictDialog* dictDialog(); diff --git a/trunk/src/plugins/xdxf/tests/test.cpp b/trunk/src/plugins/xdxf/tests/test.cpp index 4e43c2e..8500794 100644 --- a/trunk/src/plugins/xdxf/tests/test.cpp +++ b/trunk/src/plugins/xdxf/tests/test.cpp @@ -40,9 +40,9 @@ void XdxfTest::searchFile() { settings->setValue("path","../tests/dict.xdxf"); CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings); - QCOMPARE(xdxfPlugin->search("."), QString("kropka")); - QCOMPARE(xdxfPlugin->search("1"), QString("one")); - QCOMPARE(xdxfPlugin->search("test"), QString("krotest01krowa")); + QCOMPARE(xdxfPlugin->search("."), QString(".kropka")); + QCOMPARE(xdxfPlugin->search("1"), QString("1one")); + QCOMPARE(xdxfPlugin->search("test"), QString("testkrotest01krowa")); } void XdxfTest::makeCache() @@ -53,6 +53,7 @@ void XdxfTest::makeCache() settings->setValue("generateCache", "true"); CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings); QCOMPARE(xdxfPlugin->settings()->value("cached"),tr("true")); + delete xdxfPlugin; } void XdxfTest::searchCache() { @@ -63,9 +64,11 @@ void XdxfTest::searchCache() { CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings); QCOMPARE(xdxfPlugin->settings()->value("cached"),tr("true")); - QCOMPARE(xdxfPlugin->search("."), QString("kropka")); - QCOMPARE(xdxfPlugin->search("1"), QString("one")); - QCOMPARE(xdxfPlugin->search("test"), QString("krotest01krowa")); + QCOMPARE(xdxfPlugin->search("."), QString(".kropka")); + QCOMPARE(xdxfPlugin->search("1"), QString("1one")); + QCOMPARE(xdxfPlugin->search("test"), QString("testkrotest01krowa")); + + delete xdxfPlugin; } void XdxfTest::searchWordListCache(){ @@ -107,6 +110,8 @@ void XdxfTest::searchWordListCache(){ QList te11 = xdxfPlugin->searchWordList("h**?*?**e"); QCOMPARE(te11.at(0)->key(), QString("house")); + + delete xdxfPlugin; } void XdxfTest::searchWordListFile() { @@ -149,6 +154,7 @@ void XdxfTest::searchWordListFile() { QList te11 = xdxfPlugin->searchWordList("h**?*?**e"); QCOMPARE(te11.at(0)->key(), QString("house")); + delete xdxfPlugin; } void XdxfTest::stop() { @@ -163,6 +169,8 @@ void XdxfTest::stop() { QFuture > future = QtConcurrent::run(xdxfPlugin, &CommonDictInterface::searchWordList, string, 10); QList te5 = future.result(); QCOMPARE(te5.size(), 9); + + delete xdxfPlugin; } @@ -174,6 +182,8 @@ void XdxfTest::langFrom() { CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings); QCOMPARE(xdxfPlugin->langFrom(), QString("ENG")); + + delete xdxfPlugin; } QTEST_MAIN(XdxfTest) -- 1.7.9.5