summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpenmatch.h
Unidiff
Diffstat (limited to 'inputmethods/handwriting/qimpenmatch.h') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenmatch.h107
1 files changed, 107 insertions, 0 deletions
diff --git a/inputmethods/handwriting/qimpenmatch.h b/inputmethods/handwriting/qimpenmatch.h
new file mode 100644
index 0000000..d4a730e
--- a/dev/null
+++ b/inputmethods/handwriting/qimpenmatch.h
@@ -0,0 +1,107 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef _QIMPENMATCH_H_
22#define _QIMPENMATCH_H_
23
24#include "qimpenchar.h"
25
26#include <qpe/qdawg.h>
27
28#include <qlist.h>
29
30class QTimer;
31class QIMPenWidget;
32class QIMPenSetup;
33class QIMPenWordPick;
34
35class QIMPenMatch : public QObject
36{
37 Q_OBJECT
38public:
39 QIMPenMatch( QObject *parent=0, const char *name=0 );
40 virtual ~QIMPenMatch();
41
42 void resetState();
43 void backspace();
44 void setMultiStrokeTimeout( int t ) { multiTimeout = t; }
45
46 const QString &word() const { return wordEntered; }
47
48 void setWordMatchingEnabled( bool e ) { doWordMatching = e; }
49 bool isWordMatchingEnabled() const { return doWordMatching; }
50
51 struct MatchWord {
52 MatchWord( const QString &w, int e ) { word = w; error = e; }
53 QString word;
54 int error;
55 };
56
57 class MatchWordList : public QList<MatchWord>
58 {
59 public:
60 int compareItems( QCollection::Item item1, QCollection::Item item2 ) {
61 MatchWord *m1 = (MatchWord *)item1;
62 MatchWord *m2 = (MatchWord *)item2;
63 return m1->error - m2->error;
64 }
65 };
66
67public slots:
68 void setCharSet( QIMPenCharSet * );
69 void beginStroke();
70 void strokeEntered( QIMPenStroke *st );
71
72signals:
73 void erase();
74 void noMatch();
75 void removeStroke();
76 void keypress( uint ch );
77 void matchedCharacters( const QIMPenCharMatchList & );
78 void matchedWords( const QIMPenMatch::MatchWordList & );
79
80protected slots:
81 void processMatches( QIMPenCharMatchList &ml );
82 void endMulti();
83
84protected:
85 void updateWordMatch( QIMPenCharMatchList &ml );
86 void matchWords();
87 void scanDict( const QDawg::Node* n, int ipos, const QString& str, int error );
88
89 QList<QIMPenStroke> strokes;
90 QIMPenChar *prevMatchChar;
91 int prevMatchError;
92 QIMPenCharSet *charSet;
93 QIMPenCharSet *multiCharSet;
94 QList<QIMPenCharMatchList> wordChars;
95 MatchWordList wordMatches;
96 QString wordEntered;
97 bool doWordMatching;
98 bool canErase;
99 int errorThreshold;
100 int goodMatches;
101 int badMatches;
102 int maxGuess;
103 QTimer *multiTimer;
104 int multiTimeout;
105};
106
107#endif // _QIMPENINPUT_H_