summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenprofile.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/inputmethods/handwriting/qimpenprofile.cpp b/inputmethods/handwriting/qimpenprofile.cpp
index 67343c3..180b0b0 100644
--- a/inputmethods/handwriting/qimpenprofile.cpp
+++ b/inputmethods/handwriting/qimpenprofile.cpp
@@ -1,271 +1,269 @@
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" ); 51 QString t = config.readEntry( "Mono", "Dual" );
52 pmono = (QString::fromLatin1("Mono") == t ); 52 pmono = (QString::fromLatin1("Mono") == t );
53 53
54 msTimeout = config.readNumEntry( "MultiTimeout", 500 ); 54 msTimeout = config.readNumEntry( "MultiTimeout", 500 );
55 55
56 // Read user configuration 56 // Read user configuration
57 Config usrConfig( userConfig() ); 57 Config usrConfig( userConfig() );
58 usrConfig.setGroup( "Settings" ); 58 usrConfig.setGroup( "Settings" );
59 msTimeout = usrConfig.readNumEntry( "MultiTimeout", msTimeout ); 59 msTimeout = usrConfig.readNumEntry( "MultiTimeout", msTimeout );
60 60
61 if ( tstyle && usrConfig.hasKey( "Style" ) ) { 61 if ( tstyle && usrConfig.hasKey( "Style" ) ) {
62 pstyle = BothCases; 62 pstyle = BothCases;
63 QString s = usrConfig.readEntry( "Style", "BothCases" ); 63 QString s = usrConfig.readEntry( "Style", "BothCases" );
64 if ( s == "ToggleCases" ) 64 if ( s == "ToggleCases" )
65 pstyle = ToggleCases; 65 pstyle = ToggleCases;
66 } 66 }
67} 67}
68 68
69void QIMPenProfile::setStyle( Style s ) 69void QIMPenProfile::setStyle( Style s )
70{ 70{
71 if ( tstyle && s != pstyle ) { 71 if ( tstyle && s != pstyle ) {
72 pstyle = s; 72 pstyle = s;
73 Config config( userConfig() ); 73 Config config( userConfig() );
74 config.setGroup( "Settings" ); 74 config.setGroup( "Settings" );
75 QString s = pstyle == ToggleCases ? "ToggleCases" : "BothCases"; 75 QString s = pstyle == ToggleCases ? "ToggleCases" : "BothCases";
76 config.writeEntry( "Style", s ); 76 config.writeEntry( "Style", s );
77 } 77 }
78} 78}
79 79
80void QIMPenProfile::setMultiStrokeTimeout( int t ) 80void QIMPenProfile::setMultiStrokeTimeout( int t )
81{ 81{
82 if ( t != msTimeout ) { 82 if ( t != msTimeout ) {
83 msTimeout = t; 83 msTimeout = t;
84 Config config( userConfig() ); 84 Config config( userConfig() );
85 config.setGroup( "Settings" ); 85 config.setGroup( "Settings" );
86 config.writeEntry( "MultiTimeout", msTimeout ); 86 config.writeEntry( "MultiTimeout", msTimeout );
87 } 87 }
88} 88}
89 89
90QString QIMPenProfile::userConfig() 90QString QIMPenProfile::userConfig()
91{ 91{
92 QString un = filename; 92 QString un = filename;
93 int pos = un.findRev( '/' ); 93 int pos = un.findRev( '/' );
94 if ( pos >= 0 ) 94 if ( pos >= 0 )
95 un = un.mid( pos + 1 ); 95 un = un.mid( pos + 1 );
96 pos = un.find( '.' ); 96 pos = un.find( '.' );
97 if ( pos > 0 ) 97 if ( pos > 0 )
98 un.truncate( pos ); 98 un.truncate( pos );
99 99
100 un = "handwriting-" + un; // No tr 100 un = "handwriting-" + un; // No tr
101 101
102 return un; 102 return un;
103} 103}
104 104
105void QIMPenProfile::loadData() 105void QIMPenProfile::loadData()
106{ 106{
107 Config config( filename, Config::File ); 107 Config config( filename, Config::File );
108 config.setGroup( "CharSets" ); 108 config.setGroup( "CharSets" );
109 109
110 QString baseDir = QPEApplication::qpeDir(); 110 QString baseDir = QPEApplication::qpeDir();
111 baseDir += "/etc/"; 111 baseDir += "/etc/";
112 // accents 112 // accents
113 QIMPenCombining *combining = 0; 113 QIMPenCombining *combining = 0;
114 QString s = config.readEntry( "Combining" ); 114 QString s = config.readEntry( "Combining" );
115 if ( !s.isEmpty() ) { 115 if ( !s.isEmpty() ) {
116 combining = new QIMPenCombining( baseDir + "qimpen/" + s ); 116 combining = new QIMPenCombining( baseDir + "qimpen/" + s );
117 if ( combining->isEmpty() ) { 117 if ( combining->isEmpty() ) {
118 delete combining; 118 delete combining;
119 combining = 0; 119 combining = 0;
120 } 120 }
121 } 121 }
122 // uppercase latin1 122 // uppercase latin1
123 QIMPenCharSet *cs = 0; 123 QIMPenCharSet *cs = 0;
124 s = config.readEntry( "Uppercase" ); 124 s = config.readEntry( "Uppercase" );
125 if ( !s.isEmpty() && !mono() ) { 125 if ( !s.isEmpty() && !mono() ) {
126 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 126 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
127 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 127 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
128 if ( !cs->isEmpty() ) { 128 if ( !cs->isEmpty() ) {
129 if ( combining ) 129 if ( combining )
130 combining->addCombined( cs ); 130 combining->addCombined( cs );
131 sets.append( cs ); 131 sets.append( cs );
132 } else { 132 } else {
133 delete cs; 133 delete cs;
134 } 134 }
135 } 135 }
136 // lowercase latin1 136 // lowercase latin1
137 s = config.readEntry( "Lowercase" ); 137 s = config.readEntry( "Lowercase" );
138 if ( !s.isEmpty() ) { 138 if ( !s.isEmpty() ) {
139 if ( mono() ) { 139 if ( mono() ) {
140 cs = new QIMPenCharSet ( baseDir + "qimpen/" + s ); 140 cs = new QIMPenCharSet ( baseDir + "qimpen/" + s );
141 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 141 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
142 if ( !cs->isEmpty() ) { 142 if ( !cs->isEmpty() ) {
143 cs->setTitle( cs->title().upper() ); 143 cs->setTitle( cs->title().upper() );
144 cs->setType( QIMPenCharSet::Upper ); 144 cs->setType( QIMPenCharSet::Upper );
145 cs->setDescription( "Hidden uppercase" ); 145 cs->setDescription( "Hidden uppercase" );
146 cs->setHidden ( true ); 146 cs->setHidden ( true );
147 QIMPenCharIterator it( cs->characters() ); 147 QIMPenCharIterator it( cs->characters() );
148 for ( ; it.current(); ++it ) { 148 for ( ; it.current(); ++it ) {
149 uint ch = it.current()->character(); 149 uint ch = it.current()->character();
150 if ( ch >= 'a' && ch <= 'z' ) 150 if ( ch >= 'a' && ch <= 'z' )
151 it.current()->setCharacter( QChar(ch).upper() ); 151 it.current()->setCharacter( QChar(ch).upper() );
152 } 152 }
153 if ( combining ) 153 if ( combining )
154 combining->addCombined( cs ); 154 combining->addCombined( cs );
155 sets.append( cs ); 155 sets.append( cs );
156 } else { 156 } else {
157 delete cs; 157 delete cs;
158 } 158 }
159 } 159 }
160 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 160 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
161 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 161 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
162 if ( !cs->isEmpty() ) { 162 if ( !cs->isEmpty() ) {
163 if ( mono () )
164 cs->setDescription( "Latin Characters" );
165 if ( combining ) 163 if ( combining )
166 combining->addCombined( cs ); 164 combining->addCombined( cs );
167 sets.append( cs ); 165 sets.append( cs );
168 } else { 166 } else {
169 delete cs; 167 delete cs;
170 } 168 }
171 } 169 }
172 // numeric (may comtain punctuation and symbols) 170 // numeric (may comtain punctuation and symbols)
173 s = config.readEntry( "Numeric" ); 171 s = config.readEntry( "Numeric" );
174 if ( !s.isEmpty() ) { 172 if ( !s.isEmpty() ) {
175 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 173 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
176 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 174 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
177 if ( !cs->isEmpty() ) { 175 if ( !cs->isEmpty() ) {
178 sets.append( cs ); 176 sets.append( cs );
179 } else { 177 } else {
180 delete cs; 178 delete cs;
181 } 179 }
182 } 180 }
183 // punctuation 181 // punctuation
184 s = config.readEntry( "Punctuation" ); 182 s = config.readEntry( "Punctuation" );
185 if ( !s.isEmpty() ) { 183 if ( !s.isEmpty() ) {
186 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 184 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
187 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 185 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
188 if ( !cs->isEmpty() ) { 186 if ( !cs->isEmpty() ) {
189 sets.append( cs ); 187 sets.append( cs );
190 } else { 188 } else {
191 delete cs; 189 delete cs;
192 } 190 }
193 } 191 }
194 // symbol 192 // symbol
195 s = config.readEntry( "Symbol" ); 193 s = config.readEntry( "Symbol" );
196 if ( !s.isEmpty() ) { 194 if ( !s.isEmpty() ) {
197 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 195 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
198 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 196 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
199 if ( !cs->isEmpty() ) { 197 if ( !cs->isEmpty() ) {
200 sets.append( cs ); 198 sets.append( cs );
201 } else { 199 } else {
202 delete cs; 200 delete cs;
203 } 201 }
204 } 202 }
205 // shortcut 203 // shortcut
206 s = config.readEntry( "Shortcut" ); 204 s = config.readEntry( "Shortcut" );
207 if ( !s.isEmpty() ) { 205 if ( !s.isEmpty() ) {
208 cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); 206 cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
209 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); 207 cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
210 if ( !cs->isEmpty() ) { 208 if ( !cs->isEmpty() ) {
211 sets.append( cs ); 209 sets.append( cs );
212 } else { 210 } else {
213 delete cs; 211 delete cs;
214 } 212 }
215 } 213 }
216 214
217 if ( combining ) 215 if ( combining )
218 delete combining; 216 delete combining;
219} 217}
220 218
221QIMPenCharSet *QIMPenProfile::uppercase() 219QIMPenCharSet *QIMPenProfile::uppercase()
222{ 220{
223 return find( QIMPenCharSet::Upper ); 221 return find( QIMPenCharSet::Upper );
224} 222}
225 223
226QIMPenCharSet *QIMPenProfile::lowercase() 224QIMPenCharSet *QIMPenProfile::lowercase()
227{ 225{
228 return find( QIMPenCharSet::Lower ); 226 return find( QIMPenCharSet::Lower );
229} 227}
230 228
231QIMPenCharSet *QIMPenProfile::numeric() 229QIMPenCharSet *QIMPenProfile::numeric()
232{ 230{
233 return find( QIMPenCharSet::Numeric ); 231 return find( QIMPenCharSet::Numeric );
234} 232}
235 233
236QIMPenCharSet *QIMPenProfile::punctuation() 234QIMPenCharSet *QIMPenProfile::punctuation()
237{ 235{
238 return find( QIMPenCharSet::Punctuation ); 236 return find( QIMPenCharSet::Punctuation );
239} 237}
240 238
241QIMPenCharSet *QIMPenProfile::symbol() 239QIMPenCharSet *QIMPenProfile::symbol()
242{ 240{
243 return find( QIMPenCharSet::Symbol ); 241 return find( QIMPenCharSet::Symbol );
244} 242}
245 243
246QIMPenCharSet *QIMPenProfile::shortcut() 244QIMPenCharSet *QIMPenProfile::shortcut()
247{ 245{
248 return find( QIMPenCharSet::Shortcut ); 246 return find( QIMPenCharSet::Shortcut );
249} 247}
250 248
251QIMPenCharSetList &QIMPenProfile::charSets() 249QIMPenCharSetList &QIMPenProfile::charSets()
252{ 250{
253 if ( sets.isEmpty() ) 251 if ( sets.isEmpty() )
254 loadData(); 252 loadData();
255 return sets; 253 return sets;
256} 254}
257 255
258QIMPenCharSet *QIMPenProfile::find( QIMPenCharSet::Type t ) 256QIMPenCharSet *QIMPenProfile::find( QIMPenCharSet::Type t )
259{ 257{
260 if ( sets.isEmpty() ) 258 if ( sets.isEmpty() )
261 loadData(); 259 loadData();
262 QIMPenCharSetIterator it( sets ); 260 QIMPenCharSetIterator it( sets );
263 for ( ; it.current(); ++it ) { 261 for ( ; it.current(); ++it ) {
264 if ( it.current()->type() == t ) 262 if ( it.current()->type() == t )
265 return it.current(); 263 return it.current();
266 } 264 }
267 265
268 return 0; 266 return 0;
269} 267}
270 268
271 269