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

« back to all changes in this revision

Viewing changes to kbabel/kbabeldict/modules/pocompendium/pocompendium.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
 
  This file is part of KBabel
3
 
 
4
 
  Copyright (C) 2000 by Matthias Kiefer
5
 
                            <matthias.kiefer@gmx.de>
6
 
 
7
 
  This program is free software; you can redistribute it and/or modify
8
 
  it under the terms of the GNU General Public License as published by
9
 
  the Free Software Foundation; either version 2 of the License, or
10
 
  (at your option) any later version.
11
 
 
12
 
  This program is distributed in the hope that it will be useful,
13
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
  GNU General Public License for more details.
16
 
 
17
 
  You should have received a copy of the GNU General Public License
18
 
  along with this program; if not, write to the Free Software
19
 
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 
 
21
 
  In addition, as a special exception, the copyright holders give
22
 
  permission to link the code of this program with any edition of
23
 
  the Qt library by Trolltech AS, Norway (or with modified versions
24
 
  of Qt that use the same license as Qt), and distribute linked
25
 
  combinations including the two.  You must obey the GNU General
26
 
  Public License in all respects for all of the code used other than
27
 
  Qt. If you modify this file, you may extend this exception to
28
 
  your version of the file, but you are not obligated to do so.  If
29
 
  you do not wish to do so, delete this exception statement from
30
 
  your version.
31
 
 
32
 
**************************************************************************** */
33
 
 
34
 
#ifndef POCOMPENDIUM_H
35
 
#define POCOMPENDIUM_H
36
 
 
37
 
#include <poinfo.h>
38
 
 
39
 
#include "compendiumdata.h"
40
 
#include "searchengine.h"
41
 
 
42
 
#include <qdict.h>
43
 
#include <qfile.h>
44
 
#include <qguardedptr.h>
45
 
#include <qptrlist.h>
46
 
 
47
 
class CompendiumPreferencesWidget;
48
 
class KConfigBase;
49
 
class QTimer;
50
 
 
51
 
class PoCompendium : public SearchEngine
52
 
{
53
 
        Q_OBJECT
54
 
 
55
 
public:
56
 
        PoCompendium(QObject *parent=0, const char *name=0);
57
 
        virtual ~PoCompendium();
58
 
 
59
 
        virtual bool isReady() const;
60
 
    
61
 
    virtual QString translate(const QString&text, uint pluralForm);
62
 
    virtual QString searchTranslation(const QString&, int &score, const uint pluralForm);
63
 
    virtual QString fuzzyTranslation(const QString&, int &score, const uint pluralForm);
64
 
 
65
 
        virtual bool isSearching() const;
66
 
 
67
 
        virtual void saveSettings(KConfigBase *config);
68
 
        virtual void readSettings(KConfigBase *config);
69
 
 
70
 
        virtual PrefWidget *preferencesWidget(QWidget *parent);
71
 
 
72
 
        virtual const KAboutData *about() const;
73
 
 
74
 
        virtual QString name() const;
75
 
        
76
 
        virtual QString id() const;
77
 
 
78
 
        virtual QString lastError();
79
 
 
80
 
 
81
 
public slots:
82
 
        virtual bool startSearch(const QString& s, uint pluralForm = 0, const SearchFilter* filter = 0);
83
 
        virtual void stopSearch();
84
 
    virtual void setLanguageCode(const QString& lang);
85
 
 
86
 
protected slots:
87
 
        /** reads the current settings from the preferences dialog */
88
 
        void applySettings();
89
 
    
90
 
        /** sets the current settings in the preferences dialog */
91
 
        void restoreSettings();
92
 
 
93
 
    void slotLoadCompendium();
94
 
 
95
 
    void recheckData();
96
 
    void removeData();
97
 
 
98
 
protected:
99
 
    void loadCompendium();
100
 
    void addResult(SearchResult *, QPtrList<SearchResult>& allResults);
101
 
    QString maskString(QString string);
102
 
 
103
 
    void registerData();
104
 
    void unregisterData();
105
 
    
106
 
    bool searchExact(const QString& searchString, uint pluralForm, QPtrList<SearchResult>& results, QValueList<int>& foundIndices, QValueList<int>& checkedIndices );
107
 
    bool searchTextOnly(const QString& searchString, uint pluralForm, QPtrList<SearchResult>& results, QValueList<int>& foundIndices, QValueList<int>& checkedIndices );
108
 
    bool searchCaseInsensitive(const QString& searchString, uint pluralForm, QPtrList<SearchResult>& results, QValueList<int>& foundIndices, QValueList<int>& checkedIndices );
109
 
    bool searchWords(const QString& searchString, uint pluralForm, QPtrList<SearchResult>& results, QValueList<int>& foundIndices, QValueList<int>& checkedIndices );
110
 
    bool searchNGram(const QString& searchString, uint pluralForm, QPtrList<SearchResult>& results, QValueList<int>& foundIndices, QValueList<int>& checkedIndices );
111
 
 
112
 
private:
113
 
    QGuardedPtr<CompendiumPreferencesWidget> prefWidget;
114
 
    CompendiumData *data;
115
 
    KBabel::PoInfo catalogInfo;
116
 
    QTimer *loadTimer;
117
 
 
118
 
    QString url;
119
 
    QString realURL;
120
 
    QString langCode;
121
 
        
122
 
    bool caseSensitive;
123
 
    bool ignoreFuzzy;
124
 
    bool wholeWords;
125
 
 
126
 
    bool matchEqual;
127
 
    bool matchIsContained;
128
 
    bool matchContains;
129
 
    bool matchWords;
130
 
    bool matchNGram;
131
 
    
132
 
    bool buildIndex;
133
 
    uint freeMemDelay;
134
 
 
135
 
        bool error;
136
 
        QString errorMsg;
137
 
 
138
 
        bool stop;
139
 
        bool active;
140
 
        bool initialized;
141
 
    bool loading;
142
 
 
143
 
    static QDict<CompendiumData> *_compDict;
144
 
    static QDict<CompendiumData> *compendiumDict();
145
 
};
146
 
 
147
 
#endif