Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qimpenmatch.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #ifndef _QIMPENMATCH_H_
00022 #define _QIMPENMATCH_H_
00023 
00024 #include "qimpenchar.h"
00025 
00026 #include <qpe/qdawg.h>
00027 
00028 #include <qlist.h>
00029 
00030 class QTimer;
00031 class QIMPenWidget;
00032 class QIMPenSetup;
00033 class QIMPenWordPick;
00034 
00035 class QIMPenMatch : public QObject
00036 {
00037     Q_OBJECT
00038 public:
00039     QIMPenMatch( QObject *parent=0, const char *name=0 );
00040     virtual ~QIMPenMatch();
00041 
00042     void resetState();
00043     void backspace();
00044     void setMultiStrokeTimeout( int t ) { multiTimeout = t; }
00045 
00046     const QString &word() const { return wordEntered; }
00047 
00048     void setWordMatchingEnabled( bool e ) { doWordMatching = e; }
00049     bool isWordMatchingEnabled() const { return doWordMatching; }
00050 
00051     struct MatchWord {
00052         MatchWord( const QString &w, int e ) { word = w; error = e; }
00053         QString word;
00054         int error;
00055     };
00056 
00057     class MatchWordList : public QList<MatchWord>
00058     {
00059     public:
00060         int compareItems( QCollection::Item item1, QCollection::Item item2 ) {
00061             MatchWord *m1 = (MatchWord *)item1;
00062             MatchWord *m2 = (MatchWord *)item2;
00063             return m1->error - m2->error;
00064         }
00065     };
00066 
00067 public slots:
00068     void setCharSet( QIMPenCharSet * );
00069     void beginStroke();
00070     void strokeEntered( QIMPenStroke *st );
00071 
00072 signals:
00073     void erase();
00074     void noMatch();
00075     void removeStroke();
00076     void keypress( uint ch );
00077     void matchedCharacters( const QIMPenCharMatchList & );
00078     void matchedWords( const QIMPenMatch::MatchWordList & );
00079 
00080 protected slots:
00081     void processMatches( QIMPenCharMatchList &ml );
00082     void endMulti();
00083 
00084 protected:
00085     void updateWordMatch( QIMPenCharMatchList &ml );
00086     void matchWords();
00087     void scanDict( const QDawg::Node* n, int ipos, const QString& str, int error );
00088 
00089     QList<QIMPenStroke> strokes;
00090     QIMPenChar *prevMatchChar;
00091     int prevMatchError;
00092     QIMPenCharSet *charSet;
00093     QIMPenCharSet *multiCharSet;
00094     QList<QIMPenCharMatchList> wordChars;
00095     MatchWordList wordMatches;
00096     QString wordEntered;
00097     bool doWordMatching;
00098     bool canErase;
00099     int errorThreshold;
00100     int goodMatches;
00101     int badMatches;
00102     int maxGuess;
00103     QTimer *multiTimer;
00104     int multiTimeout;
00105 };
00106 
00107 #endif // _QIMPENINPUT_H_

Generated on Sat Nov 5 16:16:01 2005 for OPIE by  doxygen 1.4.2