summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpenmatch.cpp
Unidiff
Diffstat (limited to 'inputmethods/handwriting/qimpenmatch.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenmatch.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/inputmethods/handwriting/qimpenmatch.cpp b/inputmethods/handwriting/qimpenmatch.cpp
index 0d3e25a..a0448b6 100644
--- a/inputmethods/handwriting/qimpenmatch.cpp
+++ b/inputmethods/handwriting/qimpenmatch.cpp
@@ -24,8 +24,9 @@
24#include <qpe/global.h> 24#include <qpe/global.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <opie2/odebug.h>
28 29
29#include <limits.h> 30#include <limits.h>
30 31
31 #define ERROR_THRESHOLD 200000 32 #define ERROR_THRESHOLD 200000
@@ -67,9 +68,9 @@ void QIMPenMatch::beginStroke()
67 68
68void QIMPenMatch::strokeEntered( QIMPenStroke *st ) 69void QIMPenMatch::strokeEntered( QIMPenStroke *st )
69{ 70{
70#ifdef DEBUG_QIMPEN 71#ifdef DEBUG_QIMPEN
71 qDebug( "---------- new stroke -------------" ); 72 odebug << "---------- new stroke -------------" << oendl;
72#endif 73#endif
73 strokes.append( new QIMPenStroke( *st ) ); 74 strokes.append( new QIMPenStroke( *st ) );
74 75
75 QIMPenChar testChar; 76 QIMPenChar testChar;
@@ -80,14 +81,14 @@ void QIMPenMatch::strokeEntered( QIMPenStroke *st )
80 81
81 QIMPenCharMatchList ml; 82 QIMPenCharMatchList ml;
82 if ( strokes.count() > 1 && multiCharSet ) { 83 if ( strokes.count() > 1 && multiCharSet ) {
83#ifdef DEBUG_QIMPEN 84#ifdef DEBUG_QIMPEN
84 qDebug( "Matching against multi set" ); 85 odebug << "Matching against multi set" << oendl;
85#endif 86#endif
86 ml = multiCharSet->match( &testChar ); 87 ml = multiCharSet->match( &testChar );
87 } else { 88 } else {
88#ifdef DEBUG_QIMPEN 89#ifdef DEBUG_QIMPEN
89 qDebug( "Matching against single set" ); 90 odebug << "Matching against single set" << oendl;
90#endif 91#endif
91 ml = charSet->match( &testChar ); 92 ml = charSet->match( &testChar );
92 } 93 }
93 94
@@ -96,9 +97,9 @@ void QIMPenMatch::strokeEntered( QIMPenStroke *st )
96 97
97void QIMPenMatch::processMatches( QIMPenCharMatchList &ml ) 98void QIMPenMatch::processMatches( QIMPenCharMatchList &ml )
98{ 99{
99#ifdef DEBUG_QIMPEN 100#ifdef DEBUG_QIMPEN
100 qDebug( "Entering strokes.count() = %d", strokes.count() ); 101 odebug << "Entering strokes.count() = " << strokes.count() << oendl;
101#endif 102#endif
102 QIMPenCharMatch candidate1 = { INT_MAX, 0 }; 103 QIMPenCharMatch candidate1 = { INT_MAX, 0 };
103 QIMPenCharMatch candidate2 = { INT_MAX, 0 }; 104 QIMPenCharMatch candidate2 = { INT_MAX, 0 };
104 QIMPenCharMatchList ml2; 105 QIMPenCharMatchList ml2;
@@ -106,9 +107,9 @@ void QIMPenMatch::processMatches( QIMPenCharMatchList &ml )
106 if ( ml.count() ) {//&& 107 if ( ml.count() ) {//&&
107 // ml.first().penChar->penStrokes().count() == strokes.count() ) { 108 // ml.first().penChar->penStrokes().count() == strokes.count() ) {
108 candidate1 = ml.first(); 109 candidate1 = ml.first();
109#ifdef DEBUG_QIMPEN 110#ifdef DEBUG_QIMPEN
110 qDebug( QString("Candidate1 = %1").arg(QChar(candidate1.penChar->character())) ); 111 odebug << "Candidate1 = " << candidate1.penChar->character() << oendl;
111#endif 112#endif
112 } 113 }
113 114
114 if ( strokes.count() > 1 ) { 115 if ( strokes.count() > 1 ) {
@@ -119,9 +120,9 @@ void QIMPenMatch::processMatches( QIMPenCharMatchList &ml )
119 ml2 = charSet->match( &testChar ); 120 ml2 = charSet->match( &testChar );
120 if ( ml2.count() ) { 121 if ( ml2.count() ) {
121 candidate2 = ml2.first(); 122 candidate2 = ml2.first();
122#ifdef DEBUG_QIMPEN 123#ifdef DEBUG_QIMPEN
123 qDebug( QString("Candidate2 = %1").arg(QChar(candidate2.penChar->character())) ); 124 odebug << "Candidate2 = " << candidate2.penChar->character() << oendl;
124#endif 125#endif
125 } 126 }
126 } 127 }
127 128
@@ -141,18 +142,18 @@ void QIMPenMatch::processMatches( QIMPenCharMatchList &ml )
141 prevMatchError = candidate2.error; 142 prevMatchError = candidate2.error;
142 multiCharSet = charSet; 143 multiCharSet = charSet;
143 ml = ml2; 144 ml = ml2;
144#ifdef DEBUG_QIMPEN 145#ifdef DEBUG_QIMPEN
145 qDebug( "** Using Candidate2" ); 146 odebug << "** Using Candidate2" << oendl;
146#endif 147#endif
147 } else { 148 } else {
148 if ( (prevMatchChar->character() >> 16) != Qt::Key_Backspace && 149 if ( (prevMatchChar->character() >> 16) != Qt::Key_Backspace &&
149 (prevMatchChar->character() >> 16) < QIMPenChar::ModeBase ) 150 (prevMatchChar->character() >> 16) < QIMPenChar::ModeBase )
150 eraseLast = TRUE; 151 eraseLast = TRUE;
151 prevMatchChar = candidate1.penChar; 152 prevMatchChar = candidate1.penChar;
152 prevMatchError = candidate1.error; 153 prevMatchError = candidate1.error;
153#ifdef DEBUG_QIMPEN 154#ifdef DEBUG_QIMPEN
154 qDebug( "** Using Candidate1, with erase" ); 155 odebug << "** Using Candidate1, with erase" << oendl;
155#endif 156#endif
156 } 157 }
157 } else if ( candidate1.penChar ) { 158 } else if ( candidate1.penChar ) {
158 if ( strokes.count() != 1 ) 159 if ( strokes.count() != 1 )
@@ -161,9 +162,9 @@ void QIMPenMatch::processMatches( QIMPenCharMatchList &ml )
161 multiCharSet = charSet; 162 multiCharSet = charSet;
162 prevMatchChar = candidate1.penChar; 163 prevMatchChar = candidate1.penChar;
163 prevMatchError = candidate1.error; 164 prevMatchError = candidate1.error;
164#ifdef DEBUG_QIMPEN 165#ifdef DEBUG_QIMPEN
165 qDebug( "** Using Candidate1" ); 166 odebug << "** Using Candidate1" << oendl;
166#endif 167#endif
167 } else if ( candidate2.penChar ) { 168 } else if ( candidate2.penChar ) {
168 int i = strokes.count()-1; 169 int i = strokes.count()-1;
169 while ( i-- ) { 170 while ( i-- ) {
@@ -174,19 +175,19 @@ void QIMPenMatch::processMatches( QIMPenCharMatchList &ml )
174 prevMatchError = candidate2.error; 175 prevMatchError = candidate2.error;
175 multiCharSet = charSet; 176 multiCharSet = charSet;
176 ml = ml2; 177 ml = ml2;
177#ifdef DEBUG_QIMPEN 178#ifdef DEBUG_QIMPEN
178 qDebug( "** Using Candidate2" ); 179 odebug << "** Using Candidate2" << oendl;
179#endif 180#endif
180 } else { 181 } else {
181 if ( !ml.count() ) { 182 if ( !ml.count() ) {
182#ifdef DEBUG_QIMPEN 183#ifdef DEBUG_QIMPEN
183 qDebug( "** Failed" ); 184 odebug << "** Failed" << oendl;
184#endif 185#endif
185 canErase = FALSE; 186 canErase = FALSE;
186 } else { 187 } else {
187#ifdef DEBUG_QIMPEN 188#ifdef DEBUG_QIMPEN
188 qDebug( "Need more strokes" ); 189 odebug << "Need more strokes" << oendl;
189#endif 190#endif
190 if ( strokes.count() == 1 ) 191 if ( strokes.count() == 1 )
191 canErase = FALSE; 192 canErase = FALSE;
192 multiCharSet = charSet; 193 multiCharSet = charSet;
@@ -196,9 +197,9 @@ void QIMPenMatch::processMatches( QIMPenCharMatchList &ml )
196 } 197 }
197 198
198 if ( eraseLast && canErase ) { 199 if ( eraseLast && canErase ) {
199#ifdef DEBUG_QIMPEN 200#ifdef DEBUG_QIMPEN
200 qDebug( "deleting last" ); 201 odebug << "deleting last" << oendl;
201#endif 202#endif
202 emit erase(); 203 emit erase();
203 wordChars.removeLast(); 204 wordChars.removeLast();
204 wordEntered.truncate( wordEntered.length() - 1 ); 205 wordEntered.truncate( wordEntered.length() - 1 );
@@ -227,14 +228,14 @@ void QIMPenMatch::updateWordMatch( QIMPenCharMatchList &ml )
227 int code = ch >> 16; 228 int code = ch >> 16;
228 if ( qch.isPunct() || qch.isSpace() || 229 if ( qch.isPunct() || qch.isSpace() ||
229 code == Qt::Key_Enter || code == Qt::Key_Return || 230 code == Qt::Key_Enter || code == Qt::Key_Return ||
230 code == Qt::Key_Tab || code == Qt::Key_Escape ) { 231 code == Qt::Key_Tab || code == Qt::Key_Escape ) {
231 //qDebug( "Word Matching: Clearing word" ); 232 //odebug << "Word Matching: Clearing word" << oendl;
232 wordChars.clear(); 233 wordChars.clear();
233 wordMatches.clear(); 234 wordMatches.clear();
234 wordEntered = QString(); 235 wordEntered = QString();
235 } else if ( code == Qt::Key_Backspace ) { 236 } else if ( code == Qt::Key_Backspace ) {
236 //qDebug( "Word Matching: Handle backspace" ); 237 //odebug << "Word Matching: Handle backspace" << oendl;
237 wordChars.removeLast(); 238 wordChars.removeLast();
238 wordEntered.truncate( wordEntered.length() - 1 ); 239 wordEntered.truncate( wordEntered.length() - 1 );
239 matchWords(); 240 matchWords();
240 } else { 241 } else {
@@ -280,13 +281,13 @@ void QIMPenMatch::matchWords()
280 scanDict( Global::fixedDawg().root(), 0, str, 0 ); 281 scanDict( Global::fixedDawg().root(), 0, str, 0 );
281/* 282/*
282 QListIterator<MatchWord> it( wordMatches); 283 QListIterator<MatchWord> it( wordMatches);
283 for ( ; it.current(); ++it ) { 284 for ( ; it.current(); ++it ) {
284 qDebug( QString("Match word: %1").arg(it.current()->word) ); 285 odebug << "Match word: " << it.current()->word << oendl;
285 } 286 }
286*/ 287*/
287 } 288 }
288 //qDebug( "Possibles: Good %d, total %d", goodMatches, wordMatches.count() ); 289 //odebug << "Possibles: Good " << goodMatches << ", total " << wordMatches.count() << oendl;
289 wordMatches.sort(); 290 wordMatches.sort();
290} 291}
291 292
292void QIMPenMatch::scanDict( const QDawg::Node* n, int ipos, const QString& str, int error ) 293void QIMPenMatch::scanDict( const QDawg::Node* n, int ipos, const QString& str, int error )