author | brad <brad> | 2004-04-05 13:42:55 (UTC) |
---|---|---|
committer | brad <brad> | 2004-04-05 13:42:55 (UTC) |
commit | 997a521a3ee84f614e2781a663911096ffb4a91a (patch) (unidiff) | |
tree | b54102f944af07bb0a8f3930ef856cbeff5f4899 | |
parent | f31cf618522b8b8855c5905c20754f7d5a762be3 (diff) | |
download | opie-997a521a3ee84f614e2781a663911096ffb4a91a.zip opie-997a521a3ee84f614e2781a663911096ffb4a91a.tar.gz opie-997a521a3ee84f614e2781a663911096ffb4a91a.tar.bz2 |
Missed qWarning and deps
-rw-r--r-- | inputmethods/handwriting/config.in | 2 | ||||
-rw-r--r-- | inputmethods/handwriting/handwriting.pro | 2 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpenchar.cpp | 4 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpensetup.cpp | 3 |
4 files changed, 6 insertions, 5 deletions
diff --git a/inputmethods/handwriting/config.in b/inputmethods/handwriting/config.in index 3a5fddb..b4acc9a 100644 --- a/inputmethods/handwriting/config.in +++ b/inputmethods/handwriting/config.in | |||
@@ -1,8 +1,8 @@ | |||
1 | config HANDWRITING | 1 | config HANDWRITING |
2 | boolean "opie-handwriting (Handwriting recognition)" | 2 | boolean "opie-handwriting (Handwriting recognition)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE |
5 | comment "opie-handwriting-classicset automatically selected" | 5 | comment "opie-handwriting-classicset automatically selected" |
6 | depends HANDWRITING | 6 | depends HANDWRITING |
7 | comment "opie-handwriting-graffitiset automatically selected" | 7 | comment "opie-handwriting-graffitiset automatically selected" |
8 | depends HANDWRITING | 8 | depends HANDWRITING |
diff --git a/inputmethods/handwriting/handwriting.pro b/inputmethods/handwriting/handwriting.pro index 3800381..e6f3b3f 100644 --- a/inputmethods/handwriting/handwriting.pro +++ b/inputmethods/handwriting/handwriting.pro | |||
@@ -1,34 +1,34 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt plugin warn_on release | 2 | CONFIG += qt plugin warn_on release |
3 | HEADERS= qimpenchar.h \ | 3 | HEADERS= qimpenchar.h \ |
4 | qimpenprofile.h \ | 4 | qimpenprofile.h \ |
5 | qimpencombining.h \ | 5 | qimpencombining.h \ |
6 | qimpenhelp.h \ | 6 | qimpenhelp.h \ |
7 | qimpeninput.h \ | 7 | qimpeninput.h \ |
8 | qimpenmatch.h \ | 8 | qimpenmatch.h \ |
9 | qimpensetup.h \ | 9 | qimpensetup.h \ |
10 | qimpenstroke.h \ | 10 | qimpenstroke.h \ |
11 | qimpenwidget.h \ | 11 | qimpenwidget.h \ |
12 | qimpenwordpick.h \ | 12 | qimpenwordpick.h \ |
13 | handwritingimpl.h | 13 | handwritingimpl.h |
14 | SOURCES= qimpenchar.cpp \ | 14 | SOURCES= qimpenchar.cpp \ |
15 | qimpenprofile.cpp \ | 15 | qimpenprofile.cpp \ |
16 | qimpencombining.cpp \ | 16 | qimpencombining.cpp \ |
17 | qimpenhelp.cpp \ | 17 | qimpenhelp.cpp \ |
18 | qimpeninput.cpp \ | 18 | qimpeninput.cpp \ |
19 | qimpenmatch.cpp \ | 19 | qimpenmatch.cpp \ |
20 | qimpensetup.cpp \ | 20 | qimpensetup.cpp \ |
21 | qimpenstroke.cpp \ | 21 | qimpenstroke.cpp \ |
22 | qimpenwidget.cpp \ | 22 | qimpenwidget.cpp \ |
23 | qimpenwordpick.cpp \ | 23 | qimpenwordpick.cpp \ |
24 | handwritingimpl.cpp | 24 | handwritingimpl.cpp |
25 | INTERFACES = qimpenprefbase.ui | 25 | INTERFACES = qimpenprefbase.ui |
26 | TARGET = qhandwriting | 26 | TARGET = qhandwriting |
27 | DESTDIR = ../../plugins/inputmethods | 27 | DESTDIR = ../../plugins/inputmethods |
28 | INCLUDEPATH += $(OPIEDIR)/include | 28 | INCLUDEPATH += $(OPIEDIR)/include |
29 | DEPENDPATH += ../$(OPIEDIR)/include ../../launcher | 29 | DEPENDPATH += ../$(OPIEDIR)/include ../../launcher |
30 | LIBS += -lqpe | 30 | LIBS += -lqpe -lopiecore2 |
31 | VERSION = 1.0.0 | 31 | VERSION = 1.0.0 |
32 | 32 | ||
33 | include ( $(OPIEDIR)/include.pro ) | 33 | include ( $(OPIEDIR)/include.pro ) |
34 | target.path = $$prefix/plugins/inputmethods | 34 | target.path = $$prefix/plugins/inputmethods |
diff --git a/inputmethods/handwriting/qimpenchar.cpp b/inputmethods/handwriting/qimpenchar.cpp index db5d135..b83b2a4 100644 --- a/inputmethods/handwriting/qimpenchar.cpp +++ b/inputmethods/handwriting/qimpenchar.cpp | |||
@@ -11,502 +11,502 @@ | |||
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 <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qtl.h> | 22 | #include <qtl.h> |
23 | #include <math.h> | 23 | #include <math.h> |
24 | #include <limits.h> | 24 | #include <limits.h> |
25 | #include <errno.h> | 25 | #include <errno.h> |
26 | #include <qdatastream.h> | 26 | #include <qdatastream.h> |
27 | #include "qimpencombining.h" | 27 | #include "qimpencombining.h" |
28 | #include "qimpenchar.h" | 28 | #include "qimpenchar.h" |
29 | #include "opie2/odebug.h" | 29 | #include "opie2/odebug.h" |
30 | 30 | ||
31 | #define QIMPEN_MATCH_THRESHOLD 200000 | 31 | #define QIMPEN_MATCH_THRESHOLD 200000 |
32 | 32 | ||
33 | const QIMPenSpecialKeys qimpen_specialKeys[] = { | 33 | const QIMPenSpecialKeys qimpen_specialKeys[] = { |
34 | { Qt::Key_Escape, "[Esc]" }, | 34 | { Qt::Key_Escape, "[Esc]" }, |
35 | { Qt::Key_Tab, "[Tab]" }, | 35 | { Qt::Key_Tab, "[Tab]" }, |
36 | { Qt::Key_Backspace,"[BackSpace]" }, | 36 | { Qt::Key_Backspace,"[BackSpace]" }, |
37 | { Qt::Key_Return, "[Return]" }, | 37 | { Qt::Key_Return, "[Return]" }, |
38 | { QIMPenChar::Caps, "[Uppercase]" }, | 38 | { QIMPenChar::Caps, "[Uppercase]" }, |
39 | { QIMPenChar::CapsLock,"[Caps Lock]" }, | 39 | { QIMPenChar::CapsLock,"[Caps Lock]" }, |
40 | { QIMPenChar::Shortcut,"[Shortcut]" }, | 40 | { QIMPenChar::Shortcut,"[Shortcut]" }, |
41 | { QIMPenChar::Punctuation, "[Punctuation]" }, | 41 | { QIMPenChar::Punctuation, "[Punctuation]" }, |
42 | { QIMPenChar::Symbol,"[Symbol]" }, | 42 | { QIMPenChar::Symbol,"[Symbol]" }, |
43 | { QIMPenChar::Extended,"[Extended]" }, | 43 | { QIMPenChar::Extended,"[Extended]" }, |
44 | { Qt::Key_unknown, 0 } }; | 44 | { Qt::Key_unknown, 0 } }; |
45 | 45 | ||
46 | 46 | ||
47 | /*! | 47 | /*! |
48 | \class QIMPenChar qimpenchar.h | 48 | \class QIMPenChar qimpenchar.h |
49 | 49 | ||
50 | Handles a single character. Can calculate closeness of match to | 50 | Handles a single character. Can calculate closeness of match to |
51 | another character. | 51 | another character. |
52 | */ | 52 | */ |
53 | 53 | ||
54 | QIMPenChar::QIMPenChar() | 54 | QIMPenChar::QIMPenChar() |
55 | { | 55 | { |
56 | flags = 0; | 56 | flags = 0; |
57 | strokes.setAutoDelete( TRUE ); | 57 | strokes.setAutoDelete( TRUE ); |
58 | } | 58 | } |
59 | 59 | ||
60 | QIMPenChar::QIMPenChar( const QIMPenChar &chr ) | 60 | QIMPenChar::QIMPenChar( const QIMPenChar &chr ) |
61 | { | 61 | { |
62 | strokes.setAutoDelete( TRUE ); | 62 | strokes.setAutoDelete( TRUE ); |
63 | ch = chr.ch; | 63 | ch = chr.ch; |
64 | flags = chr.flags; | 64 | flags = chr.flags; |
65 | d = chr.d; | 65 | d = chr.d; |
66 | QIMPenStrokeIterator it( chr.strokes ); | 66 | QIMPenStrokeIterator it( chr.strokes ); |
67 | while ( it.current() ) { | 67 | while ( it.current() ) { |
68 | strokes.append( new QIMPenStroke( *it.current() ) ); | 68 | strokes.append( new QIMPenStroke( *it.current() ) ); |
69 | ++it; | 69 | ++it; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | QIMPenChar &QIMPenChar::operator=( const QIMPenChar &chr ) | 73 | QIMPenChar &QIMPenChar::operator=( const QIMPenChar &chr ) |
74 | { | 74 | { |
75 | strokes.clear(); | 75 | strokes.clear(); |
76 | ch = chr.ch; | 76 | ch = chr.ch; |
77 | flags = chr.flags; | 77 | flags = chr.flags; |
78 | d = chr.d; | 78 | d = chr.d; |
79 | QIMPenStrokeIterator it( chr.strokes ); | 79 | QIMPenStrokeIterator it( chr.strokes ); |
80 | while ( it.current() ) { | 80 | while ( it.current() ) { |
81 | strokes.append( new QIMPenStroke( *it.current() ) ); | 81 | strokes.append( new QIMPenStroke( *it.current() ) ); |
82 | ++it; | 82 | ++it; |
83 | } | 83 | } |
84 | 84 | ||
85 | return *this; | 85 | return *this; |
86 | } | 86 | } |
87 | 87 | ||
88 | QString QIMPenChar::name() const | 88 | QString QIMPenChar::name() const |
89 | { | 89 | { |
90 | QString n; | 90 | QString n; |
91 | 91 | ||
92 | if ( (ch & 0x0000FFFF) == 0 ) { | 92 | if ( (ch & 0x0000FFFF) == 0 ) { |
93 | int code = ch >> 16; | 93 | int code = ch >> 16; |
94 | for ( int i = 0; qimpen_specialKeys[i].code != Qt::Key_unknown; i++ ) { | 94 | for ( int i = 0; qimpen_specialKeys[i].code != Qt::Key_unknown; i++ ) { |
95 | if ( qimpen_specialKeys[i].code == code ) { | 95 | if ( qimpen_specialKeys[i].code == code ) { |
96 | n = qimpen_specialKeys[i].name; | 96 | n = qimpen_specialKeys[i].name; |
97 | break; | 97 | break; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | } else { | 100 | } else { |
101 | n = QChar( ch & 0x0000FFFF ); | 101 | n = QChar( ch & 0x0000FFFF ); |
102 | } | 102 | } |
103 | 103 | ||
104 | return n; | 104 | return n; |
105 | } | 105 | } |
106 | 106 | ||
107 | void QIMPenChar::clear() | 107 | void QIMPenChar::clear() |
108 | { | 108 | { |
109 | ch = 0; | 109 | ch = 0; |
110 | flags = 0; | 110 | flags = 0; |
111 | d = QString::null; | 111 | d = QString::null; |
112 | strokes.clear(); | 112 | strokes.clear(); |
113 | } | 113 | } |
114 | 114 | ||
115 | unsigned int QIMPenChar::strokeLength( int s ) const | 115 | unsigned int QIMPenChar::strokeLength( int s ) const |
116 | { | 116 | { |
117 | QIMPenStrokeIterator it( strokes ); | 117 | QIMPenStrokeIterator it( strokes ); |
118 | while ( it.current() && s ) { | 118 | while ( it.current() && s ) { |
119 | ++it; | 119 | ++it; |
120 | --s; | 120 | --s; |
121 | } | 121 | } |
122 | 122 | ||
123 | if ( it.current() ) | 123 | if ( it.current() ) |
124 | return it.current()->length(); | 124 | return it.current()->length(); |
125 | 125 | ||
126 | return 0; | 126 | return 0; |
127 | } | 127 | } |
128 | 128 | ||
129 | /*! | 129 | /*! |
130 | Add a stroke to the character | 130 | Add a stroke to the character |
131 | */ | 131 | */ |
132 | void QIMPenChar::addStroke( QIMPenStroke *st ) | 132 | void QIMPenChar::addStroke( QIMPenStroke *st ) |
133 | { | 133 | { |
134 | QIMPenStroke *stroke = new QIMPenStroke( *st ); | 134 | QIMPenStroke *stroke = new QIMPenStroke( *st ); |
135 | strokes.append( stroke ); | 135 | strokes.append( stroke ); |
136 | } | 136 | } |
137 | 137 | ||
138 | /*! | 138 | /*! |
139 | Return an indicator of the closeness of this character to \a pen. | 139 | Return an indicator of the closeness of this character to \a pen. |
140 | Lower value is better. | 140 | Lower value is better. |
141 | */ | 141 | */ |
142 | int QIMPenChar::match( QIMPenChar *pen ) | 142 | int QIMPenChar::match( QIMPenChar *pen ) |
143 | { | 143 | { |
144 | /* | 144 | /* |
145 | if ( strokes.count() > pen->strokes.count() ) | 145 | if ( strokes.count() > pen->strokes.count() ) |
146 | return INT_MAX; | 146 | return INT_MAX; |
147 | */ | 147 | */ |
148 | int err = 0; | 148 | int err = 0; |
149 | int maxErr = 0; | 149 | int maxErr = 0; |
150 | int diff = 0; | 150 | int diff = 0; |
151 | QIMPenStrokeIterator it1( strokes ); | 151 | QIMPenStrokeIterator it1( strokes ); |
152 | QIMPenStrokeIterator it2( pen->strokes ); | 152 | QIMPenStrokeIterator it2( pen->strokes ); |
153 | err = it1.current()->match( it2.current() ); | 153 | err = it1.current()->match( it2.current() ); |
154 | if ( err > maxErr ) | 154 | if ( err > maxErr ) |
155 | maxErr = err; | 155 | maxErr = err; |
156 | ++it1; | 156 | ++it1; |
157 | ++it2; | 157 | ++it2; |
158 | while ( err < 400000 && it1.current() && it2.current() ) { | 158 | while ( err < 400000 && it1.current() && it2.current() ) { |
159 | QPoint p1 = it1.current()->boundingRect().center() - | 159 | QPoint p1 = it1.current()->boundingRect().center() - |
160 | strokes.getFirst()->boundingRect().center(); | 160 | strokes.getFirst()->boundingRect().center(); |
161 | QPoint p2 = it2.current()->boundingRect().center() - | 161 | QPoint p2 = it2.current()->boundingRect().center() - |
162 | pen->strokes.getFirst()->boundingRect().center(); | 162 | pen->strokes.getFirst()->boundingRect().center(); |
163 | int xdiff = QABS( p1.x() - p2.x() ) - 6; | 163 | int xdiff = QABS( p1.x() - p2.x() ) - 6; |
164 | int ydiff = QABS( p1.y() - p2.y() ) - 5; | 164 | int ydiff = QABS( p1.y() - p2.y() ) - 5; |
165 | if ( xdiff < 0 ) | 165 | if ( xdiff < 0 ) |
166 | xdiff = 0; | 166 | xdiff = 0; |
167 | if ( ydiff < 0 ) | 167 | if ( ydiff < 0 ) |
168 | ydiff = 0; | 168 | ydiff = 0; |
169 | if ( xdiff > 10 || ydiff > 10 ) { // not a chance | 169 | if ( xdiff > 10 || ydiff > 10 ) { // not a chance |
170 | #ifdef DEBUG_QIMPEN | 170 | #ifdef DEBUG_QIMPEN |
171 | odebug << "char " << pen->ch <<", stroke starting pt diff excessive" << oendl; | 171 | odebug << "char " << pen->ch <<", stroke starting pt diff excessive" << oendl; |
172 | #endif | 172 | #endif |
173 | return INT_MAX; | 173 | return INT_MAX; |
174 | } | 174 | } |
175 | diff += xdiff*xdiff + ydiff*ydiff; | 175 | diff += xdiff*xdiff + ydiff*ydiff; |
176 | err = it1.current()->match( it2.current() ); | 176 | err = it1.current()->match( it2.current() ); |
177 | if ( err > maxErr ) | 177 | if ( err > maxErr ) |
178 | maxErr = err; | 178 | maxErr = err; |
179 | ++it1; | 179 | ++it1; |
180 | ++it2; | 180 | ++it2; |
181 | } | 181 | } |
182 | 182 | ||
183 | maxErr += diff * diff * 6; // magic weighting :) | 183 | maxErr += diff * diff * 6; // magic weighting :) |
184 | 184 | ||
185 | #ifdef DEBUG_QIMPEN | 185 | #ifdef DEBUG_QIMPEN |
186 | odebug << "char: " << pen->ch << ", maxErr " << maxErr << ", diff " << diff << ", " << strokes.count() << oendl; | 186 | odebug << "char: " << pen->ch << ", maxErr " << maxErr << ", diff " << diff << ", " << strokes.count() << oendl; |
187 | #endif | 187 | #endif |
188 | return maxErr; | 188 | return maxErr; |
189 | } | 189 | } |
190 | 190 | ||
191 | /*! | 191 | /*! |
192 | Return the bounding rect of this character. It may have sides with | 192 | Return the bounding rect of this character. It may have sides with |
193 | negative coords since its origin is where the user started drawing | 193 | negative coords since its origin is where the user started drawing |
194 | the character. | 194 | the character. |
195 | */ | 195 | */ |
196 | QRect QIMPenChar::boundingRect() | 196 | QRect QIMPenChar::boundingRect() |
197 | { | 197 | { |
198 | QRect br; | 198 | QRect br; |
199 | QIMPenStroke *st = strokes.first(); | 199 | QIMPenStroke *st = strokes.first(); |
200 | while ( st ) { | 200 | while ( st ) { |
201 | br |= st->boundingRect(); | 201 | br |= st->boundingRect(); |
202 | st = strokes.next(); | 202 | st = strokes.next(); |
203 | } | 203 | } |
204 | 204 | ||
205 | return br; | 205 | return br; |
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
209 | /*! | 209 | /*! |
210 | Write the character's data to the stream. | 210 | Write the character's data to the stream. |
211 | */ | 211 | */ |
212 | QDataStream &operator<< (QDataStream &s, const QIMPenChar &ws) | 212 | QDataStream &operator<< (QDataStream &s, const QIMPenChar &ws) |
213 | { | 213 | { |
214 | s << ws.ch; | 214 | s << ws.ch; |
215 | s << ws.flags; | 215 | s << ws.flags; |
216 | if ( ws.flags & QIMPenChar::Data ) | 216 | if ( ws.flags & QIMPenChar::Data ) |
217 | s << ws.d; | 217 | s << ws.d; |
218 | s << ws.strokes.count(); | 218 | s << ws.strokes.count(); |
219 | QIMPenStrokeIterator it( ws.strokes ); | 219 | QIMPenStrokeIterator it( ws.strokes ); |
220 | while ( it.current() ) { | 220 | while ( it.current() ) { |
221 | s << *it.current(); | 221 | s << *it.current(); |
222 | ++it; | 222 | ++it; |
223 | } | 223 | } |
224 | 224 | ||
225 | return s; | 225 | return s; |
226 | } | 226 | } |
227 | 227 | ||
228 | /*! | 228 | /*! |
229 | Read the character's data from the stream. | 229 | Read the character's data from the stream. |
230 | */ | 230 | */ |
231 | QDataStream &operator>> (QDataStream &s, QIMPenChar &ws) | 231 | QDataStream &operator>> (QDataStream &s, QIMPenChar &ws) |
232 | { | 232 | { |
233 | s >> ws.ch; | 233 | s >> ws.ch; |
234 | s >> ws.flags; | 234 | s >> ws.flags; |
235 | if ( ws.flags & QIMPenChar::Data ) | 235 | if ( ws.flags & QIMPenChar::Data ) |
236 | s >> ws.d; | 236 | s >> ws.d; |
237 | unsigned size; | 237 | unsigned size; |
238 | s >> size; | 238 | s >> size; |
239 | for ( unsigned i = 0; i < size; i++ ) { | 239 | for ( unsigned i = 0; i < size; i++ ) { |
240 | QIMPenStroke *st = new QIMPenStroke(); | 240 | QIMPenStroke *st = new QIMPenStroke(); |
241 | s >> *st; | 241 | s >> *st; |
242 | ws.strokes.append( st ); | 242 | ws.strokes.append( st ); |
243 | } | 243 | } |
244 | 244 | ||
245 | return s; | 245 | return s; |
246 | } | 246 | } |
247 | 247 | ||
248 | //=========================================================================== | 248 | //=========================================================================== |
249 | 249 | ||
250 | bool QIMPenCharMatch::operator>( const QIMPenCharMatch &m ) | 250 | bool QIMPenCharMatch::operator>( const QIMPenCharMatch &m ) |
251 | { | 251 | { |
252 | return error > m.error; | 252 | return error > m.error; |
253 | } | 253 | } |
254 | 254 | ||
255 | bool QIMPenCharMatch::operator<( const QIMPenCharMatch &m ) | 255 | bool QIMPenCharMatch::operator<( const QIMPenCharMatch &m ) |
256 | { | 256 | { |
257 | return error < m.error; | 257 | return error < m.error; |
258 | } | 258 | } |
259 | 259 | ||
260 | bool QIMPenCharMatch::operator<=( const QIMPenCharMatch &m ) | 260 | bool QIMPenCharMatch::operator<=( const QIMPenCharMatch &m ) |
261 | { | 261 | { |
262 | return error <= m.error; | 262 | return error <= m.error; |
263 | } | 263 | } |
264 | 264 | ||
265 | //=========================================================================== | 265 | //=========================================================================== |
266 | 266 | ||
267 | /*! | 267 | /*! |
268 | \class QIMPenCharSet qimpenchar.h | 268 | \class QIMPenCharSet qimpenchar.h |
269 | 269 | ||
270 | Maintains a set of related characters. | 270 | Maintains a set of related characters. |
271 | */ | 271 | */ |
272 | 272 | ||
273 | QIMPenCharSet::QIMPenCharSet() | 273 | QIMPenCharSet::QIMPenCharSet() |
274 | { | 274 | { |
275 | chars.setAutoDelete( TRUE ); | 275 | chars.setAutoDelete( TRUE ); |
276 | desc = "Unnamed"; | 276 | desc = "Unnamed"; |
277 | csTitle = "abc"; | 277 | csTitle = "abc"; |
278 | csType = Unknown; | 278 | csType = Unknown; |
279 | maxStrokes = 0; | 279 | maxStrokes = 0; |
280 | } | 280 | } |
281 | 281 | ||
282 | /*! | 282 | /*! |
283 | Construct and load a characters set from file \a fn. | 283 | Construct and load a characters set from file \a fn. |
284 | */ | 284 | */ |
285 | QIMPenCharSet::QIMPenCharSet( const QString &fn ) | 285 | QIMPenCharSet::QIMPenCharSet( const QString &fn ) |
286 | { | 286 | { |
287 | chars.setAutoDelete( TRUE ); | 287 | chars.setAutoDelete( TRUE ); |
288 | desc = "Unnamed"; | 288 | desc = "Unnamed"; |
289 | csTitle = "abc"; | 289 | csTitle = "abc"; |
290 | csType = Unknown; | 290 | csType = Unknown; |
291 | maxStrokes = 0; | 291 | maxStrokes = 0; |
292 | load( fn, System ); | 292 | load( fn, System ); |
293 | } | 293 | } |
294 | 294 | ||
295 | const QString &QIMPenCharSet::filename( Domain d ) const | 295 | const QString &QIMPenCharSet::filename( Domain d ) const |
296 | { | 296 | { |
297 | if ( d == System ) | 297 | if ( d == System ) |
298 | return sysFilename; | 298 | return sysFilename; |
299 | else | 299 | else |
300 | return userFilename; | 300 | return userFilename; |
301 | } | 301 | } |
302 | 302 | ||
303 | void QIMPenCharSet::setFilename( const QString &fn, Domain d ) | 303 | void QIMPenCharSet::setFilename( const QString &fn, Domain d ) |
304 | { | 304 | { |
305 | if ( d == System ) | 305 | if ( d == System ) |
306 | sysFilename = fn; | 306 | sysFilename = fn; |
307 | else if ( d == User ) | 307 | else if ( d == User ) |
308 | userFilename = fn; | 308 | userFilename = fn; |
309 | } | 309 | } |
310 | 310 | ||
311 | /*! | 311 | /*! |
312 | Load a character set from file \a fn. | 312 | Load a character set from file \a fn. |
313 | */ | 313 | */ |
314 | bool QIMPenCharSet::load( const QString &fn, Domain d ) | 314 | bool QIMPenCharSet::load( const QString &fn, Domain d ) |
315 | { | 315 | { |
316 | setFilename( fn, d ); | 316 | setFilename( fn, d ); |
317 | 317 | ||
318 | bool ok = FALSE; | 318 | bool ok = FALSE; |
319 | QFile file( fn ); | 319 | QFile file( fn ); |
320 | if ( file.open( IO_ReadOnly ) ) { | 320 | if ( file.open( IO_ReadOnly ) ) { |
321 | QDataStream ds( &file ); | 321 | QDataStream ds( &file ); |
322 | QString version; | 322 | QString version; |
323 | ds >> version; | 323 | ds >> version; |
324 | ds >> csTitle; | 324 | ds >> csTitle; |
325 | ds >> desc; | 325 | ds >> desc; |
326 | int major = version.mid( 4, 1 ).toInt(); | 326 | int major = version.mid( 4, 1 ).toInt(); |
327 | int minor = version.mid( 6 ).toInt(); | 327 | int minor = version.mid( 6 ).toInt(); |
328 | if ( major >= 1 && minor > 0 ) { | 328 | if ( major >= 1 && minor > 0 ) { |
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 | addChar( pc ); |
346 | } | 346 | } |
347 | if ( file.status() == IO_Ok ) | 347 | if ( file.status() == IO_Ok ) |
348 | ok = TRUE; | 348 | ok = TRUE; |
349 | } | 349 | } |
350 | setHidden ( false ); | 350 | setHidden ( false ); |
351 | return ok; | 351 | return ok; |
352 | } | 352 | } |
353 | 353 | ||
354 | /*! | 354 | /*! |
355 | Save this character set. | 355 | Save this character set. |
356 | */ | 356 | */ |
357 | bool QIMPenCharSet::save( Domain d ) | 357 | bool QIMPenCharSet::save( Domain d ) |
358 | { | 358 | { |
359 | if ( filename( d ).isEmpty() ) | 359 | if ( filename( d ).isEmpty() ) |
360 | return FALSE; | 360 | return FALSE; |
361 | 361 | ||
362 | if ( hidden() ) | 362 | if ( hidden() ) |
363 | return TRUE; | 363 | return TRUE; |
364 | 364 | ||
365 | bool ok = FALSE; | 365 | bool ok = FALSE; |
366 | 366 | ||
367 | QString fn = filename( d ); | 367 | QString fn = filename( d ); |
368 | QString tmpFn = fn + ".new"; | 368 | QString tmpFn = fn + ".new"; |
369 | QFile file( tmpFn ); | 369 | QFile file( tmpFn ); |
370 | if ( file.open( IO_WriteOnly|IO_Raw ) ) { | 370 | if ( file.open( IO_WriteOnly|IO_Raw ) ) { |
371 | QByteArray buf; | 371 | QByteArray buf; |
372 | QDataStream ds( buf, IO_WriteOnly ); | 372 | QDataStream ds( buf, IO_WriteOnly ); |
373 | ds << QString( "QPT 1.1" ); | 373 | ds << QString( "QPT 1.1" ); |
374 | ds << csTitle; | 374 | ds << csTitle; |
375 | ds << desc; | 375 | ds << desc; |
376 | ds << (Q_INT8)csType; | 376 | ds << (Q_INT8)csType; |
377 | QIMPenCharIterator ci( chars ); | 377 | QIMPenCharIterator ci( chars ); |
378 | for ( ; ci.current(); ++ci ) { | 378 | for ( ; ci.current(); ++ci ) { |
379 | QIMPenChar *pc = ci.current(); | 379 | QIMPenChar *pc = ci.current(); |
380 | if ( ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) || | 380 | if ( ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) || |
381 | ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) && | 381 | ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) && |
382 | ( !pc->testFlag (QIMPenChar::Combined ) ) ) { | 382 | ( !pc->testFlag (QIMPenChar::Combined ) ) ) { |
383 | ds << *pc; | 383 | ds << *pc; |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | file.writeBlock( buf ); | 387 | file.writeBlock( buf ); |
388 | file.close(); | 388 | file.close(); |
389 | if ( file.status() == IO_Ok ) | 389 | if ( file.status() == IO_Ok ) |
390 | ok = TRUE; | 390 | ok = TRUE; |
391 | } | 391 | } |
392 | 392 | ||
393 | if ( ok ) { | 393 | if ( ok ) { |
394 | if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) { | 394 | if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) { |
395 | qWarning( "problem renaming file %s to %s, errno: %d", | 395 | owarn << "problem renaming file " <<tmpFn.latin1() << " to "<< fn.latin1() |
396 | tmpFn.latin1(), fn.latin1(), errno ); | 396 | << ", errno: " << errno << oendl; |
397 | // remove the tmp file, otherwise, it will just lay around... | 397 | // remove the tmp file, otherwise, it will just lay around... |
398 | QFile::remove( tmpFn.latin1() ); | 398 | QFile::remove( tmpFn.latin1() ); |
399 | ok = FALSE; | 399 | ok = FALSE; |
400 | } | 400 | } |
401 | } | 401 | } |
402 | 402 | ||
403 | return ok; | 403 | return ok; |
404 | } | 404 | } |
405 | 405 | ||
406 | QIMPenChar *QIMPenCharSet::at( int i ) | 406 | QIMPenChar *QIMPenCharSet::at( int i ) |
407 | { | 407 | { |
408 | return chars.at(i); | 408 | return chars.at(i); |
409 | } | 409 | } |
410 | 410 | ||
411 | void QIMPenCharSet::markDeleted( uint ch ) | 411 | void QIMPenCharSet::markDeleted( uint ch ) |
412 | { | 412 | { |
413 | QIMPenCharIterator ci( chars ); | 413 | QIMPenCharIterator ci( chars ); |
414 | for ( ; ci.current(); ++ci ) { | 414 | for ( ; ci.current(); ++ci ) { |
415 | QIMPenChar *pc = ci.current(); | 415 | QIMPenChar *pc = ci.current(); |
416 | if ( pc->character() == ch && pc->testFlag( QIMPenChar::System ) ) | 416 | if ( pc->character() == ch && pc->testFlag( QIMPenChar::System ) ) |
417 | pc->setFlag( QIMPenChar::Deleted ); | 417 | pc->setFlag( QIMPenChar::Deleted ); |
418 | } | 418 | } |
419 | } | 419 | } |
420 | 420 | ||
421 | /*! | 421 | /*! |
422 | Find the best matches for \a ch in this character set. | 422 | Find the best matches for \a ch in this character set. |
423 | */ | 423 | */ |
424 | QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch ) | 424 | QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch ) |
425 | { | 425 | { |
426 | QIMPenCharMatchList matches; | 426 | QIMPenCharMatchList matches; |
427 | 427 | ||
428 | QIMPenCharIterator ci( chars ); | 428 | QIMPenCharIterator ci( chars ); |
429 | for ( ; ci.current(); ++ci ) { | 429 | for ( ; ci.current(); ++ci ) { |
430 | QIMPenChar *tmplChar = ci.current(); | 430 | QIMPenChar *tmplChar = ci.current(); |
431 | if ( tmplChar->testFlag( QIMPenChar::Deleted ) ) { | 431 | if ( tmplChar->testFlag( QIMPenChar::Deleted ) ) { |
432 | continue; | 432 | continue; |
433 | } | 433 | } |
434 | int err; | 434 | int err; |
435 | if ( ch->penStrokes().count() <= tmplChar->penStrokes().count() ) { | 435 | if ( ch->penStrokes().count() <= tmplChar->penStrokes().count() ) { |
436 | err = ch->match( tmplChar ); | 436 | err = ch->match( tmplChar ); |
437 | if ( err <= QIMPEN_MATCH_THRESHOLD ) { | 437 | if ( err <= QIMPEN_MATCH_THRESHOLD ) { |
438 | if (tmplChar->penStrokes().count() != ch->penStrokes().count()) | 438 | if (tmplChar->penStrokes().count() != ch->penStrokes().count()) |
439 | err = QMIN(err*3, QIMPEN_MATCH_THRESHOLD); | 439 | err = QMIN(err*3, QIMPEN_MATCH_THRESHOLD); |
440 | QIMPenCharMatchList::Iterator it; | 440 | QIMPenCharMatchList::Iterator it; |
441 | for ( it = matches.begin(); it != matches.end(); ++it ) { | 441 | for ( it = matches.begin(); it != matches.end(); ++it ) { |
442 | if ( (*it).penChar->character() == tmplChar->character() && | 442 | if ( (*it).penChar->character() == tmplChar->character() && |
443 | (*it).penChar->penStrokes().count() == tmplChar->penStrokes().count() ) { | 443 | (*it).penChar->penStrokes().count() == tmplChar->penStrokes().count() ) { |
444 | if ( (*it).error > err ) | 444 | if ( (*it).error > err ) |
445 | (*it).error = err; | 445 | (*it).error = err; |
446 | break; | 446 | break; |
447 | } | 447 | } |
448 | } | 448 | } |
449 | if ( it == matches.end() ) { | 449 | if ( it == matches.end() ) { |
450 | QIMPenCharMatch m; | 450 | QIMPenCharMatch m; |
451 | m.error = err; | 451 | m.error = err; |
452 | m.penChar = tmplChar; | 452 | m.penChar = tmplChar; |
453 | matches.append( m ); | 453 | matches.append( m ); |
454 | } | 454 | } |
455 | } | 455 | } |
456 | } | 456 | } |
457 | } | 457 | } |
458 | qHeapSort( matches ); | 458 | qHeapSort( matches ); |
459 | /* | 459 | /* |
460 | QIMPenCharMatchList::Iterator it; | 460 | QIMPenCharMatchList::Iterator it; |
461 | for ( it = matches.begin(); it != matches.end(); ++it ) { | 461 | for ( it = matches.begin(); it != matches.end(); ++it ) { |
462 | 462 | ||
463 | odebug << "Match: \'" << (*it).penChar->character() "\', error " << (*it).error ", strokes " <<(*it).penChar->penStrokes().count() << oendl; | 463 | odebug << "Match: \'" << (*it).penChar->character() "\', error " << (*it).error ", strokes " <<(*it).penChar->penStrokes().count() << oendl; |
464 | } | 464 | } |
465 | */ | 465 | */ |
466 | return matches; | 466 | return matches; |
467 | } | 467 | } |
468 | 468 | ||
469 | /*! | 469 | /*! |
470 | Add a character \a ch to this set. | 470 | Add a character \a ch to this set. |
471 | QIMPenCharSet will delete this character when it is no longer needed. | 471 | QIMPenCharSet will delete this character when it is no longer needed. |
472 | */ | 472 | */ |
473 | void QIMPenCharSet::addChar( QIMPenChar *ch ) | 473 | void QIMPenCharSet::addChar( QIMPenChar *ch ) |
474 | { | 474 | { |
475 | if ( ch->penStrokes().count() > maxStrokes ) | 475 | if ( ch->penStrokes().count() > maxStrokes ) |
476 | maxStrokes = ch->penStrokes().count(); | 476 | maxStrokes = ch->penStrokes().count(); |
477 | chars.append( ch ); | 477 | chars.append( ch ); |
478 | } | 478 | } |
479 | 479 | ||
480 | /*! | 480 | /*! |
481 | Remove a character by reference \a ch from this set. | 481 | Remove a character by reference \a ch from this set. |
482 | QIMPenCharSet will delete this character. | 482 | QIMPenCharSet will delete this character. |
483 | */ | 483 | */ |
484 | void QIMPenCharSet::removeChar( QIMPenChar *ch ) | 484 | void QIMPenCharSet::removeChar( QIMPenChar *ch ) |
485 | { | 485 | { |
486 | chars.remove( ch ); | 486 | chars.remove( ch ); |
487 | } | 487 | } |
488 | 488 | ||
489 | /*! | 489 | /*! |
490 | Move the character up the list of characters. | 490 | Move the character up the list of characters. |
491 | */ | 491 | */ |
492 | void QIMPenCharSet::up( QIMPenChar *ch ) | 492 | void QIMPenCharSet::up( QIMPenChar *ch ) |
493 | { | 493 | { |
494 | int idx = chars.findRef( ch ); | 494 | int idx = chars.findRef( ch ); |
495 | if ( idx > 0 ) { | 495 | if ( idx > 0 ) { |
496 | chars.take(); | 496 | chars.take(); |
497 | chars.insert( idx - 1, ch ); | 497 | chars.insert( idx - 1, ch ); |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | /*! | 501 | /*! |
502 | Move the character down the list of characters. | 502 | Move the character down the list of characters. |
503 | */ | 503 | */ |
504 | void QIMPenCharSet::down( QIMPenChar *ch ) | 504 | void QIMPenCharSet::down( QIMPenChar *ch ) |
505 | { | 505 | { |
506 | int idx = chars.findRef( ch ); | 506 | int idx = chars.findRef( ch ); |
507 | if ( idx >= 0 && idx < (int)chars.count() - 1 ) { | 507 | if ( idx >= 0 && idx < (int)chars.count() - 1 ) { |
508 | chars.take(); | 508 | chars.take(); |
509 | chars.insert( idx + 1, ch ); | 509 | chars.insert( idx + 1, ch ); |
510 | } | 510 | } |
511 | } | 511 | } |
512 | 512 | ||
diff --git a/inputmethods/handwriting/qimpensetup.cpp b/inputmethods/handwriting/qimpensetup.cpp index 3f4841d..564b6ba 100644 --- a/inputmethods/handwriting/qimpensetup.cpp +++ b/inputmethods/handwriting/qimpensetup.cpp | |||
@@ -1,495 +1,496 @@ | |||
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 "qimpenprefbase.h" | 22 | #include "qimpenprefbase.h" |
23 | #include "qimpensetup.h" | 23 | #include "qimpensetup.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | 27 | ||
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qlistbox.h> | 29 | #include <qlistbox.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <qpixmap.h> | 33 | #include <qpixmap.h> |
34 | #include <qbuttongroup.h> | 34 | #include <qbuttongroup.h> |
35 | #include <qslider.h> | 35 | #include <qslider.h> |
36 | #include <qtabwidget.h> | 36 | #include <qtabwidget.h> |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qmessagebox.h> | 38 | #include <qmessagebox.h> |
39 | #include <opie2/odebug.h> | ||
39 | 40 | ||
40 | 41 | ||
41 | /* XPM */ | 42 | /* XPM */ |
42 | static const char * const left_xpm[] = { | 43 | static const char * const left_xpm[] = { |
43 | "16 16 2 1", | 44 | "16 16 2 1", |
44 | " c None", | 45 | " c None", |
45 | ".c #000000", | 46 | ".c #000000", |
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 | ||
63 | 64 | ||
64 | /* XPM */ | 65 | /* XPM */ |
65 | static const char * const right_xpm[] = { | 66 | static const char * const right_xpm[] = { |
66 | "16 16 2 1", | 67 | "16 16 2 1", |
67 | " c None", | 68 | " c None", |
68 | ".c #000000", | 69 | ".c #000000", |
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 | " "}; |
85 | 86 | ||
86 | 87 | ||
87 | 88 | ||
88 | QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent, | 89 | QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent, |
89 | const char *name, bool modal, int WFlags ) | 90 | const char *name, bool modal, int WFlags ) |
90 | : QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p) | 91 | : QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p) |
91 | { | 92 | { |
92 | setCaption( tr("Setup Handwriting Input") ); | 93 | setCaption( tr("Setup Handwriting Input") ); |
93 | 94 | ||
94 | QVBoxLayout *vb = new QVBoxLayout( this ); | 95 | QVBoxLayout *vb = new QVBoxLayout( this ); |
95 | 96 | ||
96 | #define MULTIPROFILE | 97 | #define MULTIPROFILE |
97 | #ifdef MULTIPROFILE | 98 | #ifdef MULTIPROFILE |
98 | profileList.setAutoDelete( true ); | 99 | profileList.setAutoDelete( true ); |
99 | QHBoxLayout *hb = new QHBoxLayout( vb ); | 100 | QHBoxLayout *hb = new QHBoxLayout( vb ); |
100 | hb->setMargin( 6 ); | 101 | hb->setMargin( 6 ); |
101 | QLabel *l = new QLabel( tr("Character Profile:"), this ); | 102 | QLabel *l = new QLabel( tr("Character Profile:"), this ); |
102 | hb->addWidget( l ); | 103 | hb->addWidget( l ); |
103 | profileCombo = new QComboBox( this ); | 104 | profileCombo = new QComboBox( this ); |
104 | connect( profileCombo, SIGNAL(activated(const QString&)), | 105 | connect( profileCombo, SIGNAL(activated(const QString&)), |
105 | this, SLOT(selectProfile(const QString&)) ); | 106 | this, SLOT(selectProfile(const QString&)) ); |
106 | hb->addWidget( profileCombo ); | 107 | hb->addWidget( profileCombo ); |
107 | #else | 108 | #else |
108 | profileList.append( profile ); | 109 | profileList.append( profile ); |
109 | #endif | 110 | #endif |
110 | 111 | ||
111 | qWarning("profiles: %d", profileList.count()); | 112 | owarn << "profiles: " << profileList.count() << oendl; |
112 | 113 | ||
113 | QTabWidget *tw = new QTabWidget( this ); | 114 | QTabWidget *tw = new QTabWidget( this ); |
114 | vb->addWidget( tw ); | 115 | vb->addWidget( tw ); |
115 | 116 | ||
116 | pref = new QIMPenPrefBase( this ); | 117 | pref = new QIMPenPrefBase( this ); |
117 | tw->addTab( pref, tr("Preferences") ); | 118 | tw->addTab( pref, tr("Preferences") ); |
118 | 119 | ||
119 | pref->inputStyle->setExclusive( TRUE ); | 120 | pref->inputStyle->setExclusive( TRUE ); |
120 | 121 | ||
121 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; | 122 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; |
122 | pref->inputStyle->setButton( style ); | 123 | pref->inputStyle->setButton( style ); |
123 | connect( pref->inputStyle, SIGNAL(clicked(int)), | 124 | connect( pref->inputStyle, SIGNAL(clicked(int)), |
124 | this, SLOT(styleClicked(int)) ); | 125 | this, SLOT(styleClicked(int)) ); |
125 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); | 126 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); |
126 | 127 | ||
127 | multiTimeout = profile->multiStrokeTimeout(); | 128 | multiTimeout = profile->multiStrokeTimeout(); |
128 | pref->multiStrokeSlider->setValue( multiTimeout ); | 129 | pref->multiStrokeSlider->setValue( multiTimeout ); |
129 | multiTimeoutChanged( multiTimeout ); | 130 | multiTimeoutChanged( multiTimeout ); |
130 | connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)), | 131 | connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)), |
131 | this, SLOT(multiTimeoutChanged(int)) ); | 132 | this, SLOT(multiTimeoutChanged(int)) ); |
132 | 133 | ||
133 | edit = new QIMPenEdit( p, tw ); | 134 | edit = new QIMPenEdit( p, tw ); |
134 | tw->addTab( edit, tr("Customize") ); | 135 | tw->addTab( edit, tr("Customize") ); |
135 | #ifdef MULTIPROFILE | 136 | #ifdef MULTIPROFILE |
136 | loadProfiles(); | 137 | loadProfiles(); |
137 | #endif | 138 | #endif |
138 | 139 | ||
139 | } | 140 | } |
140 | 141 | ||
141 | void QIMPenSetup::loadProfiles() | 142 | void QIMPenSetup::loadProfiles() |
142 | { | 143 | { |
143 | QString path = QPEApplication::qpeDir() + "etc/qimpen"; | 144 | QString path = QPEApplication::qpeDir() + "etc/qimpen"; |
144 | QDir dir( path, "*.conf" ); | 145 | QDir dir( path, "*.conf" ); |
145 | QStringList list = dir.entryList(); | 146 | QStringList list = dir.entryList(); |
146 | QStringList::Iterator it; | 147 | QStringList::Iterator it; |
147 | for ( it = list.begin(); it != list.end(); ++it ) { | 148 | for ( it = list.begin(); it != list.end(); ++it ) { |
148 | QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); | 149 | QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); |
149 | profileList.append( p ); | 150 | profileList.append( p ); |
150 | profileCombo->insertItem( p->name() ); | 151 | profileCombo->insertItem( p->name() ); |
151 | if ( p->name() == profile->name() ) { | 152 | if ( p->name() == profile->name() ) { |
152 | profileCombo->setCurrentItem( profileCombo->count()-1 ); | 153 | profileCombo->setCurrentItem( profileCombo->count()-1 ); |
153 | profile = p; | 154 | profile = p; |
154 | edit->setProfile( profile ); | 155 | edit->setProfile( profile ); |
155 | } | 156 | } |
156 | } | 157 | } |
157 | } | 158 | } |
158 | 159 | ||
159 | void QIMPenSetup::styleClicked( int id ) | 160 | void QIMPenSetup::styleClicked( int id ) |
160 | { | 161 | { |
161 | style = id; | 162 | style = id; |
162 | } | 163 | } |
163 | 164 | ||
164 | void QIMPenSetup::multiTimeoutChanged( int v ) | 165 | void QIMPenSetup::multiTimeoutChanged( int v ) |
165 | { | 166 | { |
166 | multiTimeout = v; | 167 | multiTimeout = v; |
167 | pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) ); | 168 | pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) ); |
168 | } | 169 | } |
169 | 170 | ||
170 | void QIMPenSetup::selectProfile( const QString &p ) | 171 | void QIMPenSetup::selectProfile( const QString &p ) |
171 | { | 172 | { |
172 | if ( p == profile->name() ) | 173 | if ( p == profile->name() ) |
173 | return; | 174 | return; |
174 | 175 | ||
175 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); | 176 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); |
176 | profile->setMultiStrokeTimeout( multiTimeout ); | 177 | profile->setMultiStrokeTimeout( multiTimeout ); |
177 | 178 | ||
178 | for ( int i = 0; i < (int)profileList.count(); i++ ) { | 179 | for ( int i = 0; i < (int)profileList.count(); i++ ) { |
179 | if ( profileList.at(i)->name() == p ) { | 180 | if ( profileList.at(i)->name() == p ) { |
180 | profile = profileList.at(i); | 181 | profile = profileList.at(i); |
181 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; | 182 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; |
182 | pref->inputStyle->setButton( style ); | 183 | pref->inputStyle->setButton( style ); |
183 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); | 184 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); |
184 | multiTimeout = profile->multiStrokeTimeout(); | 185 | multiTimeout = profile->multiStrokeTimeout(); |
185 | pref->multiStrokeSlider->setValue( multiTimeout ); | 186 | pref->multiStrokeSlider->setValue( multiTimeout ); |
186 | multiTimeoutChanged( multiTimeout ); | 187 | multiTimeoutChanged( multiTimeout ); |
187 | edit->setProfile( profile ); | 188 | edit->setProfile( profile ); |
188 | break; | 189 | break; |
189 | } | 190 | } |
190 | } | 191 | } |
191 | } | 192 | } |
192 | 193 | ||
193 | void QIMPenSetup::accept() | 194 | void QIMPenSetup::accept() |
194 | { | 195 | { |
195 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); | 196 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); |
196 | profile->setMultiStrokeTimeout( multiTimeout ); | 197 | profile->setMultiStrokeTimeout( multiTimeout ); |
197 | // Save current profile | 198 | // Save current profile |
198 | if ( profileCombo ) { | 199 | if ( profileCombo ) { |
199 | Config config( "handwriting" ); | 200 | Config config( "handwriting" ); |
200 | config.setGroup( "Settings" ); | 201 | config.setGroup( "Settings" ); |
201 | config.writeEntry( "Profile", profileCombo->currentText() ); | 202 | config.writeEntry( "Profile", profileCombo->currentText() ); |
202 | } | 203 | } |
203 | // Save charsets | 204 | // Save charsets |
204 | bool ok = TRUE; | 205 | bool ok = TRUE; |
205 | for ( int i = 0; i < (int)profileList.count(); i++ ) { | 206 | for ( int i = 0; i < (int)profileList.count(); i++ ) { |
206 | QIMPenProfile *prof = profileList.at(i); | 207 | QIMPenProfile *prof = profileList.at(i); |
207 | QIMPenCharSetIterator it(prof->charSets()); | 208 | QIMPenCharSetIterator it(prof->charSets()); |
208 | for ( ; it.current(); ++it ) { | 209 | for ( ; it.current(); ++it ) { |
209 | if ( !(it.current()->save( QIMPenCharSet::User )) ) { | 210 | if ( !(it.current()->save( QIMPenCharSet::User )) ) { |
210 | ok = FALSE; | 211 | ok = FALSE; |
211 | break; | 212 | break; |
212 | } | 213 | } |
213 | } | 214 | } |
214 | } | 215 | } |
215 | if ( !ok ) { | 216 | if ( !ok ) { |
216 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 217 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
217 | tr("Unable to save information.\n" | 218 | tr("Unable to save information.\n" |
218 | "Free up some space\n" | 219 | "Free up some space\n" |
219 | "and try again.\n" | 220 | "and try again.\n" |
220 | "\nQuit anyway?"), | 221 | "\nQuit anyway?"), |
221 | QMessageBox::Yes|QMessageBox::Escape, | 222 | QMessageBox::Yes|QMessageBox::Escape, |
222 | QMessageBox::No|QMessageBox::Default ) | 223 | QMessageBox::No|QMessageBox::Default ) |
223 | != QMessageBox::No ) { | 224 | != QMessageBox::No ) { |
224 | QDialog::accept(); | 225 | QDialog::accept(); |
225 | } | 226 | } |
226 | } else { | 227 | } else { |
227 | QDialog::accept(); | 228 | QDialog::accept(); |
228 | } | 229 | } |
229 | } | 230 | } |
230 | 231 | ||
231 | //--------------------------------------------------------------------------- | 232 | //--------------------------------------------------------------------------- |
232 | 233 | ||
233 | QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name, | 234 | QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name, |
234 | bool modal, int WFlags) | 235 | bool modal, int WFlags) |
235 | : QDialog( parent, name, modal, WFlags ) | 236 | : QDialog( parent, name, modal, WFlags ) |
236 | { | 237 | { |
237 | setCaption( tr("Enter new character") ); | 238 | setCaption( tr("Enter new character") ); |
238 | uni = 0; | 239 | uni = 0; |
239 | 240 | ||
240 | QVBoxLayout *vb = new QVBoxLayout( this, 10 ); | 241 | QVBoxLayout *vb = new QVBoxLayout( this, 10 ); |
241 | 242 | ||
242 | QHBoxLayout *hb = new QHBoxLayout(); | 243 | QHBoxLayout *hb = new QHBoxLayout(); |
243 | vb->addLayout( hb ); | 244 | vb->addLayout( hb ); |
244 | 245 | ||
245 | QLabel *label = new QLabel( tr("Character:"), this ); | 246 | QLabel *label = new QLabel( tr("Character:"), this ); |
246 | hb->addWidget( label ); | 247 | hb->addWidget( label ); |
247 | 248 | ||
248 | QComboBox *cb = new QComboBox( TRUE, this ); | 249 | QComboBox *cb = new QComboBox( TRUE, this ); |
249 | connect( cb, SIGNAL(activated(int)), SLOT(setSpecial(int)) ); | 250 | connect( cb, SIGNAL(activated(int)), SLOT(setSpecial(int)) ); |
250 | connect( cb, SIGNAL(textChanged(const QString&)), | 251 | connect( cb, SIGNAL(textChanged(const QString&)), |
251 | SLOT(setCharacter(const QString&)) ); | 252 | SLOT(setCharacter(const QString&)) ); |
252 | addSpecial( cb ); | 253 | addSpecial( cb ); |
253 | cb->setEditText( "" ); | 254 | cb->setEditText( "" ); |
254 | hb->addWidget( cb ); | 255 | hb->addWidget( cb ); |
255 | 256 | ||
256 | hb = new QHBoxLayout(); | 257 | hb = new QHBoxLayout(); |
257 | vb->addLayout( hb ); | 258 | vb->addLayout( hb ); |
258 | 259 | ||
259 | QPushButton *pb = new QPushButton( "OK", this ); | 260 | QPushButton *pb = new QPushButton( "OK", this ); |
260 | connect( pb, SIGNAL(clicked()), SLOT(accept())); | 261 | connect( pb, SIGNAL(clicked()), SLOT(accept())); |
261 | hb->addWidget( pb ); | 262 | hb->addWidget( pb ); |
262 | pb = new QPushButton( "Cancel", this ); | 263 | pb = new QPushButton( "Cancel", this ); |
263 | connect( pb, SIGNAL(clicked()), SLOT(reject())); | 264 | connect( pb, SIGNAL(clicked()), SLOT(reject())); |
264 | hb->addWidget( pb ); | 265 | hb->addWidget( pb ); |
265 | 266 | ||
266 | cb->setFocus(); | 267 | cb->setFocus(); |
267 | } | 268 | } |
268 | 269 | ||
269 | void QIMPenInputCharDlg::addSpecial( QComboBox *cb ) | 270 | void QIMPenInputCharDlg::addSpecial( QComboBox *cb ) |
270 | { | 271 | { |
271 | int i = 0; | 272 | int i = 0; |
272 | while ( qimpen_specialKeys[i].code != Key_unknown ) { | 273 | while ( qimpen_specialKeys[i].code != Key_unknown ) { |
273 | cb->insertItem( qimpen_specialKeys[i].name ); | 274 | cb->insertItem( qimpen_specialKeys[i].name ); |
274 | i++; | 275 | i++; |
275 | } | 276 | } |
276 | } | 277 | } |
277 | 278 | ||
278 | void QIMPenInputCharDlg::setSpecial( int sp ) | 279 | void QIMPenInputCharDlg::setSpecial( int sp ) |
279 | { | 280 | { |
280 | uni = qimpen_specialKeys[sp].code << 16; | 281 | uni = qimpen_specialKeys[sp].code << 16; |
281 | } | 282 | } |
282 | 283 | ||
283 | void QIMPenInputCharDlg::setCharacter( const QString &string ) | 284 | void QIMPenInputCharDlg::setCharacter( const QString &string ) |
284 | { | 285 | { |
285 | uni = string[0].unicode(); | 286 | uni = string[0].unicode(); |
286 | } | 287 | } |
287 | 288 | ||
288 | //--------------------------------------------------------------------------- | 289 | //--------------------------------------------------------------------------- |
289 | 290 | ||
290 | class CharListItem : public QListBoxText | 291 | class CharListItem : public QListBoxText |
291 | { | 292 | { |
292 | public: | 293 | public: |
293 | CharListItem( const QString &text, uint c ) | 294 | CharListItem( const QString &text, uint c ) |
294 | : QListBoxText( text ) | 295 | : QListBoxText( text ) |
295 | { | 296 | { |
296 | _code = c; | 297 | _code = c; |
297 | } | 298 | } |
298 | 299 | ||
299 | uint code() const { return _code; } | 300 | uint code() const { return _code; } |
300 | 301 | ||
301 | protected: | 302 | protected: |
302 | uint _code; | 303 | uint _code; |
303 | }; | 304 | }; |
304 | 305 | ||
305 | /*! | 306 | /*! |
306 | \class QIMPenEdit qimpensetup.h | 307 | \class QIMPenEdit qimpensetup.h |
307 | 308 | ||
308 | Class to allow users to input totally useless character definitions | 309 | Class to allow users to input totally useless character definitions |
309 | which could match any number of the default set. | 310 | which could match any number of the default set. |
310 | */ | 311 | */ |
311 | 312 | ||
312 | QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, | 313 | QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, |
313 | const char *name ) | 314 | const char *name ) |
314 | : QWidget( parent, name ), profile(p) | 315 | : QWidget( parent, name ), profile(p) |
315 | { | 316 | { |
316 | currentChar = 0; | 317 | currentChar = 0; |
317 | currentCode = 0; | 318 | currentCode = 0; |
318 | inputChar = new QIMPenChar(); | 319 | inputChar = new QIMPenChar(); |
319 | 320 | ||
320 | QVBoxLayout *tvb = new QVBoxLayout( this, 5 ); | 321 | QVBoxLayout *tvb = new QVBoxLayout( this, 5 ); |
321 | 322 | ||
322 | QGridLayout *gl = new QGridLayout( tvb, 4, 2 ); | 323 | QGridLayout *gl = new QGridLayout( tvb, 4, 2 ); |
323 | gl->setRowStretch( 1, 1 ); | 324 | gl->setRowStretch( 1, 1 ); |
324 | gl->addRowSpacing( 2, 35 ); | 325 | gl->addRowSpacing( 2, 35 ); |
325 | gl->addRowSpacing( 3, 35 ); | 326 | gl->addRowSpacing( 3, 35 ); |
326 | 327 | ||
327 | charSetCombo = new QComboBox( this ); | 328 | charSetCombo = new QComboBox( this ); |
328 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); | 329 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); |
329 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSetVisible(int))); | 330 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSetVisible(int))); |
330 | QIMPenCharSetIterator it( profile->charSets() ); | 331 | QIMPenCharSetIterator it( profile->charSets() ); |
331 | for ( ; it.current(); ++it ) { | 332 | for ( ; it.current(); ++it ) { |
332 | charSetCombo->insertItem( it.current()->description() ); | 333 | charSetCombo->insertItem( it.current()->description() ); |
333 | } | 334 | } |
334 | 335 | ||
335 | charList = new QListBox( this ); | 336 | charList = new QListBox( this ); |
336 | charList->setMinimumHeight( charList->sizeHint().height() ); | 337 | charList->setMinimumHeight( charList->sizeHint().height() ); |
337 | connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) ); | 338 | connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) ); |
338 | gl->addWidget( charList, 1, 0 ); | 339 | gl->addWidget( charList, 1, 0 ); |
339 | 340 | ||
340 | pw = new QIMPenWidget( this ); | 341 | pw = new QIMPenWidget( this ); |
341 | pw->setFixedHeight( 75 ); | 342 | pw->setFixedHeight( 75 ); |
342 | gl->addMultiCellWidget( pw, 2, 3, 0, 0 ); | 343 | gl->addMultiCellWidget( pw, 2, 3, 0, 0 ); |
343 | connect( pw, SIGNAL(stroke(QIMPenStroke*)), | 344 | connect( pw, SIGNAL(stroke(QIMPenStroke*)), |
344 | SLOT(newStroke(QIMPenStroke*)) ); | 345 | SLOT(newStroke(QIMPenStroke*)) ); |
345 | 346 | ||
346 | QVBoxLayout *vb = new QVBoxLayout(); | 347 | QVBoxLayout *vb = new QVBoxLayout(); |
347 | gl->addLayout( vb, 1, 1 ); | 348 | gl->addLayout( vb, 1, 1 ); |
348 | newBtn = new QPushButton( tr("New..."), this ); | 349 | newBtn = new QPushButton( tr("New..."), this ); |
349 | connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) ); | 350 | connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) ); |
350 | vb->addWidget( newBtn ); | 351 | vb->addWidget( newBtn ); |
351 | 352 | ||
352 | addBtn = new QPushButton( tr("Add"), this ); | 353 | addBtn = new QPushButton( tr("Add"), this ); |
353 | connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) ); | 354 | connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) ); |
354 | vb->addWidget( addBtn ); | 355 | vb->addWidget( addBtn ); |
355 | 356 | ||
356 | removeBtn = new QPushButton( tr("Remove"), this ); | 357 | removeBtn = new QPushButton( tr("Remove"), this ); |
357 | connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) ); | 358 | connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) ); |
358 | vb->addWidget( removeBtn ); | 359 | vb->addWidget( removeBtn ); |
359 | 360 | ||
360 | QPushButton *pb = new QPushButton( tr("Default"), this ); | 361 | QPushButton *pb = new QPushButton( tr("Default"), this ); |
361 | connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) ); | 362 | connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) ); |
362 | vb->addWidget( pb ); | 363 | vb->addWidget( pb ); |
363 | 364 | ||
364 | QHBoxLayout *hb = new QHBoxLayout(); | 365 | QHBoxLayout *hb = new QHBoxLayout(); |
365 | gl->addLayout( hb, 2, 1 ); | 366 | gl->addLayout( hb, 2, 1 ); |
366 | prevBtn = new QPushButton( this ); | 367 | prevBtn = new QPushButton( this ); |
367 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); | 368 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); |
368 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); | 369 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); |
369 | hb->addWidget( prevBtn ); | 370 | hb->addWidget( prevBtn ); |
370 | 371 | ||
371 | nextBtn = new QPushButton( this ); | 372 | nextBtn = new QPushButton( this ); |
372 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); | 373 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); |
373 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); | 374 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); |
374 | hb->addWidget( nextBtn ); | 375 | hb->addWidget( nextBtn ); |
375 | 376 | ||
376 | pb = new QPushButton( tr("Clear"), this ); | 377 | pb = new QPushButton( tr("Clear"), this ); |
377 | connect( pb, SIGNAL(clicked()), SLOT(clearChar()) ); | 378 | connect( pb, SIGNAL(clicked()), SLOT(clearChar()) ); |
378 | gl->addWidget( pb, 3, 1 ); | 379 | gl->addWidget( pb, 3, 1 ); |
379 | 380 | ||
380 | //-- | 381 | //-- |
381 | #if !defined(Q_WS_QWS) | 382 | #if !defined(Q_WS_QWS) |
382 | hb = new QHBoxLayout( tvb ); | 383 | hb = new QHBoxLayout( tvb ); |
383 | pb = new QPushButton( tr("OK"), this ); | 384 | pb = new QPushButton( tr("OK"), this ); |
384 | connect( pb, SIGNAL(clicked()), SLOT(accept()) ); | 385 | connect( pb, SIGNAL(clicked()), SLOT(accept()) ); |
385 | hb->addWidget( pb ); | 386 | hb->addWidget( pb ); |
386 | 387 | ||
387 | pb = new QPushButton( tr("Cancel"), this ); | 388 | pb = new QPushButton( tr("Cancel"), this ); |
388 | connect( pb, SIGNAL(clicked()), SLOT(reject()) ); | 389 | connect( pb, SIGNAL(clicked()), SLOT(reject()) ); |
389 | hb->addWidget( pb ); | 390 | hb->addWidget( pb ); |
390 | #endif | 391 | #endif |
391 | selectCharSetVisible( 0 ); | 392 | selectCharSetVisible( 0 ); |
392 | charList->setFocus(); | 393 | charList->setFocus(); |
393 | 394 | ||
394 | resize( minimumSize() ); | 395 | resize( minimumSize() ); |
395 | enableButtons(); | 396 | enableButtons(); |
396 | } | 397 | } |
397 | 398 | ||
398 | void QIMPenEdit::setProfile( QIMPenProfile *p ) | 399 | void QIMPenEdit::setProfile( QIMPenProfile *p ) |
399 | { | 400 | { |
400 | profile = p; | 401 | profile = p; |
401 | charSetCombo->clear(); | 402 | charSetCombo->clear(); |
402 | QIMPenCharSetIterator it( profile->charSets() ); | 403 | QIMPenCharSetIterator it( profile->charSets() ); |
403 | for ( ; it.current(); ++it ) { | 404 | for ( ; it.current(); ++it ) { |
404 | if ( ! it.current()->hidden() ) | 405 | if ( ! it.current()->hidden() ) |
405 | charSetCombo->insertItem( it.current()->description() ); | 406 | charSetCombo->insertItem( it.current()->description() ); |
406 | } | 407 | } |
407 | selectCharSetVisible( 0 ); | 408 | selectCharSetVisible( 0 ); |
408 | charList->setFocus(); | 409 | charList->setFocus(); |
409 | enableButtons(); | 410 | enableButtons(); |
410 | } | 411 | } |
411 | 412 | ||
412 | void QIMPenEdit::selectCharSet( QIMPenCharSet *c ) | 413 | void QIMPenEdit::selectCharSet( QIMPenCharSet *c ) |
413 | { | 414 | { |
414 | int i = 0; | 415 | int i = 0; |
415 | QIMPenCharSetIterator it( profile->charSets() ); | 416 | QIMPenCharSetIterator it( profile->charSets() ); |
416 | for ( ; it.current(); ++it, i++ ) { | 417 | for ( ; it.current(); ++it, i++ ) { |
417 | if ( it.current() == c ) { | 418 | if ( it.current() == c ) { |
418 | charSetCombo->setCurrentItem( i ); | 419 | charSetCombo->setCurrentItem( i ); |
419 | selectCharSet( i ); | 420 | selectCharSet( i ); |
420 | } | 421 | } |
421 | } | 422 | } |
422 | } | 423 | } |
423 | 424 | ||
424 | 425 | ||
425 | /*! | 426 | /*! |
426 | Fill the character list box with the characters. Duplicates are not | 427 | Fill the character list box with the characters. Duplicates are not |
427 | inserted. | 428 | inserted. |
428 | */ | 429 | */ |
429 | void QIMPenEdit::fillCharList() | 430 | void QIMPenEdit::fillCharList() |
430 | { | 431 | { |
431 | charList->clear(); | 432 | charList->clear(); |
432 | QIMPenCharIterator it( currentSet->characters() ); | 433 | QIMPenCharIterator it( currentSet->characters() ); |
433 | CharListItem *li = 0; | 434 | CharListItem *li = 0; |
434 | for ( ; it.current(); ++it ) { | 435 | for ( ; it.current(); ++it ) { |
435 | uint ch = it.current()->character(); | 436 | uint ch = it.current()->character(); |
436 | QString n = it.current()->name(); | 437 | QString n = it.current()->name(); |
437 | if ( !n.isEmpty() ) | 438 | if ( !n.isEmpty() ) |
438 | li = new CharListItem( n, ch ); | 439 | li = new CharListItem( n, ch ); |
439 | if ( li ) { | 440 | if ( li ) { |
440 | CharListItem *i = (CharListItem *)charList->findItem( li->text() ); | 441 | CharListItem *i = (CharListItem *)charList->findItem( li->text() ); |
441 | if ( !i || i->code() != ch ) { | 442 | if ( !i || i->code() != ch ) { |
442 | charList->insertItem( li ); | 443 | charList->insertItem( li ); |
443 | } else { | 444 | } else { |
444 | delete li; | 445 | delete li; |
445 | li = 0; | 446 | li = 0; |
446 | } | 447 | } |
447 | } | 448 | } |
448 | } | 449 | } |
449 | currentChar = 0; | 450 | currentChar = 0; |
450 | } | 451 | } |
451 | 452 | ||
452 | void QIMPenEdit::enableButtons() | 453 | void QIMPenEdit::enableButtons() |
453 | { | 454 | { |
454 | bool add = !inputChar->isEmpty(); | 455 | bool add = !inputChar->isEmpty(); |
455 | newBtn->setEnabled( add ); | 456 | newBtn->setEnabled( add ); |
456 | addBtn->setEnabled( add ); | 457 | addBtn->setEnabled( add ); |
457 | removeBtn->setEnabled( currentChar ); | 458 | removeBtn->setEnabled( currentChar ); |
458 | } | 459 | } |
459 | 460 | ||
460 | /*! | 461 | /*! |
461 | Find the previous character with the same code as the current one. | 462 | Find the previous character with the same code as the current one. |
462 | returns 0 if there is no previous character. | 463 | returns 0 if there is no previous character. |
463 | */ | 464 | */ |
464 | QIMPenChar *QIMPenEdit::findPrev() | 465 | QIMPenChar *QIMPenEdit::findPrev() |
465 | { | 466 | { |
466 | if ( !currentChar ) | 467 | if ( !currentChar ) |
467 | return 0; | 468 | return 0; |
468 | QIMPenCharIterator it( currentSet->characters() ); | 469 | QIMPenCharIterator it( currentSet->characters() ); |
469 | bool found = FALSE; | 470 | bool found = FALSE; |
470 | for ( it.toLast(); it.current(); --it ) { | 471 | for ( it.toLast(); it.current(); --it ) { |
471 | if ( !found && it.current() == currentChar ) | 472 | if ( !found && it.current() == currentChar ) |
472 | found = TRUE; | 473 | found = TRUE; |
473 | else if ( found && it.current()->character() == currentCode && | 474 | else if ( found && it.current()->character() == currentCode && |
474 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { | 475 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { |
475 | return it.current(); | 476 | return it.current(); |
476 | } | 477 | } |
477 | } | 478 | } |
478 | 479 | ||
479 | return 0; | 480 | return 0; |
480 | } | 481 | } |
481 | 482 | ||
482 | /*! | 483 | /*! |
483 | Find the next character with the same code as the current one. | 484 | Find the next character with the same code as the current one. |
484 | returns 0 if there is no next character. | 485 | returns 0 if there is no next character. |
485 | */ | 486 | */ |
486 | QIMPenChar *QIMPenEdit::findNext() | 487 | QIMPenChar *QIMPenEdit::findNext() |
487 | { | 488 | { |
488 | if ( !currentChar ) | 489 | if ( !currentChar ) |
489 | return 0; | 490 | return 0; |
490 | QIMPenCharIterator it( currentSet->characters() ); | 491 | QIMPenCharIterator it( currentSet->characters() ); |
491 | bool found = FALSE; | 492 | bool found = FALSE; |
492 | for ( ; it.current(); ++it ) { | 493 | for ( ; it.current(); ++it ) { |
493 | if ( !found && it.current() == currentChar ) | 494 | if ( !found && it.current() == currentChar ) |
494 | found = TRUE; | 495 | found = TRUE; |
495 | else if ( found && it.current()->character() == currentCode && | 496 | else if ( found && it.current()->character() == currentCode && |