summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenchar.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/inputmethods/handwriting/qimpenchar.cpp b/inputmethods/handwriting/qimpenchar.cpp
index b83b2a4..96a0502 100644
--- a/inputmethods/handwriting/qimpenchar.cpp
+++ b/inputmethods/handwriting/qimpenchar.cpp
@@ -329,33 +329,34 @@ bool QIMPenCharSet::load( const QString &fn, Domain d )
329 ds >> (Q_INT8 &)csType; 329 ds >> (Q_INT8 &)csType;
330 } else { 330 } else {
331 if ( csTitle == "abc" ) 331 if ( csTitle == "abc" )
332 csType = Lower; 332 csType = Lower;
333 else if ( csTitle == "ABC" ) 333 else if ( csTitle == "ABC" )
334 csType = Upper; 334 csType = Upper;
335 else if ( csTitle == "123" ) 335 else if ( csTitle == "123" )
336 csType = Numeric; 336 csType = Numeric;
337 else if ( fn == "Combining" ) 337 else if ( fn == "Combining" )
338 csType = Combining; 338 csType = Combining;
339 } 339 }
340 while ( !ds.atEnd() ) { 340 while ( !ds.atEnd() ) {
341 QIMPenChar *pc = new QIMPenChar; 341 QIMPenChar *pc = new QIMPenChar;
342 ds >> *pc; 342 ds >> *pc;
343 if ( d == User ) 343 if ( d == User )
344 markDeleted( pc->character() ); // override system 344 markDeleted( pc->character() ); // override system
345 addChar( pc ); 345 if ( !pc->testFlag( QIMPenChar::Deleted ) )
346 addChar( pc );
346 } 347 }
347 if ( file.status() == IO_Ok ) 348 if ( file.status() == IO_Ok )
348 ok = TRUE; 349 ok = TRUE;
349 } 350 }
350 setHidden ( false ); 351 setHidden ( false );
351 return ok; 352 return ok;
352} 353}
353 354
354/*! 355/*!
355 Save this character set. 356 Save this character set.
356 */ 357 */
357bool QIMPenCharSet::save( Domain d ) 358bool QIMPenCharSet::save( Domain d )
358{ 359{
359 if ( filename( d ).isEmpty() ) 360 if ( filename( d ).isEmpty() )
360 return FALSE; 361 return FALSE;
361 362
@@ -364,34 +365,47 @@ bool QIMPenCharSet::save( Domain d )
364 365
365 bool ok = FALSE; 366 bool ok = FALSE;
366 367
367 QString fn = filename( d ); 368 QString fn = filename( d );
368 QString tmpFn = fn + ".new"; 369 QString tmpFn = fn + ".new";
369 QFile file( tmpFn ); 370 QFile file( tmpFn );
370 if ( file.open( IO_WriteOnly|IO_Raw ) ) { 371 if ( file.open( IO_WriteOnly|IO_Raw ) ) {
371 QByteArray buf; 372 QByteArray buf;
372 QDataStream ds( buf, IO_WriteOnly ); 373 QDataStream ds( buf, IO_WriteOnly );
373 ds << QString( "QPT 1.1" ); 374 ds << QString( "QPT 1.1" );
374 ds << csTitle; 375 ds << csTitle;
375 ds << desc; 376 ds << desc;
376 ds << (Q_INT8)csType; 377 ds << (Q_INT8)csType;
377 QIMPenCharIterator ci( chars ); 378 QIMPenCharIterator ci( chars );
378 for ( ; ci.current(); ++ci ) { 379 for ( ; ci.current(); ++ci ) {
379 QIMPenChar *pc = ci.current(); 380 QIMPenChar *pc = ci.current();
380 if ( ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) || 381/*
381 ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) && 382 * If the Domain is System and the Char is marked System - OR
383 * the domain is User, the Char is User and it's not deleted - OR
384 * the domain is User, the Char is System and it is deleted - AND
385 * the character is not an automated Combined Character
386 *
387 * This is required to ensure that we don't save user defined chars that have been deleted, but
388 * we *DO* save System chars that have been deleted. There is still the issue of deleted combined
389 * chars but I'm not sure how to tackle that yet
390 *
391 */
392
393 if ( ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) ||
394 ( (d == User) && !pc->testFlag( QIMPenChar::System ) && !pc->testFlag( QIMPenChar::Deleted ) ) ||
395 ( (d == User) && pc->testFlag( QIMPenChar::System ) && pc->testFlag( QIMPenChar::Deleted ) ) ) &&
382 ( !pc->testFlag (QIMPenChar::Combined ) ) ) { 396 ( !pc->testFlag (QIMPenChar::Combined ) ) ) {
383 ds << *pc; 397 ds << *pc;
384 } 398 }
385 } 399 }
386 400
387 file.writeBlock( buf ); 401 file.writeBlock( buf );
388 file.close(); 402 file.close();
389 if ( file.status() == IO_Ok ) 403 if ( file.status() == IO_Ok )
390 ok = TRUE; 404 ok = TRUE;
391 } 405 }
392 406
393 if ( ok ) { 407 if ( ok ) {
394 if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) { 408 if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) {
395 owarn << "problem renaming file " <<tmpFn.latin1() << " to "<< fn.latin1() 409 owarn << "problem renaming file " <<tmpFn.latin1() << " to "<< fn.latin1()
396 << ", errno: " << errno << oendl; 410 << ", errno: " << errno << oendl;
397 // remove the tmp file, otherwise, it will just lay around... 411 // remove the tmp file, otherwise, it will just lay around...