summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpenmatch.cpp
Side-by-side diff
Diffstat (limited to 'inputmethods/handwriting/qimpenmatch.cpp') (more/less context) (show 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
@@ -22,12 +22,13 @@
#include <qpe/qdawg.h>
#include <qpe/global.h>
#include <qapplication.h>
#include <qtimer.h>
+#include <opie2/odebug.h>
#include <limits.h>
#define ERROR_THRESHOLD 200000
#define LOOKAHEAD_ERROR 2500
//#define DEBUG_QIMPEN
@@ -65,65 +66,65 @@ void QIMPenMatch::beginStroke()
multiTimer->stop();
}
void QIMPenMatch::strokeEntered( QIMPenStroke *st )
{
#ifdef DEBUG_QIMPEN
- qDebug( "---------- new stroke -------------" );
+ odebug << "---------- new stroke -------------" << oendl;
#endif
strokes.append( new QIMPenStroke( *st ) );
QIMPenChar testChar;
QIMPenStrokeIterator it(strokes);
for ( ; it.current(); ++it ) {
testChar.addStroke( it.current() );
}
QIMPenCharMatchList ml;
if ( strokes.count() > 1 && multiCharSet ) {
#ifdef DEBUG_QIMPEN
- qDebug( "Matching against multi set" );
+ odebug << "Matching against multi set" << oendl;
#endif
ml = multiCharSet->match( &testChar );
} else {
#ifdef DEBUG_QIMPEN
- qDebug( "Matching against single set" );
+ odebug << "Matching against single set" << oendl;
#endif
ml = charSet->match( &testChar );
}
processMatches( ml );
}
void QIMPenMatch::processMatches( QIMPenCharMatchList &ml )
{
#ifdef DEBUG_QIMPEN
- qDebug( "Entering strokes.count() = %d", strokes.count() );
+ odebug << "Entering strokes.count() = " << strokes.count() << oendl;
#endif
QIMPenCharMatch candidate1 = { INT_MAX, 0 };
QIMPenCharMatch candidate2 = { INT_MAX, 0 };
QIMPenCharMatchList ml2;
if ( ml.count() ) {//&&
// ml.first().penChar->penStrokes().count() == strokes.count() ) {
candidate1 = ml.first();
#ifdef DEBUG_QIMPEN
- qDebug( QString("Candidate1 = %1").arg(QChar(candidate1.penChar->character())) );
+ odebug << "Candidate1 = " << candidate1.penChar->character() << oendl;
#endif
}
if ( strokes.count() > 1 ) {
// See if the last stroke can match a new character
QIMPenChar testChar;
QIMPenStroke *st = strokes.at(strokes.count()-1);
testChar.addStroke( st );
ml2 = charSet->match( &testChar );
if ( ml2.count() ) {
candidate2 = ml2.first();
#ifdef DEBUG_QIMPEN
- qDebug( QString("Candidate2 = %1").arg(QChar(candidate2.penChar->character())) );
+ odebug << "Candidate2 = " << candidate2.penChar->character() << oendl;
#endif
}
}
bool eraseLast = FALSE;
bool output = TRUE;
@@ -139,68 +140,68 @@ void QIMPenMatch::processMatches( QIMPenCharMatchList &ml )
}
prevMatchChar = candidate2.penChar;
prevMatchError = candidate2.error;
multiCharSet = charSet;
ml = ml2;
#ifdef DEBUG_QIMPEN
- qDebug( "** Using Candidate2" );
+ odebug << "** Using Candidate2" << oendl;
#endif
} else {
if ( (prevMatchChar->character() >> 16) != Qt::Key_Backspace &&
(prevMatchChar->character() >> 16) < QIMPenChar::ModeBase )
eraseLast = TRUE;
prevMatchChar = candidate1.penChar;
prevMatchError = candidate1.error;
#ifdef DEBUG_QIMPEN
- qDebug( "** Using Candidate1, with erase" );
+ odebug << "** Using Candidate1, with erase" << oendl;
#endif
}
} else if ( candidate1.penChar ) {
if ( strokes.count() != 1 )
eraseLast = TRUE;
else
multiCharSet = charSet;
prevMatchChar = candidate1.penChar;
prevMatchError = candidate1.error;
#ifdef DEBUG_QIMPEN
- qDebug( "** Using Candidate1" );
+ odebug << "** Using Candidate1" << oendl;
#endif
} else if ( candidate2.penChar ) {
int i = strokes.count()-1;
while ( i-- ) {
strokes.removeFirst();
emit removeStroke();
}
prevMatchChar = candidate2.penChar;
prevMatchError = candidate2.error;
multiCharSet = charSet;
ml = ml2;
#ifdef DEBUG_QIMPEN
- qDebug( "** Using Candidate2" );
+ odebug << "** Using Candidate2" << oendl;
#endif
} else {
if ( !ml.count() ) {
#ifdef DEBUG_QIMPEN
- qDebug( "** Failed" );
+ odebug << "** Failed" << oendl;
#endif
canErase = FALSE;
} else {
#ifdef DEBUG_QIMPEN
- qDebug( "Need more strokes" );
+ odebug << "Need more strokes" << oendl;
#endif
if ( strokes.count() == 1 )
canErase = FALSE;
multiCharSet = charSet;
}
output = FALSE;
emit noMatch();
}
if ( eraseLast && canErase ) {
#ifdef DEBUG_QIMPEN
- qDebug( "deleting last" );
+ odebug << "deleting last" << oendl;
#endif
emit erase();
wordChars.removeLast();
wordEntered.truncate( wordEntered.length() - 1 );
}
@@ -225,18 +226,18 @@ void QIMPenMatch::updateWordMatch( QIMPenCharMatchList &ml )
int ch = ml.first().penChar->character();
QChar qch( ch );
int code = ch >> 16;
if ( qch.isPunct() || qch.isSpace() ||
code == Qt::Key_Enter || code == Qt::Key_Return ||
code == Qt::Key_Tab || code == Qt::Key_Escape ) {
-// qDebug( "Word Matching: Clearing word" );
+// odebug << "Word Matching: Clearing word" << oendl;
wordChars.clear();
wordMatches.clear();
wordEntered = QString();
} else if ( code == Qt::Key_Backspace ) {
- //qDebug( "Word Matching: Handle backspace" );
+ //odebug << "Word Matching: Handle backspace" << oendl;
wordChars.removeLast();
wordEntered.truncate( wordEntered.length() - 1 );
matchWords();
} else {
QIMPenChar *matchCh;
@@ -278,17 +279,17 @@ void QIMPenMatch::matchWords()
maxGuess = 3;
QString str;
scanDict( Global::fixedDawg().root(), 0, str, 0 );
/*
QListIterator<MatchWord> it( wordMatches);
for ( ; it.current(); ++it ) {
- qDebug( QString("Match word: %1").arg(it.current()->word) );
+ odebug << "Match word: " << it.current()->word << oendl;
}
*/
}
- //qDebug( "Possibles: Good %d, total %d", goodMatches, wordMatches.count() );
+ //odebug << "Possibles: Good " << goodMatches << ", total " << wordMatches.count() << oendl;
wordMatches.sort();
}
void QIMPenMatch::scanDict( const QDawg::Node* n, int ipos, const QString& str, int error )
{
if ( !n )