summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpenchar.cpp
Side-by-side diff
Diffstat (limited to 'inputmethods/handwriting/qimpenchar.cpp') (more/less context) (show 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
@@ -384,97 +384,97 @@ bool QIMPenCharSet::save( Domain d )
}
if ( ok ) {
if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) {
qWarning( "problem renaming file %s to %s, errno: %d",
tmpFn.latin1(), fn.latin1(), errno );
// remove the tmp file, otherwise, it will just lay around...
QFile::remove( tmpFn.latin1() );
ok = FALSE;
}
}
return ok;
}
QIMPenChar *QIMPenCharSet::at( int i )
{
return chars.at(i);
}
void QIMPenCharSet::markDeleted( uint ch )
{
QIMPenCharIterator ci( chars );
for ( ; ci.current(); ++ci ) {
QIMPenChar *pc = ci.current();
if ( pc->character() == ch && pc->testFlag( QIMPenChar::System ) )
pc->setFlag( QIMPenChar::Deleted );
}
}
/*!
Find the best matches for \a ch in this character set.
*/
QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch )
{
QIMPenCharMatchList matches;
QIMPenCharIterator ci( chars );
for ( ; ci.current(); ++ci ) {
QIMPenChar *tmplChar = ci.current();
if ( tmplChar->testFlag( QIMPenChar::Deleted ) ) {
continue;
}
int err;
if ( ch->penStrokes().count() <= tmplChar->penStrokes().count() ) {
err = ch->match( tmplChar );
if ( err <= QIMPEN_MATCH_THRESHOLD ) {
if (tmplChar->penStrokes().count() != ch->penStrokes().count())
- err = QIMPEN_MATCH_THRESHOLD;
+ err = QMIN(err*3, QIMPEN_MATCH_THRESHOLD);
QIMPenCharMatchList::Iterator it;
for ( it = matches.begin(); it != matches.end(); ++it ) {
if ( (*it).penChar->character() == tmplChar->character() &&
(*it).penChar->penStrokes().count() == tmplChar->penStrokes().count() ) {
if ( (*it).error > err )
(*it).error = err;
break;
}
}
if ( it == matches.end() ) {
QIMPenCharMatch m;
m.error = err;
m.penChar = tmplChar;
matches.append( m );
}
}
}
}
qHeapSort( matches );
/*
QIMPenCharMatchList::Iterator it;
for ( it = matches.begin(); it != matches.end(); ++it ) {
qDebug( "Match: \'%c\', error %d, strokes %d", (*it).penChar->character(),
(*it).error, (*it).penChar->penStrokes().count() );
}
*/
return matches;
}
/*!
Add a character \a ch to this set.
QIMPenCharSet will delete this character when it is no longer needed.
*/
void QIMPenCharSet::addChar( QIMPenChar *ch )
{
if ( ch->penStrokes().count() > maxStrokes )
maxStrokes = ch->penStrokes().count();
chars.append( ch );
}
/*!
Remove a character by reference \a ch from this set.
QIMPenCharSet will delete this character.
*/
void QIMPenCharSet::removeChar( QIMPenChar *ch )
{
chars.remove( ch );
}