summaryrefslogtreecommitdiffstats
path: root/kbabel/kbabeldict/modules/dbsearchengine2
diff options
context:
space:
mode:
Diffstat (limited to 'kbabel/kbabeldict/modules/dbsearchengine2')
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/AUTHOR1
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/KDBSearchEngine2.cpp686
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/KDBSearchEngine2.h202
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/Makefile.am34
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/README21
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/algorithms.cpp425
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/algorithms.h157
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/chunk.cpp203
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/chunk.h151
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/database.cpp752
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/database.h237
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/dbentries.cpp171
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/dbentries.h170
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/dbscan.cpp280
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/dbscan.h120
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/dbse2.ui732
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/dbse2_factory.cpp83
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/dbse2_factory.h26
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/dbsearchengine2.desktop52
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/dbseprefwidget.ui1039
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/preferenceswidget.cpp98
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/preferenceswidget.h26
-rw-r--r--kbabel/kbabeldict/modules/dbsearchengine2/sourcedialog.ui266
23 files changed, 5932 insertions, 0 deletions
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/AUTHOR b/kbabel/kbabeldict/modules/dbsearchengine2/AUTHOR
new file mode 100644
index 00000000..2a79312d
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/AUTHOR
@@ -0,0 +1 @@
+Andrea Rizzi <rizzi@kde.org> \ No newline at end of file
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/KDBSearchEngine2.cpp b/kbabel/kbabeldict/modules/dbsearchengine2/KDBSearchEngine2.cpp
new file mode 100644
index 00000000..5bf088b8
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/KDBSearchEngine2.cpp
@@ -0,0 +1,686 @@
+/***************************************************************************
+ KDBSearchEngine2.cpp - description
+ -------------------
+ begin : Fri Sep 8 2000
+ copyright : (C) 2000-2003 by Andrea Rizzi
+ email : rizzi@kde.org
+***************************************************************************/
+
+/*
+ Translation search engine. Version II
+
+
+ Copyright 2000-2003
+ Andrea Rizzi rizzi@kde.org
+
+ License GPL v 2.0
+
+ * *
+ * In addition, as a special exception, the copyright holders give *
+ * permission to link the code of this program with any edition of *
+ * the Qt library by Trolltech AS, Norway (or with modified versions *
+ * of Qt that use the same license as Qt), and distribute linked *
+ * combinations including the two. You must obey the GNU General *
+ * Public License in all respects for all of the code used other than *
+ * Qt. If you modify this file, you may extend this exception to *
+ * your version of the file, but you are not obligated to do so. If *
+ * you do not wish to do so, delete this exception statement from *
+ * your version. *
+
+*/
+#include "algorithms.h"
+#include "chunk.h"
+#include "database.h"
+#include "KDBSearchEngine2.h"
+#include "dbscan.h"
+#include <klineedit.h>
+#include <kapplication.h>
+#include <qpushbutton.h>
+#include <kurlrequester.h>
+#include <qcheckbox.h>
+#include <knuminput.h>
+#include <kstandarddirs.h>
+#include <kmessagebox.h>
+
+#include <qmap.h>
+
+#include <kdebug.h>
+#define i18n (const char *)
+
+KDBSearchEngine2::KDBSearchEngine2(QObject *parent,const char*name)
+ : SearchEngine(parent,name)
+ {
+ pw=0;
+ dbDirectory=".";
+
+ di=0; //Database Interface is not yet initialized
+
+ connect(this,SIGNAL(hasError(QString)),SLOT(setLastError(QString)));
+
+ searching=false; // i'm not searching
+ iAmReady=true; //there are no reason to say I'm not ready.
+
+}
+
+
+KDBSearchEngine2::~KDBSearchEngine2()
+{
+ if(di)
+ delete di; //delete database interface
+}
+
+bool KDBSearchEngine2::startSearch(QString str)
+{
+ kdDebug(0) << "Start a new search. Looking for: " << str << endl;
+
+ static QString queryString;
+
+ queryString=str; //set the latest query string (note: it is static)
+
+ if(autoupdate)
+ {
+ updateSettings();
+ }
+
+
+ if(!init()) return false; //-check initialization
+ di->stop(true); //stop all new emits from database interface
+ emit started(); //say everybody we are starting
+
+ if(searching) return true; //We already have a search loop, as soon as we come back
+ //on the search loop we will start the new search (queryString).
+
+ searching=true; //really start searching
+
+ QString searchingString;
+
+ do //Search loop, it stops only when finished and latest searched string is the actual query string.
+ {
+ searchingString=queryString; //-set new search string
+ di->stop(false); //-unlock searching
+
+ if(numberOfResult<1) numberOfResult=1;
+
+// di->singleWordMatch(searchingString,0,true);
+
+ GenericSearchAlgorithm strategy(di,&settings);
+
+ //Let's create a search sequence:
+ ExactSearchAlgorithm exact(di,&settings);
+ AlphaSearchAlgorithm alpha(di,&settings);
+ SentenceArchiveSearchAlgorithm sent(di,&settings);
+ ChunkByChunkSearchAlgorithm sbys(di,&settings);
+ ChunkByChunkSearchAlgorithm wbyw(di,&settings);
+ CorrelationSearchAlgorithm corr(di,&settings);
+ FuzzyChunkSearchAlgorithm fs(di,&settings);
+ FuzzyChunkSearchAlgorithm fw(di,&settings);
+
+ SentenceChunkFactory sf(di);
+ sbys.setChunkFactory(&sf);
+ fs.setChunkFactory(&sf);
+
+
+ WordChunkFactory wf(di);
+ wbyw.setChunkFactory(&wf);
+ fw.setChunkFactory(&wf);
+
+ strategy.addAlgorithm(&exact);
+ strategy.addAlgorithm(&alpha);
+ strategy.addAlgorithm(&sent);
+ strategy.addAlgorithm(&sbys);
+ //strategy.addAlgorithm(&fs);
+ strategy.addAlgorithm(&fw);
+ strategy.addAlgorithm(&corr);
+ strategy.addAlgorithm(&wbyw);
+
+
+ connect(&strategy,SIGNAL(newResult(QueryResult)),this,SLOT(receiveResult(QueryResult)));
+ strategy.exec(searchingString); disconnect(&strategy,SIGNAL(newResult(QueryResult)),this,SLOT(receiveResult(QueryResult)));
+
+
+ kdDebug(0) << "End of search for " << searchingString << endl;
+ }
+ while(searchingString!=queryString);
+ kdDebug(0) << "Exiting the search loop" << endl;
+ //if != someone asked a different string when we was searching
+ //so we restart our search (maybe a cleanresult is needed?).
+
+
+ di->stop(false); //-clean searching locks
+ searching=false; //-clean searching locks
+ emit finished(); //Finished
+
+ return true;
+
+}
+
+
+
+
+
+bool KDBSearchEngine2::startSearchInTranslation(QString str)
+{
+ if(autoupdate)
+ {
+ updateSettings();
+ }
+
+ //TODO!!!!
+ return true;
+
+}
+
+
+
+bool KDBSearchEngine2::messagesForPackage(const QString& package
+ , QValueList<Message>& resultList, QString& error)
+{
+ //FIXME implement this (needs filters)
+ return true;
+}
+
+
+void KDBSearchEngine2::setLastError(QString er)
+{
+ lasterror=er;
+}
+
+QString KDBSearchEngine2::translate(const QString text)
+{
+ ExactSearchAlgorithm exact(di,&settings);
+
+ return exact.exec(text)[0].result();
+
+}
+
+
+void KDBSearchEngine2::receiveResult(QueryResult r)
+{
+
+ SearchResult se; // Create a new SearchResult for our QueryResult
+
+ se.translation=r.richResult();
+ se.found=r.richOriginal();
+
+ se.plainTranslation=r.result();
+ se.plainFound=r.original();
+ se.score=r.score();
+
+ emit resultFound(&se); // dispatch the new SearchResult
+
+}
+
+
+/* A SEARCH RESULT CONTAINS (see searchengine.h)
+ QString requested;
+ QString found;
+ QString translation;
+ QString plainTranslation;
+ QString plainFound;
+ QString plainRequested;
+ int score;
+ QPtrList<TranslationInfo> descriptions;
+*/
+
+
+
+bool KDBSearchEngine2::init()
+{
+ if(di!=0) return true; //if there already is a DBinterface we are ok
+ else
+ {
+ di = new DataBaseInterface(dbDirectory,&settings);
+ connect(di,SIGNAL(newResult(QueryResult)),this,SLOT(receiveResult(QueryResult)));
+ //FIXME: what wbout ready()
+ if(!di->mainOk()) return false; //check if the main DB is OK.
+
+ return true;
+ }
+
+}
+const KAboutData *KDBSearchEngine2::about() const
+{
+ return DbSe2Factory::instance()->aboutData();
+}
+
+void KDBSearchEngine2::stringChanged( QString orig, QString translated
+ , QString description)
+{
+
+ if(!init()) return;
+ //if(translated.isEmpty()) return;
+ InputInfo ii;
+ if(description.find("fuzzy",false)==-1)
+ di->addEntry(orig,translated,&ii);
+
+}
+
+PrefWidget * KDBSearchEngine2::preferencesWidget(QWidget *parent)
+{
+
+ pw = new KDB2PreferencesWidget(parent);
+ kdDebug(0) << "new KDB2 preferences widget" << endl;
+ setSettings();
+ connect(pw,SIGNAL(restoreNow()),this,SLOT(setSettings()));
+ connect(pw,SIGNAL(applyNow()),this,SLOT(updateSettings()));
+ connect(pw,SIGNAL(destroyed()),this,SLOT(prefDestr()));
+
+
+ connect(pw->dbpw->scanAll,SIGNAL(clicked()),this,SLOT(scanAllPressed()));
+ connect(pw->dbpw->scanSource,SIGNAL(clicked()),this,SLOT(scanNowPressed()));
+ connect(pw->dbpw->addSource,SIGNAL(clicked()),this,SLOT(addSource()));
+ connect(pw->dbpw->editSource,SIGNAL(clicked()),this,SLOT(editSource()));
+ connect(pw->dbpw->removeSource,SIGNAL(clicked()),this,SLOT(removeSource()));
+
+
+ return pw;
+}
+
+void KDBSearchEngine2::saveSettings(KConfigBase *config)
+{
+ KConfigGroupSaver cgs(config,"KDBSearchEngine2");
+
+
+
+ config->writeEntry("DBDirectory",dbDirectory);
+ config->writeEntry("AutoAdd",autoAdd);
+ config->writeEntry("UseSentence",useSentence);
+ config->writeEntry("UseGlossary",useGlossary);
+ config->writeEntry("UseExact",useExact);
+ config->writeEntry("UseDivide",useDivide);
+ config->writeEntry("UseAlpha",useAlpha);
+ config->writeEntry("UseWordByWord",useWordByWord);
+ config->writeEntry("UseDynamic",useDynamic);
+ config->writeEntry("NumberOfResults",numberOfResult);
+
+ config->writeEntry("ScoreDivide",settings.scoreDivide);
+ config->writeEntry("ScoreExact",settings.scoreExact);
+ config->writeEntry("ScoreSentence",settings.scoreSentence);
+ config->writeEntry("ScoreWordByWord",settings.scoreWordByWord);
+ config->writeEntry("ScoreGlossary",settings.scoreGlossary);
+ config->writeEntry("ScoreAlpha",settings.scoreAlpha);
+ config->writeEntry("ScoreDynamic",settings.scoreDynamic);
+ config->writeEntry("MinimumScore",settings.minScore);
+ config->writeEntry("FirstCapital",settings.firstCapital);
+ config->writeEntry("AllCapital",settings.allCapital);
+ config->writeEntry("Accelerator",settings.accelerator);
+ config->writeEntry("SameLetter",settings.sameLetter);
+
+ uint sourceNumber=0;
+ config->writeEntry("NumberOfDBImportSources",sources.count());
+
+ for(QMap<QString,MessagesSource>::iterator sourceIt=sources.begin() ; sourceIt!=sources.end(); ++sourceIt)
+ {
+ sourceNumber++;
+ config->setGroup("DBImportSource-"+QString::number(sourceNumber));
+ config->writeEntry("Name",sourceIt.key());
+ sourceIt.data().writeConfig(config);
+ }
+}
+
+void KDBSearchEngine2::readSettings(KConfigBase *config)
+{
+
+ /*QString defaultDir;
+ KStandardDirs * dirs = KGlobal::dirs();
+ if(dirs)
+ {
+ defaultDir = dirs->saveLocation("data");
+ if(defaultDir.right(1)!="/")
+ defaultDir+="/";
+ defaultDir += "kbabeldict/dbsearchengine2";
+ }
+*/
+ KConfigGroupSaver cgs(config,"KDBSearchEngine2");
+
+ // dbDirectory=config->readEntry("DBDirectory",defaultDir);
+ autoAdd=config->readBoolEntry("AutoAdd",true);
+ useSentence=config->readBoolEntry("UseSentence",true);
+ useGlossary=config->readBoolEntry("UseGlossary",true);
+ useExact=config->readBoolEntry("UseExact",true);
+ useDivide=config->readBoolEntry("UseDivide",true);
+ useAlpha=config->readBoolEntry("UseAlpha",true);
+ useWordByWord=config->readBoolEntry("UseWordByWord",true);
+ useDynamic=config->readBoolEntry("UseDynamic",true);
+ numberOfResult=config->readNumEntry("NumberOfResults",5);
+
+ settings.scoreDivide=config->readNumEntry("ScoreDivide",90);
+ settings.scoreExact=config->readNumEntry("ScoreExact",100);
+ settings.scoreSentence=config->readNumEntry("ScoreSentence",90);
+ settings.scoreWordByWord=config->readNumEntry("ScoreWordByWord",70);
+ settings.scoreGlossary=config->readNumEntry("ScoreGlossary",98);
+ settings.scoreAlpha=config->readNumEntry("ScoreAlpha",98);
+ settings.scoreDynamic=config->readNumEntry("ScoreDynamic",80);
+ settings.minScore=config->readNumEntry("MinimumScore",60);
+ settings.firstCapital=config->readBoolEntry("FirstCapital",true);
+ settings.allCapital=config->readBoolEntry("AllCapital",false);
+ settings.accelerator=config->readBoolEntry("Accelerator",true);
+ settings.sameLetter=config->readBoolEntry("SameLetter",true);
+
+ uint numberOfSources=config->readNumEntry("NumberOfDBImportSources",0);
+ kdDebug(0) << "Found "<< numberOfSources << " sources" << endl;
+ for(uint sourceNumber=1;sourceNumber<=numberOfSources;sourceNumber++)
+ {
+ config->setGroup("DBImportSource-"+QString::number(sourceNumber));
+ QString name=config->readEntry("Name");
+ sources[name].readConfig(config);
+ }
+ if(pw)
+ setSettings();
+
+}
+
+void KDBSearchEngine2::setSettings()
+{
+ if(pw) {
+ pw->dbpw->dbDirectory->setURL(dbDirectory);
+ pw->dbpw->autoUpdate->setChecked(autoAdd);
+
+ pw->dbpw->useSentence->setChecked(useSentence);
+ pw->dbpw->useGlossary->setChecked(useGlossary);
+ pw->dbpw->useExact->setChecked(useExact);
+ pw->dbpw->useDivide->setChecked(useDivide);
+ pw->dbpw->useAlpha->setChecked(useAlpha);
+ pw->dbpw->useWordByWord->setChecked(useWordByWord);
+ pw->dbpw->useDynamic->setChecked(useDynamic);
+ pw->dbpw->numberOfResult->setValue(numberOfResult);
+ pw->dbpw->scoreDivide->setValue(settings.scoreDivide);
+ pw->dbpw->scoreExact->setValue(settings.scoreExact);
+ pw->dbpw->scoreSentence->setValue(settings.scoreSentence);
+ pw->dbpw->scoreWordByWord->setValue(settings.scoreWordByWord);
+ pw->dbpw->scoreGlossary->setValue(settings.scoreGlossary);
+ pw->dbpw->scoreAlpha->setValue(settings.scoreAlpha);
+ pw->dbpw->scoreDynamic->setValue(settings.scoreDynamic);
+ pw->dbpw->minScore->setValue(settings.minScore);
+ pw->dbpw->firstCapital->setChecked(settings.firstCapital);
+ pw->dbpw->allCapital->setChecked(settings.allCapital);
+ pw->dbpw->accelerator->setChecked(settings.accelerator);
+ pw->dbpw->sameLetter->setChecked(settings.sameLetter);
+
+ //pw->dbpw->checkLang->setChecked(true);
+ //pw->dbpw->useFilters->setChecked(false);
+ //pw->dbpw->dateToday->setChecked(false);
+ pw->dbpw->sourceList->clear();
+ for(QMap<QString,MessagesSource>::iterator sourceIt=sources.begin() ; sourceIt!=sources.end(); ++sourceIt)
+ {
+ pw->dbpw->sourceList->insertItem(sourceIt.key());
+ }
+ }
+
+}
+
+void KDBSearchEngine2::updateSettings()
+{
+ if(!pw) return;
+
+ QString newdb = pw->dbpw->dbDirectory->url();
+ if(newdb !=dbDirectory)
+ {
+ kdDebug(0) << "Recreate DB-Interface cause dbdir is changed" << endl;
+ dbDirectory=newdb;
+ if (di!=0) delete di;
+ di= new DataBaseInterface(dbDirectory,&settings);
+ }
+
+ autoAdd=pw->dbpw->autoUpdate->isChecked();
+
+ useSentence=pw->dbpw->useSentence->isChecked();
+ useGlossary=pw->dbpw->useGlossary->isChecked();
+ useExact=pw->dbpw->useExact->isChecked();
+ useDivide=pw->dbpw->useDivide->isChecked();
+ useAlpha=pw->dbpw->useAlpha->isChecked();
+ useWordByWord=pw->dbpw->useWordByWord->isChecked();
+ useDynamic=pw->dbpw->useDynamic->isChecked();
+
+ numberOfResult=pw->dbpw->numberOfResult->value();
+
+ settings.scoreWordByWord=pw->dbpw->scoreWordByWord->value();
+ settings.scoreGlossary=pw->dbpw->scoreGlossary->value();
+ settings.scoreDivide=pw->dbpw->scoreDivide->value();
+ settings.scoreExact=pw->dbpw->scoreExact->value();
+ settings.scoreSentence=pw->dbpw->scoreSentence->value();
+ settings.scoreAlpha=pw->dbpw->scoreAlpha->value();
+ settings.scoreDynamic=pw->dbpw->scoreDynamic->value();
+
+ settings.minScore=pw->dbpw->minScore->value();
+
+ settings.firstCapital=pw->dbpw->firstCapital->isChecked();
+ settings.allCapital=pw->dbpw->allCapital->isChecked();
+ settings.accelerator=pw->dbpw->accelerator->isChecked();
+ settings.sameLetter=pw->dbpw->sameLetter->isChecked();
+
+ //pw->dbpw->editRule->
+ //pw->dbpw->deleteRule->
+ //pw->dbpw->customRules->
+
+ /*
+pw->dbpw->checkLang->
+pw->dbpw->useFilters->
+pw->dbpw->dateToday->
+
+pw->dbpw->removeSource->
+pw->dbpw->scanSource->
+pw->dbpw->addSource->
+pw->dbpw->sourceDir->
+pw->dbpw->scanAll->
+pw->dbpw->sourceList->
+*/
+
+}
+
+
+/*void KDBSearchEngine2::scanSource(QString sourceName)
+{
+ //FIXME: an error here would be nice
+ if(!init()) return;
+
+
+ for(QValueList<MessagesSource>::iterator sourceIt=sources.begin() ; sourceIt!=sources.end(); sourceIt++)
+ {
+ if((*sourceIt).getName()==sourceName)
+ {
+ QValueList<KURL> urls=(*sourceIt).urls();
+ PoScanner ps(di);
+ for(QValueList<KURL>::iterator urlIt=urls.begin();urlIt!=urls.end();urlIt++)
+ ps.scanFile(*urlIt);
+
+ //We suppose name are unique so no need for further scrolling
+ return ;
+ }
+ }
+}*/
+void KDBSearchEngine2::scanNowPressed()
+{
+ if(!pw)
+ {
+ kdDebug(0) << "We should not be here, scanNow called without a pw!" << endl;
+ return;
+ }
+ QString sourceName;
+ sourceName=pw->dbpw->sourceList->currentText();
+ if(!init()) return;
+ if(sources.contains(sourceName))
+ {
+ QValueList<KURL> urls=sources[sourceName].urls();
+ PoScanner ps(di);
+ for(QValueList<KURL>::iterator urlIt=urls.begin();urlIt!=urls.end();++urlIt)
+ ps.scanURL(*urlIt);
+
+ }
+ else
+ {
+ kdDebug(0) << "source name not found in our MAP. This is a bug." << endl;
+ }
+}
+
+void KDBSearchEngine2::scanAllPressed()
+{
+ //FIXME: an error here would be nice too
+ if(!init()) return;
+ PoScanner ps(di);
+
+
+ for(QMap<QString,MessagesSource>::iterator sourceIt=sources.begin() ; sourceIt!=sources.end(); ++sourceIt)
+ {
+ QValueList<KURL> urls=(*sourceIt).urls();
+ for(QValueList<KURL>::iterator urlIt=urls.begin();urlIt!=urls.end();++urlIt)
+ ps.scanURL(*urlIt);
+ }
+}
+
+void KDBSearchEngine2::editSource()
+{
+ if(!pw)
+ {
+ kdDebug(0) << "We should not be here, editSource called without a pw!" << endl;
+ return;
+ }
+ QString sourceName;
+ sourceName=pw->dbpw->sourceList->currentText();
+
+ if(sources.contains(sourceName))
+ {
+ bool nameIsNew;
+ QString newName;
+ SourceDialog sd;
+ do{
+ sources[sourceName].setDialogValues(&sd);
+ sd.sourceName->setText(sourceName);
+ if(sd.exec()==QDialog::Accepted)
+ {
+ sources[sourceName].getDialogValues(&sd);
+ newName= sd.sourceName->text();
+ } else
+ {
+ return;
+ }
+ nameIsNew=sources.contains(newName);
+ if(newName!=sourceName && !nameIsNew)
+ {
+
+ KMessageBox::error(0,
+ i18n("The name you chose is already used.\nPlease change the source name."),
+ i18n("Name is Not Unique"));
+ kdDebug(0) << "Name is not uniqe" << endl;
+ }
+ }while(newName!=sourceName && !nameIsNew);
+
+ if(newName!=sourceName){
+ sources[newName]=sources[sourceName];
+ sources.remove(sourceName);
+ }
+ pw->dbpw->sourceList->changeItem(newName,pw->dbpw->sourceList->currentItem());
+
+ }
+ else
+ {
+ kdDebug(0) << "source name not found in our MAP. This is a bug." << endl;
+ }
+
+}
+void KDBSearchEngine2::removeSource()
+{
+
+ if(!pw)
+ {
+ kdDebug(0) << "We should not be here, delteSource called without a pw!" << endl;
+ return;
+ }
+ QString sourceName;
+ sourceName=pw->dbpw->sourceList->currentText();
+ sources.remove(sourceName);
+ pw->dbpw->sourceList->removeItem(pw->dbpw->sourceList->currentItem());
+
+}
+
+void KDBSearchEngine2::addSource()
+{
+ QString newName;
+ SourceDialog sd;
+ bool nameIsNew;
+ do{
+ if(sd.exec()==QDialog::Accepted)
+ {
+ newName= sd.sourceName->text();
+ nameIsNew=!sources.contains(newName);
+ }
+ else
+ {
+ return;
+ }
+ // nameIsNew=sources.contains(newName);
+ if(!nameIsNew)
+ {
+ KMessageBox::error(0,i18n("The name you chose is already used.\nPlease change the source name."),
+ i18n("Name is Not Unique"));
+ kdDebug(0) << "Name is not uniqe" << endl;
+ }
+ else
+ {
+ sources[newName].getDialogValues(&sd);
+ }
+ }while(!nameIsNew);
+
+ pw->dbpw->sourceList->insertItem(newName);
+
+
+}
+QString KDBSearchEngine2::searchTranslation( const QString text, int & score )
+{
+ GenericSearchAlgorithm strategy(di,&settings);
+ strategy.setMaxResultNumber(1);
+
+ ExactSearchAlgorithm exact(di,&settings);
+ AlphaSearchAlgorithm alpha(di,&settings);
+ SentenceArchiveSearchAlgorithm sent(di,&settings);
+
+ strategy.addAlgorithm(&exact);
+ strategy.addAlgorithm(&alpha);
+ strategy.addAlgorithm(&sent);
+
+ QueryResult firstRes=strategy.exec(text)[0];
+ score=firstRes.score();
+ return firstRes.result();
+
+}
+
+QString KDBSearchEngine2::fuzzyTranslation( const QString text, int & score )
+{
+ GenericSearchAlgorithm strategy(di,&settings);
+ strategy.setMaxResultNumber(1);
+ ExactSearchAlgorithm exact(di,&settings);
+ AlphaSearchAlgorithm alpha(di,&settings);
+ SentenceArchiveSearchAlgorithm sent(di,&settings);
+ ChunkByChunkSearchAlgorithm sbys(di,&settings);
+ ChunkByChunkSearchAlgorithm wbyw(di,&settings);
+ FuzzyChunkSearchAlgorithm fs(di,&settings);
+ FuzzyChunkSearchAlgorithm fw(di,&settings);
+
+ SentenceChunkFactory sf(di);
+ sbys.setChunkFactory(&sf);
+ fs.setChunkFactory(&sf);
+
+
+ WordChunkFactory wf(di);
+ wbyw.setChunkFactory(&wf);
+ fw.setChunkFactory(&wf);
+
+ strategy.addAlgorithm(&exact);
+ strategy.addAlgorithm(&alpha);
+ strategy.addAlgorithm(&sent);
+ strategy.addAlgorithm(&sbys);
+ //strategy.addAlgorithm(&fs);
+ strategy.addAlgorithm(&fw);
+ strategy.addAlgorithm(&wbyw);
+
+
+ QueryResult firstRes=strategy.exec(text)[0];
+ score=firstRes.score();
+ return firstRes.result();
+
+
+}
+
+//FIXME: ProgressBasr, progressbar,progressbasr
+#include "KDBSearchEngine2.moc"
+
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/KDBSearchEngine2.h b/kbabel/kbabeldict/modules/dbsearchengine2/KDBSearchEngine2.h
new file mode 100644
index 00000000..0db19c6c
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/KDBSearchEngine2.h
@@ -0,0 +1,202 @@
+/* ****************************************************************************
+
+DBSE2
+Andrea Rizzi
+
+**************************************************************************** */
+
+#ifndef DBSEARCH_ENGINE2_H
+#define DBSEARCH_ENGINE2_H
+
+#include <searchengine.h>
+#include <qdialog.h>
+
+#include "database.h"
+#include "dbse2_factory.h"
+#include "preferenceswidget.h"
+#include "dbscan.h"
+#include "sourcedialog.h"
+
+//#include "DBSESettings.h"
+
+class KDBSearchEngine2 : public SearchEngine
+{
+ Q_OBJECT
+
+ public:
+
+ KDBSearchEngine2(QObject *parent=0, const char *name=0);
+ virtual ~KDBSearchEngine2();
+
+ //init if needed.
+ bool init();
+
+ /** @return true, if a search is currently active */
+ bool isSearching() const {return searching;}
+
+ void stopSearch() { if(di) di->stop();}
+
+
+
+ /** @returns true, if it was initialized correctly */
+ bool isReady() const {return iAmReady; }
+
+
+ void saveSettings(KConfigBase *config);
+ void readSettings(KConfigBase *config);
+
+
+ QString translate(const QString text);
+
+ QString fuzzyTranslation(const QString text, int &score);
+ QString searchTranslation(const QString, int &score );
+
+ /**
+ * Finds all messages belonging to package package. If nothing is found,
+ * the list is empty.
+ * @param package The name of the file, something like "kbabel.po"
+ * @param resultList Will contain the found messages afterwards
+ * @param error If an error occured, this should contain a description
+ *
+ * @return true, if successfull
+ */
+ bool messagesForPackage(const QString& package
+ , QValueList<Message>& resultList, QString& error);
+
+ /**
+ * @returns true, if the searchresults are given as rich text
+ * the default implementation returns false
+ */
+ bool usesRichTextResults(){return true;}
+
+ /** @returns true, if the the entries in the database can be edited */
+ bool isEditable(){return false;}
+
+ /**
+ * @returns a widget which lets the user setup all preferences of this
+ * search engine. The returned widget should not be bigger than
+ * 400x400. If you need more space, you maybe want to use
+ * a tabbed widget.
+ * @param parent the parent of the returned widget
+ */
+ virtual PrefWidget* preferencesWidget(QWidget *parent);
+
+ /** @returns information about this SearchEngine */
+ virtual const KAboutData *about() const;
+
+ /** @returns the i18n name of this search engine */
+ QString name() const {return i18n("DB SearchEngine II");}
+
+ /** @returns a untranslated name of this engine */
+ QString id() const {return "dbse2";}
+
+ /** @returns the last error message */
+ QString lastError() {return lasterror;}
+
+
+ /**
+ * sets the engine to always ask the preferences dialog for settings
+ * if is existing before starting the search.
+ */
+ virtual void setAutoUpdateOptions(bool activate)
+ {
+ autoupdate=activate;
+ }
+
+
+
+ public slots:
+
+ void receiveResult(QueryResult r);
+
+ /**
+ * starts a search for string s in the original text
+ * @returns false, if an error occured. Use @ref lastError
+ * to get the last error message
+ */
+ bool startSearch(QString s);
+
+ /**
+ * starts a search for string s in the translated text
+ * @returns false, if an error occured. Use @ref lastError
+ * to get the last error message
+ */
+ bool startSearchInTranslation(QString s);
+
+
+ /** stops a search */
+ // virtual void stopSearch() ;
+
+
+ /**
+ * This method allows a search engine to use different settings depending
+ * on the edited file. The default implementation does nothing.
+ * @param file The edited file with path
+ */
+ // virtual void setEditedFile(QString file);
+
+ /**
+ * This method allows a search engine to use different settings depending
+ * on the edited package. The default implementation does nothing.
+ * @param package The name of the package, that is currently translated.
+ */
+ // virtual void setEditedPackage(QString package);
+
+ /**
+ * This method allows a search engine to use different settings depending
+ * on the language code. The default implementation does nothing.
+ * @param lang The current language code (e.g. de).
+ */
+ // virtual void setLanguageCode(QString lang);
+ // virtual void setLanguage(QString languageCode, QString languageName);
+
+
+
+ /**
+ * This method is called, if something has been changed in the
+ * current file. See @ref setEditedFile if you want to know the file
+ * name
+ * @param orig the original string
+ * @param translation the translated string
+ */
+
+ void stringChanged( QString orig, QString translated
+ , QString description);
+
+ //void scan();
+
+ void setLastError(QString er);
+
+ //Slots for preference dialog
+ // void scanSource(QString sourceName);
+ void scanNowPressed();
+ void scanAllPressed();
+ void editSource();
+ void removeSource();
+ void addSource();
+
+
+ private:
+ DataBaseInterface *di;
+ bool searching;
+ bool iAmReady;
+ bool autoupdate;
+ QString lasterror;
+ KDB2PreferencesWidget *pw;
+
+ //PrefWidg -> DBSE
+ void updateSettings();
+ //DBSE -> PrefWidg
+ void setSettings();
+
+ DBSESettings settings;
+ QString dbDirectory;
+ bool autoAdd,useSentence,useGlossary,useExact;
+ bool useDivide,useAlpha,useWordByWord,useDynamic;
+ uint numberOfResult;
+ QMap<QString,MessagesSource> sources;
+
+};
+
+
+#endif // SEARCH_ENGINE2_H
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/Makefile.am b/kbabel/kbabeldict/modules/dbsearchengine2/Makefile.am
new file mode 100644
index 00000000..cdcd3083
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/Makefile.am
@@ -0,0 +1,34 @@
+## Makefile.am for DBSE2
+
+# this has all of the subdirectories that make will recurse into. if
+# there are none, comment this out
+#SUBDIRS =
+
+
+# this is the program that gets installed. it's name is used for all
+# of the other Makefile.am variables
+kde_module_LTLIBRARIES = kbabeldict_dbsearchengine2.la
+
+# set the include path for X, qt and KDE
+INCLUDES = -I$(srcdir)/../.. -I$(srcdir)/../../../common $(all_includes) -I$(DBIV_INCLUDES)
+
+# which sources should be compiled for kbabel
+kbabeldict_dbsearchengine2_la_SOURCES = dbscan.cpp preferenceswidget.cpp dbse2.ui KDBSearchEngine2.cpp database.cpp dbentries.cpp dbse2_factory.cpp sourcedialog.ui algorithms.cpp chunk.cpp
+
+#kbabeldict_dbsearchengine2_la_SOURCES = KDBSearchEngine2.cpp database.cpp dbentries.cpp dbse2_factory.cpp
+kbabeldict_dbsearchengine2_la_LIBADD = ../../libkbabeldictplugin.la ../../../common/libkbabelcommon.la $(LIB_KDEUI) $(LIB_KIO) $(LIB_DBIV)_cxx
+kbabeldict_dbsearchengine2_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined -L$(DBIV_LDFLAGS)
+
+
+# these are the headers for your project
+noinst_HEADERS = KDBSearchEngine2.h database.h dbentries.h dbse2_factory.h
+#chunk.h algorithms.h
+
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+kde_services_DATA = dbsearchengine2.desktop
+EXTRA_DIST = $(kde_services_DATA)
+
+
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/README b/kbabel/kbabeldict/modules/dbsearchengine2/README
new file mode 100644
index 00000000..907ab84e
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/README
@@ -0,0 +1,21 @@
+If you want to test this new plugin:
+launch
+# make ; make install in this directory
+then (to create the database)
+# source compile
+# cp scan ~/mytestdir
+# cd ~/mytestdir
+# ./scan file.po (I suggest to download and scan $LANG.messages)
+
+ok now you can launch kbabel, you should be in the same
+directory you launched "scan" from.
+
+# kbabel
+
+
+change kbabel settings to use "DB Search Engine II" or use
+CTRL+2 to search.
+
+
+Bye
+Andrea
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/algorithms.cpp b/kbabel/kbabeldict/modules/dbsearchengine2/algorithms.cpp
new file mode 100644
index 00000000..0ca040e8
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/algorithms.cpp
@@ -0,0 +1,425 @@
+//
+// C++ Implementation: algorithms
+//
+// Description:
+//
+//
+// Author: Andrea Rizzi <rizzi@kde.org>, (C) 2003
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "algorithms.h"
+#include <qstringlist.h>
+#include <kdebug.h>
+
+//FIXME: remove
+#define i18n (const char*)
+
+DataBaseInterface::ResultList ExactSearchAlgorithm::exec(const QString& query )
+{
+ DataBaseInterface::ResultList res;
+ DataBaseInterface::MainEntry e=di->get(query,0);
+
+ QStringList trs=e.second.getTranslations();
+
+ for(QStringList::iterator it=trs.begin();it!=trs.end();++it)
+ {
+
+ emit newResult(QueryResult(*it,e.first.getString(),settings->scoreExact));
+
+ res.push_back(QueryResult(*it));
+ }
+ kdDebug(0) <<"Exact algo found " << res.count() << "entries" << endl;
+ return res;
+}
+
+
+DataBaseInterface::ResultList GenericSearchAlgorithm::exec(const QString& query )
+{
+ DataBaseInterface::ResultList res;
+ // ExactSearchAlgorithm exact(query,settings);
+ uint countResults=0;
+ for(QValueList<AbstractSearchAlgorithm *>::iterator algoit = algoChain.begin(); algoit!=algoChain.end() && countResults < maxResults; algoit++)
+ {
+ connect(*algoit,SIGNAL(newResult(QueryResult)),this,SIGNAL(newResult(QueryResult)));
+ kdDebug(0) << "Algo pointer" << (*algoit) << endl;
+ res+=(*algoit)->exec(query);
+ countResults=res.count();
+ kdDebug(0) << "Count = " << countResults << endl;
+ disconnect(*algoit,SIGNAL(newResult(QueryResult)),this,SIGNAL(newResult(QueryResult)));
+ }
+ return res;
+}
+
+void GenericSearchAlgorithm::addAlgorithm( AbstractSearchAlgorithm * algo )
+{
+ algoChain.append(algo);
+}
+
+DataBaseInterface::ResultList AlphaSearchAlgorithm::exec( const QString & query )
+{
+ DataBaseInterface::ResultList res;
+ DBItemMultiIndex::IndexList il=di->getAlpha(query);
+
+ for(DBItemMultiIndex::IndexList::iterator it=il.begin();it!=il.end()&&!di->stopNow();++it)
+ {
+ DataBaseInterface::MainEntry e=di->getFromIndex(*it);
+ QStringList trs=e.second.getTranslations();
+ for(QStringList::iterator it=trs.begin();it!=trs.end() && !di->stopNow();++it)
+ {
+ QueryResult r(di->format(di->simple(*it,true),query),e.first.getString(),settings->scoreAlpha);
+ emit newResult(r);
+ res.push_back(r);
+ }
+ }
+ kdDebug(0) <<"Alpha algo found " << res.count() << "entries" << endl;
+
+ return res;
+}
+
+DataBaseInterface::ResultList SentenceArchiveSearchAlgorithm::exec( const QString & query )
+{
+ DataBaseInterface::ResultList res;
+
+ DataBaseInterface::MainEntry e = di->getSentence(query);
+
+ QStringList trs=e.second.getTranslations();
+
+ kdDebug(0) << "Count in sentence archive " << trs.count()<< endl;
+
+ for(QStringList::iterator it=trs.begin();it!=trs.end();++it)
+ {
+ QueryResult r(di->format(di->simple(*it,true),query),e.first.getString(),settings->scoreSentence);
+ emit newResult(r);
+
+ res.push_back(r);
+ }
+ kdDebug(0) <<"Sentence algo found " << res.count() << "entries" << endl;
+
+ return res;
+}
+
+DataBaseInterface::ResultList ChunkByChunkSearchAlgorithm::exec( const QString & query )
+{
+ ResultList res;
+ factory->setQuery(query);
+ QPtrList<AbstractChunk> chunks=factory->chunks();
+ kdDebug(0) << "Number of chunks " << chunks.count() << endl;
+ chunks.setAutoDelete(true); //I should delete the chunks myself
+ QStringList querySeparators=factory->separators();
+
+ //This prevents recursive loop.
+ if (chunks.count()<=1) return res;
+
+ QStringList translations,tmpTranslations;
+
+ translations.push_back(""); //FIXME this is needed to start , but is not good
+ int finalscore=0;
+ int i=0;
+ QMap<QString,bool> translationUsed;
+
+ //Loop on all chunk
+ for(AbstractChunk *it=chunks.first();it && !di->stopNow(); it=chunks.next())
+ {
+ kdDebug(0) << "Process next chunk" << endl;
+ int chunkscore=0;
+ QValueList<QueryResult> r=it->translations();
+ kdDebug(0) << "Number of results for this chunk " << r.count() << endl;
+
+ if(r.count()<1) {
+ // kdDebug(0) << "Nothing found for:" << it->translations() << endl;
+ chunkscore=-10;
+
+ }
+ else
+ {
+ //FIXME: check this, why 0? it is the best one?
+ chunkscore=r[0].score();
+ kdDebug(0) << "ChunkScore " << chunkscore << endl;
+ tmpTranslations.clear();
+
+
+ //Loop on results
+ translationUsed.clear();
+ for(ResultList::iterator it1=r.begin();it1!=r.end() &&!di->stopNow(); ++it1)
+ {
+ QString chunkTranslation= (*it1).result();
+ if(!translationUsed.contains(chunkTranslation))
+ {
+ translationUsed[chunkTranslation]=true;
+ kdDebug(0) << "a translation is: " << chunkTranslation << endl;
+ for(QStringList::iterator it2=translations.begin();it2!=translations.end() && !di->stopNow() ; it2++)
+ {
+ QString prevTranslation=*it2;
+ tmpTranslations.push_back(prevTranslation+chunkTranslation+querySeparators[i]);
+ kdDebug(0) << "..appending it to " << prevTranslation << endl;
+ }
+ }
+ }
+
+ translations=tmpTranslations;
+
+ }
+
+ //kdDebug(0) << it-> << r[0].result() << "#" << querySeparators[i] << endl;
+ i++;
+ finalscore+=chunkscore;
+
+ kdDebug(0) << "partial score " << finalscore;
+ }
+ kdDebug(0) << "this is finishd" << endl;
+ if(settings->scoreChunkByChunk==0)
+ settings->scoreChunkByChunk=1;
+// FIXME:fix the score system
+// finalscore/=(i*100*100/settings->scoreChunkByChunk); //change 100 to 120(?) to lower this result (done)
+
+ if (finalscore<50) return res;
+
+ for(QStringList::iterator it2=translations.begin();it2!=translations.end() && !di->stopNow() ; it2++)
+ {
+ QString theTranslation=*it2;
+ QueryResult qr(di->format(theTranslation,query),i18n("CHUNK BY CHUNK"),finalscore);
+ qr.setRichOriginal(i18n("<h3>Chunk by chunk</h3>CHANGE THIS TEXT!!!!This translation is"
+ "obtained translating the sentences and using a"
+ "fuzzy sentence translation database.<br>"
+ " <b>Do not rely on it</b>. Translations may be fuzzy.<br>"));
+ qr.setRichResult("<font color=#800000>"+theTranslation+"</font>") ;
+ emit newResult(qr);
+ res.push_back(qr);
+ }
+
+
+ return res;
+
+
+}
+
+ChunkByChunkSearchAlgorithm::ChunkByChunkSearchAlgorithm( DataBaseInterface * dbi, DBSESettings * sets ): AbstractSearchAlgorithm(dbi,sets) , factory(0)
+{
+
+}
+
+
+SentenceArchiveSearchAlgorithm::SentenceArchiveSearchAlgorithm( DataBaseInterface * dbi, DBSESettings * sets ): AbstractSearchAlgorithm(dbi,sets)
+{
+}
+
+FuzzyChunkSearchAlgorithm::FuzzyChunkSearchAlgorithm( DataBaseInterface * dbi, DBSESettings * sets ) : AbstractSearchAlgorithm(dbi,sets)
+{
+
+}
+
+
+DataBaseInterface::ResultList FuzzyChunkSearchAlgorithm::exec( const QString & query )
+{
+ //FIXME: this code is shit too
+ ResultList res;
+ factory->setQuery(query);
+ QPtrList<AbstractChunk> querychunks = factory->chunks();
+ querychunks.setAutoDelete(true);
+
+ typedef QMap<QString,QValueList<unsigned int> > ResultMap;
+ ResultMap rmap; //result of words index query
+ unsigned int notfound=0,frequent=0,nchunks = querychunks.count();
+
+ //Get index list for each word
+ for(AbstractChunk *it=querychunks.first(); it &&!di->stopNow() ; it=querychunks.next() )
+ {
+ QValueList<uint> locations = (*it).locationReferences();
+
+ if(locations.count()>0)
+ {
+ rmap[(*it).chunkString()] = locations;
+
+ if(locations.count()>1000) //FIXME NORMALIZE THIS!!!
+ {
+ frequent++;
+ kdDebug(0) << "\""<<(*it).chunkString() << "\" is frequent" <<endl;
+ }
+ }
+ else
+ notfound++;
+
+ }
+
+
+ //Now we have a map (rmap) "word in query->list of occurency"
+
+ QValueList<unsigned int>::iterator countpos[nchunks+1];
+
+
+ QValueList<unsigned int> il;
+ for(int i = 0;i<=nchunks&&!di->stopNow();i++)
+ countpos[i]=il.end();
+
+ unsigned int bestcount=0;
+ while(!rmap.isEmpty())
+ {
+ unsigned int ref,count;
+ ref=(unsigned int)-1;
+ count=0;
+
+
+ //This will find the min head and count how many times it occurs
+ for(ResultMap::iterator it = rmap.begin();it!=rmap.end()&&!di->stopNow();++it)
+ {
+ unsigned int thisref=it.data().first();
+ if(thisref<ref)
+ {
+ ref=thisref;
+ count=0;
+ }
+ if(thisref==ref)
+ {
+ count++;
+ }
+
+ }
+
+
+ for(ResultMap::iterator it = rmap.begin();it!=rmap.end()&&!di->stopNow();)
+ {
+ it.data().remove(ref);
+
+ //kdDebug(0)<< ((frequent<(nwords-notfound)) && (it.data().count()>350)) <<endl;
+ //FIXME: I think the frequent word check is not in the right place
+ if(it.data().isEmpty() || (((frequent+notfound)<nchunks) && (it.data().count()>1000)))
+ //very dirty hack...
+ {
+
+ ResultMap::iterator it2=it;
+ it++;
+ rmap.remove(it2);
+ }
+ else it++;
+
+ }
+
+ //This should be configurable or optimized:
+ if(count>=(nchunks-notfound)*0.50 && count!=0)
+ {
+ il.insert(countpos[count],ref);
+ for(unsigned int i = nchunks;i>=count;i--)
+ if(countpos[i]==countpos[count])
+ countpos[i]--;
+ }
+ }
+
+ //loop on number of words found
+ int bestscore=0;
+
+ for(unsigned int wf=nchunks;wf>0;wf-- ){
+ for(QValueList<unsigned int>::iterator it=countpos[wf];it!=countpos[wf-1] ;++it)
+ { //loop on entries with same number of word found
+ DataBaseInterface::MainEntry e;
+ e=di->getFromIndex(*it);
+ QStringList trs=e.second.getTranslations();
+ for(QStringList::iterator it=trs.begin();it!=trs.end()&&!di->stopNow();++it)
+ {
+ unsigned int cinr=factory->chunks(*it).count(); //chunk in result
+ //compute a score, lets kbabel sort now, it should be fast...
+ int score=90*wf/nchunks-(signed int)90*(((nchunks-cinr)>0)?(nchunks-cinr):(cinr-nchunks))/(nchunks*10);
+ if(score>bestscore) bestscore=score;
+ if(score>bestscore*0.40)
+ {
+ // kdDebug(0) << "s: "<<score << " wf: "<<wf<<" nwords: "<<nwords<<" winr: "<<winr
+ // <<" 90*wf/nwords: "<<90*wf/nwords << " -:" << 90*(((nwords-winr)>0)?(nwords-winr):(winr-nwords))/(nwords*10)<< endl;
+ // FIXME: format better the richtext
+ QString ori=e.first.getString();
+ QString re=di->format(di->simple(*it,true),query);
+ QueryResult r(re,ori,score);
+ for(QPtrListIterator<AbstractChunk> it(querychunks); it.current() && di->stopNow() ; ++it){
+ ori=ori.replace(QRegExp((*it)->chunkString(),false),"<font color=#000080><u><b>"+(*it)->chunkString()+"</b></u></font>");
+ }
+ r.setRichOriginal(ori);
+ if(!di->stopNow())
+ emit newResult(r);
+ res.push_back(r);
+ }
+ }
+ }
+ }
+ return res;
+
+}
+
+DataBaseInterface::ResultList CorrelationSearchAlgorithm::exec( const QString & query )
+{
+ //FIXME, this code is shit.
+ DataBaseInterface::ResultList res;
+ if(di->words(query).count()>1) return res;
+ QMap<QString,float> corRes = di->correlation(query,0,false);
+ float max=0,max1=0,max2=0;
+ QString best,best1,best2;
+
+ for(QMap<QString,float>::iterator it = corRes.begin(); it !=corRes.end(); ++it)
+ {
+ if(it.data()>max)
+ {
+ max2=max1;
+ best2=best1;
+ max1=max;
+ best1=best;
+ best = it.key();
+ max=it.data();
+
+ }
+
+
+ }
+ if(!best.isEmpty())
+ {
+ double myscore=0.01*max*settings->scoreDynamic;
+ QueryResult r(di->format(best,query),i18n("DYNAMIC DICT:"),myscore);
+ r.setRichOriginal(i18n("<h3>Dynamic Dictionary</h3>This is a dynamic dictionary created"
+ " looking for correlation of original and translated words.<br>"
+ " <b>Do not rely on it</b>. Translations may be fuzzy.<br>"));
+ r.setRichResult("<font size=+2 color=#A00000>"+di->format(best,query)+"</font>") ;
+ res.push_back(r);
+ if(!di->stopNow())
+ emit newResult(r);
+ }
+ if(!best1.isEmpty())
+ {
+ double myscore=0.01*max1*settings->scoreDynamic;
+ QueryResult r(di->format(best1,query),i18n("DYNAMIC DICT:"),myscore);
+ r.setRichOriginal(i18n("<h3>Dynamic Dictionary</h3>This is a dynamic dictionary created"
+ " looking for correlation of original and translated words.<br>"
+ " <b>Do not rely on it</b>. Translations may be fuzzy.<br>"));
+ r.setRichResult("<font size=+2 color=#800000>"+di->format(best1,query)+"</font>") ;
+ res.push_back(r);
+ if(!di->stopNow())
+ emit newResult(r);
+ }
+
+ kdDebug(0) << "Correlation algorithm found" << res.count() << "results";
+ return res;
+
+}
+
+GenericSearchAlgorithm::GenericSearchAlgorithm( DataBaseInterface * dbi, DBSESettings * sets ): AbstractSearchAlgorithm(dbi,sets)
+{
+ maxResults = 5; //FIXME use as default somthing from DBSESettings
+}
+
+SingleWordSearchAlgorithm::SingleWordSearchAlgorithm( DataBaseInterface * dbi, DBSESettings * sets ) : GenericSearchAlgorithm(dbi,sets),
+ exact(dbi,sets), alpha(dbi,sets), sentence(dbi,sets), corr(dbi,sets), chunk(dbi,sets),casefactory(dbi)
+ {
+ addAlgorithm(&exact);
+ addAlgorithm(&alpha);
+ addAlgorithm(&sentence);
+ chunk.setChunkFactory(&casefactory);
+ addAlgorithm(&chunk);
+ addAlgorithm(&corr);
+}
+
+DataBaseInterface::ResultList SingleWordSearchAlgorithm::exec( const QString & query )
+{
+ if(di->words(query).count()>1)
+ return ResultList();
+ return GenericSearchAlgorithm::exec(query);
+}
+
+
+//#include "algorithms.moc"
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/algorithms.h b/kbabel/kbabeldict/modules/dbsearchengine2/algorithms.h
new file mode 100644
index 00000000..5f9ee682
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/algorithms.h
@@ -0,0 +1,157 @@
+//
+// C++ Interface: strategies
+//
+// Description:
+//
+//
+// Author: Andrea Rizzi <rizzi@kde.org>, (C) 2003
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef DBSE2_STRATEGIES_H
+#define DBSE2_STRATEGIES_H
+
+#include "database.h"
+#include "chunk.h"
+#include <qobject.h>
+
+class AbstractSearchAlgorithm : public QObject
+{
+ Q_OBJECT
+ public:
+
+ typedef QValueList<QueryResult> ResultList;
+
+ AbstractSearchAlgorithm(DataBaseInterface *dbi,DBSESettings *sets)
+ {
+ di=dbi;
+ settings=sets;
+ }
+ /**
+ * this contains the algo and return some results.
+ */
+ virtual DataBaseInterface::ResultList exec(const QString& query)=0;
+
+ signals:
+ void newResult(QueryResult);
+
+ protected:
+ DataBaseInterface *di;
+ DBSESettings *settings;
+
+};
+
+
+
+class ExactSearchAlgorithm : public AbstractSearchAlgorithm
+{
+ Q_OBJECT
+ public:
+ ExactSearchAlgorithm(DataBaseInterface *dbi,DBSESettings *sets) : AbstractSearchAlgorithm(dbi,sets) {}
+
+ virtual DataBaseInterface::ResultList exec(const QString& query);
+};
+
+class AlphaSearchAlgorithm : public AbstractSearchAlgorithm
+{
+ Q_OBJECT
+ public:
+ AlphaSearchAlgorithm(DataBaseInterface *dbi,DBSESettings *sets) : AbstractSearchAlgorithm(dbi,sets) {}
+
+ virtual DataBaseInterface::ResultList exec(const QString& query);
+};
+
+class SentenceArchiveSearchAlgorithm : public AbstractSearchAlgorithm
+{
+ Q_OBJECT
+ public:
+ SentenceArchiveSearchAlgorithm(DataBaseInterface *dbi,DBSESettings *sets) ;
+
+ virtual DataBaseInterface::ResultList exec(const QString& query);
+};
+
+class ChunkByChunkSearchAlgorithm : public AbstractSearchAlgorithm
+{
+ Q_OBJECT
+ public:
+ ChunkByChunkSearchAlgorithm(DataBaseInterface *dbi,DBSESettings *sets);
+
+ virtual DataBaseInterface::ResultList exec(const QString& query);
+
+ void setChunkFactory(AbstractChunkFactory *_factory)
+ {
+ factory=_factory;
+ }
+ protected:
+ AbstractChunkFactory *factory;
+};
+
+class FuzzyChunkSearchAlgorithm : public AbstractSearchAlgorithm
+{
+ Q_OBJECT
+ public:
+ FuzzyChunkSearchAlgorithm(DataBaseInterface *dbi,DBSESettings *sets);
+
+ virtual DataBaseInterface::ResultList exec(const QString& query);
+ void setChunkFactory(AbstractChunkFactory *_factory)
+ {
+ factory=_factory;
+ }
+ protected:
+ AbstractChunkFactory *factory;
+};
+
+class GenericSearchAlgorithm : public AbstractSearchAlgorithm
+{
+ Q_OBJECT
+ public:
+ GenericSearchAlgorithm(DataBaseInterface *dbi,DBSESettings *sets) ;
+
+ virtual ResultList exec(const QString& query);
+
+ void addAlgorithm(AbstractSearchAlgorithm *algo);
+ void setMaxResultNumber(uint num){maxResults=num;}
+
+
+ protected:
+ QValueList<AbstractSearchAlgorithm *> algoChain;
+ uint maxResults;
+ };
+
+
+class CorrelationSearchAlgorithm : public AbstractSearchAlgorithm
+{
+ Q_OBJECT
+ public:
+ CorrelationSearchAlgorithm(DataBaseInterface *dbi,DBSESettings *sets) : AbstractSearchAlgorithm(dbi,sets) {}
+ virtual ResultList exec(const QString& query);
+};
+
+
+
+class SingleWordSearchAlgorithm : public GenericSearchAlgorithm
+{
+ Q_OBJECT
+ public:
+ SingleWordSearchAlgorithm(DataBaseInterface *dbi,DBSESettings *sets);
+ virtual DataBaseInterface::ResultList exec(const QString& query);
+
+ private:
+ ExactSearchAlgorithm exact;
+ AlphaSearchAlgorithm alpha;
+ SentenceArchiveSearchAlgorithm sentence;
+ CorrelationSearchAlgorithm corr;
+ ChunkByChunkSearchAlgorithm chunk;
+ CaseBasedWordChunkFactory casefactory;
+};
+
+
+class UpdateChunkIndexAlgorithm
+{
+
+};
+
+
+
+#endif //DBSE2_STRATEGIES_H
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/chunk.cpp b/kbabel/kbabeldict/modules/dbsearchengine2/chunk.cpp
new file mode 100644
index 00000000..7c62748a
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/chunk.cpp
@@ -0,0 +1,203 @@
+//
+// C++ Implementation: chunk
+//
+// Description:
+//
+//
+// Author: Andrea Rizzi <rizzi@kde.org>, (C) 2003
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "chunk.h"
+#include "algorithms.h"
+#include <kdebug.h>
+
+
+
+AbstractChunk::~AbstractChunk( )
+{
+}
+
+WordChunk::WordChunk( DataBaseInterface * di, QString _word ) : AbstractChunk(di)
+{
+ word=_word;
+}
+
+QValueList<QueryResult> WordChunk::translations( )
+{
+ DataBaseInterface::ResultList r;
+ SingleWordSearchAlgorithm sa(di,di->getSettings());
+ r=sa.exec(word);
+ return r;
+}
+
+//QValueList<QueryResult> WordChunk::translationsFromReference( uint reference )
+//{
+//}
+
+QValueList< uint > WordChunk::locationReferences( )
+{
+ QValueList<uint> res=di->getWordIndex(word);
+ kdDebug(0) << "Number of locations " << res.count() <<endl ;
+ return res;
+/* DBItemMainKey *k = new DBItemMainKey(word);
+ DBItemMultiIndex *d = new DBItemMultiIndex();
+ if(wordsindex->get(k,d)!=DB_NOTFOUND)
+ return d->getList();
+ else
+ return QValueList<uint> tmpList;
+*/
+}
+
+void WordChunk::setLocationReferences( QValueList< uint > )
+{
+}
+
+SentenceChunk::SentenceChunk( DataBaseInterface * di, QString _sentence ): AbstractChunk(di)
+{
+ sentence=_sentence;
+}
+
+QValueList<QueryResult> SentenceChunk::translations( )
+{
+ GenericSearchAlgorithm g(di,di->getSettings());
+
+ ExactSearchAlgorithm e(di,di->getSettings());
+ AlphaSearchAlgorithm a(di,di->getSettings());
+ SentenceArchiveSearchAlgorithm s(di,di->getSettings());
+
+ g.addAlgorithm(&e);
+ g.addAlgorithm(&a);
+ g.addAlgorithm(&s);
+
+ return g.exec(sentence);
+
+}
+
+//QValueList<QueryResult> SentenceChunk::translationsFromReference( uint reference )
+//{
+//
+//}
+
+QValueList< uint > SentenceChunk::locationReferences( )
+{
+}
+
+void SentenceChunk::setLocationReferences( QValueList< uint > )
+{
+}
+
+QPtrList< AbstractChunk> WordChunkFactory::chunks()
+{
+ QString str=di->simple(string);
+ QPtrList<AbstractChunk> list;
+ if(str.isEmpty()) return list;
+ _separators.clear();
+ kdDebug(0) << "Word chunks of:" <<str << endl;
+ int pos;
+ QString sep;
+ QRegExp r("(\\s)");
+ do {
+ pos=r.search(str);
+
+ sep=r.cap(1);
+ if(!str.left(pos).isEmpty()){
+ //WordChunk *c=new WordChunk(di,di->simple(str.left(pos)))
+ list.append(new WordChunk(di,str.left(pos)));
+ _separators.append(sep);
+ }
+ else
+ {
+ uint current=_separators.count()-1;
+ _separators[current]=_separators[current]+sep;
+ }
+ str=str.remove(0,pos+1);
+ } while(!str.isEmpty() && pos != -1);
+
+ return list;
+}
+
+
+
+QPtrList<AbstractChunk> SentenceChunkFactory::chunks()
+{
+ QString str=string;
+ QPtrList<AbstractChunk> list;
+ if(str.isEmpty()) return list;
+
+ // kdDebug(0) << s << endl;
+
+ int pos;
+
+
+ do {
+ QRegExp re("((\\.|;|\\?|\\!|:)( |$|\\\\n\\n))");
+ pos=re.search(str);
+ QString sep=re.cap(1);
+
+ if(!str.left(pos).isEmpty())
+ {
+ list.append(new SentenceChunk(di,str.left(pos).stripWhiteSpace()));
+ _separators.append(sep);
+ }
+ else
+ {
+ uint current=_separators.count()-1;
+ _separators[current]=_separators[current]+sep;
+ }
+
+ str=str.remove(0,pos+re.cap(1).length());
+ } while(!str.isEmpty() && pos != -1);
+
+
+ return list;
+
+}
+QPtrList< AbstractChunk > CaseBasedWordChunkFactory::chunks( )
+{
+ QString str=string;
+ QPtrList<AbstractChunk> list;
+ if(str.isEmpty()) return list;
+ uint slen=str.length();
+ kdDebug(0) << "CaseWordChunk string:" << str << endl;
+ QString tmpWord;
+ bool upcase;
+ for(uint i=0;i<=slen;i++)
+ {
+ bool tmpCase=(str[i]==str[i].upper());
+ if(upcase!=tmpCase)
+ {
+ if(!tmpWord.isEmpty() && !tmpWord.isNull()){
+ list.append(new WordChunk(di,tmpWord));
+ _separators.append("");
+ }
+ kdDebug(0) << "CaseWordChunk:" << tmpWord << endl;
+ tmpWord="";
+
+ }
+ tmpWord+=str[i];
+ upcase=tmpCase;
+ }
+
+ return list;
+}
+
+WordChunkFactory::WordChunkFactory( DataBaseInterface * _di ) : AbstractChunkFactory(_di)
+{
+}
+
+SentenceChunkFactory::SentenceChunkFactory( DataBaseInterface * _di ): AbstractChunkFactory(_di)
+{
+}
+
+CaseBasedWordChunkFactory::CaseBasedWordChunkFactory( DataBaseInterface * _di ): AbstractChunkFactory(_di)
+{
+}
+
+
+
+
+
+
+
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/chunk.h b/kbabel/kbabeldict/modules/dbsearchengine2/chunk.h
new file mode 100644
index 00000000..5c5fcb93
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/chunk.h
@@ -0,0 +1,151 @@
+//
+// C++ Interface: chunk
+//
+// Description:
+//
+//
+// Author: Andrea Rizzi <rizzi@kde.org>, (C) 2003
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef DBSE2_CHUNK_H
+#define DBSE2_CHUNK_H
+#include <qstring.h>
+#include <qvaluelist.h>
+#include "database.h"
+
+/**
+ * Abstract class for text chunks.
+ * Examples of chunks are "Words" or "Sentences"
+ * This abstraction allow to use generic algorithm on chunks,
+ * like chunkByChunk translation or chunk indexing.
+ */
+class AbstractChunk
+{
+ public:
+ AbstractChunk(DataBaseInterface *_di) {di=_di;}
+ virtual ~AbstractChunk();
+ /**
+ * This function should return a list of translation for the current chunk.
+ */
+ virtual QValueList<QueryResult> translations()=0;
+
+ //FIXME: is this in the right place, better in factory? check that stuff
+ //virtual QValueList<QueryResult> translationsFromReference(uint reference)=0;
+ virtual QValueList<uint> locationReferences()=0;
+ virtual void setLocationReferences(QValueList<uint>)=0;
+ virtual QString chunkString()=0;
+
+ protected:
+ DataBaseInterface *di;
+};
+
+/**
+ * Concrete impl of Chunk, in this case chunks are words.
+ */
+class WordChunk : public AbstractChunk
+{
+ public:
+ WordChunk(DataBaseInterface *di,QString _word);
+ virtual QValueList<QueryResult> translations();
+ //virtual QValueList<QueryResult> translationsFromReference(uint reference);
+ virtual QValueList<uint> locationReferences();
+ virtual void setLocationReferences(QValueList<uint>);
+ virtual QString chunkString(){return word;}
+
+ //static QValueList<WordChunk> divide(QString);
+ private:
+ QString word;
+};
+
+/**
+ * Concrete impl of Chunk, in this case chunks are sentences.
+ */
+class SentenceChunk : public AbstractChunk
+{
+ public:
+ SentenceChunk(DataBaseInterface *di,QString _sentence);
+ virtual QValueList<QueryResult> translations();
+ //virtual QValueList<QueryResult> translationsFromReference(uint reference);
+ virtual QValueList<uint> locationReferences();
+ virtual void setLocationReferences(QValueList<uint>);
+ virtual QString chunkString(){return sentence;}
+
+ // static QValueList<SentenceChunk> divide(QString);
+
+ private:
+ QString sentence;
+};
+
+
+/**********************************
+ CHUNK FACTORIES
+**********************************/
+
+
+class AbstractChunkFactory
+{
+ public:
+ AbstractChunkFactory(DataBaseInterface *_di)
+ {
+ di=_di;
+ }
+ virtual ~AbstractChunkFactory(){}
+ virtual QPtrList<AbstractChunk> chunks()=0;
+ /**
+ Change th string and return the chunks
+ */
+ virtual QPtrList<AbstractChunk> chunks(const QString& s)
+ {
+ string=s;
+ return chunks();
+ }
+ /**
+ * Returns the list of separators of last @ref chunks() call
+ */
+
+ virtual QStringList separators(){ return _separators;}
+ void setQuery(const QString& s)
+ {
+ string=s;
+ }
+ protected:
+ QString string;
+ QStringList _separators;
+ DataBaseInterface *di;
+};
+
+class WordChunkFactory : public AbstractChunkFactory
+{
+ public:
+ WordChunkFactory(DataBaseInterface *_di);
+ /**
+ YOU SHOULD DELETE THE CHUNKS!!
+ */
+ virtual QPtrList<AbstractChunk> chunks();
+};
+
+class CaseBasedWordChunkFactory : public AbstractChunkFactory
+{
+ public:
+ CaseBasedWordChunkFactory(DataBaseInterface *_di);
+ /**
+ YOU SHOULD DELETE THE CHUNKS!!
+ */
+ virtual QPtrList<AbstractChunk> chunks();
+};
+
+class SentenceChunkFactory : public AbstractChunkFactory
+{
+ public:
+ SentenceChunkFactory(DataBaseInterface *_di);
+
+ /**
+ YOU SHOULD DELETE THE CHUNKS!!
+ */
+ virtual QPtrList<AbstractChunk> chunks();
+};
+
+
+#endif //_CHUNK_H_
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/database.cpp b/kbabel/kbabeldict/modules/dbsearchengine2/database.cpp
new file mode 100644
index 00000000..ea0e8379
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/database.cpp
@@ -0,0 +1,752 @@
+/*
+
+DBSE 3
+(c) 2000-2003 Andrea Rizzi
+License: GPLv2
+
+*/
+#include <math.h>
+#include "database.h"
+
+#include <qregexp.h>
+#include <qdict.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+
+#define i18n (const char*)
+
+
+
+
+
+
+DataBase::DataBase(QString dbpath,QString dbname, QString dblang) : Db(0,DB_CXX_NO_EXCEPTIONS)
+{
+
+ filename=dbpath+"."+dblang+".db";
+ database=dbname;
+
+}
+
+int DataBase::open(DBTYPE type,unsigned int flags)
+{
+ int ret;
+ ret = Db::open(
+#if DB_VERSION_MINOR > 0
+ NULL,
+#endif
+ (const char*)filename.local8Bit(),(const char *)database.local8Bit(),type,flags,0644);
+ mytype=type;
+ return ret;
+}
+
+unsigned int DataBase::getLast()
+{
+ if(mytype!=DB_RECNO)
+ return 0;
+
+ Dbc *cur;
+ cursor(0,&cur,0);
+ DBItemNum index;
+ DBItemMainKey key;
+ cur->get(&index,&key,DB_LAST);
+ return index.getNum();
+
+}
+
+
+
+
+
+QueryResult::QueryResult(QString r)
+{
+ res=r;
+}
+QueryResult::QueryResult(QString r,QString o,int s)
+{
+ res=r;
+ richr=r;
+ orig=o;
+ richo=o;
+ sco=s;
+}
+
+QueryResult::QueryResult()
+{
+ res="";
+}
+
+
+
+
+DataBaseInterface::DataBaseInterface(QString dir, DBSESettings *sets)
+{
+
+ //FIXME Better db names!!
+ main = openMyDataBase(dir+"/testm","main","it",DB_BTREE);
+ alpha = openMyDataBase(dir+"/testa","alpha","it",DB_BTREE);
+ numindex = openMyDataBase(dir+"/testn","numindex","it",DB_RECNO);
+ wordsindex = openMyDataBase(dir+"/testw","wordsindex","it",DB_BTREE);
+ sentence = openMyDataBase(dir+"/tests","sentence","it",DB_BTREE);
+ corr = openMyDataBase(dir+"/testc","corr","it",DB_BTREE);
+ transword = openMyDataBase(dir+"/testt","transword","it",DB_RECNO);
+
+ // kdDebug(0) << main << endl;
+ // kdDebug(0) << alpha << endl;
+ settings=sets;
+ _stopNow=false;
+}
+
+DataBaseInterface::~DataBaseInterface()
+{
+
+ if(main){
+ main->close(0);
+ delete main;
+ }
+ if(numindex){
+ numindex->close(0);
+ delete numindex;
+ }
+
+ if(alpha){
+ alpha->close(0);
+ delete alpha;
+ }
+ if(wordsindex){
+ wordsindex->close(0);
+ delete wordsindex;
+ }
+ if(sentence){
+ sentence->close(0);
+ delete sentence;
+ }
+
+}
+
+DataBase *DataBaseInterface::openMyDataBase(const QString& prefix,const QString& name,const QString& l,DBTYPE tt)
+{
+
+ DataBase *aDb = new DataBase(prefix,name,l);
+ if(aDb==0){
+ return 0;
+ }
+ else
+ {
+ if(aDb->open(tt)!=0)
+ {
+ kdDebug(0) << "Database '"<< name <<"'do not exist, I try to create it.." << endl;
+ //ask only the first time.
+ static bool create=( KMessageBox::questionYesNo(0,"Database do not exist. Do you want to create it now?",
+ i18n("Create Database"), i18n("Create"), i18n("Do Not Create"))==KMessageBox::Yes);
+ if(create)
+ if(aDb->open(tt,DB_CREATE)!=0)
+ {
+ kdDebug(0) << "...cannot create!!"<< endl;
+ return 0;
+ }
+ else
+ {
+ kdDebug(0) << "...done!" << endl;
+ return aDb;
+ }
+ }
+
+ }
+ return aDb;
+}
+
+/*
+ * query functions.
+ *
+ */
+
+
+DataBaseInterface::MainEntry DataBaseInterface::get(const QString& query,SearchFilter *filter)
+{
+ static int counter=1;
+ counter++;
+ DBItemMainKey k(query);
+ DBItemMainData d;
+ //int r=
+ main->get(&k,&d);
+ // kdDebug(0) << "MAINDB->GET returned: " << r << endl;
+ if(counter%5==0) kapp->processEvents(100);
+ // kdDebug(0) << "events processed" << endl;
+ return qMakePair(k,d);
+
+}
+
+/*
+ * put functions
+ * *
+ */
+
+
+bool DataBaseInterface::addEntry(QString original,QString translated,InputInfo *info)
+{
+ DBItemMainKey mk(original);
+ DBItemMainData md;
+ QMap<QString, int> correlationDiff;
+ bool newentry=false;
+ //try to get
+ kdDebug(0) << "Inserting the pair:" << endl;
+ kdDebug(0) << "ORIGINAL:" << original << endl;
+ kdDebug(0) << "TRANSLATED:" << translated << endl;
+
+ if(main->get(&mk,&md)==DB_NOTFOUND)
+ {
+ kdDebug(0) << "new entry" << endl;
+ newentry=true;
+ //This is a new entry, create index entry
+ DBItemNum *nind;
+ int newid=numindex->getLast()+1;
+ nind=new DBItemNum(newid);
+ numindex->put(nind,&mk);
+
+ delete nind;
+
+ md.clear();
+ md.setIndexnumber(newid);
+
+
+ //Update secondary index alpha
+ DBItemMainKey ka(simple(original));
+ DBItemMultiIndex in;
+ if(alpha->get(&ka,&in)==DB_NOTFOUND) in.clear() ;
+ //alpha->get(&ka,&in);
+ in.addEntry(newid);
+ alpha->put(&ka,&in);
+ kdDebug(0) << "Updating the word index " << endl;
+ //Update words index
+ QStringList ws=words(original);
+ for(QStringList::iterator it = ws.begin(); it!=ws.end(); ++it)
+ {
+ DBItemMainKey word(*it);
+ DBItemMultiIndex win;
+ if(wordsindex->get(&word,&win)==DB_NOTFOUND) win.clear();
+ win.addEntry(newid);
+ wordsindex->put(&word,&win);
+ }
+
+ kdDebug(0) << "new entry preparation DONE" << endl;
+ }
+ else
+ {
+
+ kdDebug(0) << "It exists!" <<endl;
+ }
+
+
+ //Update sentence index
+ QStringList so=sentences(original);
+ QStringList st=sentences(translated);
+ if(so.count()==st.count() && st.count() >1 ) //we already hav a database for single string.
+ {
+ kdDebug(0) << "inside sentence loop" << endl;
+ for(int i=0; i< so.count() ; i++)
+ {
+ DBItemMainKey sk(so[i]);
+ DBItemMainData sd;
+ if(sentence->get(&sk,&sd)==DB_NOTFOUND&&!newentry)
+ kdDebug(0) << "Warning: new sentence for old entry, do we changed sentence definition? " << endl;
+
+ kdDebug(0) << "here alive" << endl;
+
+ // if(clean)
+ sd.removeRef(info->ref());
+ kdDebug(0) << "now alive" << endl;
+ sd.addTranslation(st[i],info->ref());
+ kdDebug(0) << "still alive" << endl;
+
+ sentence->put(&sk,&sd);
+
+ }
+
+
+
+ }
+ kdDebug(0) << "Fuzzy sentence archive updated" << endl;
+
+
+
+ //Add that translation, link to ref for information on that translation
+
+ if(!translated.isEmpty())
+ {
+ //loop on all translations to update correlation
+ QStringList tmpTranslations=md.getTranslations();
+ for(QStringList::iterator otIt=tmpTranslations.begin(); otIt!=tmpTranslations.end();++otIt)
+ {
+ QStringList wt=words(*otIt);
+ for(QStringList::iterator it = wt.begin(); it!=wt.end(); ++it)
+ {
+ if(correlationDiff.contains(*it))
+ correlationDiff[*it]--;
+ else
+ correlationDiff[*it]=-1;
+ }
+ }
+
+ //clean so that we have only one translation per catalog.
+ md.removeRef(info->ref());
+ md.addTranslation(translated,info->ref());
+
+ tmpTranslations=md.getTranslations();
+ for(QStringList::iterator otIt=tmpTranslations.begin(); otIt!=tmpTranslations.end();++otIt)
+ {
+ QStringList wt=words(*otIt);
+ for(QStringList::iterator it = wt.begin(); it!=wt.end(); ++it)
+ {
+ if(correlationDiff.contains(*it))
+ correlationDiff[*it]++;
+ else
+ correlationDiff[*it]=1;
+ }
+ }
+
+ //FIXME: use the correlationDIff map somehow
+
+ }
+
+ //finally put!
+ return (main->put(&mk,&md)==0);
+
+}
+
+
+bool DataBaseInterface::removeEntry(QString original)
+{
+ DBItemMainKey mk(original);
+ DBItemMainData md;
+
+ //FIXME implement remove
+ //try to get
+ if(main->get(&mk,&md)==DB_NOTFOUND)
+ {
+ /* //This is a new entry, create index entry
+ DBItemNum *nind;
+ int newid=numindex->getLast()+1;
+ nind=new DBItemNum(newid);
+ numindex->put(nind,&mk);
+
+ delete nind;
+
+ md.clear();
+ md.setIndexnumber(newid);
+
+
+ //Update secondary index alpha
+ DBItemMainKey ka(simple(original));
+ DBItemMultiIndex in;
+ if(alpha->get(&ka,&in)==DB_NOTFOUND) in.clear() ;
+ //alpha->get(&ka,&in);
+ in.addEntry(newid);
+ alpha->put(&ka,&in);
+
+ //Update words index
+ QStringList ws=words(original);
+ for(QStringList::iterator it = ws.begin(); it!=ws.end(); it++)
+ {
+ DBItemMainKey word(*it);
+ DBItemMultiIndex win;
+ if(wordsindex->get(&word,&win)==DB_NOTFOUND) win.clear();
+ win.addEntry(newid);
+ wordsindex->put(&word,&win);
+ }
+
+ //Update sentence index
+ QStringList so=sentences(original);
+ QStringList st=sentences(translated);
+ if(so.count()==st.count() && st.count() >1 ) //we already hav a database for single string.
+ {
+ for(int i=0; i< so.count() ; i++)
+ {
+ DBItemMainKey sk(so[i]);
+ DBItemMainKey sd(st[i]); //should be a list i.e. main data?
+ sentence->put(&sk,&sd);
+
+ }
+ }
+
+*/
+ }
+
+
+ return false;
+
+}
+
+
+
+QMap<QString,float> DataBaseInterface::correlation(QString word,SearchFilter *filter,bool notify, float minSign)
+{
+ QDict<unsigned int> res;
+ // res.setAutoDelete(true);
+ QMap<QString, float>final;
+ DBItemMultiIndex::IndexList il;
+ unsigned int tot=0;
+ unsigned int background=0;
+ unsigned int nocck;
+ QString sword=simple(word);
+ DBItemMainKey *k = new DBItemMainKey(sword);
+ DBItemMultiIndex *d = new DBItemMultiIndex();
+ if(wordsindex->get(k,d)!=DB_NOTFOUND)
+ {
+
+ il=d->getList();
+ kdDebug(0) << il.count()<<endl;
+ tot=0;
+ for(QValueList<unsigned int>::iterator it=il.begin();it!=il.end();++it)
+ {
+ numindex->get(*it,k);
+
+
+ // QValueList<QueryResult> trad=exactMatch(k->getString(),filter);
+
+ MainEntry e=get(k->getString(),filter);
+ QStringList trad=e.second.getTranslations();
+
+ nocck=words(k->getString()).contains(sword);
+ for( QStringList::iterator it2=trad.begin();it2!=trad.end();++it2)
+ {
+
+ QStringList w=words(*it2);
+ unsigned int numWords = w.count()*10+1;
+ unsigned int wei=100000/sqrt(numWords); //weight (is the best one?)
+
+ background+=(numWords-nocck)*wei;
+ QDict<uint> count;
+ //count.setAutoDelete(true);
+ //FIXME:SET AUTODELETE FOR ALL DICTS
+ for(QStringList::iterator it1=w.begin();it1!=w.end();it1++)
+ {
+ uint *ip;
+ if(!(ip=count[*it1])) count.insert(*it1,new uint(1));
+ else
+ (*ip)++;
+ }
+
+ for(QStringList::iterator it1=w.begin();it1!=w.end();it1++)
+ {
+ uint *ip;
+ if(*(count[*it1])==nocck) //add only if same number of entry (it cuts articles)
+ if(!(ip=res[*it1])) res.insert(*it1,new uint(wei));
+ else
+ (*ip)+=wei;
+ }
+
+ }
+ }
+
+ unsigned int sqrBG=sqrt((1.0*background+1)/10000);
+
+ for(QDictIterator<uint> it(res) ; it.current(); ++it)
+ {
+ float sign=1.0*(*(it.current()))/(10000.0*sqrBG);
+ if(sign >minSign){
+ final[it.currentKey()]=sign;
+ kdDebug(0) << it.currentKey() <<" Score:" << 1.0*(*(it.current()))/10000 << "/" <<sqrBG << " = " <<sign << endl;
+ }
+ }
+
+ kdDebug(0) << "final count " <<final.count()<< endl;
+ }
+
+ return final;
+}
+
+QStringList DataBaseInterface::words(QString s)
+{
+ QString str=simple(s);
+ QStringList list;
+
+ int pos;
+
+ do {
+ pos=str.find(QRegExp("\\s"));
+ // if(!simple(str.left(pos)).isEmpty())
+ // list.append(simple(str.left(pos)));
+ if(!str.left(pos).isEmpty())
+ list.append(str.left(pos));
+ str=str.remove(0,pos+1);
+ } while(!str.isEmpty() && pos != -1);
+
+ return list;
+}
+
+QString DataBaseInterface::simple(QString str,bool ck)
+{
+ QString res;
+ if(ck)
+ res=str; //case keep
+ else
+ res=str.lower(); //lowercase
+ //FIXME: uncoment the foll. line (check speed)
+ res=res.replace(QRegExp("(<(.*)>)(.*)(</\\2>)"),"\\3"); //remove enclosing tags
+
+
+ //Try to get rid of regexps.
+ // res=res.replace(QRegExp("(('|-|_|\\s|[^\\w%])+)")," "); //strip non-word char
+ // res=res.replace(QRegExp("(('|-|_)+)")," "); //strip non-word char
+ // res=res.replace(QRegExp("[^\\w\\s%]"),""); //strip non-word char
+
+ QString r;
+ QChar c;
+ bool wasSpace=true;
+ uint len=res.length();
+ for(uint i=0; i<len;i++)
+ {
+ c=res[i];
+ if(c.isLetterOrNumber())
+ {
+ r+=c;
+ wasSpace=false;
+ }
+ else
+ {
+ if(!wasSpace && c.isSpace())
+ {
+ r+=' ';
+ wasSpace=true;
+ }
+ else
+ {
+ if(!wasSpace && (c=='-' || c=='\'' || c=='_'))
+ {
+ r+=' ';
+ wasSpace=true;
+ }
+ else
+ {
+ if(c=='%'){
+ r+=c;
+ wasSpace=false;
+ }
+ }
+ }
+ }
+ // wasSpace=c.isSpace();
+ }
+ if(r[len-1].isSpace())
+ r.truncate(len-1);
+ res=r;
+ //kdDebug(0) << "Simple: "<<res<< endl;
+ //res=res.simplifyWhiteSpace(); //remove double spaces
+ //res=res.stripWhiteSpace(); //" as " -> "as"
+
+ // kdDebug(0) << res << endl;
+ return res;
+}
+
+QStringList DataBaseInterface::sentences(QString s)
+{
+ QString str=s;
+ QStringList list;
+
+ // kdDebug(0) << s << endl;
+
+ int pos;
+
+
+ do {
+ QRegExp re("((\\.|;|\\?|\\!|:)( |$|\\\\n\\n))");
+ pos=re.search(str);
+ if(!str.left(pos).isEmpty())
+ list.append(str.left(pos).stripWhiteSpace());
+
+ kdDebug(0) << str.left(pos) << endl;
+
+ str=str.remove(0,pos+re.cap(1).length());
+ } while(!str.isEmpty() && pos != -1);
+
+
+ return list;
+}
+
+QStringList DataBaseInterface::sentencesSeparator(QString s)
+{
+ QString str=s;
+ QStringList list;
+
+ // kdDebug(0) << s << endl;
+
+ int pos;
+
+ do {
+ QRegExp re;
+ re.setPattern("([.:?!;]( |$|\\\\n\\n))");
+ pos = re.search(str);
+ QString separator=re.cap(1);
+ if(pos!=-1){
+ list.append(separator);
+ }
+
+ str=str.remove(0,pos+1);
+ } while(!str.isEmpty() && pos != -1);
+
+ return list;
+}
+
+bool DataBaseInterface::isUpper(QChar s)
+{
+ return s==s.upper();
+}
+
+bool DataBaseInterface::isLower(QChar s)
+{
+ return s==s.lower();
+}
+
+
+
+QString DataBaseInterface::format(QString _s,QString t)
+{
+ //FIXME use settings
+ //FIXME use regexp
+
+ QString s=_s;
+ QString noTagT=t.replace(QRegExp("(<(.*)>)(.*)(</\\2>)"),"\\3");
+ QChar first=noTagT[noTagT.find(QRegExp("\\w"))];
+ bool firstCapital=isUpper(first);
+
+ /*
+bool dotsAtEnd=(t.find("...")+3==t.length());
+bool gtgtAtEnd=(t.find(">>")+2==t.length());
+bool ltltAtEnd=(t.find("<<")==t.length()-2);
+
+bool columnAtEnd=(t.find(":")+1==t.length());
+*/
+
+ bool allupper=(t.upper()==t);
+
+
+ if(firstCapital)
+ s[0]=s[0].upper();
+ else
+ s[0]=s[0].lower();
+
+ //if(dotsAtEnd)
+ // s+="...";
+
+ /*if(gtgtAtEnd)
+ s+=">>";
+
+if(ltltAtEnd)
+ s+="<<";
+
+if(columnAtEnd)
+ s+=":";
+*/
+
+ if(allupper)
+ s=s.upper();
+
+ int pos=t.find(QRegExp("&"));
+ if(pos>=0) {
+ QChar accel=t[t.find(QRegExp("&"))+1];
+ if(accel!='&')
+ {
+
+ pos=s.find(accel,false);
+ if(pos<0)
+ pos=0;
+ s.insert(pos,"&");
+ }
+ }
+ s=formatRegExp(s,t,".*(\\.\\.\\.|:|>>|<<|\\.|\\?)$",
+ "^(.*)$",
+ "\\1@CAP1@");
+ s=formatRegExp(s,t,"(<(.*)>).*(\\.\\.\\.|:|>>|<<|\\.|\\?)*(</\\2>)$",
+ "^(.*)$",
+ "@CAP1@\\1@CAP3@@CAP4@");
+
+ return s;
+
+}
+
+
+QString DataBaseInterface::formatRegExp(QString _s, QString t, QString tre,QString stringSearch,QString stringReplace)
+{
+ QString s=_s;
+ QRegExp templateRegExp(tre);
+ //QString stringSearch = "(.*)!@CAP1@$"; // use @CAP1.. fot caps in templates
+ //QString stringReplace = "\\1@CAP1@"; // use \1, \2 for caps in str and @CAP1 fot caps in template
+
+
+ if(templateRegExp.exactMatch(t))
+ {
+ QStringList caps=templateRegExp.capturedTexts();
+ int i=0;
+ for(QStringList::iterator capit=caps.begin();capit!=caps.end();++capit)
+ {
+ QString phRegExp="(?!\\\\)@CAP"+QString::number(i)+"@";
+ //kdDebug(0) << "phRegExp: " << phRegExp << endl;
+ //kdDebug(0) << "cap[" << i << "]: "<< *capit<< endl;
+
+ stringReplace = stringReplace.replace(QRegExp(phRegExp),*capit);
+ stringSearch = stringSearch.replace(QRegExp(phRegExp),*capit);
+ i++;
+
+ }
+ // kdDebug(0) << "stringSearch " << stringSearch << endl;
+ // kdDebug(0) << "stringReplace " << stringReplace << endl;
+ QRegExp stringSearchRegExp = QRegExp(stringSearch);
+ // kdDebug(0) << "before: "<<s<<endl;
+ s = s.replace(stringSearchRegExp,stringReplace);
+ // kdDebug(0) << "after: "<<s<<endl;
+
+ }
+
+ return s;
+}
+
+DBItemMultiIndex::IndexList DataBaseInterface::getAlpha( const QString & query )
+{
+ DBItemMainKey *k = new DBItemMainKey(simple(query));
+ DBItemMultiIndex *d = new DBItemMultiIndex();
+ alpha->get(k,d);
+
+ return d->getList();
+}
+
+DataBaseInterface::MainEntry DataBaseInterface::getFromIndex( uint i )
+{
+ DBItemMainKey k;
+ numindex->get(i,&k);
+ return get(k.getString(),0); //FIXME: this is a BUG right now but the filter should be removed
+}
+
+DataBaseInterface::MainEntry DataBaseInterface::getSentence( const QString & query )
+{
+
+ static int counter=1;
+ counter++;
+ DBItemMainKey k(query);
+ DBItemMainData d;
+ sentence->get(&k,&d);
+ if(counter%5==0) kapp->processEvents(100);
+ return qMakePair(k,d);
+
+}
+
+DBItemMultiIndex::IndexList DataBaseInterface::getWordIndex( const QString & query )
+{
+ DBItemMainKey k = DBItemMainKey(query);
+ DBItemMultiIndex d = DBItemMultiIndex();
+ if(wordsindex->get(&k,&d)!=DB_NOTFOUND){
+ return d.getList();
+ }
+ else
+ {
+ QValueList<unsigned int> tmpList;
+ return tmpList;
+ }
+
+}
+
+
+
+//#include "database.moc.cpp"
+
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/database.h b/kbabel/kbabeldict/modules/dbsearchengine2/database.h
new file mode 100644
index 00000000..c447fa59
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/database.h
@@ -0,0 +1,237 @@
+/*
+
+ DBSE 3
+ (c) 2000-2003 Andrea Rizzi
+ License: GPLv2
+
+*/
+#ifndef DATABASE_2_H
+#define DATABASE_2_H
+
+#include <qstring.h>
+#include <qvaluelist.h>
+#include <db4/db_cxx.h>
+#include <qobject.h>
+#include <qregexp.h>
+
+#include "dbentries.h"
+
+
+class DBSESettings
+{
+public:
+ //DatabaseInterface Settings
+ uint scoreWordByWord;
+ uint scoreGlossary;
+ uint scoreDivide;
+ uint scoreExact;
+ uint scoreSentence;
+ uint scoreAlpha;
+ uint scoreDynamic;
+ uint scoreChunkByChunk;
+ uint minScore;
+ bool firstCapital;
+ bool allCapital;
+ bool accelerator;
+ bool sameLetter;
+
+
+
+};
+
+
+class DataBase : Db
+{
+ public:
+ DataBase(QString dbpath, QString dbname, QString dblang);
+
+ int open(DBTYPE type,unsigned int flags=0);
+
+//Standard access (overload std functions)
+
+
+
+int del(DBItem * key){
+ key->set();
+ int r = Db::del(0,key,0);
+ key->get();
+ return r;
+ }
+
+
+
+int get(DBItem * key,DBItem *data){
+ key->set();
+ data->set();
+ int r = Db::get(0,key,data,0);
+ key->get();
+ data->get();
+ return r;
+ }
+ int put(DBItem * key,DBItem *data,int fl=0){
+ key->set();
+ data->set();
+ int r= Db::put(0,key,data,0);
+ key->get();
+ data->get();
+ return r;
+ }
+
+ int del(DBItemNum * key){
+ int r = Db::del(0,key,0);
+ return r;
+ }
+
+ int get(DBItemNum * key,DBItem *data){
+ data->set();
+ int r = Db::get(0,key,data,0);
+ data->get();
+ return r;
+ }
+ int put(DBItemNum * key,DBItem *data)
+ {
+ data->set();
+ int r= Db::put(0,key,data,0);
+ data->get();
+ return r;
+ }
+
+//Overload, using this you loose the Key!!
+ int del(int i){DBItemNum n(i); return del(&n);}
+ int get(int i,DBItem *data){DBItemNum n(i); return get(&n,data);}
+ int put(int i,DBItem *data){DBItemNum n(i); return put(&n,data);}
+
+ unsigned int getLast();
+ int close(unsigned int i) {return Db::close( i); }
+
+//For scrolling
+ // int getFirst(DBItem *key,DBItem *data,QString table);
+ // int getNext(DBItem *key,DBItem *data,QString table);
+ // bool isEnd(QString table);
+private:
+ QString filename;
+ QString database;
+ DBTYPE mytype;
+};
+
+
+
+
+
+class QueryResult //from DBInterface to KDBSearchEngine
+{
+public:
+ QueryResult();
+ QueryResult(QString r);
+ QueryResult(QString r,QString o,int s);
+ void setRichResult(QString r) { richr=r; }
+ void setRichOriginal(QString r) { richo=r; }
+
+ QString richResult() {return richr;}
+ QString richOriginal() {return richo;}
+
+ QString result(){ return res; }
+ QString original() {return orig; }
+ int score() {return sco;}
+//info contains originalkey,catalog,date,author etc...
+ ResultInfo info(){ResultInfo i; i.info="no info"; return i;}
+
+
+private:
+ QString res;
+ QString orig;
+ QString richr;
+ QString richo;
+ int sco;
+
+};
+
+class SearchFilter
+{
+ int filter; //placeholder
+};
+
+
+
+class DataBaseInterface : public QObject
+{
+
+ public:
+ //move result list typedef to AbstractAlgorthm or somewhere else
+ typedef QValueList<QueryResult> ResultList;
+ typedef QPair<DBItemMainKey,DBItemMainData> MainEntry;
+
+ DataBaseInterface( QString dir, DBSESettings *sets);
+ ~DataBaseInterface();
+
+ //Ask the Database to stop now.
+ void stop(bool b=true) {_stopNow=b;}
+
+ //Search words
+ ResultList wordsMatch(QString query,SearchFilter *filter=0,bool notify=true);
+
+ //Edit database functions.
+ //addEntry and sync all the tables
+ bool addEntry(QString original,QString translated,InputInfo *info);
+ //FIXME:implement me!
+ bool removeEntry(QString original);
+
+ //FIXME: go persistent!
+ QMap<QString,float> correlation(QString word,SearchFilter *filter=0,bool notify=true,float minSign=0.2);
+
+
+ // Read the database
+ MainEntry get(const QString& query,SearchFilter *filter=0);
+ MainEntry getFromIndex(uint i);
+ DBItemMultiIndex::IndexList getAlpha(const QString& query);
+ DBItemMultiIndex::IndexList getWordIndex(const QString& query);
+ MainEntry getSentence(const QString& query);
+
+ //Database status check functions
+ bool mainOk() {return main!=0;}
+ bool catalogOk() {return catalog!=0;}
+ bool alphaOk() {return alpha!=0;}
+ bool sentenceOk() {return sentence!=0;}
+ bool numindexOk() {return numindex!=0;}
+ bool wordsindexOk() {return wordsindex!=0;}
+ bool externalOk() {return external!=0;}
+ bool wordOk() {return word!=0;}
+ bool transwordOk() {return transword!=0;}
+ bool correlationOk() {return corr!=0;}
+ bool stopNow() {return _stopNow;}
+
+ // signals:
+ // void newResult(QueryResult);
+
+ DBSESettings *getSettings() {return settings;}
+
+ private:
+ DataBase * openMyDataBase(const QString& prefix,const QString& name,const QString& l,DBTYPE tt);
+ DataBase *main;
+ DataBase *numindex;
+ DataBase *wordsindex;
+ DataBase *catalog;
+ DataBase *alpha;
+ DataBase *sentence;
+ DataBase *word;
+ DataBase *external;
+ DataBase *transword;
+ DataBase *corr;
+ bool _stopNow;
+ DBSESettings *settings;
+
+ //FIXME:Move to KBabel common library.
+ public:
+ QString format( QString _s,QString t);
+ QString formatRegExp(QString _s, QString t, QString tre,QString stringSearch,QString stringReplace);
+ static QStringList words(QString s);
+ static QStringList sentences(QString s);
+ static QStringList sentencesSeparator(QString s);
+ static QString simple(QString str,bool ck=false);
+ static bool isUpper(QChar s);
+ static bool isLower(QChar s);
+
+ };
+
+#endif
+
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/dbentries.cpp b/kbabel/kbabeldict/modules/dbsearchengine2/dbentries.cpp
new file mode 100644
index 00000000..4f048f9c
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/dbentries.cpp
@@ -0,0 +1,171 @@
+#include "dbentries.h"
+#include <qdatastream.h>
+
+
+void DBItem::set()
+{
+ QBuffer b(mydata);
+ b.open( IO_WriteOnly );
+ QDataStream s(&b);
+ write(&s);
+ b.close();
+ set_data(mydata.data());
+ set_size(mydata.size());
+
+}
+ void DBItem::get()
+ {
+ mydata.resize(get_size());
+ mydata.duplicate((const char *)get_data(),(unsigned int)get_size());
+
+ QDataStream *s = new QDataStream(mydata,IO_ReadOnly);
+ read(s);
+ delete s;
+ }
+
+
+
+DBItemMainKey::DBItemMainKey()
+{
+ sstr="";
+ //set();
+}
+
+DBItemMainKey::DBItemMainKey(QString searchstring)
+{
+ sstr=searchstring;
+ //set();
+}
+
+void DBItemMainKey::read(QDataStream *s)
+{
+*s >> sstr;
+}
+
+void DBItemMainKey::write(QDataStream *s)
+{
+ *s << sstr;
+ }
+
+
+
+
+
+DBItemMainData::DBItemMainData()
+{
+ clear();
+ //set();
+}
+
+void DBItemMainData::clear()
+{
+ indexnumber=0;
+ translations.clear();
+ //set();
+}
+
+void DBItemMainData::read(QDataStream *s)
+{
+*s >> indexnumber >> translations;
+}
+
+void DBItemMainData::write(QDataStream *s)
+{
+ *s << (Q_UINT32)indexnumber << translations;
+}
+
+void DBItemMainData::addTranslation(QString str, unsigned int ref)
+{
+//get();
+ if(translations[str].find(ref)==translations[str].end()) // If it do not exists
+ translations[str].append(ref); //add a new reference.
+ else
+ {
+
+ }
+//set();
+
+}
+
+void DBItemMainData::removeTranslation(QString str, unsigned int ref)
+{
+//get();
+ translations[str].remove(ref);
+ if(translations[str].isEmpty())
+ translations.remove(str);
+//set();
+
+}
+
+void DBItemMainData::removeRef( unsigned int ref)
+{
+//get();
+QMapIterator<QString,QValueList<unsigned int> > it2;
+ for(QMapIterator<QString,QValueList<unsigned int> > it = translations.begin();
+ it!= translations.end(); /* it++*/)
+ { //Dirty hack
+ it2=it;
+ it++;
+ if(it2.data().find(ref)!=it2.data().end())
+ removeTranslation(it2.key(),ref);
+ }
+
+//set();
+}
+
+QStringList DBItemMainData::getTranslations()
+{
+//get();
+QStringList result;
+ for(QMapIterator<QString,QValueList<unsigned int> > it = translations.begin();
+ it!= translations.end(); it++)
+ result.append(it.key());
+
+return result;
+
+}
+
+QValueList<unsigned int> DBItemMainData::getReferences(QString str)
+{
+//get();
+return translations[str]; //this also add a "str" entry but we do not call set()!
+}
+
+
+
+DBItemMultiIndex::DBItemMultiIndex()
+{
+list.clear();
+//set();
+}
+
+void DBItemMultiIndex::addEntry(unsigned int index)
+{
+// get();
+ if(list.find(index)==list.end())
+ {
+ list.append(index);
+ qHeapSort(list);
+ // set();
+
+ }
+
+}
+
+void DBItemMultiIndex::removeEntry(unsigned int index)
+{
+// get();
+ list.remove(index);
+// set();
+}
+
+
+void DBItemMultiIndex::read(QDataStream *s)
+{
+*s >> list;
+}
+
+void DBItemMultiIndex::write(QDataStream *s)
+{
+ *s << list;
+ }
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/dbentries.h b/kbabel/kbabeldict/modules/dbsearchengine2/dbentries.h
new file mode 100644
index 00000000..0a40878c
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/dbentries.h
@@ -0,0 +1,170 @@
+#ifndef DBENTRIES_H
+#define DBENTRIES_H
+
+#include <db4/db_cxx.h>
+#include <qstring.h>
+#include <qbuffer.h>
+#include <qmap.h>
+#include <qstringlist.h>
+#include <qdatetime.h>
+
+class CatalogInfo
+{
+
+ QString author;
+ QDateTime datetime;
+ QString filename;
+ QString filepath;
+
+
+};
+
+class ResultInfo
+{
+public:
+//Common info
+ QString original; //placeholder
+
+//
+//Multi reference info
+ QValueList<CatalogInfo> catalogs;
+
+ QString info;
+
+};
+
+class InputInfo
+{
+public:
+ unsigned int ref() {return 1;}
+
+};
+
+class DBItem : public Dbt
+{
+public:
+
+ virtual ~DBItem(){}
+
+ virtual bool isEmpty(){return empty;}
+//void fromDbt(Dbt *dbt);
+
+ void set();
+ void get();
+
+
+protected:
+ virtual void read(QDataStream *s) = 0;
+ virtual void write(QDataStream *s) = 0;
+ QByteArray mydata;
+ bool empty;
+
+};
+
+class DBItemMainKey : public DBItem
+{
+ public:
+ DBItemMainKey();
+ DBItemMainKey(QString searchstring);
+
+
+ QString getString(){ return sstr;}
+
+private:
+
+ virtual void read(QDataStream *s);
+ virtual void write(QDataStream *s);
+
+ QString sstr;
+
+};
+
+
+class DBItemMainData : public DBItem
+{
+ public:
+
+ typedef QMapIterator<QString,QValueList<unsigned int> > TranslationIterator;
+ typedef QMap<QString,QValueList<unsigned int> > TranslationMap;
+
+ DBItemMainData();
+
+ QStringList getTranslations();
+ QValueList<unsigned int> getReferences(QString str);
+
+ void clear();
+
+
+//Add a translation with reference ref, if translation exists append
+// ref to the list of references
+ void addTranslation(QString str,unsigned int ref);
+ void removeTranslation(QString str,unsigned int ref);
+
+//remove any reference to ref, if ref is the only reference of a translation
+// the translation is removed
+ void removeRef(unsigned int ref);
+
+ unsigned int getIndexnumber(){ return indexnumber; }
+ void setIndexnumber(int i){ indexnumber=i; }
+
+private:
+
+ virtual void read(QDataStream *s);
+ virtual void write(QDataStream *s);
+
+ unsigned int indexnumber;
+ TranslationMap translations;
+
+};
+
+
+class DBItemMultiIndex : public DBItem
+{
+ public:
+ typedef QValueList<unsigned int> IndexList;
+
+ DBItemMultiIndex();
+ // DBItemMultiIndex(IndexList l);
+
+ void addEntry(unsigned int index);
+ void removeEntry(unsigned int index);
+
+ IndexList getList(){ return list;}
+ void clear() {list.clear();}
+
+private:
+
+ virtual void read(QDataStream *s);
+ virtual void write(QDataStream *s);
+
+ IndexList list;
+
+};
+
+
+class DBItemNum : public Dbt
+{
+ public:
+ DBItemNum(){
+ set_data(&num);
+ set_size(4);
+ num=0;
+ }
+ DBItemNum(unsigned int i){
+ set_data(&num);
+ set_size(4);
+ num=i;
+ }
+
+ unsigned int getNum(){ num=*(unsigned int *)get_data(); return num;}
+
+private:
+
+ unsigned int num;
+
+};
+
+
+
+
+#endif
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/dbscan.cpp b/kbabel/kbabeldict/modules/dbsearchengine2/dbscan.cpp
new file mode 100644
index 00000000..b19b2db2
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/dbscan.cpp
@@ -0,0 +1,280 @@
+/***************************************************************************
+ dbscan.cpp - Scan for po files to add in the DB
+ -------------------
+ begin : Fri Sep 8 2000
+ copyright : (C) 2000 by Andrea Rizzi
+ email : rizzi@kde.org
+ ***************************************************************************/
+
+/*
+ Translation search engine
+
+
+ Copyright 2000
+ Andrea Rizzi rizzi@kde.org
+
+ License GPL v 2.0
+
+*/
+#include "dbscan.h"
+#include <kconfig.h>
+#include <qdir.h>
+#include <qfile.h>
+#include <kapplication.h>
+#include <kurl.h>
+#include <kdebug.h>
+#include <klineedit.h>
+#include <kurlrequester.h>
+#include <kcombobox.h>
+
+using namespace KBabel;
+
+MessagesSource::MessagesSource()
+{
+ //FIXMR: check if we should put something in that constructor
+}
+void MessagesSource::writeConfig(KConfigBase *config)
+{
+ config->writeEntry("Location",location.url());
+ config->writeEntry("LocationType",type);
+ config->writeEntry("ProjectName",projectName);
+ config->writeEntry("ProjectKeywords",projectKeywords);
+ config->writeEntry("Status",status);
+}
+
+void MessagesSource::readConfig(KConfigBase *config)
+{
+ location=config->readEntry("Location");
+ type=config->readNumEntry("LocationType",0);
+ projectName=config->readEntry("ProjectName");
+ projectKeywords=config->readEntry("ProjectKeywords");
+ status=config->readEntry("Status");
+
+}
+
+void MessagesSource::setDialogValues(SourceDialog *sd)
+{
+ sd->projectName->setText(projectName);
+ sd->projectKeywords->setText(projectKeywords);
+ sd->sourceLocation->setURL(location.url());
+ sd->status->setCurrentText(status);
+ sd->type->setCurrentItem(type);
+}
+void MessagesSource::getDialogValues(SourceDialog *sd)
+{
+ projectName=sd->projectName->text();
+ projectKeywords=sd->projectKeywords->text();
+ location=sd->sourceLocation->url();
+ status=sd->status->currentText();
+ type=sd->type->currentItem();
+}
+
+QValueList<KURL> MessagesSource::urls()
+{
+ QValueList<KURL> urlList;
+ if(type==0)
+ urlList.append(location);
+ if(type==1|| type==2)
+ urlList=filesInDir(location,(type==2));
+
+ return urlList;
+
+}
+
+QValueList<KURL> MessagesSource::filesInDir(KURL url,bool recursive)
+{
+ QValueList<KURL> result;
+ QDir d(url.path());
+ d.setMatchAllDirs(true);
+ kdDebug(0) << d.count() << " files in dir "<< url.path()<<endl;
+ const QFileInfoList* files = d.entryInfoList();
+ kdDebug(0) << files << endl;
+
+ // QPtrListIterator<QFileInfo> it(*files);
+ if(files){
+ for (QPtrListIterator<QFileInfo> fileit(*files); !fileit.atLast(); ++fileit )
+ {
+ if ((*fileit)->isDir())
+ {
+ if(recursive)
+ {
+ if((*fileit)->fileName()!="." && (*fileit)->fileName() !="..")
+ {
+ result+=filesInDir(KURL((*fileit)->absFilePath()),recursive);
+ kdDebug(0) << "Recursion done for " << (*fileit)->fileName() << endl;
+ }
+ }
+
+ }
+ else
+ {
+ kdDebug(0) << (*fileit)->fileName() << endl;
+ result.append(KURL((*fileit)->absFilePath()));
+ }
+ }
+ }
+ kdDebug(0) << result.count() << endl;
+
+ return result;
+}
+
+//FIXME: clean this class
+PoScanner::PoScanner(DataBaseInterface *dbi,
+ QObject *parent,const char *name):QObject(parent,name)
+{
+ di=dbi;
+ removeOldCatalogTranslation=true;
+ count=0;
+}
+
+bool PoScanner::scanPattern(QString pathName,QString pattern,bool rec)
+{
+int tot;
+//Only one progress bar!!
+
+bool pb=false;
+static bool called=false;
+if (!called)
+{ pb=true; count=0;}
+called=true;
+
+kdDebug(0) << QString("Scanning: %1, %2").arg(pathName).arg(pattern) << endl;
+
+if(pb)
+{
+emit patternStarted();
+emit patternProgress(0);
+}
+ QDir d(pathName,pattern);
+ d.setMatchAllDirs(true);
+ const QFileInfoList* files = d.entryInfoList();
+ tot=files->count();
+ QPtrListIterator<QFileInfo> it(*files);
+kdDebug(0) << tot << endl;
+ for ( int i=0; i<tot; i++ )
+ {
+ if ((*it)->isDir())
+ {
+ if(rec)
+ {
+ kdDebug(0) << d[i] << endl;
+ if(d[i]!="." && d[i]!="..")
+ scanPattern(pathName+"/"+d[i],pattern,true);
+ }
+ } else
+ {
+ kdDebug(0) << d[i] << endl;
+ scanFile(pathName+"/"+d[i]);
+ }
+
+ if(pb)
+
+ emit patternProgress(100*i/tot);
+
+
+ ++it;
+ }
+
+
+
+if(pb)
+emit patternProgress(100);
+
+
+if(pb)
+emit patternFinished();
+if(pb){called=false;count=0;}
+
+return true;
+}
+
+bool PoScanner::scanFile(QString fileName)
+{
+ KURL u(fileName);
+ return scanURL(u);
+}
+
+bool PoScanner::scanURL(KURL u)
+{
+
+
+emit fileStarted();
+
+Catalog * catalog=new Catalog(this,"ScanPoCatalog");
+
+QString pretty=u.prettyURL();
+QString location=pretty.right(pretty.length()-pretty.findRev("/")-1);
+
+connect(catalog,SIGNAL(signalProgress(int)),this,SIGNAL(fileLoading(int)));
+emit filename(location);
+emit fileProgress(0);
+emit fileLoading(0);
+
+bool error;
+
+ConversionStatus rr=catalog->openURL(u);
+if(rr != OK && rr !=RECOVERED_PARSE_ERROR )
+{
+ delete catalog;
+ return false;
+}
+emit fileLoading(100);
+
+QString author;
+if(rr != HEADER_ERROR)
+ author=catalog->lastTranslator();
+else author=QString("");
+
+//int catnum=dm->catalogRef(location,author,fileName);
+InputInfo ii;
+
+
+uint i,tot;
+tot=catalog->numberOfEntries();
+
+bool fuzzy;
+bool untra;
+
+
+for (i=0;i<tot;i++) //Skip header = ????
+{
+
+ if(i % 10==0)
+ {
+ emit fileProgress(100*i/tot);
+ emit added(count);
+ kapp->processEvents(100);
+ }
+
+ fuzzy=catalog->isFuzzy(i);
+ untra=catalog->isUntranslated(i);
+
+
+ if(!fuzzy && !untra)
+ {
+ int res;
+ QString msgid,msgstr;
+ msgid=catalog->msgid(i,true).first();
+ msgstr=catalog->msgstr(i).first();
+ res=di->addEntry(msgid,msgstr,&ii);
+ count+=res;
+ }
+
+
+}
+
+
+// kdDebug(0) << QString("File finished") << endl;
+
+emit fileProgress(0);
+emit fileLoading(0);
+emit fileFinished();
+// dm->loadInfo(); // Sync the list of catalogs NOT NEEDED (?)
+
+delete catalog;
+
+//clear();
+return true;
+
+}
+#include "dbscan.moc"
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/dbscan.h b/kbabel/kbabeldict/modules/dbsearchengine2/dbscan.h
new file mode 100644
index 00000000..990d556c
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/dbscan.h
@@ -0,0 +1,120 @@
+/***************************************************************************
+ dbscan.h -
+ -------------------
+ begin : Fri Sep 8 2000
+ copyright : (C) 2000 by Andrea Rizzi
+ email : rizzi@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/*
+ Translation search engine
+ Copyright 2000
+ Andrea Rizzi rizzi@kde.org
+
+*/
+
+
+#ifndef _DBSCAN_H_
+#define _DBSCAN_H_
+
+#include <catalog.h>
+#include <kurl.h>
+#include "database.h"
+
+#include "sourcedialog.h"
+
+class KConfigBase;
+
+class MessagesSource
+{
+ //FIXME Use KURL and add network support
+
+ public:
+ MessagesSource();
+ void writeConfig(KConfigBase *config);
+ void readConfig(KConfigBase *config);
+ void setDialogValues(SourceDialog *sd);
+ void getDialogValues(SourceDialog *sd);
+
+ /**
+ * It returns a list of urls to scan, the list contains single file if type is "SingleFile"
+ * or a list of files if type is "SingleDir" or "RecDir"
+ */
+ QValueList<KURL> urls();
+
+ private:
+ QValueList<KURL> filesInDir(KURL url,bool recursive);
+
+ KURL location;
+ // The source type "SingleFile" =0, "SingleDirectory"=1, "RecursiveDirectory"=2
+ uint type;
+
+ /**
+ * A filter to apply on source files
+*/
+
+ SearchFilter filter;
+
+ QString projectName;
+ QString projectKeywords;
+ QString status;
+};
+
+
+class PoScanner : public QObject
+{
+ Q_OBJECT;
+
+ public:
+
+ PoScanner(DataBaseInterface *dbi,QObject *parent=0,const char *name=0);
+
+ /*
+ Scan a single PO file.
+ */
+ bool scanFile(QString fileName);
+
+ /*
+ Scan a single URL file.
+ */
+ bool scanURL(KURL u);
+
+
+ /*
+ Scan a list of space separated files with possible MetaCharacters
+ */
+ bool scanPattern(QString pathName,QString pattern="*.po",bool rec=false);
+
+
+
+
+ signals:
+ void fileStarted();
+ void fileProgress(int);
+ void fileFinished();
+ void fileLoading(int);
+ void patternStarted();
+ void patternProgress(int);
+ void patternFinished();
+ void added(int);
+ void filename(QString);
+ private:
+
+ // If true when a translation is found in a CATALOG the old translation for this CATALOG
+ // will be removed
+ bool removeOldCatalogTranslation;
+ int count;
+ DataBaseInterface *di;
+ // InfoItem cinfo;
+};
+
+
+#endif
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/dbse2.ui b/kbabel/kbabeldict/modules/dbsearchengine2/dbse2.ui
new file mode 100644
index 00000000..327a9d9d
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/dbse2.ui
@@ -0,0 +1,732 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>DBSearchEnginePrefWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>447</width>
+ <height>483</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QTabWidget" row="0" column="0">
+ <property name="name">
+ <cstring>tabWidget2</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>General</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Database</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>DB folder:</string>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="0" column="1">
+ <property name="name">
+ <cstring>dbDirectory</cstring>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>autoUpdate</cstring>
+ </property>
+ <property name="text">
+ <string>Automatic update in kbabel</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>New Entries</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Author:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="0" column="2">
+ <property name="name">
+ <cstring>checkBox2</cstring>
+ </property>
+ <property name="text">
+ <string>From kbabel</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>kLineEdit1</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Algorithm</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel5</cstring>
+ </property>
+ <property name="text">
+ <string>Minimum score:</string>
+ </property>
+ </widget>
+ <spacer row="4" column="1">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="Line" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>Algorithms to Use</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="1" column="1">
+ <property name="name">
+ <cstring>textLabel3_2</cstring>
+ </property>
+ <property name="text">
+ <string>Score:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="6" column="2">
+ <property name="name">
+ <cstring>scoreWordByWord</cstring>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="1" column="2">
+ <property name="name">
+ <cstring>scoreGlossary</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>textLabel3_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Score:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="0">
+ <property name="name">
+ <cstring>useSentence</cstring>
+ </property>
+ <property name="text">
+ <string>Fuzzy sentence archive</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>useGlossary</cstring>
+ </property>
+ <property name="text">
+ <string>Glossary</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>useExact</cstring>
+ </property>
+ <property name="text">
+ <string>Exact </string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="4" column="2">
+ <property name="name">
+ <cstring>scoreDivide</cstring>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="0" column="2">
+ <property name="name">
+ <cstring>scoreExact</cstring>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="3" column="2">
+ <property name="name">
+ <cstring>scoreSentence</cstring>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="4" column="0">
+ <property name="name">
+ <cstring>useDivide</cstring>
+ </property>
+ <property name="text">
+ <string>Sentence by sentence</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>useAlpha</cstring>
+ </property>
+ <property name="text">
+ <string>Alphanumeric</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="1">
+ <property name="name">
+ <cstring>textLabel3_2_3</cstring>
+ </property>
+ <property name="text">
+ <string>Score:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="1">
+ <property name="name">
+ <cstring>textLabel3_2_4</cstring>
+ </property>
+ <property name="text">
+ <string>Score:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Score:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="2" column="2">
+ <property name="name">
+ <cstring>scoreAlpha</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="6" column="1">
+ <property name="name">
+ <cstring>textLabel3_2_6</cstring>
+ </property>
+ <property name="text">
+ <string>Score:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="5" column="1">
+ <property name="name">
+ <cstring>textLabel3_2_5</cstring>
+ </property>
+ <property name="text">
+ <string>Score:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="6" column="0">
+ <property name="name">
+ <cstring>useWordByWord</cstring>
+ </property>
+ <property name="text">
+ <string>Word by word</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="5" column="0">
+ <property name="name">
+ <cstring>useDynamic</cstring>
+ </property>
+ <property name="text">
+ <string>Dynamic dictionary</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="5" column="2">
+ <property name="name">
+ <cstring>scoreDynamic</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Preferred number of results:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="2" column="2">
+ <property name="name">
+ <cstring>numberOfResult</cstring>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="3" column="2">
+ <property name="name">
+ <cstring>minScore</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Output</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox4</cstring>
+ </property>
+ <property name="title">
+ <string>Output Processing</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>firstCapital</cstring>
+ </property>
+ <property name="text">
+ <string>First capital letter match</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>allCapital</cstring>
+ </property>
+ <property name="text">
+ <string>All capital letter match</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>accelerator</cstring>
+ </property>
+ <property name="text">
+ <string>Accelerator symbol (&amp;&amp;)</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="1">
+ <property name="name">
+ <cstring>sameLetter</cstring>
+ </property>
+ <property name="text">
+ <string>Try to use same letter</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox5</cstring>
+ </property>
+ <property name="title">
+ <string>Custom Rules</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Original string regexp:</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>kLineEdit1_2</cstring>
+ </property>
+ </widget>
+ <widget class="QListView" row="3" column="0" rowspan="3" colspan="2">
+ <column>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Description</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>customRules</cstring>
+ </property>
+ </widget>
+ <spacer row="5" column="2">
+ <property name="name">
+ <cstring>spacer7_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton" row="4" column="2">
+ <property name="name">
+ <cstring>deleteRule</cstring>
+ </property>
+ <property name="text">
+ <string>Delete</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="3" column="2">
+ <property name="name">
+ <cstring>addRule</cstring>
+ </property>
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel3_3</cstring>
+ </property>
+ <property name="text">
+ <string>Replace string:</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="2" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>kLineEdit3</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="1" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>kLineEdit2</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Translated regexp(search):</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Import</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox6</cstring>
+ </property>
+ <property name="title">
+ <string>Options</string>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>checkLang</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>30</y>
+ <width>150</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Check language</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>useFilters</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>60</y>
+ <width>140</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Use current filters</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>dateToday</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>90</y>
+ <width>180</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Set date to today</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox7</cstring>
+ </property>
+ <property name="title">
+ <string>Sources</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>editSource</cstring>
+ </property>
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="2" column="1">
+ <property name="name">
+ <cstring>removeSource</cstring>
+ </property>
+ <property name="text">
+ <string>Remove</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="3" column="1">
+ <property name="name">
+ <cstring>scanSource</cstring>
+ </property>
+ <property name="text">
+ <string>Scan Now</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>addSource</cstring>
+ </property>
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ <spacer row="4" column="1">
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton" row="5" column="1">
+ <property name="name">
+ <cstring>scanAll</cstring>
+ </property>
+ <property name="text">
+ <string>Scan All</string>
+ </property>
+ </widget>
+ <widget class="QListBox" row="0" column="0" rowspan="6" colspan="1">
+ <property name="name">
+ <cstring>sourceList</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Filters</string>
+ </attribute>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/dbse2_factory.cpp b/kbabel/kbabeldict/modules/dbsearchengine2/dbse2_factory.cpp
new file mode 100644
index 00000000..9c286052
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/dbse2_factory.cpp
@@ -0,0 +1,83 @@
+
+#include <klocale.h>
+#include <kinstance.h>
+#include <kaboutdata.h>
+#include <kdebug.h>
+
+#include "dbse2_factory.h"
+#include "KDBSearchEngine2.h"
+
+
+extern "C"
+{
+ KDE_EXPORT void *init_kbabeldict_dbsearchengine2()
+// void *init_libdbsearchengine2()
+ {
+ return new DbSe2Factory;
+ }
+};
+
+
+KInstance *DbSe2Factory::s_instance = 0;
+KAboutData *DbSe2Factory::s_about = 0;
+
+
+DbSe2Factory::DbSe2Factory( QObject *parent, const char *name)
+ : KLibFactory(parent,name)
+{
+}
+
+DbSe2Factory::~DbSe2Factory()
+{
+ if(s_instance)
+ {
+ delete s_instance;
+ s_instance=0;
+ }
+
+ if(s_about)
+ {
+ delete s_about;
+ s_about=0;
+ }
+}
+
+
+QObject *DbSe2Factory::createObject( QObject *parent, const char *name,
+ const char *classname, const QStringList &)
+{
+ if(QCString(classname) != "SearchEngine")
+ {
+ kdError() << "not a SearchEngine requested" << endl;
+ return 0;
+ }
+
+ KDBSearchEngine2 *se = new KDBSearchEngine2(parent,name);
+
+ emit objectCreated(se);
+ return se;
+}
+
+
+KInstance *DbSe2Factory::instance()
+{
+ if(!s_instance)
+ {
+
+ s_about = new KAboutData( "kdbsearchengine2",
+ I18N_NOOP("Translation Database")
+ , "1.99" ,
+I18N_NOOP("A fast translation search engine based on databases")
+ , KAboutData::License_GPL
+ , I18N_NOOP("Copyright 2000-2003 by Andrea Rizzi")
+ ,0,0, "rizzi@kde.org");
+
+ s_about->addAuthor("Andrea Rizzi",0,"rizzi@kde.org");
+
+ s_instance = new KInstance(s_about);
+ }
+
+ return s_instance;
+}
+
+#include "dbse2_factory.moc"
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/dbse2_factory.h b/kbabel/kbabeldict/modules/dbsearchengine2/dbse2_factory.h
new file mode 100644
index 00000000..4285d53c
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/dbse2_factory.h
@@ -0,0 +1,26 @@
+#ifndef DBSE2_FACTORY_H
+#define DBSE2_FACTORY_H
+
+#include <klibloader.h>
+class KInstance;
+class KAboutData;
+
+class DbSe2Factory : public KLibFactory
+{
+ Q_OBJECT
+public:
+ DbSe2Factory( QObject *parent=0, const char *name=0);
+ ~DbSe2Factory();
+
+ virtual QObject *createObject( QObject *parent=0, const char *name=0,
+ const char *classname="QObject",
+ const QStringList &args = QStringList());
+
+ static KInstance *instance();
+
+private:
+ static KInstance *s_instance;
+ static KAboutData *s_about;
+};
+
+#endif
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/dbsearchengine2.desktop b/kbabel/kbabeldict/modules/dbsearchengine2/dbsearchengine2.desktop
new file mode 100644
index 00000000..a46bfff1
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/dbsearchengine2.desktop
@@ -0,0 +1,52 @@
+[Desktop Entry]
+Type=Service
+Name=Translation Database v2 for KBabelDict
+Name[bg]=БД с преводи v2 за KBabelDict
+Name[br]=Stlennvon geriaoueg v2 evit KBabelDict
+Name[bs]=Baza prijevoda v2 za KBabelDict
+Name[ca]=Base de dades de traducció v2 per a KBabelDict
+Name[cs]=Databáze překladů v2 pro KBabelDict
+Name[cy]=Cronfa ddata Cyfieithiadau v2 i KBabelDict
+Name[da]=Oversættelsesdatabase v2 for KBabelDict
+Name[de]=Übersetzungsdatenbank Version 2 für KBabelDict
+Name[el]=Βάση δεδομένων μετάφρασης έκδοση 2 για το KBabelDict
+Name[es]=Base de datos de traducciones v2 para KBabelDict
+Name[et]=KBabelDicti tõlgete andmebaas (versioon 2)
+Name[eu]=v2 itzulpen datu-basea KBabelDict-entzat
+Name[fa]=دادگان ترجمۀ نسخه ۲ برای KBabelDict
+Name[fi]=KBabelDict-ohjelman käännöstietokanta v2
+Name[fr]=Base de données des traductions v2 pour KBabelDict
+Name[ga]=Cuimhne Aistriúcháin (v2) le haghaidh KBabelDict
+Name[gl]=Base de datos de traducións v2 de KBabelDict
+Name[hi]=के-बेबल-डिक्श के लिए अनुवाद डाटाबेस वी2
+Name[hu]=Fordítási adatbázis (v2) a KBabelDicthez
+Name[is]=Þýðingagagnagrunnur v2 fyrir KBabel orðabókina
+Name[it]=Banca dati delle traduzioni v2 per KBabelDict
+Name[ja]=KBabelDict トランザクションデータベース v2
+Name[ka]=თარგმნის მონაცემთა ბაზა ვ2 KBabelDict-სთვის
+Name[kk]=KBabelDict-тың аударма деректер қорының 2-нұсқасы
+Name[lt]=KBabelDict vertimų duomenų bazės 2 versija
+Name[ms]=Pangkalan Data Penterjemahan v2 KBabelDict
+Name[nb]=Oversettelsesdatabase versjon 2 for KBabelDict
+Name[nds]=Översettendatenbank V2 för KBabelDict
+Name[ne]=KBabelDict का लागि अनुबाद डाटाबेस v2
+Name[nl]=Vertalingendatabase versie2 voor KBabelDict
+Name[nn]=Omsetjingsdatabase versjon 2 for KBabelDict
+Name[pa]=ਕੇਬਬੇਲ-ਸ਼ਬਦ-ਕੋਸ਼ ਲਈ ਅਨੁਵਾਦ ਡਾਟਾਬੇਸ ਵਰਜਨ2
+Name[pl]=Baza tłumaczeń v2 dla KBabelDict
+Name[pt]=Base de Dados de Traduções v2 do KBabelDict
+Name[pt_BR]=Banco de Dados de Traduções v2 para o KBabelDict
+Name[ru]=Версия 2 базы данных перевода для KBabelDict
+Name[sk]=Databáza prekladov v2 pre KBabelDict
+Name[sl]=Zbirka prevodov različice 2 za KBabelDict
+Name[sr]=Преводилачка база података v2 за KBabelDict
+Name[sr@Latn]=Prevodilačka baza podataka v2 za KBabelDict
+Name[sv]=Översättningsdatabas version 2 för Kbabeldict
+Name[ta]= Kபாபேலுக்கான மொழிபெயர்ப்பு தரவுத்தளம் v2
+Name[tg]=Тафсири 2 базаи маълумоти тарҷумаҳо барои KBabelDict
+Name[tr]=KBabelDict için Çeviri Veritabanı v2
+Name[uk]=Версія 2 бази даних перекладів для KBabelDict
+Name[zh_CN]=KBabelDict 的翻译数据库 v2
+Name[zh_TW]=KBabelDict 翻譯資料庫 v2
+X-KDE-Library=kbabeldict_dbsearchengine2
+ServiceTypes=KBabelDictModule
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/dbseprefwidget.ui b/kbabel/kbabeldict/modules/dbsearchengine2/dbseprefwidget.ui
new file mode 100644
index 00000000..c233265f
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/dbseprefwidget.ui
@@ -0,0 +1,1039 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>DBSearchEnginePref</class>
+<author>Andrea Rizzi &lt;rizzi@kde.org&gt;</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>DBSEPrefWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>414</width>
+ <height>426</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>DBSEPrefWidget</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QTabWidget" row="0" column="0">
+ <property name="name">
+ <cstring>TabWidget6</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string></string>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>Widget4</cstring>
+ </property>
+ <attribute name="title">
+ <string>Generic</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>ButtonGroup2</cstring>
+ </property>
+ <property name="title">
+ <string>Search Mode</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>allRB</cstring>
+ </property>
+ <property name="text">
+ <string>Search in whole database (slow)</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qml&gt;Scroll the whole database and return everything that matches
+according to the rules defined in tabs &lt;strong&gt; Generic &lt;/strong&gt;
+and &lt;strong&gt;Match&lt;/strong&gt;</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>slistRB</cstring>
+ </property>
+ <property name="text">
+ <string>Search in list of "good keys" (best)</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qml&gt;Search in a list of &lt;em&gt;good keys&lt;/em&gt; (see &lt;strong&gt;Good keys&lt;/strong&gt; tab) with rules defined in &lt;strong&gt;Search&lt;/strong&gt; tab.
+This is the best way to search because the &lt;em&gt;good keys&lt;/em&gt; list probably contains all the keys that match with your query. However, it is smaller than the whole database.</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>rlistRB</cstring>
+ </property>
+ <property name="text">
+ <string>Return the list of "good keys" (fast)</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qml&gt;Returns the whole &lt;em&gt;good keys&lt;/em&gt; list. Rules defined in &lt;strong&gt;Search&lt;/strong&gt; tab are ignored.</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>caseSensitiveCB</cstring>
+ </property>
+ <property name="text">
+ <string>Case sensitive</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qml&gt;If it is checked the search will be case sensitive. It is ignored if you use &lt;em&gt;Return the list of "good keys"&lt;/em&gt; search mode.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>normalizeCB</cstring>
+ </property>
+ <property name="text">
+ <string>Normalize white space</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Remove white spaces at the beginning and at the end of the phrase.
+It also substitutes groups of more than one space character with only one space character.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>removeContextCB</cstring>
+ </property>
+ <property name="text">
+ <string>Remove context comment</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Remove, if exists, the _:comment</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout11</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Character to be ignored:</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>ignoreLE</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>20</height>
+ </size>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>Widget5</cstring>
+ </property>
+ <attribute name="title">
+ <string>Search</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>ButtonGroup1</cstring>
+ </property>
+ <property name="title">
+ <string>Matching Method</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>Spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>Spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox" row="2" column="1">
+ <property name="name">
+ <cstring>containedCB</cstring>
+ </property>
+ <property name="text">
+ <string>Query is contained</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Match if query is contained in database string</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="1">
+ <property name="name">
+ <cstring>containsCB</cstring>
+ </property>
+ <property name="text">
+ <string>Query contains</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Match if query contains the database string</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>normalTextRB</cstring>
+ </property>
+ <property name="text">
+ <string>Normal text</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Consider the search string as normal text.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="1">
+ <property name="name">
+ <cstring>equalCB</cstring>
+ </property>
+ <property name="text">
+ <string>Equal</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="tristate">
+ <bool>false</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Match if query and database string are equal</string>
+ </property>
+ </widget>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>Spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QRadioButton" row="4" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>RegExpRB</cstring>
+ </property>
+ <property name="text">
+ <string>Regular expression</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Consider the search string as a regular expression</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>GroupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>Word Substitution</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qml&gt;If you use one or two &lt;em&gt;word substitution&lt;/em&gt; each time you search a phrase with less than the specified number of words, the search engine will also search for all phrases that differ from the original one in one or two words.&lt;p&gt;
+&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
+If you search for &lt;em&gt;My name is Andrea&lt;/em&gt; and you have activated &lt;em&gt;one word substitution&lt;/em&gt; you may also find phrases like &lt;em&gt;My name is Joe&lt;/em&gt; or &lt;em&gt;Your name is Andrea&lt;/em&gt;.</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>Spacer8</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>oneWordSubCB</cstring>
+ </property>
+ <property name="text">
+ <string>Use one word substitution</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="tristate">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>Spacer9</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="1" column="1">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Max number of words in the query:</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="3" column="2">
+ <property name="name">
+ <cstring>twoWordSubSB</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maxValue">
+ <number>14</number>
+ </property>
+ <property name="value">
+ <number>10</number>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>twoWordSubCB</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Use two word substitution</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="1">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Max number of words in the query:</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="5" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>Layout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel5_3</cstring>
+ </property>
+ <property name="text">
+ <string>[A-Za-z0-9_%</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property name="hAlign" stdset="0">
+ </property>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>regExpLE</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel6_2</cstring>
+ </property>
+ <property name="text">
+ <string>]</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="4" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>TextLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Local characters for regular expressions:</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="1" column="2">
+ <property name="name">
+ <cstring>oneWordSubSB</cstring>
+ </property>
+ <property name="maxValue">
+ <number>200</number>
+ </property>
+ <property name="minValue">
+ <number>2</number>
+ </property>
+ <property name="value">
+ <number>40</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer1_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>Widget6</cstring>
+ </property>
+ <attribute name="title">
+ <string>Database</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>TextLabel7_2</cstring>
+ </property>
+ <property name="text">
+ <string>Database folder:</string>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>dirInput</cstring>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>autoAddCB_2</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Auto add entry to database</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Automatically add an entry to the database if a new translation is notified by someone (may be kbabel)</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>Layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel1_4</cstring>
+ </property>
+ <property name="text">
+ <string>Auto added entry author:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>authorLE</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qml&gt;Put here the name and email address that you want to use as &lt;em&gt;last translator&lt;/em&gt; filed when you auto-add entry to the database (e.g. when you modify a translation with kbabel).&lt;p&gt;</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QPushButton" row="4" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>scanFilePB</cstring>
+ </property>
+ <property name="text">
+ <string>Scan Single PO File</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="5" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>scanPB_2</cstring>
+ </property>
+ <property name="text">
+ <string>Scan Folder</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="6" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>scanrecPB</cstring>
+ </property>
+ <property name="text">
+ <string>Scan Folder &amp;&amp; Subfolders</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="8" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>Layout5</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>filenameLB</cstring>
+ </property>
+ <property name="text">
+ <string>Scanning file:</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>entriesLB</cstring>
+ </property>
+ <property name="text">
+ <string>Entries added:</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget" row="9" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>Layout4</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QProgressBar" row="2" column="1">
+ <property name="name">
+ <cstring>processPB</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>Panel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="centerIndicator">
+ <bool>true</bool>
+ </property>
+ <property name="indicatorFollowsStyle">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Total progress:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>TextLabel3_3</cstring>
+ </property>
+ <property name="text">
+ <string>Processing file:</string>
+ </property>
+ </widget>
+ <widget class="QProgressBar" row="0" column="1">
+ <property name="name">
+ <cstring>totalPB</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>Panel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="centerIndicator">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QProgressBar" row="1" column="1">
+ <property name="name">
+ <cstring>loadingPB</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>Panel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="centerIndicator">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel2_3</cstring>
+ </property>
+ <property name="text">
+ <string>Loading file:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QPushButton" row="10" column="2">
+ <property name="name">
+ <cstring>exportPB</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Export...</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="10" column="0">
+ <property name="name">
+ <cstring>statPB</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Statistics</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="10" column="1">
+ <property name="name">
+ <cstring>repeatPB</cstring>
+ </property>
+ <property name="text">
+ <string>Repeated Strings</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Good Keys</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>GroupBox4</cstring>
+ </property>
+ <property name="title">
+ <string>Generic</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qml&gt;Here you can define how to fill the &lt;em&gt;good keys list&lt;/em&gt;.&lt;p&gt;
+You can set the minimum number of words of the query that a key must have to be inserted in the &lt;em&gt;good keys list&lt;/em&gt;.&lt;p&gt;
+You can also set the minimum number of words of the key that the query must have to insert the key in the list.&lt;p&gt;
+These two numbers are the percentage of the total number of words. If the result of this percentage is less than one, the engine will set it to one.&lt;p&gt;
+Finally you can set the maximum number of entries in the list.</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>TextLabel3_2</cstring>
+ </property>
+ <property name="text">
+ <string>Minimum number of words of the key also in the query (%):</string>
+ </property>
+ <property name="textFormat">
+ <enum>RichText</enum>
+ </property>
+ </widget>
+ <widget class="QSlider" row="1" column="0">
+ <property name="name">
+ <cstring>thresholdSL</cstring>
+ </property>
+ <property name="maxValue">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>50</number>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="1" column="1">
+ <property name="name">
+ <cstring>SpinBox5</cstring>
+ </property>
+ <property name="suffix">
+ <string>%</string>
+ </property>
+ <property name="maxValue">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>50</number>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>TextLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Minimum number of query words in the key (%):</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="4" column="1">
+ <property name="name">
+ <cstring>maxSB</cstring>
+ </property>
+ <property name="maxValue">
+ <number>5000</number>
+ </property>
+ <property name="value">
+ <number>30</number>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="3" column="1">
+ <property name="name">
+ <cstring>SpinBox6</cstring>
+ </property>
+ <property name="suffix">
+ <string>%</string>
+ </property>
+ <property name="maxValue">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>50</number>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>TextLabel4_2</cstring>
+ </property>
+ <property name="text">
+ <string>Max list length:</string>
+ </property>
+ </widget>
+ <widget class="QSlider" row="3" column="0">
+ <property name="name">
+ <cstring>thresholdOrigSL</cstring>
+ </property>
+ <property name="maxValue">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>50</number>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>GroupBox3_2</cstring>
+ </property>
+ <property name="title">
+ <string>Frequent Words</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Discard words more frequent than:</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="0" column="1">
+ <property name="name">
+ <cstring>freqSB</cstring>
+ </property>
+ <property name="suffix">
+ <string>/10000</string>
+ </property>
+ <property name="maxValue">
+ <number>10000</number>
+ </property>
+ <property name="lineStep">
+ <number>1</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>nothingCB</cstring>
+ </property>
+ <property name="text">
+ <string>Frequent words are considered as in every key</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>thresholdSL</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SpinBox5</receiver>
+ <slot>setValue(int)</slot>
+ </connection>
+ <connection>
+ <sender>thresholdOrigSL</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SpinBox6</receiver>
+ <slot>setValue(int)</slot>
+ </connection>
+ <connection>
+ <sender>SpinBox5</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>thresholdSL</receiver>
+ <slot>setValue(int)</slot>
+ </connection>
+ <connection>
+ <sender>SpinBox6</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>thresholdOrigSL</receiver>
+ <slot>setValue(int)</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in declaration">klocale.h</include>
+ <include location="global" impldecl="in declaration">kseparator.h</include>
+</includes>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/preferenceswidget.cpp b/kbabel/kbabeldict/modules/dbsearchengine2/preferenceswidget.cpp
new file mode 100644
index 00000000..7634a799
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/preferenceswidget.cpp
@@ -0,0 +1,98 @@
+#include <qradiobutton.h>
+#include <qslider.h>
+#include <qspinbox.h>
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <klocale.h>
+#include <kfiledialog.h>
+#include <kurlrequester.h>
+#include <qtoolbutton.h>
+#include <klineedit.h>
+#include <kstandarddirs.h>
+#include <knuminput.h>
+
+#include "dbse2.h"
+#include "preferenceswidget.h"
+
+KDB2PreferencesWidget::KDB2PreferencesWidget(QWidget *parent, const char* name)
+ : PrefWidget(parent,name)
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+// QLabel *label = new QLabel(i18n("Settings for KDE Database Search Engine"),this);
+// layout->addWidget(label);
+
+ dbpw = new DBSearchEnginePrefWidget(this);
+ dbpw->dbDirectory->setMode(KFile::Directory | KFile::LocalOnly);
+ dbpw->show();
+ layout->addWidget(dbpw);
+ setMinimumSize(300,300);
+
+ standard();
+
+// connect(dbpw->browseTB_3,SIGNAL(clicked()),SLOT(browse1()));
+
+ emit restoreNow(); //Fill with actual params.
+
+}
+
+KDB2PreferencesWidget::~KDB2PreferencesWidget()
+{
+}
+
+void KDB2PreferencesWidget::apply()
+{
+emit applyNow();
+}
+
+void KDB2PreferencesWidget::cancel()
+{
+emit restoreNow();
+}
+
+void KDB2PreferencesWidget::standard()
+{
+QString defaultDir;
+ KStandardDirs * dirs = KGlobal::dirs();
+ if(dirs)
+ {
+ defaultDir = dirs->saveLocation("data");
+ if(defaultDir.right(1)!="/")
+ defaultDir+="/";
+ defaultDir += "kbabeldict/dbsearchengine2";
+ }
+dbpw->dbDirectory->setURL(defaultDir);
+
+dbpw->autoUpdate->setChecked(true);
+
+dbpw->useSentence->setChecked(true);
+dbpw->useGlossary->setChecked(true);
+dbpw->useExact->setChecked(true);
+dbpw->useDivide->setChecked(true);
+dbpw->useAlpha->setChecked(true);
+dbpw->useWordByWord->setChecked(true);
+dbpw->useDynamic->setChecked(true);
+dbpw->scoreDivide->setValue(90);
+dbpw->scoreExact->setValue(100);
+dbpw->scoreSentence->setValue(90);
+dbpw->scoreWordByWord->setValue(70);
+dbpw->scoreGlossary->setValue(98);
+dbpw->scoreAlpha->setValue(98);
+dbpw->scoreDynamic->setValue(80);
+
+dbpw->numberOfResult->setValue(5);
+dbpw->minScore->setValue(60);
+
+dbpw->firstCapital->setChecked(true);
+dbpw->allCapital->setChecked(false);
+dbpw->accelerator->setChecked(true);
+dbpw->sameLetter->setChecked(true);
+dbpw->checkLang->setChecked(true);
+dbpw->useFilters->setChecked(false);
+dbpw->dateToday->setChecked(false);
+/*
+ */
+ //dbpw->dirInput->setURL(defaultDir);
+}
+
+#include "preferenceswidget.moc"
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/preferenceswidget.h b/kbabel/kbabeldict/modules/dbsearchengine2/preferenceswidget.h
new file mode 100644
index 00000000..4714fd13
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/preferenceswidget.h
@@ -0,0 +1,26 @@
+#ifndef PREFERENCESWIDGET_H
+#define PREFERENCESWIDGET_H
+
+#include "searchengine.h"
+#include "dbse2.h"
+
+class KDB2PreferencesWidget : public PrefWidget
+{
+ Q_OBJECT
+
+public:
+ KDB2PreferencesWidget(QWidget *parent=0, const char* name=0);
+ virtual ~KDB2PreferencesWidget();
+
+ virtual void apply();
+ virtual void cancel();
+ virtual void standard();
+ DBSearchEnginePrefWidget *dbpw;
+
+signals:
+ void applyNow();
+ void restoreNow();
+
+};
+
+#endif
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/sourcedialog.ui b/kbabel/kbabeldict/modules/dbsearchengine2/sourcedialog.ui
new file mode 100644
index 00000000..3f4030a0
--- /dev/null
+++ b/kbabel/kbabeldict/modules/dbsearchengine2/sourcedialog.ui
@@ -0,0 +1,266 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>SourceDialog</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>SourceDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>415</width>
+ <height>385</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Edit Source</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton" row="2" column="0">
+ <property name="name">
+ <cstring>ok</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="2" column="2">
+ <property name="name">
+ <cstring>cancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Additional Informations</string>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel6</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>11</x>
+ <y>76</y>
+ <width>108</width>
+ <height>29</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Status: </string>
+ </property>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>projectName</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>125</x>
+ <y>22</y>
+ <width>182</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>projectKeywords</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>125</x>
+ <y>49</y>
+ <width>182</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>status</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>125</x>
+ <y>76</y>
+ <width>182</width>
+ <height>29</height>
+ </rect>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>11</x>
+ <y>22</y>
+ <width>108</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Project name:</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel5</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>11</x>
+ <y>49</y>
+ <width>108</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Project keywords:</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>General Info</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>sourceName</cstring>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="1" column="1">
+ <item>
+ <property name="text">
+ <string>Single File</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Single Folder</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Recursive Folder</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>type</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Source name:</string>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="2" column="1">
+ <property name="name">
+ <cstring>sourceLocation</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="3" column="1">
+ <property name="name">
+ <cstring>filterDialog</cstring>
+ </property>
+ <property name="text">
+ <string>Setup Filter...</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Location:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="0">
+ <property name="name">
+ <cstring>useFilter</cstring>
+ </property>
+ <property name="text">
+ <string>Use filter</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>ok</sender>
+ <signal>clicked()</signal>
+ <receiver>SourceDialog</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>cancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SourceDialog</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>