~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to kbabel/kbabeldict/modules/dbsearchengine2/KDBSearchEngine2.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-28 10:11:43 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: james.westby@ubuntu.com-20080528101143-gzc3styjz1b70zxu
Tags: upstream-4.0.80
ImportĀ upstreamĀ versionĀ 4.0.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ****************************************************************************
2
 
   
3
 
DBSE2  
4
 
Andrea Rizzi
5
 
 
6
 
**************************************************************************** */
7
 
 
8
 
#ifndef DBSEARCH_ENGINE2_H
9
 
#define DBSEARCH_ENGINE2_H
10
 
 
11
 
#include <searchengine.h>
12
 
#include <qdialog.h>
13
 
 
14
 
#include "database.h"
15
 
#include "dbse2_factory.h"
16
 
#include "preferenceswidget.h"
17
 
#include "dbscan.h"
18
 
#include "sourcedialog.h"
19
 
 
20
 
//#include "DBSESettings.h"
21
 
 
22
 
class KDBSearchEngine2 : public SearchEngine
23
 
{
24
 
    Q_OBJECT
25
 
    
26
 
    public:
27
 
    
28
 
    KDBSearchEngine2(QObject *parent=0, const char *name=0);
29
 
    virtual ~KDBSearchEngine2();
30
 
    
31
 
    //init if needed.
32
 
    bool init();
33
 
    
34
 
    /** @return true, if a search is currently active */
35
 
    bool isSearching() const {return searching;}
36
 
    
37
 
    void stopSearch()  { if(di) di->stop();}
38
 
    
39
 
    
40
 
    
41
 
    /** @returns true, if it was initialized correctly */
42
 
    bool isReady() const {return iAmReady; }
43
 
    
44
 
 
45
 
    void saveSettings(KConfigBase *config);
46
 
    void readSettings(KConfigBase *config);
47
 
 
48
 
 
49
 
    QString translate(const QString text);
50
 
 
51
 
    QString fuzzyTranslation(const QString text, int &score);
52
 
    QString searchTranslation(const QString, int &score );
53
 
 
54
 
    /**
55
 
     * Finds all messages belonging to package package. If nothing is found,
56
 
     * the list is empty.
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
60
 
     *
61
 
     * @return true, if successfull
62
 
     */
63
 
    bool messagesForPackage(const QString& package
64
 
                            , QValueList<Message>& resultList, QString& error);
65
 
 
66
 
    /** 
67
 
     * @returns true, if the searchresults are given as rich text
68
 
     * the default implementation returns false
69
 
     */ 
70
 
    bool usesRichTextResults(){return true;}
71
 
    
72
 
    /** @returns true, if the the entries in the database can be edited */
73
 
    bool isEditable(){return false;}
74
 
    
75
 
    /** 
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
79
 
     * a tabbed widget.
80
 
     * @param parent the parent of the returned widget
81
 
     */
82
 
    virtual PrefWidget* preferencesWidget(QWidget *parent);
83
 
    
84
 
    /** @returns information about this SearchEngine */
85
 
    virtual const KAboutData *about() const;
86
 
    
87
 
    /** @returns the i18n name of this search engine */
88
 
    QString name() const {return i18n("DB SearchEngine II");}
89
 
    
90
 
    /** @returns a untranslated name of this engine */
91
 
    QString id() const {return "dbse2";}
92
 
    
93
 
    /** @returns the last error message */
94
 
    QString lastError() {return lasterror;}
95
 
    
96
 
    
97
 
    /**
98
 
     * sets the engine to always ask the preferences dialog for settings
99
 
     * if is existing before starting the search.
100
 
     */
101
 
    virtual void setAutoUpdateOptions(bool activate)
102
 
    {
103
 
        autoupdate=activate;
104
 
    }
105
 
    
106
 
    
107
 
    
108
 
    public slots:       
109
 
        
110
 
        void receiveResult(QueryResult r);
111
 
    
112
 
    /**
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
116
 
     */
117
 
    bool startSearch(QString s);
118
 
    
119
 
    /**
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
123
 
     */
124
 
    bool startSearchInTranslation(QString s);
125
 
    
126
 
    
127
 
    /** stops a search */
128
 
    //  virtual void stopSearch() ;
129
 
    
130
 
    
131
 
    /**
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
135
 
     */
136
 
    //    virtual void setEditedFile(QString file);
137
 
    
138
 
    /**
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.
142
 
     */
143
 
    //    virtual void setEditedPackage(QString package);
144
 
    
145
 
    /**
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).
149
 
     */ 
150
 
    //    virtual void setLanguageCode(QString lang);
151
 
    //    virtual void setLanguage(QString languageCode, QString languageName);
152
 
    
153
 
    
154
 
    
155
 
    /**
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
158
 
     * name
159
 
     * @param orig the original string
160
 
     * @param translation the translated string  
161
 
     */
162
 
    
163
 
    void stringChanged( QString orig, QString translated
164
 
                        , QString description);
165
 
    
166
 
    //void scan();
167
 
    
168
 
    void  setLastError(QString er);
169
 
    
170
 
    //Slots for preference dialog
171
 
  //  void  scanSource(QString sourceName);
172
 
    void  scanNowPressed();
173
 
    void  scanAllPressed();
174
 
    void  editSource();
175
 
    void  removeSource();
176
 
    void  addSource();
177
 
    
178
 
        
179
 
    private:
180
 
    DataBaseInterface *di;
181
 
    bool searching;
182
 
    bool iAmReady;
183
 
    bool autoupdate;
184
 
    QString lasterror;
185
 
    KDB2PreferencesWidget *pw;
186
 
    
187
 
    //PrefWidg -> DBSE
188
 
    void updateSettings();
189
 
    //DBSE -> PrefWidg
190
 
    void    setSettings();
191
 
    
192
 
    DBSESettings settings;
193
 
    QString dbDirectory;
194
 
    bool autoAdd,useSentence,useGlossary,useExact;
195
 
    bool useDivide,useAlpha,useWordByWord,useDynamic;
196
 
    uint numberOfResult;
197
 
    QMap<QString,MessagesSource> sources;
198
 
    
199
 
};
200
 
 
201
 
 
202
 
#endif // SEARCH_ENGINE2_H