summaryrefslogtreecommitdiff
path: root/inputmethods
authortreke <treke>2003-12-23 15:35:21 (UTC)
committer treke <treke>2003-12-23 15:35:21 (UTC)
commit0a613593f2e57c2805d1eef47c16b9fcb8c94a08 (patch) (side-by-side diff)
tree070fe1957d0900ba3364142fe7ecccbf53c3f847 /inputmethods
parent127c50cc446de489c702400ebc5fc4874f6311b2 (diff)
downloadopie-0a613593f2e57c2805d1eef47c16b9fcb8c94a08.zip
opie-0a613593f2e57c2805d1eef47c16b9fcb8c94a08.tar.gz
opie-0a613593f2e57c2805d1eef47c16b9fcb8c94a08.tar.bz2
Patch from Brad Campbell to fix opie-handwritings writing of data files
Diffstat (limited to 'inputmethods') (more/less context) (show whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenchar.cpp13
-rw-r--r--inputmethods/handwriting/qimpenchar.h2
-rw-r--r--inputmethods/handwriting/qimpencombining.cpp1
3 files changed, 10 insertions, 6 deletions
diff --git a/inputmethods/handwriting/qimpenchar.cpp b/inputmethods/handwriting/qimpenchar.cpp
index 152bfec..0c37e5c 100644
--- a/inputmethods/handwriting/qimpenchar.cpp
+++ b/inputmethods/handwriting/qimpenchar.cpp
@@ -355,39 +355,42 @@ bool QIMPenCharSet::load( const QString &fn, Domain d )
*/
bool QIMPenCharSet::save( Domain d )
{
if ( filename( d ).isEmpty() )
return FALSE;
bool ok = FALSE;
QString fn = filename( d );
QString tmpFn = fn + ".new";
QFile file( tmpFn );
if ( file.open( IO_WriteOnly|IO_Raw ) ) {
- QDataStream ds( &file );
+ QByteArray buf;
+ QDataStream ds( buf, IO_WriteOnly );
ds << QString( "QPT 1.1" );
ds << csTitle;
ds << desc;
ds << (Q_INT8)csType;
QIMPenCharIterator ci( chars );
for ( ; ci.current(); ++ci ) {
QIMPenChar *pc = ci.current();
- if ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) ||
- ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) {
+ if ( ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) ||
+ ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) &&
+ ( !pc->testFlag (QIMPenChar::Combined ) ) ) {
ds << *pc;
}
- if ( file.status() != IO_Ok )
- break;
}
+
+ file.writeBlock( buf );
+ file.close();
if ( file.status() == IO_Ok )
ok = TRUE;
}
if ( ok ) {
if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) {
qWarning( "problem renaming file %s to %s, errno: %d",
tmpFn.latin1(), fn.latin1(), errno );
// remove the tmp file, otherwise, it will just lay around...
QFile::remove( tmpFn.latin1() );
ok = FALSE;
}
diff --git a/inputmethods/handwriting/qimpenchar.h b/inputmethods/handwriting/qimpenchar.h
index 9a5f687..efd6f16 100644
--- a/inputmethods/handwriting/qimpenchar.h
+++ b/inputmethods/handwriting/qimpenchar.h
@@ -51,25 +51,25 @@ public:
unsigned int strokeCount() const { return strokes.count(); }
unsigned int strokeLength( int s ) const;
void clear();
int match( QIMPenChar *ch );
const QIMPenStrokeList &penStrokes() { return strokes; }
QPoint startingPoint() const { return strokes.getFirst()->startingPoint(); }
QRect boundingRect();
void setFlag( int f ) { flags |= f; }
void clearFlag( int f ) { flags &= ~f; }
bool testFlag( int f ) { return flags & f; }
- enum Flags { System=0x01, Deleted=0x02, CombineRight=0x04, Data=0x08 };
+ enum Flags { System=0x01, Deleted=0x02, CombineRight=0x04, Data=0x08, Combined=0x10 };
// Correspond to codes in template files. Do not change values.
enum Mode { ModeBase=0x4000, Caps=0x4001, Shortcut=0x4002, CapsLock=0x4003,
Punctuation=0x4004, Symbol=0x4005, Extended=0x4006 };
QIMPenChar &operator=( const QIMPenChar &s );
void addStroke( QIMPenStroke * );
protected:
unsigned int ch;
QString d;
Q_UINT8 flags;
diff --git a/inputmethods/handwriting/qimpencombining.cpp b/inputmethods/handwriting/qimpencombining.cpp
index 30459e7..2e01ac2 100644
--- a/inputmethods/handwriting/qimpencombining.cpp
+++ b/inputmethods/handwriting/qimpencombining.cpp
@@ -63,24 +63,25 @@ void QIMPenCombining::addCombined( QIMPenCharSet *cs )
continue;
int charIdx = findCombining( pc->character() );
if ( charIdx < 0 )
continue;
for ( int i = 0; i < 6; i++ ) {
if ( combiningChars[charIdx][i+1] ) {
QIMPenCharIterator cit( chars );
for ( ; cit.current(); ++cit ) {
QIMPenChar *accentPc = cit.current();
if ( accentPc->character() == combiningSymbols[i] ) {
QIMPenChar *combined = combine( pc, accentPc );
combined->setCharacter( combiningChars[charIdx][i+1] );
+ combined->setFlag( QIMPenChar::Combined );
cs->addChar( combined );
}
}
}
}
}
}
int QIMPenCombining::findCombining( unsigned int ch ) const
{
int i = 0;
while ( combiningChars[i][0] ) {