nueng-muen</ar>
<ar><k>100</k>
nueng-roy</ar>
-<ar><k>Aluminum</k>
-Aluminium to kolejne tlumaczenie z innego slownika</ar>
<ar><k>100,000</k>
nueng-saen</ar>
<ar><k>101</k>
<ar><k>Airplane</k>
Aeroplane</ar>
<ar><k>Aluminum</k>
-Aluminium <tr>wymowa</tr> <ex>przyklad</ex> <c c="#FF00FF"> <b> test koloru i pogrobienia </b> </c> </ar>
+Aluminium</ar>
<ar><k>Apartment</k>
Flatlane</ar>
<ar><k>Appetizer</k>
<ar><k>airplane</k>
Aeroplane</ar>
<ar><k>aluminum</k>
-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</ar>
+Aluminium</ar>
<ar><k>amrtment</k>
Medium Wave</ar>
<ar><k>anesthesia</k>
trans += t + "\n";
}
+ qDebug()<<trans;
trans=tr("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") + tr("\n <ar>") + trans + tr("\n </ar>");
-// trans.replace("&","&");
trans=XslConversion(trans);
- qDebug()<<trans;
-// trans.replace("&","&");
textEdit->insertHtml(trans);
// textEdit->setPlainText(trans);
<html>
<body>
<table border="1" WIDTH="100%">
- <tr bgcolor="#99CCFF">
- <th><xsl:value-of select="ar/dict[1]/key"/></th>
- </tr>
<xsl:for-each select="ar/dict">
- <!-- <xsl:variable name="path" select="info/@path"/>-->
- <tr bgcolor="#99FF99">
- <th><xsl:value-of select="info"/> <!-- <img src="{$path}"/> --></th>
- </tr>
- <xsl:for-each select="t">
- <tr>
- <td><xsl:apply-templates/></td>
- </tr>
- </xsl:for-each>
+ <xsl:apply-templates/>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
+<xsl:template match="info">
+ <!-- <xsl:variable name="path" select="info/@path"/>-->
+ <tr bgcolor="#99FF99">
+ <th><xsl:value-of select="."/> <!-- <img src="{$path}"/> --></th>
+ </tr>
+</xsl:template>
+
+<xsl:template match="key">
+ <tr bgcolor="#99CCFF">
+ <th><xsl:value-of select="."/></th>
+ </tr>
+</xsl:template>
+
+<xsl:template match="t">
+ <tr>
+ <td><xsl:apply-templates/></td>
+ </tr>
+</xsl:template>
+
<xsl:template match="tr">
[<i><xsl:apply-templates/></i>]
</xsl:template>
public:
CommonDictInterface(QObject *parent = 0):QObject(parent) {}
+ virtual ~CommonDictInterface() {}
+
//! returns source language code iso 639-2
virtual QString langFrom() const = 0;
QString TranslationXdxf::toHtml() const {
QString result("");
-// qDebug()<<xdxfPlugin->search(_key);
- result+="<dict>" + _dictionaryInfo + "<key>" + _key + "</key>" +xdxfPlugin->search(_key) + "</dict>";
+ result+="<dict>" + _dictionaryInfo + xdxfPlugin->search(_key) + "</dict>";
result.replace("&","&");
-
-// qDebug()<<result;
return result;
}
_icon = QIcon(":/icons/xdxf.png");
}
+XdxfPlugin::~XdxfPlugin()
+{
+ db.removeDatabase(_type+path);
+}
+
QString XdxfPlugin::langFrom() const {
return _langFrom;
}
}
QSqlQuery cur(db);
-// cur.prepare("select translation from dict where word like ? limit 1");
cur.prepare("select translation from dict where word like ?");
cur.addBindValue(key);
cur.exec();
-// if(cur.next())
while(cur.next())
-// result = cur.value(0).toString();
result += cur.value(0).toString();
db.close();
return result;
}
if(temp.at(0)==QChar('\n'))
temp.remove(0,1);
- resultString+=tr("<t>") + temp + tr("</t>"); //.replace("\n","")
+ resultString+=tr("<key>") + a +tr("</key>");
+ resultString+=tr("<t>") + temp + tr("</t>");
match=false;
}
this->thread()->yieldCurrentThread();
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() &&
plugin->makeCache("");
}
}
-
plugin->getDictionaryInfo();
return plugin;
}
QString format = "png";
QString initialPath = QDir::currentPath() + tr("/xdxf.") + format;
-// qDebug()<<initialPath;
-// qDebug()<<QPixmap(":/icons/xdxf.png").save(initialPath,format.toAscii());
+// qDebug()<<initialPath;
+// QPixmap test(":/icons/xdxf.png");
+// qDebug()<<QPixmap(test).save(initialPath,format.toAscii());
+// qDebug()<<QPixmap("/home/jakub/star.jpg").save(initialPath,format.toAscii());
- _infoNote="<info path=\""+initialPath+"\">"+"\n" + _name + "(" + _type + ")" + "</info>";
+ _infoNote="<info path=\""+initialPath+"\">"+"\n" + _name + " [" + _langFrom + "-" + _langTo + "] "+ "(" + _type + ")" + "</info>";
}
if(temp.at(0)==QChar('\n'))
temp.remove(0,1);
- temp=tr("<t>") + temp+ tr("</t>"); //.replace("\n","")
+ temp=tr("<key>") + a + tr("</key>") + tr("<t>") + temp+ tr("</t>");
match=false;
cur.prepare("insert into dict values(?,?)");
cur.addBindValue(a);
public:
XdxfPlugin(QObject *parent=0);
+ virtual ~XdxfPlugin();
+
//! returns source language code iso 639-2
QString langFrom() const;
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();
settings->setValue("path","../tests/dict.xdxf");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
- QCOMPARE(xdxfPlugin->search("."), QString("<t>kropka</t>"));
- QCOMPARE(xdxfPlugin->search("1"), QString("<t>one</t>"));
- QCOMPARE(xdxfPlugin->search("test"), QString("<t><c c=\"FF00FF\">kro</c>test01<pos>krowa</pos></t>"));
+ QCOMPARE(xdxfPlugin->search("."), QString("<key>.</key><t>kropka</t>"));
+ QCOMPARE(xdxfPlugin->search("1"), QString("<key>1</key><t>one</t>"));
+ QCOMPARE(xdxfPlugin->search("test"), QString("<key>test</key><t><c c=\"FF00FF\">kro</c>test01<pos>krowa</pos></t>"));
}
void XdxfTest::makeCache()
settings->setValue("generateCache", "true");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
QCOMPARE(xdxfPlugin->settings()->value("cached"),tr("true"));
+ delete xdxfPlugin;
}
void XdxfTest::searchCache() {
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
QCOMPARE(xdxfPlugin->settings()->value("cached"),tr("true"));
- QCOMPARE(xdxfPlugin->search("."), QString("<t>kropka</t>"));
- QCOMPARE(xdxfPlugin->search("1"), QString("<t>one</t>"));
- QCOMPARE(xdxfPlugin->search("test"), QString("<t><c c=\"FF00FF\">kro</c>test01<pos>krowa</pos></t>"));
+ QCOMPARE(xdxfPlugin->search("."), QString("<key>.</key><t>kropka</t>"));
+ QCOMPARE(xdxfPlugin->search("1"), QString("<key>1</key><t>one</t>"));
+ QCOMPARE(xdxfPlugin->search("test"), QString("<key>test</key><t><c c=\"FF00FF\">kro</c>test01<pos>krowa</pos></t>"));
+
+ delete xdxfPlugin;
}
void XdxfTest::searchWordListCache(){
QList<Translation*> te11 = xdxfPlugin->searchWordList("h**?*?**e");
QCOMPARE(te11.at(0)->key(), QString("house"));
+
+ delete xdxfPlugin;
}
void XdxfTest::searchWordListFile() {
QList<Translation*> te11 = xdxfPlugin->searchWordList("h**?*?**e");
QCOMPARE(te11.at(0)->key(), QString("house"));
+ delete xdxfPlugin;
}
void XdxfTest::stop() {
QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin, &CommonDictInterface::searchWordList, string, 10);
QList<Translation*> te5 = future.result();
QCOMPARE(te5.size(), 9);
+
+ delete xdxfPlugin;
}
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
QCOMPARE(xdxfPlugin->langFrom(), QString("ENG"));
+
+ delete xdxfPlugin;
}
QTEST_MAIN(XdxfTest)