void Backbone::removeDictionary(CommonDictInterface *dict) {
_dicts.remove(dict);
- dict->clean();
+ if(dict)
+ dict->clean();
+ else
+ qDebug()<<"delete empty dict";
delete dict;
dictUpdated();
set.endGroup();
addInternalDictionary(plug->getNew(plugSet), active);
+ delete plugSet;
}
}
if(settings != NULL) {
CommonDictInterface* newDict = selectedPlugin->getNew(settings);
+ delete settings;
Q_EMIT addDictionary(newDict);
}
}
QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) {
QList<QListWidgetItem*> selected = dictListWidget->selectedItems();
if(selected.count() > 0) {
- refreshDictsList();
emit removeDictionary(dictsHash[selected[0]]);
+ refreshDictsList();
}
}
}
#include <QString>
#include <QMetaType>
+#include <QDebug>
+
class CommonDictInterface;
as late as possible*/
class Translation {
public:
- Translation () { _bookmark = 0; }
+ Translation () { _bookmark = 0;}
virtual ~Translation () {}
//! \return word to be translated
virtual QString key() const = 0;
Settings* GooglePlugin::settings() {
- Settings *returnSettings=new Settings;
+/* Settings *returnSettings=new Settings;
QStringList list = _settings->keys();
foreach(QString key, list)
returnSettings->setValue(key,_settings->value(key));
return returnSettings;
+*/
+ return _settings;
}
CommonDictInterface* GooglePlugin::getNew(const Settings* settings) const {
GooglePlugin *plugin = new GooglePlugin();
- plugin->setSettings(settings);
+ if(settings)
+ plugin->setSettings(settings);
return plugin;
}
QWidget *parent) {
Settings *settings = new Settings();
settings=getSettings(parent,plugin->settings(),tr("Save changes"));
- if(settings)
- plugin->setSettings(settings);
+ plugin->setSettings(settings);
+ delete settings;
}
TranslationXdxf::TranslationXdxf():_key(""),_dictionaryInfo("") {
xdxfPlugin=0;
+ qDebug()<<"\n\n create translaton Xdxf\n\n";
}
TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo,
if(xdxfPlugin)
_dictHash = xdxfPlugin->hash();
_bookmark=0;
+
+ qDebug()<<"create translaton Xdxf";
}
TranslationXdxf::~TranslationXdxf() {
- // qDebug()<<"\n\n delete translation:: Xdxf\n\n";
+ qDebug()<<"delete translation:: Xdxf";
}
QString TranslationXdxf::key() const {
cacheLayout = new QHBoxLayout;
verticalLayout->addLayout(cacheLayout);
- accentsCheckBox = new QCheckBox(tr("Strip accents \n(searching takes more time, "
- "but spelling don't have to be exact)"));
+ accentsCheckBox = new QCheckBox(tr("Strip accents \n(searching takes more "
+ "time, but spelling don't have to be exact)"));
verticalLayout->addWidget(accentsCheckBox);
cacheCheckBox = new QCheckBox(tr("Optimize for quicker searches (may take some time)"),this);
QDialog(parent)
{
this->plugin = plugin;
- verticalLayout = new QVBoxLayout(this);
+ verticalLayout = new QVBoxLayout();
setLayout(verticalLayout);
setWindowTitle(tr("XDXF Settings"));
verticalLayout->addWidget(infoLabel);
- browseLayout = new QHBoxLayout(this);
+ browseLayout = new QHBoxLayout();
verticalLayout->addLayout(browseLayout);
- browseButton = new QPushButton(tr("Browse"),this);
+ browseButton = new QPushButton(tr("Browse"));
browseLabel = new QLabel(tr("Dictionary file: ") +
- plugin->settings()->value("path"),this);
+ plugin->settings()->value("path"));
browseLayout->addWidget(browseLabel);
browseLayout->addWidget(browseButton,0, Qt::AlignRight);
- cacheLayout = new QHBoxLayout(this);
+ cacheLayout = new QHBoxLayout();
verticalLayout->insertLayout(-1,cacheLayout,0);
accentsCheckBox = new QCheckBox(tr("Strip accents \n(searching takes more time, "
"but spelling don't have to be exact)"));
cacheLayout->addWidget(cacheCheckBox);
- saveButton = new QPushButton(tr("Save settings"),this);
+ saveButton = new QPushButton(tr("Save settings"));
verticalLayout->addWidget(saveButton);
settings->setValue("strip_accents", "false");
plugin->setSettings(settings);
+ delete settings;
return 0;
}
Settings* XdxfPlugin::settings() {
+/*
+ Settings *returnSettings=new Settings;
+ QStringList list = _settings->keys();
+ foreach(QString key, list)
+ returnSettings->setValue(key,_settings->value(key));
+ return returnSettings;
+*/
return _settings;
}
timer.start();
countWords();
int lastProg = -1;
- settings()->setValue("strip_accents", "true");
+ _settings->setValue("strip_accents", "true");
counter=0;
/*add all words to db*/
Settings *settings=new Settings;
settings->setValue("path","../tests/dict.xdxf");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
QList<Translation*> te6=xdxfPlugin->searchWordList("*",8);
QCOMPARE(te6.size(),8);
Settings *settings=new Settings;
settings->setValue("path","../tests/dict.xdxf");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
QCOMPARE(xdxfPlugin->search("."), QString("<key>.</key><t>kropka</t>"));
QCOMPARE(xdxfPlugin->search("1"), QString("<key>1</key><t>one</t>"));
settings->setValue("path","../tests/dict.xdxf");
settings->setValue("generateCache", "true");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
+
QCOMPARE(xdxfPlugin->settings()->value("cached"),tr("true"));
xdxfPlugin->clean();
settings->setValue("path","../tests/dict.xdxf");
settings->setValue("generateCache", "true");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
QCOMPARE(xdxfPlugin->settings()->value("cached"),tr("true"));
QCOMPARE(xdxfPlugin->search("."), QString("<key>.</key><t>kropka</t>"));
settings->setValue("path","../tests/dict.xdxf");
settings->setValue("generateCache", "true");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
QList<Translation*> te = xdxfPlugin->searchWordList(".", 10);
if(te.size()>0)
Settings *settings=new Settings;
settings->setValue("path","../tests/dict.xdxf");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
QList<Translation*> te = xdxfPlugin->searchWordList(".", 10);
if(te.size()>0)
Settings *settings=new Settings;
settings->setValue("path","../tests/dict.xdxf");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
QString string("*");
QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin,
void XdxfTest::langFrom() {
-
XdxfPlugin xdxfPluginB(this);
Settings *settings=new Settings;
settings->setValue("path","../tests/dict.xdxf");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
QCOMPARE(xdxfPlugin->langFrom(), QString("ENG"));
settings->setValue("path","../../../../../../dict.xdxf");
settings->setValue("generateCache", "true");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
out<<"\n<date>" + date.currentDate().toString("dd.MM.yyyy") +" ";
out<<timer.currentTime().toString(Qt::TextDate) + "</date>";
Settings *settings=new Settings;
settings->setValue("path","../../../../../../dict.xdxf");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
timer.start();
xdxfPlugin->search("Bantu");
settings->setValue("generateCache", "true");
settings->setValue("strip_accents", "true");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
out<<"\n<type> Cache with strip accent </type> <time>" << timer.elapsed();
out<<"</time>";
XdxfPluginSub xdxf;
xdxf.settings()->setValue(QString("strip_accents"), QString("true"));
+
QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("nóżka")), QString("nozka"));
QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("motor")), QString("motor"));
QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("nÓżKa")), QString("nozka"));
settings->setValue("path","../../../../../../dict.xdxf");
settings->setValue("strip_accents", "true");
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+ delete settings;
timer.start();
xdxfPlugin->search("Bantu");
File.close();
xdxfPlugin->clean();
delete xdxfPlugin;
-
}
QTEST_MAIN(XdxfTest)