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.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/inputmethods/handwriting/qimpenchar.cpp b/inputmethods/handwriting/qimpenchar.cpp
index 9c38ec9..152bfec 100644
--- a/inputmethods/handwriting/qimpenchar.cpp
+++ b/inputmethods/handwriting/qimpenchar.cpp
@@ -400,65 +400,65 @@ QIMPenChar *QIMPenCharSet::at( int i )
400{ 400{
401 return chars.at(i); 401 return chars.at(i);
402} 402}
403 403
404void QIMPenCharSet::markDeleted( uint ch ) 404void QIMPenCharSet::markDeleted( uint ch )
405{ 405{
406 QIMPenCharIterator ci( chars ); 406 QIMPenCharIterator ci( chars );
407 for ( ; ci.current(); ++ci ) { 407 for ( ; ci.current(); ++ci ) {
408 QIMPenChar *pc = ci.current(); 408 QIMPenChar *pc = ci.current();
409 if ( pc->character() == ch && pc->testFlag( QIMPenChar::System ) ) 409 if ( pc->character() == ch && pc->testFlag( QIMPenChar::System ) )
410 pc->setFlag( QIMPenChar::Deleted ); 410 pc->setFlag( QIMPenChar::Deleted );
411 } 411 }
412} 412}
413 413
414/*! 414/*!
415 Find the best matches for \a ch in this character set. 415 Find the best matches for \a ch in this character set.
416*/ 416*/
417QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch ) 417QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch )
418{ 418{
419 QIMPenCharMatchList matches; 419 QIMPenCharMatchList matches;
420 420
421 QIMPenCharIterator ci( chars ); 421 QIMPenCharIterator ci( chars );
422 for ( ; ci.current(); ++ci ) { 422 for ( ; ci.current(); ++ci ) {
423 QIMPenChar *tmplChar = ci.current(); 423 QIMPenChar *tmplChar = ci.current();
424 if ( tmplChar->testFlag( QIMPenChar::Deleted ) ) { 424 if ( tmplChar->testFlag( QIMPenChar::Deleted ) ) {
425 continue; 425 continue;
426 } 426 }
427 int err; 427 int err;
428 if ( ch->penStrokes().count() <= tmplChar->penStrokes().count() ) { 428 if ( ch->penStrokes().count() <= tmplChar->penStrokes().count() ) {
429 err = ch->match( tmplChar ); 429 err = ch->match( tmplChar );
430 if ( err <= QIMPEN_MATCH_THRESHOLD ) { 430 if ( err <= QIMPEN_MATCH_THRESHOLD ) {
431 if (tmplChar->penStrokes().count() != ch->penStrokes().count()) 431 if (tmplChar->penStrokes().count() != ch->penStrokes().count())
432 err = QIMPEN_MATCH_THRESHOLD; 432 err = QMIN(err*3, QIMPEN_MATCH_THRESHOLD);
433 QIMPenCharMatchList::Iterator it; 433 QIMPenCharMatchList::Iterator it;
434 for ( it = matches.begin(); it != matches.end(); ++it ) { 434 for ( it = matches.begin(); it != matches.end(); ++it ) {
435 if ( (*it).penChar->character() == tmplChar->character() && 435 if ( (*it).penChar->character() == tmplChar->character() &&
436 (*it).penChar->penStrokes().count() == tmplChar->penStrokes().count() ) { 436 (*it).penChar->penStrokes().count() == tmplChar->penStrokes().count() ) {
437 if ( (*it).error > err ) 437 if ( (*it).error > err )
438 (*it).error = err; 438 (*it).error = err;
439 break; 439 break;
440 } 440 }
441 } 441 }
442 if ( it == matches.end() ) { 442 if ( it == matches.end() ) {
443 QIMPenCharMatch m; 443 QIMPenCharMatch m;
444 m.error = err; 444 m.error = err;
445 m.penChar = tmplChar; 445 m.penChar = tmplChar;
446 matches.append( m ); 446 matches.append( m );
447 } 447 }
448 } 448 }
449 } 449 }
450 } 450 }
451 qHeapSort( matches ); 451 qHeapSort( matches );
452/* 452/*
453 QIMPenCharMatchList::Iterator it; 453 QIMPenCharMatchList::Iterator it;
454 for ( it = matches.begin(); it != matches.end(); ++it ) { 454 for ( it = matches.begin(); it != matches.end(); ++it ) {
455 qDebug( "Match: \'%c\', error %d, strokes %d", (*it).penChar->character(), 455 qDebug( "Match: \'%c\', error %d, strokes %d", (*it).penChar->character(),
456 (*it).error, (*it).penChar->penStrokes().count() ); 456 (*it).error, (*it).penChar->penStrokes().count() );
457 } 457 }
458*/ 458*/
459 return matches; 459 return matches;
460} 460}
461 461
462/*! 462/*!
463 Add a character \a ch to this set. 463 Add a character \a ch to this set.
464 QIMPenCharSet will delete this character when it is no longer needed. 464 QIMPenCharSet will delete this character when it is no longer needed.