1
/* ****************************************************************************
6
**************************************************************************** */
8
#ifndef DBSEARCH_ENGINE2_H
9
#define DBSEARCH_ENGINE2_H
11
#include <searchengine.h>
15
#include "dbse2_factory.h"
16
#include "preferenceswidget.h"
18
#include "sourcedialog.h"
20
//#include "DBSESettings.h"
22
class KDBSearchEngine2 : public SearchEngine
28
KDBSearchEngine2(QObject *parent=0, const char *name=0);
29
virtual ~KDBSearchEngine2();
34
/** @return true, if a search is currently active */
35
bool isSearching() const {return searching;}
37
void stopSearch() { if(di) di->stop();}
41
/** @returns true, if it was initialized correctly */
42
bool isReady() const {return iAmReady; }
45
void saveSettings(KConfigBase *config);
46
void readSettings(KConfigBase *config);
49
QString translate(const QString text);
51
QString fuzzyTranslation(const QString text, int &score);
52
QString searchTranslation(const QString, int &score );
55
* Finds all messages belonging to package package. If nothing is found,
57
* @param package The name of the file, something like "kbabel.po"
58
* @param resultList Will contain the found messages afterwards
59
* @param error If an error occured, this should contain a description
61
* @return true, if successfull
63
bool messagesForPackage(const QString& package
64
, QValueList<Message>& resultList, QString& error);
67
* @returns true, if the searchresults are given as rich text
68
* the default implementation returns false
70
bool usesRichTextResults(){return true;}
72
/** @returns true, if the the entries in the database can be edited */
73
bool isEditable(){return false;}
76
* @returns a widget which lets the user setup all preferences of this
77
* search engine. The returned widget should not be bigger than
78
* 400x400. If you need more space, you maybe want to use
80
* @param parent the parent of the returned widget
82
virtual PrefWidget* preferencesWidget(QWidget *parent);
84
/** @returns information about this SearchEngine */
85
virtual const KAboutData *about() const;
87
/** @returns the i18n name of this search engine */
88
QString name() const {return i18n("DB SearchEngine II");}
90
/** @returns a untranslated name of this engine */
91
QString id() const {return "dbse2";}
93
/** @returns the last error message */
94
QString lastError() {return lasterror;}
98
* sets the engine to always ask the preferences dialog for settings
99
* if is existing before starting the search.
101
virtual void setAutoUpdateOptions(bool activate)
110
void receiveResult(QueryResult r);
113
* starts a search for string s in the original text
114
* @returns false, if an error occured. Use @ref lastError
115
* to get the last error message
117
bool startSearch(QString s);
120
* starts a search for string s in the translated text
121
* @returns false, if an error occured. Use @ref lastError
122
* to get the last error message
124
bool startSearchInTranslation(QString s);
127
/** stops a search */
128
// virtual void stopSearch() ;
132
* This method allows a search engine to use different settings depending
133
* on the edited file. The default implementation does nothing.
134
* @param file The edited file with path
136
// virtual void setEditedFile(QString file);
139
* This method allows a search engine to use different settings depending
140
* on the edited package. The default implementation does nothing.
141
* @param package The name of the package, that is currently translated.
143
// virtual void setEditedPackage(QString package);
146
* This method allows a search engine to use different settings depending
147
* on the language code. The default implementation does nothing.
148
* @param lang The current language code (e.g. de).
150
// virtual void setLanguageCode(QString lang);
151
// virtual void setLanguage(QString languageCode, QString languageName);
156
* This method is called, if something has been changed in the
157
* current file. See @ref setEditedFile if you want to know the file
159
* @param orig the original string
160
* @param translation the translated string
163
void stringChanged( QString orig, QString translated
164
, QString description);
168
void setLastError(QString er);
170
//Slots for preference dialog
171
// void scanSource(QString sourceName);
172
void scanNowPressed();
173
void scanAllPressed();
180
DataBaseInterface *di;
185
KDB2PreferencesWidget *pw;
188
void updateSettings();
192
DBSESettings settings;
194
bool autoAdd,useSentence,useGlossary,useExact;
195
bool useDivide,useAlpha,useWordByWord,useDynamic;
197
QMap<QString,MessagesSource> sources;
202
#endif // SEARCH_ENGINE2_H