summaryrefslogtreecommitdiff
authorzecke <zecke>2004-01-18 13:26:43 (UTC)
committer zecke <zecke>2004-01-18 13:26:43 (UTC)
commit7d94c9b04f8702d0f94c6c64454d159a186a2576 (patch) (unidiff)
treea5989f07e02e610abab7cf7514737a67c78b1d68
parenta2a3aabf21655cc9c7df8e2ed0d420d2b208fd3d (diff)
downloadopie-7d94c9b04f8702d0f94c6c64454d159a186a2576.zip
opie-7d94c9b04f8702d0f94c6c64454d159a186a2576.tar.gz
opie-7d94c9b04f8702d0f94c6c64454d159a186a2576.tar.bz2
Comit the "Mono" patch by
Brad Campbell <brad@wasp.net.au>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenchar.cpp5
-rw-r--r--inputmethods/handwriting/qimpenchar.h3
-rw-r--r--inputmethods/handwriting/qimpenprofile.cpp25
-rw-r--r--inputmethods/handwriting/qimpenprofile.h2
-rw-r--r--inputmethods/handwriting/qimpensetup.cpp3
5 files changed, 35 insertions, 3 deletions
diff --git a/inputmethods/handwriting/qimpenchar.cpp b/inputmethods/handwriting/qimpenchar.cpp
index 0c37e5c..929f370 100644
--- a/inputmethods/handwriting/qimpenchar.cpp
+++ b/inputmethods/handwriting/qimpenchar.cpp
@@ -221,268 +221,271 @@ QDataStream &operator<< (QDataStream &s, const QIMPenChar &ws)
221 ++it; 221 ++it;
222 } 222 }
223 223
224 return s; 224 return s;
225} 225}
226 226
227/*! 227/*!
228 Read the character's data from the stream. 228 Read the character's data from the stream.
229 */ 229 */
230QDataStream &operator>> (QDataStream &s, QIMPenChar &ws) 230QDataStream &operator>> (QDataStream &s, QIMPenChar &ws)
231{ 231{
232 s >> ws.ch; 232 s >> ws.ch;
233 s >> ws.flags; 233 s >> ws.flags;
234 if ( ws.flags & QIMPenChar::Data ) 234 if ( ws.flags & QIMPenChar::Data )
235 s >> ws.d; 235 s >> ws.d;
236 unsigned size; 236 unsigned size;
237 s >> size; 237 s >> size;
238 for ( unsigned i = 0; i < size; i++ ) { 238 for ( unsigned i = 0; i < size; i++ ) {
239 QIMPenStroke *st = new QIMPenStroke(); 239 QIMPenStroke *st = new QIMPenStroke();
240 s >> *st; 240 s >> *st;
241 ws.strokes.append( st ); 241 ws.strokes.append( st );
242 } 242 }
243 243
244 return s; 244 return s;
245} 245}
246 246
247//=========================================================================== 247//===========================================================================
248 248
249bool QIMPenCharMatch::operator>( const QIMPenCharMatch &m ) 249bool QIMPenCharMatch::operator>( const QIMPenCharMatch &m )
250{ 250{
251 return error > m.error; 251 return error > m.error;
252} 252}
253 253
254bool QIMPenCharMatch::operator<( const QIMPenCharMatch &m ) 254bool QIMPenCharMatch::operator<( const QIMPenCharMatch &m )
255{ 255{
256 return error < m.error; 256 return error < m.error;
257} 257}
258 258
259bool QIMPenCharMatch::operator<=( const QIMPenCharMatch &m ) 259bool QIMPenCharMatch::operator<=( const QIMPenCharMatch &m )
260{ 260{
261 return error <= m.error; 261 return error <= m.error;
262} 262}
263 263
264//=========================================================================== 264//===========================================================================
265 265
266/*! 266/*!
267 \class QIMPenCharSet qimpenchar.h 267 \class QIMPenCharSet qimpenchar.h
268 268
269 Maintains a set of related characters. 269 Maintains a set of related characters.
270 */ 270 */
271 271
272QIMPenCharSet::QIMPenCharSet() 272QIMPenCharSet::QIMPenCharSet()
273{ 273{
274 chars.setAutoDelete( TRUE ); 274 chars.setAutoDelete( TRUE );
275 desc = "Unnamed"; 275 desc = "Unnamed";
276 csTitle = "abc"; 276 csTitle = "abc";
277 csType = Unknown; 277 csType = Unknown;
278 maxStrokes = 0; 278 maxStrokes = 0;
279} 279}
280 280
281/*! 281/*!
282 Construct and load a characters set from file \a fn. 282 Construct and load a characters set from file \a fn.
283 */ 283 */
284QIMPenCharSet::QIMPenCharSet( const QString &fn ) 284QIMPenCharSet::QIMPenCharSet( const QString &fn )
285{ 285{
286 chars.setAutoDelete( TRUE ); 286 chars.setAutoDelete( TRUE );
287 desc = "Unnamed"; 287 desc = "Unnamed";
288 csTitle = "abc"; 288 csTitle = "abc";
289 csType = Unknown; 289 csType = Unknown;
290 maxStrokes = 0; 290 maxStrokes = 0;
291 load( fn, System ); 291 load( fn, System );
292} 292}
293 293
294const QString &QIMPenCharSet::filename( Domain d ) const 294const QString &QIMPenCharSet::filename( Domain d ) const
295{ 295{
296 if ( d == System ) 296 if ( d == System )
297 return sysFilename; 297 return sysFilename;
298 else 298 else
299 return userFilename; 299 return userFilename;
300} 300}
301 301
302void QIMPenCharSet::setFilename( const QString &fn, Domain d ) 302void QIMPenCharSet::setFilename( const QString &fn, Domain d )
303{ 303{
304 if ( d == System ) 304 if ( d == System )
305 sysFilename = fn; 305 sysFilename = fn;
306 else if ( d == User ) 306 else if ( d == User )
307 userFilename = fn; 307 userFilename = fn;
308} 308}
309 309
310/*! 310/*!
311 Load a character set from file \a fn. 311 Load a character set from file \a fn.
312 */ 312 */
313bool QIMPenCharSet::load( const QString &fn, Domain d ) 313bool QIMPenCharSet::load( const QString &fn, Domain d )
314{ 314{
315 setFilename( fn, d ); 315 setFilename( fn, d );
316 316
317 bool ok = FALSE; 317 bool ok = FALSE;
318 QFile file( fn ); 318 QFile file( fn );
319 if ( file.open( IO_ReadOnly ) ) { 319 if ( file.open( IO_ReadOnly ) ) {
320 QDataStream ds( &file ); 320 QDataStream ds( &file );
321 QString version; 321 QString version;
322 ds >> version; 322 ds >> version;
323 ds >> csTitle; 323 ds >> csTitle;
324 ds >> desc; 324 ds >> desc;
325 int major = version.mid( 4, 1 ).toInt(); 325 int major = version.mid( 4, 1 ).toInt();
326 int minor = version.mid( 6 ).toInt(); 326 int minor = version.mid( 6 ).toInt();
327 if ( major >= 1 && minor > 0 ) { 327 if ( major >= 1 && minor > 0 ) {
328 ds >> (Q_INT8 &)csType; 328 ds >> (Q_INT8 &)csType;
329 } else { 329 } else {
330 if ( csTitle == "abc" ) 330 if ( csTitle == "abc" )
331 csType = Lower; 331 csType = Lower;
332 else if ( csTitle == "ABC" ) 332 else if ( csTitle == "ABC" )
333 csType = Upper; 333 csType = Upper;
334 else if ( csTitle == "123" ) 334 else if ( csTitle == "123" )
335 csType = Numeric; 335 csType = Numeric;
336 else if ( fn == "Combining" ) 336 else if ( fn == "Combining" )
337 csType = Combining; 337 csType = Combining;
338 } 338 }
339 while ( !ds.atEnd() ) { 339 while ( !ds.atEnd() ) {
340 QIMPenChar *pc = new QIMPenChar; 340 QIMPenChar *pc = new QIMPenChar;
341 ds >> *pc; 341 ds >> *pc;
342 if ( d == User ) 342 if ( d == User )
343 markDeleted( pc->character() ); // override system 343 markDeleted( pc->character() ); // override system
344 addChar( pc ); 344 addChar( pc );
345 } 345 }
346 if ( file.status() == IO_Ok ) 346 if ( file.status() == IO_Ok )
347 ok = TRUE; 347 ok = TRUE;
348 } 348 }
349 349 setHidden ( false );
350 return ok; 350 return ok;
351} 351}
352 352
353/*! 353/*!
354 Save this character set. 354 Save this character set.
355 */ 355 */
356bool QIMPenCharSet::save( Domain d ) 356bool QIMPenCharSet::save( Domain d )
357{ 357{
358 if ( filename( d ).isEmpty() ) 358 if ( filename( d ).isEmpty() )
359 return FALSE; 359 return FALSE;
360 360
361 if ( hidden() )
362 return TRUE;
363
361 bool ok = FALSE; 364 bool ok = FALSE;
362 365
363 QString fn = filename( d ); 366 QString fn = filename( d );
364 QString tmpFn = fn + ".new"; 367 QString tmpFn = fn + ".new";
365 QFile file( tmpFn ); 368 QFile file( tmpFn );
366 if ( file.open( IO_WriteOnly|IO_Raw ) ) { 369 if ( file.open( IO_WriteOnly|IO_Raw ) ) {
367 QByteArray buf; 370 QByteArray buf;
368 QDataStream ds( buf, IO_WriteOnly ); 371 QDataStream ds( buf, IO_WriteOnly );
369 ds << QString( "QPT 1.1" ); 372 ds << QString( "QPT 1.1" );
370 ds << csTitle; 373 ds << csTitle;
371 ds << desc; 374 ds << desc;
372 ds << (Q_INT8)csType; 375 ds << (Q_INT8)csType;
373 QIMPenCharIterator ci( chars ); 376 QIMPenCharIterator ci( chars );
374 for ( ; ci.current(); ++ci ) { 377 for ( ; ci.current(); ++ci ) {
375 QIMPenChar *pc = ci.current(); 378 QIMPenChar *pc = ci.current();
376 if ( ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) || 379 if ( ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) ||
377 ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) && 380 ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) &&
378 ( !pc->testFlag (QIMPenChar::Combined ) ) ) { 381 ( !pc->testFlag (QIMPenChar::Combined ) ) ) {
379 ds << *pc; 382 ds << *pc;
380 } 383 }
381 } 384 }
382 385
383 file.writeBlock( buf ); 386 file.writeBlock( buf );
384 file.close(); 387 file.close();
385 if ( file.status() == IO_Ok ) 388 if ( file.status() == IO_Ok )
386 ok = TRUE; 389 ok = TRUE;
387 } 390 }
388 391
389 if ( ok ) { 392 if ( ok ) {
390 if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) { 393 if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) {
391 qWarning( "problem renaming file %s to %s, errno: %d", 394 qWarning( "problem renaming file %s to %s, errno: %d",
392 tmpFn.latin1(), fn.latin1(), errno ); 395 tmpFn.latin1(), fn.latin1(), errno );
393 // remove the tmp file, otherwise, it will just lay around... 396 // remove the tmp file, otherwise, it will just lay around...
394 QFile::remove( tmpFn.latin1() ); 397 QFile::remove( tmpFn.latin1() );
395 ok = FALSE; 398 ok = FALSE;
396 } 399 }
397 } 400 }
398 401
399 return ok; 402 return ok;
400} 403}
401 404
402QIMPenChar *QIMPenCharSet::at( int i ) 405QIMPenChar *QIMPenCharSet::at( int i )
403{ 406{
404 return chars.at(i); 407 return chars.at(i);
405} 408}
406 409
407void QIMPenCharSet::markDeleted( uint ch ) 410void QIMPenCharSet::markDeleted( uint ch )
408{ 411{
409 QIMPenCharIterator ci( chars ); 412 QIMPenCharIterator ci( chars );
410 for ( ; ci.current(); ++ci ) { 413 for ( ; ci.current(); ++ci ) {
411 QIMPenChar *pc = ci.current(); 414 QIMPenChar *pc = ci.current();
412 if ( pc->character() == ch && pc->testFlag( QIMPenChar::System ) ) 415 if ( pc->character() == ch && pc->testFlag( QIMPenChar::System ) )
413 pc->setFlag( QIMPenChar::Deleted ); 416 pc->setFlag( QIMPenChar::Deleted );
414 } 417 }
415} 418}
416 419
417/*! 420/*!
418 Find the best matches for \a ch in this character set. 421 Find the best matches for \a ch in this character set.
419 */ 422 */
420QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch ) 423QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch )
421{ 424{
422 QIMPenCharMatchList matches; 425 QIMPenCharMatchList matches;
423 426
424 QIMPenCharIterator ci( chars ); 427 QIMPenCharIterator ci( chars );
425 for ( ; ci.current(); ++ci ) { 428 for ( ; ci.current(); ++ci ) {
426 QIMPenChar *tmplChar = ci.current(); 429 QIMPenChar *tmplChar = ci.current();
427 if ( tmplChar->testFlag( QIMPenChar::Deleted ) ) { 430 if ( tmplChar->testFlag( QIMPenChar::Deleted ) ) {
428 continue; 431 continue;
429 } 432 }
430 int err; 433 int err;
431 if ( ch->penStrokes().count() <= tmplChar->penStrokes().count() ) { 434 if ( ch->penStrokes().count() <= tmplChar->penStrokes().count() ) {
432 err = ch->match( tmplChar ); 435 err = ch->match( tmplChar );
433 if ( err <= QIMPEN_MATCH_THRESHOLD ) { 436 if ( err <= QIMPEN_MATCH_THRESHOLD ) {
434 if (tmplChar->penStrokes().count() != ch->penStrokes().count()) 437 if (tmplChar->penStrokes().count() != ch->penStrokes().count())
435 err = QMIN(err*3, QIMPEN_MATCH_THRESHOLD); 438 err = QMIN(err*3, QIMPEN_MATCH_THRESHOLD);
436 QIMPenCharMatchList::Iterator it; 439 QIMPenCharMatchList::Iterator it;
437 for ( it = matches.begin(); it != matches.end(); ++it ) { 440 for ( it = matches.begin(); it != matches.end(); ++it ) {
438 if ( (*it).penChar->character() == tmplChar->character() && 441 if ( (*it).penChar->character() == tmplChar->character() &&
439 (*it).penChar->penStrokes().count() == tmplChar->penStrokes().count() ) { 442 (*it).penChar->penStrokes().count() == tmplChar->penStrokes().count() ) {
440 if ( (*it).error > err ) 443 if ( (*it).error > err )
441 (*it).error = err; 444 (*it).error = err;
442 break; 445 break;
443 } 446 }
444 } 447 }
445 if ( it == matches.end() ) { 448 if ( it == matches.end() ) {
446 QIMPenCharMatch m; 449 QIMPenCharMatch m;
447 m.error = err; 450 m.error = err;
448 m.penChar = tmplChar; 451 m.penChar = tmplChar;
449 matches.append( m ); 452 matches.append( m );
450 } 453 }
451 } 454 }
452 } 455 }
453 } 456 }
454 qHeapSort( matches ); 457 qHeapSort( matches );
455 /* 458 /*
456 QIMPenCharMatchList::Iterator it; 459 QIMPenCharMatchList::Iterator it;
457 for ( it = matches.begin(); it != matches.end(); ++it ) { 460 for ( it = matches.begin(); it != matches.end(); ++it ) {
458 qDebug( "Match: \'%c\', error %d, strokes %d", (*it).penChar->character(), 461 qDebug( "Match: \'%c\', error %d, strokes %d", (*it).penChar->character(),
459 (*it).error, (*it).penChar->penStrokes().count() ); 462 (*it).error, (*it).penChar->penStrokes().count() );
460 } 463 }
461 */ 464 */
462 return matches; 465 return matches;
463} 466}
464 467
465/*! 468/*!
466 Add a character \a ch to this set. 469 Add a character \a ch to this set.
467 QIMPenCharSet will delete this character when it is no longer needed. 470 QIMPenCharSet will delete this character when it is no longer needed.
468 */ 471 */
469void QIMPenCharSet::addChar( QIMPenChar *ch ) 472void QIMPenCharSet::addChar( QIMPenChar *ch )
470{ 473{
471 if ( ch->penStrokes().count() > maxStrokes ) 474 if ( ch->penStrokes().count() > maxStrokes )
472 maxStrokes = ch->penStrokes().count(); 475 maxStrokes = ch->penStrokes().count();
473 chars.append( ch ); 476 chars.append( ch );
474} 477}
475 478
476/*! 479/*!
477 Remove a character by reference \a ch from this set. 480 Remove a character by reference \a ch from this set.
478 QIMPenCharSet will delete this character. 481 QIMPenCharSet will delete this character.
479 */ 482 */
480void QIMPenCharSet::removeChar( QIMPenChar *ch ) 483void QIMPenCharSet::removeChar( QIMPenChar *ch )
481{ 484{
482 chars.remove( ch ); 485 chars.remove( ch );
483} 486}
484 487
485/*! 488/*!
486 Move the character up the list of characters. 489 Move the character up the list of characters.
487 */ 490 */
488void QIMPenCharSet::up( QIMPenChar *ch ) 491void QIMPenCharSet::up( QIMPenChar *ch )
diff --git a/inputmethods/handwriting/qimpenchar.h b/inputmethods/handwriting/qimpenchar.h
index efd6f16..e4e7645 100644
--- a/inputmethods/handwriting/qimpenchar.h
+++ b/inputmethods/handwriting/qimpenchar.h
@@ -1,157 +1,160 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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#ifndef QIMPENCHAR_H_ 21#ifndef QIMPENCHAR_H_
22#define QIMPENCHAR_H_ 22#define QIMPENCHAR_H_
23 23
24#include <qlist.h> 24#include <qlist.h>
25#include <qvaluelist.h> 25#include <qvaluelist.h>
26#include <qcstring.h> 26#include <qcstring.h>
27#include "qimpenstroke.h" 27#include "qimpenstroke.h"
28 28
29struct QIMPenSpecialKeys { 29struct QIMPenSpecialKeys {
30 int code; 30 int code;
31 char *name; 31 char *name;
32}; 32};
33 33
34extern const QIMPenSpecialKeys qimpen_specialKeys[]; 34extern const QIMPenSpecialKeys qimpen_specialKeys[];
35 35
36 36
37class QIMPenChar 37class QIMPenChar
38{ 38{
39public: 39public:
40 QIMPenChar(); 40 QIMPenChar();
41 QIMPenChar( const QIMPenChar & ); 41 QIMPenChar( const QIMPenChar & );
42 42
43 unsigned int character() const { return ch; } 43 unsigned int character() const { return ch; }
44 void setCharacter( unsigned int c ) { ch = c; } 44 void setCharacter( unsigned int c ) { ch = c; }
45 45
46 const QString &data() const { return d; } 46 const QString &data() const { return d; }
47 void setData( const QString &ba ) { d = ba; } 47 void setData( const QString &ba ) { d = ba; }
48 48
49 QString name() const; 49 QString name() const;
50 bool isEmpty() const { return strokes.isEmpty(); } 50 bool isEmpty() const { return strokes.isEmpty(); }
51 unsigned int strokeCount() const { return strokes.count(); } 51 unsigned int strokeCount() const { return strokes.count(); }
52 unsigned int strokeLength( int s ) const; 52 unsigned int strokeLength( int s ) const;
53 void clear(); 53 void clear();
54 int match( QIMPenChar *ch ); 54 int match( QIMPenChar *ch );
55 const QIMPenStrokeList &penStrokes() { return strokes; } 55 const QIMPenStrokeList &penStrokes() { return strokes; }
56 QPoint startingPoint() const { return strokes.getFirst()->startingPoint(); } 56 QPoint startingPoint() const { return strokes.getFirst()->startingPoint(); }
57 QRect boundingRect(); 57 QRect boundingRect();
58 58
59 void setFlag( int f ) { flags |= f; } 59 void setFlag( int f ) { flags |= f; }
60 void clearFlag( int f ) { flags &= ~f; } 60 void clearFlag( int f ) { flags &= ~f; }
61 bool testFlag( int f ) { return flags & f; } 61 bool testFlag( int f ) { return flags & f; }
62 62
63 enum Flags { System=0x01, Deleted=0x02, CombineRight=0x04, Data=0x08, Combined=0x10 }; 63 enum Flags { System=0x01, Deleted=0x02, CombineRight=0x04, Data=0x08, Combined=0x10 };
64 // Correspond to codes in template files. Do not change values. 64 // Correspond to codes in template files. Do not change values.
65 enum Mode { ModeBase=0x4000, Caps=0x4001, Shortcut=0x4002, CapsLock=0x4003, 65 enum Mode { ModeBase=0x4000, Caps=0x4001, Shortcut=0x4002, CapsLock=0x4003,
66 Punctuation=0x4004, Symbol=0x4005, Extended=0x4006 }; 66 Punctuation=0x4004, Symbol=0x4005, Extended=0x4006 };
67 67
68 QIMPenChar &operator=( const QIMPenChar &s ); 68 QIMPenChar &operator=( const QIMPenChar &s );
69 69
70 void addStroke( QIMPenStroke * ); 70 void addStroke( QIMPenStroke * );
71 71
72protected: 72protected:
73 unsigned int ch; 73 unsigned int ch;
74 QString d; 74 QString d;
75 Q_UINT8 flags; 75 Q_UINT8 flags;
76 QIMPenStrokeList strokes; 76 QIMPenStrokeList strokes;
77 77
78 friend QDataStream &operator<< (QDataStream &, const QIMPenChar &); 78 friend QDataStream &operator<< (QDataStream &, const QIMPenChar &);
79 friend QDataStream &operator>> (QDataStream &, QIMPenChar &); 79 friend QDataStream &operator>> (QDataStream &, QIMPenChar &);
80}; 80};
81 81
82typedef QList<QIMPenChar> QIMPenCharList; 82typedef QList<QIMPenChar> QIMPenCharList;
83typedef QListIterator<QIMPenChar> QIMPenCharIterator; 83typedef QListIterator<QIMPenChar> QIMPenCharIterator;
84 84
85QDataStream & operator<< (QDataStream & s, const QIMPenChar &ws); 85QDataStream & operator<< (QDataStream & s, const QIMPenChar &ws);
86QDataStream & operator>> (QDataStream & s, QIMPenChar &ws); 86QDataStream & operator>> (QDataStream & s, QIMPenChar &ws);
87 87
88struct QIMPenCharMatch 88struct QIMPenCharMatch
89{ 89{
90 int error; 90 int error;
91 QIMPenChar *penChar; 91 QIMPenChar *penChar;
92 92
93 bool operator>( const QIMPenCharMatch &m ); 93 bool operator>( const QIMPenCharMatch &m );
94 bool operator<( const QIMPenCharMatch &m ); 94 bool operator<( const QIMPenCharMatch &m );
95 bool operator<=( const QIMPenCharMatch &m ); 95 bool operator<=( const QIMPenCharMatch &m );
96}; 96};
97 97
98typedef QValueList<QIMPenCharMatch> QIMPenCharMatchList; 98typedef QValueList<QIMPenCharMatch> QIMPenCharMatchList;
99 99
100 100
101class QIMPenCharSet 101class QIMPenCharSet
102{ 102{
103public: 103public:
104 QIMPenCharSet(); 104 QIMPenCharSet();
105 QIMPenCharSet( const QString &fn ); 105 QIMPenCharSet( const QString &fn );
106 106
107 bool isEmpty() const { return chars.isEmpty(); } 107 bool isEmpty() const { return chars.isEmpty(); }
108 unsigned int count() const { return chars.count(); } 108 unsigned int count() const { return chars.count(); }
109 void clear() { chars.clear(); } 109 void clear() { chars.clear(); }
110 110
111 void setDescription( const QString &d ) { desc = d; } 111 void setDescription( const QString &d ) { desc = d; }
112 QString description() const { return desc; } 112 QString description() const { return desc; }
113 void setTitle( const QString &t ) { csTitle = t; } 113 void setTitle( const QString &t ) { csTitle = t; }
114 QString title() const { return csTitle; } 114 QString title() const { return csTitle; }
115 115
116 QIMPenCharMatchList match( QIMPenChar *ch ); 116 QIMPenCharMatchList match( QIMPenChar *ch );
117 void addChar( QIMPenChar *ch ); 117 void addChar( QIMPenChar *ch );
118 void removeChar( QIMPenChar *ch ); 118 void removeChar( QIMPenChar *ch );
119 QIMPenChar *at( int i ); 119 QIMPenChar *at( int i );
120 void setHidden ( const bool &b ) { phidden = &b; }
121 bool hidden() const { return phidden; }
120 122
121 unsigned maximumStrokes() const { return maxStrokes; } 123 unsigned maximumStrokes() const { return maxStrokes; }
122 124
123 void up( QIMPenChar *ch ); 125 void up( QIMPenChar *ch );
124 void down( QIMPenChar *ch ); 126 void down( QIMPenChar *ch );
125 127
126 enum Domain { System, User }; 128 enum Domain { System, User };
127 enum Type { Unknown=0x00, Lower=0x01, Upper=0x02, Combining=0x04, 129 enum Type { Unknown=0x00, Lower=0x01, Upper=0x02, Combining=0x04,
128 Numeric=0x08, Punctuation=0x10, Symbol=0x20, Shortcut=0x40 }; 130 Numeric=0x08, Punctuation=0x10, Symbol=0x20, Shortcut=0x40 };
129 131
130 const QIMPenCharList &characters() const { return chars; } 132 const QIMPenCharList &characters() const { return chars; }
131 133
132 void setType( Type t ) { csType = t; } 134 void setType( Type t ) { csType = t; }
133 Type type() const { return csType; } 135 Type type() const { return csType; }
134 136
135 const QString &filename( Domain d ) const; 137 const QString &filename( Domain d ) const;
136 void setFilename( const QString &fn, Domain d=System ); 138 void setFilename( const QString &fn, Domain d=System );
137 bool load( const QString &fn, Domain d=System ); 139 bool load( const QString &fn, Domain d=System );
138 bool save( Domain d=System ); 140 bool save( Domain d=System );
139 141
140protected: 142protected:
141 void markDeleted( uint ch ); 143 void markDeleted( uint ch );
142 144
143protected: 145protected:
144 QString csTitle; 146 QString csTitle;
145 QString desc; 147 QString desc;
146 QString sysFilename; 148 QString sysFilename;
147 QString userFilename; 149 QString userFilename;
148 Type csType; 150 Type csType;
149 unsigned maxStrokes; 151 unsigned maxStrokes;
150 QIMPenCharList chars; 152 QIMPenCharList chars;
151 QIMPenCharMatchList matches; 153 QIMPenCharMatchList matches;
154 bool phidden : 1;
152}; 155};
153 156
154typedef QList<QIMPenCharSet> QIMPenCharSetList; 157typedef QList<QIMPenCharSet> QIMPenCharSetList;
155typedef QListIterator<QIMPenCharSet> QIMPenCharSetIterator; 158typedef QListIterator<QIMPenCharSet> QIMPenCharSetIterator;
156 159
157#endif 160#endif
diff --git a/inputmethods/handwriting/qimpenprofile.cpp b/inputmethods/handwriting/qimpenprofile.cpp
index 3b1b5e9..b1a6592 100644
--- a/inputmethods/handwriting/qimpenprofile.cpp
+++ b/inputmethods/handwriting/qimpenprofile.cpp
@@ -1,245 +1,268 @@
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 "qimpencombining.h" 21#include "qimpencombining.h"
22#include "qimpenprofile.h" 22#include "qimpenprofile.h"
23 23
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/global.h> 26#include <qpe/global.h>
27 27
28 28
29QIMPenProfile::QIMPenProfile( const QString &fn ) 29QIMPenProfile::QIMPenProfile( const QString &fn )
30 : filename( fn ) 30 : filename( fn )
31{ 31{
32 sets.setAutoDelete( true ); 32 sets.setAutoDelete( true );
33 33
34 Config config( filename, Config::File ); 34 Config config( filename, Config::File );
35 config.setGroup( "Handwriting" ); 35 config.setGroup( "Handwriting" );
36 36
37 pname = config.readEntry( "Name" ); 37 pname = config.readEntry( "Name" );
38 pdesc = config.readEntry( "Description" ); 38 pdesc = config.readEntry( "Description" );
39 39
40 tstyle = config.readBoolEntry( "CanSelectStyle", false ); 40 tstyle = config.readBoolEntry( "CanSelectStyle", false );
41 41
42 wordMatch = config.readBoolEntry( "MatchWords", true ); 42 wordMatch = config.readBoolEntry( "MatchWords", true );
43 43
44 config.setGroup( "Settings" ); 44 config.setGroup( "Settings" );
45 45
46 pstyle = BothCases; 46 pstyle = BothCases;
47 QString s = config.readEntry( "Style", "BothCases" ); 47 QString s = config.readEntry( "Style", "BothCases" );
48 if ( s == "ToggleCases" ) 48 if ( s == "ToggleCases" )
49 pstyle = ToggleCases; 49 pstyle = ToggleCases;
50 50
51 QString t = config.readEntry( "Mono", "Dual" );
52 pmono = (QString::fromLatin1("Mono") == t );
53
51 msTimeout = config.readNumEntry( "MultiTimeout", 500 ); 54 msTimeout = config.readNumEntry( "MultiTimeout", 500 );
52 55
53 // Read user configuration 56 // Read user configuration
54 Config usrConfig( userConfig() ); 57 Config usrConfig( userConfig() );
55 usrConfig.setGroup( "Settings" ); 58 usrConfig.setGroup( "Settings" );
56 msTimeout = usrConfig.readNumEntry( "MultiTimeout", msTimeout ); 59 msTimeout = usrConfig.readNumEntry( "MultiTimeout", msTimeout );
57 60
58 if ( tstyle && usrConfig.hasKey( "Style" ) ) { 61 if ( tstyle && usrConfig.hasKey( "Style" ) ) {
59 pstyle = BothCases; 62 pstyle = BothCases;
60 QString s = usrConfig.readEntry( "Style", "BothCases" ); 63 QString s = usrConfig.readEntry( "Style", "BothCases" );
61 if ( s == "ToggleCases" ) 64 if ( s == "ToggleCases" )
62 pstyle = ToggleCases; 65 pstyle = ToggleCases;
63 } 66 }
64} 67}
65 68
66void QIMPenProfile::setStyle( Style s ) 69void QIMPenProfile::setStyle( Style s )
67{ 70{
68 if ( tstyle && s != pstyle ) { 71 if ( tstyle && s != pstyle ) {
69 pstyle = s; 72 pstyle = s;
70 Config config( userConfig() ); 73 Config config( userConfig() );
71 config.setGroup( "Settings" ); 74 config.setGroup( "Settings" );
72 QString s = pstyle == ToggleCases ? "ToggleCases" : "BothCases"; 75 QString s = pstyle == ToggleCases ? "ToggleCases" : "BothCases";
73 config.writeEntry( "Style", s ); 76 config.writeEntry( "Style", s );
74 } 77 }
75} 78}
76 79
77void QIMPenProfile::setMultiStrokeTimeout( int t ) 80void QIMPenProfile::setMultiStrokeTimeout( int t )
78{ 81{
79 if ( t != msTimeout ) { 82 if ( t != msTimeout ) {
80 msTimeout = t; 83 msTimeout = t;
81 Config config( userConfig() ); 84 Config config( userConfig() );
82 config.setGroup( "Settings" ); 85 config.setGroup( "Settings" );
83 config.writeEntry( "MultiTimeout", msTimeout ); 86 config.writeEntry( "MultiTimeout", msTimeout );
84 } 87 }
85} 88}
86 89
87QString QIMPenProfile::userConfig() 90QString QIMPenProfile::userConfig()
88{ 91{
89 QString un = filename; 92 QString un = filename;
90 int pos = un.findRev( '/' ); 93 int pos = un.findRev( '/' );
91 if ( pos >= 0 ) 94 if ( pos >= 0 )
92 un = un.mid( pos + 1 ); 95 un = un.mid( pos + 1 );
93 pos = un.find( '.' ); 96 pos = un.find( '.' );
94 if ( pos > 0 ) 97 if ( pos > 0 )
95 un.truncate( pos ); 98 un.truncate( pos );
96 99
97 un = "handwriting-" + un; // No tr 100 un = "handwriting-" + un; // No tr
98 101
99 return un; 102 return un;
100} 103}
101 104
102void QIMPenProfile::loadData() 105void QIMPenProfile::loadData()
103{ 106{
104 Config config( filename, Config::File ); 107 Config config( filename, Config::File );
105 config.setGroup( "CharSets" ); 108 config.setGroup( "CharSets" );
106 109
107 QString baseDir = QPEApplication::qpeDir(); 110 QString baseDir = QPEApplication::qpeDir();
108 baseDir += "/etc/"; 111 baseDir += "/etc/";
109 // accents 112 // accents
110 QIMPenCombining *combining = 0; 113 QIMPenCombining *combining = 0;
111 QString s = config.readEntry( "Combining" ); 114 QString s = config.readEntry( "Combining" );
112 if ( !s.isEmpty() ) { 115 if ( !s.isEmpty() ) {
113 combining = new QIMPenCombining( baseDir + "qimpen/" + s ); 116 combining = new QIMPenCombining( baseDir + "qimpen/" + s );
114 if ( combining->isEmpty() ) { 117 if ( combining->isEmpty() ) {
115 delete combining; 118 delete combining;
116 combining = 0; 119 combining = 0;
117 } 120 }
118 } 121 }
119 // uppercase latin1 122 // uppercase latin1
120 QIMPenCharSet *cs = 0; 123 QIMPenCharSet *cs = 0;
121 s = config.readEntry( "Uppercase" ); 124 s = config.readEntry( "Uppercase" );
122 if ( !s.isEmpty() ) { 125 if ( !s.isEmpty() && !mono() ) {
123 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 126 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
124 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 127 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
125 if ( !cs->isEmpty() ) { 128 if ( !cs->isEmpty() ) {
126 if ( combining ) 129 if ( combining )
127 combining->addCombined( cs ); 130 combining->addCombined( cs );
128 sets.append( cs ); 131 sets.append( cs );
129 } else { 132 } else {
130 delete cs; 133 delete cs;
131 } 134 }
132 } 135 }
133 // lowercase latin1 136 // lowercase latin1
134 s = config.readEntry( "Lowercase" ); 137 s = config.readEntry( "Lowercase" );
135 if ( !s.isEmpty() ) { 138 if ( !s.isEmpty() ) {
139 if ( mono() ) {
140 cs = new QIMPenCharSet ( baseDir + "qimpen/" + s );
141 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
142 if ( !cs->isEmpty() ) {
143 cs->setTitle( cs->title().upper() );
144 cs->setType( QIMPenCharSet::Upper );
145 cs->setHidden ( true );
146 QIMPenCharIterator it( cs->characters() );
147 for ( ; it.current(); ++it ) {
148 uint ch = it.current()->character();
149 if ( ch >= 'a' && ch <= 'z' )
150 it.current()->setCharacter( QChar(ch).upper() );
151 }
152 if ( combining )
153 combining->addCombined( cs );
154 sets.append( cs );
155 } else {
156 delete cs;
157 }
158 }
136 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 159 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
137 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 160 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
138 if ( !cs->isEmpty() ) { 161 if ( !cs->isEmpty() ) {
139 if ( combining ) 162 if ( combining )
140 combining->addCombined( cs ); 163 combining->addCombined( cs );
141 sets.append( cs ); 164 sets.append( cs );
142 } else { 165 } else {
143 delete cs; 166 delete cs;
144 } 167 }
145 } 168 }
146 // numeric (may comtain punctuation and symbols) 169 // numeric (may comtain punctuation and symbols)
147 s = config.readEntry( "Numeric" ); 170 s = config.readEntry( "Numeric" );
148 if ( !s.isEmpty() ) { 171 if ( !s.isEmpty() ) {
149 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 172 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
150 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 173 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
151 if ( !cs->isEmpty() ) { 174 if ( !cs->isEmpty() ) {
152 sets.append( cs ); 175 sets.append( cs );
153 } else { 176 } else {
154 delete cs; 177 delete cs;
155 } 178 }
156 } 179 }
157 // punctuation 180 // punctuation
158 s = config.readEntry( "Punctuation" ); 181 s = config.readEntry( "Punctuation" );
159 if ( !s.isEmpty() ) { 182 if ( !s.isEmpty() ) {
160 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 183 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
161 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 184 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
162 if ( !cs->isEmpty() ) { 185 if ( !cs->isEmpty() ) {
163 sets.append( cs ); 186 sets.append( cs );
164 } else { 187 } else {
165 delete cs; 188 delete cs;
166 } 189 }
167 } 190 }
168 // symbol 191 // symbol
169 s = config.readEntry( "Symbol" ); 192 s = config.readEntry( "Symbol" );
170 if ( !s.isEmpty() ) { 193 if ( !s.isEmpty() ) {
171 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 194 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
172 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 195 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
173 if ( !cs->isEmpty() ) { 196 if ( !cs->isEmpty() ) {
174 sets.append( cs ); 197 sets.append( cs );
175 } else { 198 } else {
176 delete cs; 199 delete cs;
177 } 200 }
178 } 201 }
179 // shortcut 202 // shortcut
180 s = config.readEntry( "Shortcut" ); 203 s = config.readEntry( "Shortcut" );
181 if ( !s.isEmpty() ) { 204 if ( !s.isEmpty() ) {
182 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 205 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
183 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 206 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
184 if ( !cs->isEmpty() ) { 207 if ( !cs->isEmpty() ) {
185 sets.append( cs ); 208 sets.append( cs );
186 } else { 209 } else {
187 delete cs; 210 delete cs;
188 } 211 }
189 } 212 }
190 213
191 if ( combining ) 214 if ( combining )
192 delete combining; 215 delete combining;
193} 216}
194 217
195QIMPenCharSet *QIMPenProfile::uppercase() 218QIMPenCharSet *QIMPenProfile::uppercase()
196{ 219{
197 return find( QIMPenCharSet::Upper ); 220 return find( QIMPenCharSet::Upper );
198} 221}
199 222
200QIMPenCharSet *QIMPenProfile::lowercase() 223QIMPenCharSet *QIMPenProfile::lowercase()
201{ 224{
202 return find( QIMPenCharSet::Lower ); 225 return find( QIMPenCharSet::Lower );
203} 226}
204 227
205QIMPenCharSet *QIMPenProfile::numeric() 228QIMPenCharSet *QIMPenProfile::numeric()
206{ 229{
207 return find( QIMPenCharSet::Numeric ); 230 return find( QIMPenCharSet::Numeric );
208} 231}
209 232
210QIMPenCharSet *QIMPenProfile::punctuation() 233QIMPenCharSet *QIMPenProfile::punctuation()
211{ 234{
212 return find( QIMPenCharSet::Punctuation ); 235 return find( QIMPenCharSet::Punctuation );
213} 236}
214 237
215QIMPenCharSet *QIMPenProfile::symbol() 238QIMPenCharSet *QIMPenProfile::symbol()
216{ 239{
217 return find( QIMPenCharSet::Symbol ); 240 return find( QIMPenCharSet::Symbol );
218} 241}
219 242
220QIMPenCharSet *QIMPenProfile::shortcut() 243QIMPenCharSet *QIMPenProfile::shortcut()
221{ 244{
222 return find( QIMPenCharSet::Shortcut ); 245 return find( QIMPenCharSet::Shortcut );
223} 246}
224 247
225QIMPenCharSetList &QIMPenProfile::charSets() 248QIMPenCharSetList &QIMPenProfile::charSets()
226{ 249{
227 if ( sets.isEmpty() ) 250 if ( sets.isEmpty() )
228 loadData(); 251 loadData();
229 return sets; 252 return sets;
230} 253}
231 254
232QIMPenCharSet *QIMPenProfile::find( QIMPenCharSet::Type t ) 255QIMPenCharSet *QIMPenProfile::find( QIMPenCharSet::Type t )
233{ 256{
234 if ( sets.isEmpty() ) 257 if ( sets.isEmpty() )
235 loadData(); 258 loadData();
236 QIMPenCharSetIterator it( sets ); 259 QIMPenCharSetIterator it( sets );
237 for ( ; it.current(); ++it ) { 260 for ( ; it.current(); ++it ) {
238 if ( it.current()->type() == t ) 261 if ( it.current()->type() == t )
239 return it.current(); 262 return it.current();
240 } 263 }
241 264
242 return 0; 265 return 0;
243} 266}
244 267
245 268
diff --git a/inputmethods/handwriting/qimpenprofile.h b/inputmethods/handwriting/qimpenprofile.h
index 4ce4367..adfa866 100644
--- a/inputmethods/handwriting/qimpenprofile.h
+++ b/inputmethods/handwriting/qimpenprofile.h
@@ -1,70 +1,72 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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#ifndef QIMPENPROFILE_H_ 21#ifndef QIMPENPROFILE_H_
22#define QIMPENPROFILE_H_ 22#define QIMPENPROFILE_H_
23 23
24#include "qimpenchar.h" 24#include "qimpenchar.h"
25 25
26class QIMPenProfile 26class QIMPenProfile
27{ 27{
28public: 28public:
29 QIMPenProfile( const QString &fn ); 29 QIMPenProfile( const QString &fn );
30 30
31 const QString &name() const { return pname; } 31 const QString &name() const { return pname; }
32 const QString &description() const { return pdesc; } 32 const QString &description() const { return pdesc; }
33 33
34 enum Style { ToggleCases, BothCases }; 34 enum Style { ToggleCases, BothCases };
35 Style style() const { return pstyle; } 35 Style style() const { return pstyle; }
36 bool mono() const { return pmono; }
36 void setStyle( Style s ); 37 void setStyle( Style s );
37 38
38 bool canSelectStyle() const { return tstyle; } 39 bool canSelectStyle() const { return tstyle; }
39 40
40 int multiStrokeTimeout() const { return msTimeout; } 41 int multiStrokeTimeout() const { return msTimeout; }
41 void setMultiStrokeTimeout( int t ); 42 void setMultiStrokeTimeout( int t );
42 43
43 bool matchWords() const { return wordMatch; } 44 bool matchWords() const { return wordMatch; }
44 45
45 QIMPenCharSet *uppercase(); 46 QIMPenCharSet *uppercase();
46 QIMPenCharSet *lowercase(); 47 QIMPenCharSet *lowercase();
47 QIMPenCharSet *numeric(); 48 QIMPenCharSet *numeric();
48 QIMPenCharSet *punctuation(); 49 QIMPenCharSet *punctuation();
49 QIMPenCharSet *symbol(); 50 QIMPenCharSet *symbol();
50 QIMPenCharSet *shortcut(); 51 QIMPenCharSet *shortcut();
51 QIMPenCharSet *find( QIMPenCharSet::Type t ); 52 QIMPenCharSet *find( QIMPenCharSet::Type t );
52 53
53 QIMPenCharSetList &charSets(); 54 QIMPenCharSetList &charSets();
54 55
55private: 56private:
56 QString userConfig(); 57 QString userConfig();
57 void loadData(); 58 void loadData();
58 59
59private: 60private:
60 QIMPenCharSetList sets; 61 QIMPenCharSetList sets;
61 QString filename; 62 QString filename;
62 QString pname; 63 QString pname;
63 QString pdesc; 64 QString pdesc;
64 Style pstyle; 65 Style pstyle;
65 bool tstyle; 66 bool tstyle;
66 int msTimeout; 67 int msTimeout;
67 bool wordMatch; 68 bool wordMatch;
69 bool pmono;
68}; 70};
69 71
70#endif 72#endif
diff --git a/inputmethods/handwriting/qimpensetup.cpp b/inputmethods/handwriting/qimpensetup.cpp
index 2441102..d0f9ffd 100644
--- a/inputmethods/handwriting/qimpensetup.cpp
+++ b/inputmethods/handwriting/qimpensetup.cpp
@@ -276,257 +276,258 @@ void QIMPenInputCharDlg::addSpecial( QComboBox *cb )
276} 276}
277 277
278void QIMPenInputCharDlg::setSpecial( int sp ) 278void QIMPenInputCharDlg::setSpecial( int sp )
279{ 279{
280 uni = qimpen_specialKeys[sp].code << 16; 280 uni = qimpen_specialKeys[sp].code << 16;
281} 281}
282 282
283void QIMPenInputCharDlg::setCharacter( const QString &string ) 283void QIMPenInputCharDlg::setCharacter( const QString &string )
284{ 284{
285 uni = string[0].unicode(); 285 uni = string[0].unicode();
286} 286}
287 287
288//--------------------------------------------------------------------------- 288//---------------------------------------------------------------------------
289 289
290class CharListItem : public QListBoxText 290class CharListItem : public QListBoxText
291{ 291{
292public: 292public:
293 CharListItem( const QString &text, uint c ) 293 CharListItem( const QString &text, uint c )
294 : QListBoxText( text ) 294 : QListBoxText( text )
295 { 295 {
296 _code = c; 296 _code = c;
297 } 297 }
298 298
299 uint code() const { return _code; } 299 uint code() const { return _code; }
300 300
301protected: 301protected:
302 uint _code; 302 uint _code;
303}; 303};
304 304
305/*! 305/*!
306 \class QIMPenEdit qimpensetup.h 306 \class QIMPenEdit qimpensetup.h
307 307
308 Class to allow users to input totally useless character definitions 308 Class to allow users to input totally useless character definitions
309 which could match any number of the default set. 309 which could match any number of the default set.
310*/ 310*/
311 311
312QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, 312QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent,
313 const char *name ) 313 const char *name )
314 : QWidget( parent, name ), profile(p) 314 : QWidget( parent, name ), profile(p)
315{ 315{
316 currentChar = 0; 316 currentChar = 0;
317 currentCode = 0; 317 currentCode = 0;
318 inputChar = new QIMPenChar(); 318 inputChar = new QIMPenChar();
319 319
320 QVBoxLayout *tvb = new QVBoxLayout( this, 5 ); 320 QVBoxLayout *tvb = new QVBoxLayout( this, 5 );
321 321
322 QGridLayout *gl = new QGridLayout( tvb, 4, 2 ); 322 QGridLayout *gl = new QGridLayout( tvb, 4, 2 );
323 gl->setRowStretch( 1, 1 ); 323 gl->setRowStretch( 1, 1 );
324 gl->addRowSpacing( 2, 35 ); 324 gl->addRowSpacing( 2, 35 );
325 gl->addRowSpacing( 3, 35 ); 325 gl->addRowSpacing( 3, 35 );
326 326
327 charSetCombo = new QComboBox( this ); 327 charSetCombo = new QComboBox( this );
328 gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); 328 gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 );
329 connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); 329 connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int)));
330 QIMPenCharSetIterator it( profile->charSets() ); 330 QIMPenCharSetIterator it( profile->charSets() );
331 for ( ; it.current(); ++it ) { 331 for ( ; it.current(); ++it ) {
332 charSetCombo->insertItem( it.current()->description() ); 332 charSetCombo->insertItem( it.current()->description() );
333 } 333 }
334 334
335 charList = new QListBox( this ); 335 charList = new QListBox( this );
336 charList->setMinimumHeight( charList->sizeHint().height() ); 336 charList->setMinimumHeight( charList->sizeHint().height() );
337 connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) ); 337 connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) );
338 gl->addWidget( charList, 1, 0 ); 338 gl->addWidget( charList, 1, 0 );
339 339
340 pw = new QIMPenWidget( this ); 340 pw = new QIMPenWidget( this );
341 pw->setFixedHeight( 75 ); 341 pw->setFixedHeight( 75 );
342 gl->addMultiCellWidget( pw, 2, 3, 0, 0 ); 342 gl->addMultiCellWidget( pw, 2, 3, 0, 0 );
343 connect( pw, SIGNAL(stroke(QIMPenStroke *)), 343 connect( pw, SIGNAL(stroke(QIMPenStroke *)),
344 SLOT(newStroke(QIMPenStroke *)) ); 344 SLOT(newStroke(QIMPenStroke *)) );
345 345
346 QVBoxLayout *vb = new QVBoxLayout(); 346 QVBoxLayout *vb = new QVBoxLayout();
347 gl->addLayout( vb, 1, 1 ); 347 gl->addLayout( vb, 1, 1 );
348 newBtn = new QPushButton( tr("New..."), this ); 348 newBtn = new QPushButton( tr("New..."), this );
349 connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) ); 349 connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) );
350 vb->addWidget( newBtn ); 350 vb->addWidget( newBtn );
351 351
352 addBtn = new QPushButton( tr("Add"), this ); 352 addBtn = new QPushButton( tr("Add"), this );
353 connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) ); 353 connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) );
354 vb->addWidget( addBtn ); 354 vb->addWidget( addBtn );
355 355
356 removeBtn = new QPushButton( tr("Remove"), this ); 356 removeBtn = new QPushButton( tr("Remove"), this );
357 connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) ); 357 connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) );
358 vb->addWidget( removeBtn ); 358 vb->addWidget( removeBtn );
359 359
360 QPushButton *pb = new QPushButton( tr("Default"), this ); 360 QPushButton *pb = new QPushButton( tr("Default"), this );
361 connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) ); 361 connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) );
362 vb->addWidget( pb ); 362 vb->addWidget( pb );
363 363
364 QHBoxLayout *hb = new QHBoxLayout(); 364 QHBoxLayout *hb = new QHBoxLayout();
365 gl->addLayout( hb, 2, 1 ); 365 gl->addLayout( hb, 2, 1 );
366 prevBtn = new QPushButton( this ); 366 prevBtn = new QPushButton( this );
367 prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); 367 prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) );
368 connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); 368 connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar()));
369 hb->addWidget( prevBtn ); 369 hb->addWidget( prevBtn );
370 370
371 nextBtn = new QPushButton( this ); 371 nextBtn = new QPushButton( this );
372 nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); 372 nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) );
373 connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); 373 connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar()));
374 hb->addWidget( nextBtn ); 374 hb->addWidget( nextBtn );
375 375
376 pb = new QPushButton( tr("Clear"), this ); 376 pb = new QPushButton( tr("Clear"), this );
377 connect( pb, SIGNAL(clicked()), SLOT(clearChar()) ); 377 connect( pb, SIGNAL(clicked()), SLOT(clearChar()) );
378 gl->addWidget( pb, 3, 1 ); 378 gl->addWidget( pb, 3, 1 );
379 379
380 //-- 380 //--
381#if !defined(Q_WS_QWS) 381#if !defined(Q_WS_QWS)
382 hb = new QHBoxLayout( tvb ); 382 hb = new QHBoxLayout( tvb );
383 pb = new QPushButton( tr("OK"), this ); 383 pb = new QPushButton( tr("OK"), this );
384 connect( pb, SIGNAL(clicked()), SLOT(accept()) ); 384 connect( pb, SIGNAL(clicked()), SLOT(accept()) );
385 hb->addWidget( pb ); 385 hb->addWidget( pb );
386 386
387 pb = new QPushButton( tr("Cancel"), this ); 387 pb = new QPushButton( tr("Cancel"), this );
388 connect( pb, SIGNAL(clicked()), SLOT(reject()) ); 388 connect( pb, SIGNAL(clicked()), SLOT(reject()) );
389 hb->addWidget( pb ); 389 hb->addWidget( pb );
390#endif 390#endif
391 selectCharSet( 0 ); 391 selectCharSet( 0 );
392 charList->setFocus(); 392 charList->setFocus();
393 393
394 resize( minimumSize() ); 394 resize( minimumSize() );
395 enableButtons(); 395 enableButtons();
396} 396}
397 397
398void QIMPenEdit::setProfile( QIMPenProfile *p ) 398void QIMPenEdit::setProfile( QIMPenProfile *p )
399{ 399{
400 profile = p; 400 profile = p;
401 charSetCombo->clear(); 401 charSetCombo->clear();
402 QIMPenCharSetIterator it( profile->charSets() ); 402 QIMPenCharSetIterator it( profile->charSets() );
403 for ( ; it.current(); ++it ) { 403 for ( ; it.current(); ++it ) {
404 charSetCombo->insertItem( it.current()->description() ); 404 if ( ! it.current()->hidden() )
405 charSetCombo->insertItem( it.current()->description() );
405 } 406 }
406 selectCharSet( 0 ); 407 selectCharSet( 0 );
407 charList->setFocus(); 408 charList->setFocus();
408 enableButtons(); 409 enableButtons();
409} 410}
410 411
411void QIMPenEdit::selectCharSet( QIMPenCharSet *c ) 412void QIMPenEdit::selectCharSet( QIMPenCharSet *c )
412{ 413{
413 int i = 0; 414 int i = 0;
414 QIMPenCharSetIterator it( profile->charSets() ); 415 QIMPenCharSetIterator it( profile->charSets() );
415 for ( ; it.current(); ++it, i++ ) { 416 for ( ; it.current(); ++it, i++ ) {
416 if ( it.current() == c ) { 417 if ( it.current() == c ) {
417 charSetCombo->setCurrentItem( i ); 418 charSetCombo->setCurrentItem( i );
418 selectCharSet( i ); 419 selectCharSet( i );
419 } 420 }
420 } 421 }
421} 422}
422 423
423 424
424/*! 425/*!
425 Fill the character list box with the characters. Duplicates are not 426 Fill the character list box with the characters. Duplicates are not
426 inserted. 427 inserted.
427*/ 428*/
428void QIMPenEdit::fillCharList() 429void QIMPenEdit::fillCharList()
429{ 430{
430 charList->clear(); 431 charList->clear();
431 QIMPenCharIterator it( currentSet->characters() ); 432 QIMPenCharIterator it( currentSet->characters() );
432 CharListItem *li = 0; 433 CharListItem *li = 0;
433 for ( ; it.current(); ++it ) { 434 for ( ; it.current(); ++it ) {
434 uint ch = it.current()->character(); 435 uint ch = it.current()->character();
435 QString n = it.current()->name(); 436 QString n = it.current()->name();
436 if ( !n.isEmpty() ) 437 if ( !n.isEmpty() )
437 li = new CharListItem( n, ch ); 438 li = new CharListItem( n, ch );
438 if ( li ) { 439 if ( li ) {
439 CharListItem *i = (CharListItem *)charList->findItem( li->text() ); 440 CharListItem *i = (CharListItem *)charList->findItem( li->text() );
440 if ( !i || i->code() != ch ) { 441 if ( !i || i->code() != ch ) {
441 charList->insertItem( li ); 442 charList->insertItem( li );
442 } else { 443 } else {
443 delete li; 444 delete li;
444 li = 0; 445 li = 0;
445 } 446 }
446 } 447 }
447 } 448 }
448 currentChar = 0; 449 currentChar = 0;
449} 450}
450 451
451void QIMPenEdit::enableButtons() 452void QIMPenEdit::enableButtons()
452{ 453{
453 bool add = !inputChar->isEmpty(); 454 bool add = !inputChar->isEmpty();
454 newBtn->setEnabled( add ); 455 newBtn->setEnabled( add );
455 addBtn->setEnabled( add ); 456 addBtn->setEnabled( add );
456 removeBtn->setEnabled( currentChar ); 457 removeBtn->setEnabled( currentChar );
457} 458}
458 459
459/*! 460/*!
460 Find the previous character with the same code as the current one. 461 Find the previous character with the same code as the current one.
461 returns 0 if there is no previous character. 462 returns 0 if there is no previous character.
462*/ 463*/
463QIMPenChar *QIMPenEdit::findPrev() 464QIMPenChar *QIMPenEdit::findPrev()
464{ 465{
465 if ( !currentChar ) 466 if ( !currentChar )
466 return 0; 467 return 0;
467 QIMPenCharIterator it( currentSet->characters() ); 468 QIMPenCharIterator it( currentSet->characters() );
468 bool found = FALSE; 469 bool found = FALSE;
469 for ( it.toLast(); it.current(); --it ) { 470 for ( it.toLast(); it.current(); --it ) {
470 if ( !found && it.current() == currentChar ) 471 if ( !found && it.current() == currentChar )
471 found = TRUE; 472 found = TRUE;
472 else if ( found && it.current()->character() == currentCode && 473 else if ( found && it.current()->character() == currentCode &&
473 !it.current()->testFlag( QIMPenChar::Deleted ) ) { 474 !it.current()->testFlag( QIMPenChar::Deleted ) ) {
474 return it.current(); 475 return it.current();
475 } 476 }
476 } 477 }
477 478
478 return 0; 479 return 0;
479} 480}
480 481
481/*! 482/*!
482 Find the next character with the same code as the current one. 483 Find the next character with the same code as the current one.
483 returns 0 if there is no next character. 484 returns 0 if there is no next character.
484*/ 485*/
485QIMPenChar *QIMPenEdit::findNext() 486QIMPenChar *QIMPenEdit::findNext()
486{ 487{
487 if ( !currentChar ) 488 if ( !currentChar )
488 return 0; 489 return 0;
489 QIMPenCharIterator it( currentSet->characters() ); 490 QIMPenCharIterator it( currentSet->characters() );
490 bool found = FALSE; 491 bool found = FALSE;
491 for ( ; it.current(); ++it ) { 492 for ( ; it.current(); ++it ) {
492 if ( !found && it.current() == currentChar ) 493 if ( !found && it.current() == currentChar )
493 found = TRUE; 494 found = TRUE;
494 else if ( found && it.current()->character() == currentCode && 495 else if ( found && it.current()->character() == currentCode &&
495 !it.current()->testFlag( QIMPenChar::Deleted ) ) { 496 !it.current()->testFlag( QIMPenChar::Deleted ) ) {
496 return it.current(); 497 return it.current();
497 } 498 }
498 } 499 }
499 500
500 return 0; 501 return 0;
501} 502}
502 503
503void QIMPenEdit::setCurrentChar( QIMPenChar *pc ) 504void QIMPenEdit::setCurrentChar( QIMPenChar *pc )
504{ 505{
505 currentChar = pc; 506 currentChar = pc;
506 pw->showCharacter( currentChar ); 507 pw->showCharacter( currentChar );
507 if ( currentChar ) { 508 if ( currentChar ) {
508 prevBtn->setEnabled( findPrev() != 0 ); 509 prevBtn->setEnabled( findPrev() != 0 );
509 nextBtn->setEnabled( findNext() != 0 ); 510 nextBtn->setEnabled( findNext() != 0 );
510 } 511 }
511} 512}
512 513
513void QIMPenEdit::prevChar() 514void QIMPenEdit::prevChar()
514{ 515{
515 QIMPenChar *pc = findPrev(); 516 QIMPenChar *pc = findPrev();
516 if ( pc ) 517 if ( pc )
517 setCurrentChar( pc ); 518 setCurrentChar( pc );
518} 519}
519 520
520void QIMPenEdit::nextChar() 521void QIMPenEdit::nextChar()
521{ 522{
522 QIMPenChar *pc = findNext(); 523 QIMPenChar *pc = findNext();
523 if ( pc ) 524 if ( pc )
524 setCurrentChar( pc ); 525 setCurrentChar( pc );
525} 526}
526 527
527void QIMPenEdit::clearChar() 528void QIMPenEdit::clearChar()
528{ 529{
529 inputChar->clear(); 530 inputChar->clear();
530 pw->clear(); 531 pw->clear();
531 enableButtons(); 532 enableButtons();
532} 533}