summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpenchar.cpp
Unidiff
Diffstat (limited to 'inputmethods/handwriting/qimpenchar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenchar.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/inputmethods/handwriting/qimpenchar.cpp b/inputmethods/handwriting/qimpenchar.cpp
index 929f370..db5d135 100644
--- a/inputmethods/handwriting/qimpenchar.cpp
+++ b/inputmethods/handwriting/qimpenchar.cpp
@@ -17,24 +17,25 @@
17 ** not clear to you. 17 ** not clear to you.
18 ** 18 **
19 **********************************************************************/ 19 **********************************************************************/
20 20
21#include <qfile.h> 21#include <qfile.h>
22#include <qtl.h> 22#include <qtl.h>
23#include <math.h> 23#include <math.h>
24#include <limits.h> 24#include <limits.h>
25#include <errno.h> 25#include <errno.h>
26#include <qdatastream.h> 26#include <qdatastream.h>
27#include "qimpencombining.h" 27#include "qimpencombining.h"
28#include "qimpenchar.h" 28#include "qimpenchar.h"
29#include "opie2/odebug.h"
29 30
30 #define QIMPEN_MATCH_THRESHOLD 200000 31 #define QIMPEN_MATCH_THRESHOLD 200000
31 32
32const QIMPenSpecialKeys qimpen_specialKeys[] = { 33const QIMPenSpecialKeys qimpen_specialKeys[] = {
33 { Qt::Key_Escape, "[Esc]" }, 34 { Qt::Key_Escape, "[Esc]" },
34 { Qt::Key_Tab, "[Tab]" }, 35 { Qt::Key_Tab, "[Tab]" },
35 { Qt::Key_Backspace,"[BackSpace]" }, 36 { Qt::Key_Backspace,"[BackSpace]" },
36 { Qt::Key_Return, "[Return]" }, 37 { Qt::Key_Return, "[Return]" },
37 { QIMPenChar::Caps, "[Uppercase]" }, 38 { QIMPenChar::Caps, "[Uppercase]" },
38 { QIMPenChar::CapsLock,"[Caps Lock]" }, 39 { QIMPenChar::CapsLock,"[Caps Lock]" },
39 { QIMPenChar::Shortcut,"[Shortcut]" }, 40 { QIMPenChar::Shortcut,"[Shortcut]" },
40 { QIMPenChar::Punctuation, "[Punctuation]" }, 41 { QIMPenChar::Punctuation, "[Punctuation]" },
@@ -158,40 +159,40 @@ int QIMPenChar::match( QIMPenChar *pen )
158 QPoint p1 = it1.current()->boundingRect().center() - 159 QPoint p1 = it1.current()->boundingRect().center() -
159 strokes.getFirst()->boundingRect().center(); 160 strokes.getFirst()->boundingRect().center();
160 QPoint p2 = it2.current()->boundingRect().center() - 161 QPoint p2 = it2.current()->boundingRect().center() -
161 pen->strokes.getFirst()->boundingRect().center(); 162 pen->strokes.getFirst()->boundingRect().center();
162 int xdiff = QABS( p1.x() - p2.x() ) - 6; 163 int xdiff = QABS( p1.x() - p2.x() ) - 6;
163 int ydiff = QABS( p1.y() - p2.y() ) - 5; 164 int ydiff = QABS( p1.y() - p2.y() ) - 5;
164 if ( xdiff < 0 ) 165 if ( xdiff < 0 )
165 xdiff = 0; 166 xdiff = 0;
166 if ( ydiff < 0 ) 167 if ( ydiff < 0 )
167 ydiff = 0; 168 ydiff = 0;
168 if ( xdiff > 10 || ydiff > 10 ) { // not a chance 169 if ( xdiff > 10 || ydiff > 10 ) { // not a chance
169#ifdef DEBUG_QIMPEN 170#ifdef DEBUG_QIMPEN
170 qDebug( "char %c, stroke starting pt diff excessive", pen->ch ); 171 odebug << "char " << pen->ch <<", stroke starting pt diff excessive" << oendl;
171#endif 172#endif
172 return INT_MAX; 173 return INT_MAX;
173 } 174 }
174 diff += xdiff*xdiff + ydiff*ydiff; 175 diff += xdiff*xdiff + ydiff*ydiff;
175 err = it1.current()->match( it2.current() ); 176 err = it1.current()->match( it2.current() );
176 if ( err > maxErr ) 177 if ( err > maxErr )
177 maxErr = err; 178 maxErr = err;
178 ++it1; 179 ++it1;
179 ++it2; 180 ++it2;
180 } 181 }
181 182
182 maxErr += diff * diff * 6; // magic weighting :) 183 maxErr += diff * diff * 6; // magic weighting :)
183 184
184#ifdef DEBUG_QIMPEN 185#ifdef DEBUG_QIMPEN
185 qDebug( "char: %c, maxErr %d, diff %d, (%d)", pen->ch, maxErr, diff, strokes.count() ); 186 odebug << "char: " << pen->ch << ", maxErr " << maxErr << ", diff " << diff << ", " << strokes.count() << oendl;
186#endif 187#endif
187 return maxErr; 188 return maxErr;
188} 189}
189 190
190/*! 191/*!
191 Return the bounding rect of this character. It may have sides with 192 Return the bounding rect of this character. It may have sides with
192 negative coords since its origin is where the user started drawing 193 negative coords since its origin is where the user started drawing
193 the character. 194 the character.
194 */ 195 */
195QRect QIMPenChar::boundingRect() 196QRect QIMPenChar::boundingRect()
196{ 197{
197 QRect br; 198 QRect br;
@@ -449,26 +450,26 @@ QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch )
449 QIMPenCharMatch m; 450 QIMPenCharMatch m;
450 m.error = err; 451 m.error = err;
451 m.penChar = tmplChar; 452 m.penChar = tmplChar;
452 matches.append( m ); 453 matches.append( m );
453 } 454 }
454 } 455 }
455 } 456 }
456 } 457 }
457 qHeapSort( matches ); 458 qHeapSort( matches );
458 /* 459 /*
459 QIMPenCharMatchList::Iterator it; 460 QIMPenCharMatchList::Iterator it;
460 for ( it = matches.begin(); it != matches.end(); ++it ) { 461 for ( it = matches.begin(); it != matches.end(); ++it ) {
461 qDebug( "Match: \'%c\', error %d, strokes %d", (*it).penChar->character(), 462
462 (*it).error, (*it).penChar->penStrokes().count() ); 463 odebug << "Match: \'" << (*it).penChar->character() "\', error " << (*it).error ", strokes " <<(*it).penChar->penStrokes().count() << oendl;
463 } 464 }
464 */ 465 */
465 return matches; 466 return matches;
466} 467}
467 468
468/*! 469/*!
469 Add a character \a ch to this set. 470 Add a character \a ch to this set.
470 QIMPenCharSet will delete this character when it is no longer needed. 471 QIMPenCharSet will delete this character when it is no longer needed.
471 */ 472 */
472void QIMPenCharSet::addChar( QIMPenChar *ch ) 473void QIMPenCharSet::addChar( QIMPenChar *ch )
473{ 474{
474 if ( ch->penStrokes().count() > maxStrokes ) 475 if ( ch->penStrokes().count() > maxStrokes )