author | brad <brad> | 2004-07-03 07:07:40 (UTC) |
---|---|---|
committer | brad <brad> | 2004-07-03 07:07:40 (UTC) |
commit | 88c9b1b2bbc64bae352eb7ddb7eabf9fbaca416d (patch) (unidiff) | |
tree | b2f5bf2b2bf4ab8638708c6e2228e6c3f9fe83e7 /inputmethods | |
parent | 0b0cc8ff22fdae62b8f40dc2a77a4de9a6fd0cb6 (diff) | |
download | opie-88c9b1b2bbc64bae352eb7ddb7eabf9fbaca416d.zip opie-88c9b1b2bbc64bae352eb7ddb7eabf9fbaca416d.tar.gz opie-88c9b1b2bbc64bae352eb7ddb7eabf9fbaca416d.tar.bz2 |
Don't display hidden sets in trainer.
-rw-r--r-- | inputmethods/handwriting/qimpenhelp.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/inputmethods/handwriting/qimpenhelp.cpp b/inputmethods/handwriting/qimpenhelp.cpp index 0727931..d0ccd55 100644 --- a/inputmethods/handwriting/qimpenhelp.cpp +++ b/inputmethods/handwriting/qimpenhelp.cpp | |||
@@ -1,339 +1,340 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qimpenwidget.h" | 21 | #include "qimpenwidget.h" |
22 | #include "qimpencombining.h" | 22 | #include "qimpencombining.h" |
23 | #include "qimpenmatch.h" | 23 | #include "qimpenmatch.h" |
24 | #include "qimpenhelp.h" | 24 | #include "qimpenhelp.h" |
25 | 25 | ||
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/global.h> | 27 | #include <qpe/global.h> |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | #include <qpe/stringutil.h> | 29 | #include <qpe/stringutil.h> |
30 | 30 | ||
31 | #include <qtextview.h> | 31 | #include <qtextview.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qlistbox.h> | 33 | #include <qlistbox.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
39 | 39 | ||
40 | /* XPM */ | 40 | /* XPM */ |
41 | static const char * const left_xpm[] = { | 41 | static const char * const left_xpm[] = { |
42 | "16 16 2 1", | 42 | "16 16 2 1", |
43 | " c None", | 43 | " c None", |
44 | ". c #000000", | 44 | ". c #000000", |
45 | " ", | 45 | " ", |
46 | " ", | 46 | " ", |
47 | " ", | 47 | " ", |
48 | " . ", | 48 | " . ", |
49 | " .. ", | 49 | " .. ", |
50 | " ... ", | 50 | " ... ", |
51 | " .... ", | 51 | " .... ", |
52 | " ..... ", | 52 | " ..... ", |
53 | " ...... ", | 53 | " ...... ", |
54 | " ..... ", | 54 | " ..... ", |
55 | " .... ", | 55 | " .... ", |
56 | " ... ", | 56 | " ... ", |
57 | " .. ", | 57 | " .. ", |
58 | " . ", | 58 | " . ", |
59 | " ", | 59 | " ", |
60 | " "}; | 60 | " "}; |
61 | 61 | ||
62 | 62 | ||
63 | /* XPM */ | 63 | /* XPM */ |
64 | static const char * const right_xpm[] = { | 64 | static const char * const right_xpm[] = { |
65 | "16 16 2 1", | 65 | "16 16 2 1", |
66 | " c None", | 66 | " c None", |
67 | ". c #000000", | 67 | ". c #000000", |
68 | " ", | 68 | " ", |
69 | " ", | 69 | " ", |
70 | " ", | 70 | " ", |
71 | " . ", | 71 | " . ", |
72 | " .. ", | 72 | " .. ", |
73 | " ... ", | 73 | " ... ", |
74 | " .... ", | 74 | " .... ", |
75 | " ..... ", | 75 | " ..... ", |
76 | " ...... ", | 76 | " ...... ", |
77 | " ..... ", | 77 | " ..... ", |
78 | " .... ", | 78 | " .... ", |
79 | " ... ", | 79 | " ... ", |
80 | " .. ", | 80 | " .. ", |
81 | " . ", | 81 | " . ", |
82 | " ", | 82 | " ", |
83 | " "}; | 83 | " "}; |
84 | 84 | ||
85 | class CharListItem : public QListBoxText | 85 | class CharListItem : public QListBoxText |
86 | { | 86 | { |
87 | public: | 87 | public: |
88 | CharListItem( const QString &text, uint c ) | 88 | CharListItem( const QString &text, uint c ) |
89 | : QListBoxText( text ) | 89 | : QListBoxText( text ) |
90 | { | 90 | { |
91 | _code = c; | 91 | _code = c; |
92 | } | 92 | } |
93 | 93 | ||
94 | uint code() const { return _code; } | 94 | uint code() const { return _code; } |
95 | 95 | ||
96 | protected: | 96 | protected: |
97 | uint _code; | 97 | uint _code; |
98 | }; | 98 | }; |
99 | 99 | ||
100 | HandwritingHelp::HandwritingHelp( QIMPenProfile *p, QWidget *parent, const char *name, WFlags f ) | 100 | HandwritingHelp::HandwritingHelp( QIMPenProfile *p, QWidget *parent, const char *name, WFlags f ) |
101 | : QTabWidget( parent, name, f ) | 101 | : QTabWidget( parent, name, f ) |
102 | { | 102 | { |
103 | setCaption( tr("Handwriting Help") ); | 103 | setCaption( tr("Handwriting Help") ); |
104 | QTextView *help = new QTextView( this ); | 104 | QTextView *help = new QTextView( this ); |
105 | help->setFrameStyle( QFrame::NoFrame ); | 105 | help->setFrameStyle( QFrame::NoFrame ); |
106 | help->setText( | 106 | help->setText( |
107 | tr( "<ul><li>When you start to use the handwriting recogniser " | 107 | tr( "<ul><li>When you start to use the handwriting recogniser " |
108 | "write slowly, accurately and firmly." | 108 | "write slowly, accurately and firmly." |
109 | "<li>Use the guide lines when drawing your characters." | 109 | "<li>Use the guide lines when drawing your characters." |
110 | "<li>When drawing a character with multiple strokes, each " | 110 | "<li>When drawing a character with multiple strokes, each " |
111 | "successive stroke must be drawn before the grayed strokes are erased." | 111 | "successive stroke must be drawn before the grayed strokes are erased." |
112 | "<li>Practice your handwriting using the handwriting trainer." | 112 | "<li>Practice your handwriting using the handwriting trainer." |
113 | "<li>When adding your own character templates make sure they " | 113 | "<li>When adding your own character templates make sure they " |
114 | "are sufficiently different from other characters' templates." | 114 | "are sufficiently different from other characters' templates." |
115 | "</ul>") ); | 115 | "</ul>") ); |
116 | 116 | ||
117 | addTab( help, tr("Tips") ); | 117 | addTab( help, tr("Tips") ); |
118 | 118 | ||
119 | HandwritingTrainer *trainer = new HandwritingTrainer( p, this ); | 119 | HandwritingTrainer *trainer = new HandwritingTrainer( p, this ); |
120 | addTab( trainer, tr("Trainer") ); | 120 | addTab( trainer, tr("Trainer") ); |
121 | } | 121 | } |
122 | 122 | ||
123 | void HandwritingHelp::showEvent( QShowEvent * ) | 123 | void HandwritingHelp::showEvent( QShowEvent * ) |
124 | { | 124 | { |
125 | Global::hideInputMethod(); | 125 | Global::hideInputMethod(); |
126 | } | 126 | } |
127 | 127 | ||
128 | void HandwritingHelp::hideEvent( QHideEvent * ) | 128 | void HandwritingHelp::hideEvent( QHideEvent * ) |
129 | { | 129 | { |
130 | Global::showInputMethod(); | 130 | Global::showInputMethod(); |
131 | } | 131 | } |
132 | 132 | ||
133 | //--------------------------------------------------------------------------- | 133 | //--------------------------------------------------------------------------- |
134 | 134 | ||
135 | HandwritingTrainer::HandwritingTrainer( QIMPenProfile *p, QWidget *parent, const char *name ) | 135 | HandwritingTrainer::HandwritingTrainer( QIMPenProfile *p, QWidget *parent, const char *name ) |
136 | : QWidget( parent, name ), profile(p) | 136 | : QWidget( parent, name ), profile(p) |
137 | { | 137 | { |
138 | QGridLayout *gl = new QGridLayout( this, 4, 2, 0, 4 ); | 138 | QGridLayout *gl = new QGridLayout( this, 4, 2, 0, 4 ); |
139 | gl->setColStretch( 1, 1 ); | 139 | gl->setColStretch( 1, 1 ); |
140 | gl->setRowStretch(3, 1); | 140 | gl->setRowStretch(3, 1); |
141 | 141 | ||
142 | charSetCombo = new QComboBox( this ); | 142 | charSetCombo = new QComboBox( this ); |
143 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); | 143 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); |
144 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); | 144 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); |
145 | QIMPenCharSetIterator it( profile->charSets() ); | 145 | QIMPenCharSetIterator it( profile->charSets() ); |
146 | for ( ; it.current(); ++it ) { | 146 | for ( ; it.current(); ++it ) { |
147 | charSetCombo->insertItem( it.current()->description() ); | 147 | if ( ! it.current()->hidden() ) |
148 | charSetCombo->insertItem( it.current()->description() ); | ||
148 | } | 149 | } |
149 | 150 | ||
150 | charList = new QListBox( this ); | 151 | charList = new QListBox( this ); |
151 | charList->setHScrollBarMode( QListBox::AlwaysOff ); | 152 | charList->setHScrollBarMode( QListBox::AlwaysOff ); |
152 | charList->setFixedWidth(80); | 153 | charList->setFixedWidth(80); |
153 | connect( charList, SIGNAL(highlighted(int)), this, SLOT(selectChar(int)) ); | 154 | connect( charList, SIGNAL(highlighted(int)), this, SLOT(selectChar(int)) ); |
154 | gl->addWidget(charList, 1, 0); | 155 | gl->addWidget(charList, 1, 0); |
155 | 156 | ||
156 | result = new QLabel( this ); | 157 | result = new QLabel( this ); |
157 | result->setAlignment(AlignLeft | AlignVCenter | WordBreak); | 158 | result->setAlignment(AlignLeft | AlignVCenter | WordBreak); |
158 | result->setText( | 159 | result->setText( |
159 | tr( "Select a reference character from the list. Practice writing in " | 160 | tr( "Select a reference character from the list. Practice writing in " |
160 | "the area on the right.")); | 161 | "the area on the right.")); |
161 | gl->addMultiCellWidget(result, 1, 2, 1, 1); | 162 | gl->addMultiCellWidget(result, 1, 2, 1, 1); |
162 | 163 | ||
163 | matcher = new QIMPenMatch( this ); | 164 | matcher = new QIMPenMatch( this ); |
164 | matcher->setCharSet( currentSet ); | 165 | matcher->setCharSet( currentSet ); |
165 | connect( matcher, SIGNAL(noMatch()), this, SLOT(noMatch()) ); | 166 | connect( matcher, SIGNAL(noMatch()), this, SLOT(noMatch()) ); |
166 | connect( matcher, SIGNAL(matchedCharacters(const QIMPenCharMatchList&)), | 167 | connect( matcher, SIGNAL(matchedCharacters(const QIMPenCharMatchList&)), |
167 | this, SLOT(matched(const QIMPenCharMatchList&)) ); | 168 | this, SLOT(matched(const QIMPenCharMatchList&)) ); |
168 | 169 | ||
169 | QHBoxLayout *hb = new QHBoxLayout(); | 170 | QHBoxLayout *hb = new QHBoxLayout(); |
170 | gl->addLayout( hb, 2, 0 ); | 171 | gl->addLayout( hb, 2, 0 ); |
171 | prevBtn = new QPushButton( this ); | 172 | prevBtn = new QPushButton( this ); |
172 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); | 173 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); |
173 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); | 174 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); |
174 | hb->addWidget( prevBtn ); | 175 | hb->addWidget( prevBtn ); |
175 | 176 | ||
176 | nextBtn = new QPushButton( this ); | 177 | nextBtn = new QPushButton( this ); |
177 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); | 178 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); |
178 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); | 179 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); |
179 | hb->addWidget( nextBtn ); | 180 | hb->addWidget( nextBtn ); |
180 | 181 | ||
181 | refPw = new QIMPenWidget( this ); | 182 | refPw = new QIMPenWidget( this ); |
182 | refPw->setReadOnly( TRUE ); | 183 | refPw->setReadOnly( TRUE ); |
183 | gl->addWidget( refPw, 3, 0 ); | 184 | gl->addWidget( refPw, 3, 0 ); |
184 | 185 | ||
185 | pracPw = new QIMPenWidget( this ); | 186 | pracPw = new QIMPenWidget( this ); |
186 | connect( matcher, SIGNAL(removeStroke()), pracPw, SLOT(removeStroke()) ); | 187 | connect( matcher, SIGNAL(removeStroke()), pracPw, SLOT(removeStroke()) ); |
187 | connect( pracPw, SIGNAL(beginStroke()), | 188 | connect( pracPw, SIGNAL(beginStroke()), |
188 | this, SLOT(beginStroke()) ); | 189 | this, SLOT(beginStroke()) ); |
189 | connect( pracPw, SIGNAL(stroke(QIMPenStroke*)), | 190 | connect( pracPw, SIGNAL(stroke(QIMPenStroke*)), |
190 | this, SLOT(strokeEntered(QIMPenStroke*)) ); | 191 | this, SLOT(strokeEntered(QIMPenStroke*)) ); |
191 | connect( pracPw, SIGNAL(beginStroke()), | 192 | connect( pracPw, SIGNAL(beginStroke()), |
192 | matcher, SLOT(beginStroke()) ); | 193 | matcher, SLOT(beginStroke()) ); |
193 | connect( pracPw, SIGNAL(stroke(QIMPenStroke*)), | 194 | connect( pracPw, SIGNAL(stroke(QIMPenStroke*)), |
194 | matcher, SLOT(strokeEntered(QIMPenStroke*)) ); | 195 | matcher, SLOT(strokeEntered(QIMPenStroke*)) ); |
195 | gl->addWidget( pracPw, 3, 1 ); | 196 | gl->addWidget( pracPw, 3, 1 ); |
196 | 197 | ||
197 | redrawTimer = new QTimer( this ); | 198 | redrawTimer = new QTimer( this ); |
198 | connect( redrawTimer, SIGNAL(timeout()), this, SLOT(redrawChar()) ); | 199 | connect( redrawTimer, SIGNAL(timeout()), this, SLOT(redrawChar()) ); |
199 | redrawTimer->start( 5000 ); | 200 | redrawTimer->start( 5000 ); |
200 | 201 | ||
201 | currentSet = 0; | 202 | currentSet = 0; |
202 | charSetCombo->setCurrentItem( 1 ); | 203 | charSetCombo->setCurrentItem( 1 ); |
203 | selectCharSet( 1 ); | 204 | selectCharSet( 1 ); |
204 | } | 205 | } |
205 | 206 | ||
206 | HandwritingTrainer::~HandwritingTrainer() | 207 | HandwritingTrainer::~HandwritingTrainer() |
207 | { | 208 | { |
208 | } | 209 | } |
209 | 210 | ||
210 | void HandwritingTrainer::showEvent( QShowEvent * ) | 211 | void HandwritingTrainer::showEvent( QShowEvent * ) |
211 | { | 212 | { |
212 | redrawChar(); | 213 | redrawChar(); |
213 | redrawTimer->start( 5000 ); | 214 | redrawTimer->start( 5000 ); |
214 | } | 215 | } |
215 | 216 | ||
216 | void HandwritingTrainer::setCurrentChar( QIMPenChar *c ) | 217 | void HandwritingTrainer::setCurrentChar( QIMPenChar *c ) |
217 | { | 218 | { |
218 | currentChar = c; | 219 | currentChar = c; |
219 | refPw->showCharacter( currentChar ); | 220 | refPw->showCharacter( currentChar ); |
220 | pracPw->clear(); | 221 | pracPw->clear(); |
221 | if ( currentChar ) { | 222 | if ( currentChar ) { |
222 | prevBtn->setEnabled( findPrev() != 0 ); | 223 | prevBtn->setEnabled( findPrev() != 0 ); |
223 | nextBtn->setEnabled( findNext() != 0 ); | 224 | nextBtn->setEnabled( findNext() != 0 ); |
224 | } | 225 | } |
225 | redrawTimer->start( 5000 ); | 226 | redrawTimer->start( 5000 ); |
226 | } | 227 | } |
227 | 228 | ||
228 | void HandwritingTrainer::selectChar( int i ) | 229 | void HandwritingTrainer::selectChar( int i ) |
229 | { | 230 | { |
230 | static int last_char = 0; | 231 | static int last_char = 0; |
231 | 232 | ||
232 | if (last_char != i) { | 233 | if (last_char != i) { |
233 | result->setText(""); | 234 | result->setText(""); |
234 | } | 235 | } |
235 | 236 | ||
236 | currentChar = 0; | 237 | currentChar = 0; |
237 | currentCode = ((CharListItem *)charList->item(i))->code(); | 238 | currentCode = ((CharListItem *)charList->item(i))->code(); |
238 | QIMPenCharIterator it(currentSet->characters() ); | 239 | QIMPenCharIterator it(currentSet->characters() ); |
239 | for ( ; it.current(); ++it ) { | 240 | for ( ; it.current(); ++it ) { |
240 | if ( it.current()->character() == currentCode && | 241 | if ( it.current()->character() == currentCode && |
241 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { | 242 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { |
242 | setCurrentChar( it.current() ); | 243 | setCurrentChar( it.current() ); |
243 | break; | 244 | break; |
244 | } | 245 | } |
245 | } | 246 | } |
246 | if ( !it.current() ) | 247 | if ( !it.current() ) |
247 | setCurrentChar( 0 ); | 248 | setCurrentChar( 0 ); |
248 | } | 249 | } |
249 | 250 | ||
250 | void HandwritingTrainer::selectCharSet( int i ) | 251 | void HandwritingTrainer::selectCharSet( int i ) |
251 | { | 252 | { |
252 | if ( currentSet ) { | 253 | if ( currentSet ) { |
253 | refPw->removeCharSet( 0 ); | 254 | refPw->removeCharSet( 0 ); |
254 | pracPw->removeCharSet( 0 ); | 255 | pracPw->removeCharSet( 0 ); |
255 | result->setText(""); | 256 | result->setText(""); |
256 | } | 257 | } |
257 | currentSet = profile->charSets().at( i ); | 258 | currentSet = profile->charSets().at( i ); |
258 | fillCharList(); | 259 | fillCharList(); |
259 | refPw->insertCharSet( currentSet ); | 260 | refPw->insertCharSet( currentSet ); |
260 | pracPw->insertCharSet( currentSet ); | 261 | pracPw->insertCharSet( currentSet ); |
261 | matcher->setCharSet( currentSet ); | 262 | matcher->setCharSet( currentSet ); |
262 | if ( charList->count() ) { | 263 | if ( charList->count() ) { |
263 | charList->setSelected( 0, TRUE ); | 264 | charList->setSelected( 0, TRUE ); |
264 | selectChar(0); | 265 | selectChar(0); |
265 | } | 266 | } |
266 | } | 267 | } |
267 | 268 | ||
268 | void HandwritingTrainer::noMatch() | 269 | void HandwritingTrainer::noMatch() |
269 | { | 270 | { |
270 | result->setText( tr("No match") ); | 271 | result->setText( tr("No match") ); |
271 | } | 272 | } |
272 | 273 | ||
273 | void HandwritingTrainer::matched( const QIMPenCharMatchList &ml ) | 274 | void HandwritingTrainer::matched( const QIMPenCharMatchList &ml ) |
274 | { | 275 | { |
275 | int maxErr = 20000 + (*ml.begin()).penChar->strokeLength(0) * 1000; | 276 | int maxErr = 20000 + (*ml.begin()).penChar->strokeLength(0) * 1000; |
276 | int baseErr = (*ml.begin()).penChar->strokeLength(0) * 250; | 277 | int baseErr = (*ml.begin()).penChar->strokeLength(0) * 250; |
277 | unsigned int numStrokes = (*ml.begin()).penChar->strokeCount(); | 278 | unsigned int numStrokes = (*ml.begin()).penChar->strokeCount(); |
278 | QIMPenCharMatchList::ConstIterator it; | 279 | QIMPenCharMatchList::ConstIterator it; |
279 | /* | 280 | /* |
280 | for ( it = ml.begin(); it != ml.end(); ++it ) { | 281 | for ( it = ml.begin(); it != ml.end(); ++it ) { |
281 | if ( (*it).penChar->strokeCount() == numStrokes ) { | 282 | if ( (*it).penChar->strokeCount() == numStrokes ) { |
282 | if ( (*it).error > maxErr ) | 283 | if ( (*it).error > maxErr ) |
283 | maxErr = (*it).error; | 284 | maxErr = (*it).error; |
284 | } | 285 | } |
285 | } | 286 | } |
286 | */ | 287 | */ |
287 | int i; | 288 | int i; |
288 | QString res; | 289 | QString res; |
289 | QTextStream ts(&res, IO_WriteOnly); | 290 | QTextStream ts(&res, IO_WriteOnly); |
290 | ts << "<qt>" << tr("Matched: "); | 291 | ts << "<qt>" << tr("Matched: "); |
291 | for ( i = 0, it = ml.begin(); it != ml.end() && i < 4; ++it, i++ ) { | 292 | for ( i = 0, it = ml.begin(); it != ml.end() && i < 4; ++it, i++ ) { |
292 | if ( (*it).penChar->strokeCount() == numStrokes ) { | 293 | if ( (*it).penChar->strokeCount() == numStrokes ) { |
293 | int rate = 100 - ( ((*it).error - baseErr) * 100 ) / maxErr; | 294 | int rate = 100 - ( ((*it).error - baseErr) * 100 ) / maxErr; |
294 | if ( it != ml.begin() ) { | 295 | if ( it != ml.begin() ) { |
295 | if ( rate < -10 ) | 296 | if ( rate < -10 ) |
296 | continue; | 297 | continue; |
297 | ts << "<br>"; | 298 | ts << "<br>"; |
298 | ts << tr("Similar to: "); | 299 | ts << tr("Similar to: "); |
299 | } | 300 | } |
300 | ts << "<big>"; | 301 | ts << "<big>"; |
301 | if ( (*it).penChar->character() == currentChar->character() ) | 302 | if ( (*it).penChar->character() == currentChar->character() ) |
302 | ts << "<b>"; | 303 | ts << "<b>"; |
303 | ts << Qtopia::escapeString((*it).penChar->name()); | 304 | ts << Qtopia::escapeString((*it).penChar->name()); |
304 | ts << " (" << rateString(rate) << ")"; | 305 | ts << " (" << rateString(rate) << ")"; |
305 | if ( (*it).penChar->character() == currentChar->character() ) | 306 | if ( (*it).penChar->character() == currentChar->character() ) |
306 | ts << "</b>"; | 307 | ts << "</b>"; |
307 | ts << "</big>"; | 308 | ts << "</big>"; |
308 | } | 309 | } |
309 | } | 310 | } |
310 | ts << "</qt>"; | 311 | ts << "</qt>"; |
311 | result->setText( res ); | 312 | result->setText( res ); |
312 | } | 313 | } |
313 | 314 | ||
314 | QString HandwritingTrainer::rateString( int rate ) const | 315 | QString HandwritingTrainer::rateString( int rate ) const |
315 | { | 316 | { |
316 | if ( rate < 1 ) | 317 | if ( rate < 1 ) |
317 | rate = 1; | 318 | rate = 1; |
318 | if ( rate > 100 ) | 319 | if ( rate > 100 ) |
319 | rate = 100; | 320 | rate = 100; |
320 | return tr("%1%").arg(rate); | 321 | return tr("%1%").arg(rate); |
321 | } | 322 | } |
322 | 323 | ||
323 | void HandwritingTrainer::prevChar() | 324 | void HandwritingTrainer::prevChar() |
324 | { | 325 | { |
325 | QIMPenChar *pc = findPrev(); | 326 | QIMPenChar *pc = findPrev(); |
326 | if ( pc ) | 327 | if ( pc ) |
327 | setCurrentChar( pc ); | 328 | setCurrentChar( pc ); |
328 | } | 329 | } |
329 | 330 | ||
330 | void HandwritingTrainer::nextChar() | 331 | void HandwritingTrainer::nextChar() |
331 | { | 332 | { |
332 | QIMPenChar *pc = findNext(); | 333 | QIMPenChar *pc = findNext(); |
333 | if ( pc ) | 334 | if ( pc ) |
334 | setCurrentChar( pc ); | 335 | setCurrentChar( pc ); |
335 | } | 336 | } |
336 | 337 | ||
337 | void HandwritingTrainer::redrawChar() | 338 | void HandwritingTrainer::redrawChar() |
338 | { | 339 | { |
339 | if ( currentChar ) | 340 | if ( currentChar ) |