QList<Translation*> XdxfPlugin::searchWordList(QString word, int limit) {
QRegExp regWord(word);
- QList<Translation*> translations;
+ 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";
a = dictionaryReader.readElementText();
if(regWord.exactMatch(a) && i<limit) {
translations.append(new TranslationXdxf(a,_infoNote,this));
- qDebug()<<a;
i++;
if(i>=limit)
break;
QString XdxfPlugin::search(QString key) {
QFile dictionaryFile(path);
if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
- return ""; //blad otwarcia pliku
+ qDebug()<<"Error: could not open file";
+ return "";
}
QXmlStreamReader dictionaryReader(&dictionaryFile);
match = true;
}
}
- else if(dictionaryReader.tokenType() == QXmlStreamReader::Characters)
+ else if(dictionaryReader.tokenType() == QXmlStreamReader::Characters) {
if(match) {
- dictionaryFile.close();
- qDebug()<<dictionaryReader.text().toString().replace("\n","");
- return dictionaryReader.text().toString().replace("\n","");
+ QString temp(dictionaryReader.text().toString().replace("\n",""));
+ dictionaryFile.close();
+ return temp;
}
+ }
}
return "";
}
}
QDialog* XdxfPlugin::settingsDialog() {
- ;
+ path="dict.xdxf";
}
CommonDictInterface* XdxfPlugin::getNew(const Settings*) const {
+ // CommonDictInterface *commonDictInterface= new
;
}
return true;
}
+void XdxfPlugin::setHash(uint _hash)
+{
+ this->_hash=_hash;
+}
+
uint XdxfPlugin::hash() const
{
- return 1;
+ return _hash;
}
#include <QDialog>
#include <QRegExp>
#include "TranslationXdxf.h"
+#include <QTime>
class XdxfPlugin : public CommonDictInterface
{
//! 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
QDialog *_loadDialog;
QDialog *_settingsDialog;
QString path;
+ uint _hash;
bool stopped; /*volatile*/
};
xdxfPlugin.loadDialog();
xdxfPlugin.searchWordList("Cain",10);
xdxfPlugin.search("Cain");
- QCOMPARE(xdxfPlugin.search("cain"), QString("lina"));
- QCOMPARE(xdxfPlugin.search("sin"), QString("grzech"));
- //QCOMPARE(xdxfPlugin.search("boss"), QString(""));
+ QCOMPARE(xdxfPlugin.search("Apacz"), QString("Apachee"));
+ // QCOMPARE(xdxfPlugin.search("sin"), QString("grzech"));
+ // QCOMPARE(xdxfPlugin.search("boss"), QString(""));
}
void Testowanie::langFrom()
{
XdxfPlugin xdxfPlugin(this);
xdxfPlugin.loadDialog();
- // xdxfPlugin.searchWordList("rope",10);
- //QCOMPARE(xdxfPlugin.langFrom(), QString("ENG"));
+ xdxfPlugin.searchWordList("rope",10);
+ QCOMPARE(xdxfPlugin.langFrom(), QString("ENG"));
+}
+
+void Testowanie::hash()
+{
+ XdxfPlugin xdxfPlugin(this);
+ xdxfPlugin.loadDialog();
+ xdxfPlugin.hash();
}
void Testowanie::sig()
XdxfPlugin xdxfPlugin(this);
xdxfPlugin.loadDialog();
- QSignalSpy spy(&xdxfPlugin, SIGNAL(finalTranslation(QList<Translation*>)));
+ QSignalSpy spy(&xdxfPlugin, SIGNAL(finalTranslation()));
- xdxfPlugin.searchWordList("rope",10);
+ xdxfPlugin.searchWordList("Apacz",10);
QCOMPARE(spy.count(), 1); // make sure the signal was emitted exactly one time
}
QTEST_MAIN(Testowanie)
//#include "testqstring.moc"
+
+/*duze i małe litery*/
#include "../../../includes/translation.h"
#include <QList>
+#include <QTime>
class Testowanie: public QObject
{
void search();
void langFrom();
void sig();
+ void hash();
};