author | hash <hash> | 2002-11-27 09:53:25 (UTC) |
---|---|---|
committer | hash <hash> | 2002-11-27 09:53:25 (UTC) |
commit | 796b942cc070da91982689eb6e50b1e1e776c5ed (patch) (unidiff) | |
tree | e0c1733ca8f5fa9721af101f3db689c5cf0392dd | |
parent | e52158d2f9e1fdc9766d991dc672729648d5a020 (diff) | |
download | opie-796b942cc070da91982689eb6e50b1e1e776c5ed.zip opie-796b942cc070da91982689eb6e50b1e1e776c5ed.tar.gz opie-796b942cc070da91982689eb6e50b1e1e776c5ed.tar.bz2 |
now saving profiles works! yay!
-rw-r--r-- | inputmethods/handwriting/qimpensetup.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/inputmethods/handwriting/qimpensetup.cpp b/inputmethods/handwriting/qimpensetup.cpp index 10c136d..2441102 100644 --- a/inputmethods/handwriting/qimpensetup.cpp +++ b/inputmethods/handwriting/qimpensetup.cpp | |||
@@ -1,656 +1,664 @@ | |||
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 | 39 | ||
40 | 40 | ||
41 | /* XPM */ | 41 | /* XPM */ |
42 | static const char * const left_xpm[] = { | 42 | static const char * const left_xpm[] = { |
43 | "16 16 2 1", | 43 | "16 16 2 1", |
44 | " c None", | 44 | " c None", |
45 | ".c #000000", | 45 | ".c #000000", |
46 | " ", | 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 | /* XPM */ | 64 | /* XPM */ |
65 | static const char * const right_xpm[] = { | 65 | static const char * const right_xpm[] = { |
66 | "16 16 2 1", | 66 | "16 16 2 1", |
67 | " c None", | 67 | " c None", |
68 | ".c #000000", | 68 | ".c #000000", |
69 | " ", | 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 | QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent, | 88 | QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent, |
89 | const char *name, bool modal, int WFlags ) | 89 | const char *name, bool modal, int WFlags ) |
90 | : QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p) | 90 | : QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p) |
91 | { | 91 | { |
92 | setCaption( tr("Setup Handwriting Input") ); | 92 | setCaption( tr("Setup Handwriting Input") ); |
93 | 93 | ||
94 | QVBoxLayout *vb = new QVBoxLayout( this ); | 94 | QVBoxLayout *vb = new QVBoxLayout( this ); |
95 | 95 | ||
96 | #if 0 | 96 | #define MULTIPROFILE |
97 | #ifdef MULTIPROFILE | ||
97 | profileList.setAutoDelete( true ); | 98 | profileList.setAutoDelete( true ); |
98 | QHBoxLayout *hb = new QHBoxLayout( vb ); | 99 | QHBoxLayout *hb = new QHBoxLayout( vb ); |
99 | hb->setMargin( 6 ); | 100 | hb->setMargin( 6 ); |
100 | QLabel *l = new QLabel( tr("Character Profile:"), this ); | 101 | QLabel *l = new QLabel( tr("Character Profile:"), this ); |
101 | hb->addWidget( l ); | 102 | hb->addWidget( l ); |
102 | profileCombo = new QComboBox( this ); | 103 | profileCombo = new QComboBox( this ); |
103 | connect( profileCombo, SIGNAL(activated(const QString &)), | 104 | connect( profileCombo, SIGNAL(activated(const QString &)), |
104 | this, SLOT(selectProfile(const QString &)) ); | 105 | this, SLOT(selectProfile(const QString &)) ); |
105 | hb->addWidget( profileCombo ); | 106 | hb->addWidget( profileCombo ); |
106 | loadProfiles(); | ||
107 | #else | 107 | #else |
108 | profileList.append( profile ); | 108 | profileList.append( profile ); |
109 | #endif | 109 | #endif |
110 | |||
111 | qWarning("profiles: %d", profileList.count()); | ||
110 | 112 | ||
111 | QTabWidget *tw = new QTabWidget( this ); | 113 | QTabWidget *tw = new QTabWidget( this ); |
112 | vb->addWidget( tw ); | 114 | vb->addWidget( tw ); |
113 | 115 | ||
114 | pref = new QIMPenPrefBase( this ); | 116 | pref = new QIMPenPrefBase( this ); |
115 | tw->addTab( pref, tr("Preferences") ); | 117 | tw->addTab( pref, tr("Preferences") ); |
116 | 118 | ||
117 | pref->inputStyle->setExclusive( TRUE ); | 119 | pref->inputStyle->setExclusive( TRUE ); |
118 | 120 | ||
119 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; | 121 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; |
120 | pref->inputStyle->setButton( style ); | 122 | pref->inputStyle->setButton( style ); |
121 | connect( pref->inputStyle, SIGNAL(clicked(int)), | 123 | connect( pref->inputStyle, SIGNAL(clicked(int)), |
122 | this, SLOT(styleClicked(int)) ); | 124 | this, SLOT(styleClicked(int)) ); |
123 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); | 125 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); |
124 | 126 | ||
125 | multiTimeout = profile->multiStrokeTimeout(); | 127 | multiTimeout = profile->multiStrokeTimeout(); |
126 | pref->multiStrokeSlider->setValue( multiTimeout ); | 128 | pref->multiStrokeSlider->setValue( multiTimeout ); |
127 | multiTimeoutChanged( multiTimeout ); | 129 | multiTimeoutChanged( multiTimeout ); |
128 | connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)), | 130 | connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)), |
129 | this, SLOT(multiTimeoutChanged(int)) ); | 131 | this, SLOT(multiTimeoutChanged(int)) ); |
130 | 132 | ||
131 | edit = new QIMPenEdit( p, tw ); | 133 | edit = new QIMPenEdit( p, tw ); |
132 | tw->addTab( edit, tr("Customize") ); | 134 | tw->addTab( edit, tr("Customize") ); |
135 | #ifdef MULTIPROFILE | ||
136 | loadProfiles(); | ||
137 | #endif | ||
138 | |||
133 | } | 139 | } |
134 | 140 | ||
135 | void QIMPenSetup::loadProfiles() | 141 | void QIMPenSetup::loadProfiles() |
136 | { | 142 | { |
137 | QString path = QPEApplication::qpeDir() + "etc/qimpen"; | 143 | QString path = QPEApplication::qpeDir() + "etc/qimpen"; |
138 | QDir dir( path, "*.conf" ); | 144 | QDir dir( path, "*.conf" ); |
139 | QStringList list = dir.entryList(); | 145 | QStringList list = dir.entryList(); |
140 | QStringList::Iterator it; | 146 | QStringList::Iterator it; |
141 | for ( it = list.begin(); it != list.end(); ++it ) { | 147 | for ( it = list.begin(); it != list.end(); ++it ) { |
142 | QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); | 148 | QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); |
143 | profileList.append( p ); | 149 | profileList.append( p ); |
144 | profileCombo->insertItem( p->name() ); | 150 | profileCombo->insertItem( p->name() ); |
145 | if ( p->name() == profile->name() ) { | 151 | if ( p->name() == profile->name() ) { |
146 | profileCombo->setCurrentItem( profileCombo->count()-1 ); | 152 | profileCombo->setCurrentItem( profileCombo->count()-1 ); |
147 | profile = p; | 153 | profile = p; |
154 | edit->setProfile( profile ); | ||
148 | } | 155 | } |
149 | } | 156 | } |
150 | } | 157 | } |
151 | 158 | ||
152 | void QIMPenSetup::styleClicked( int id ) | 159 | void QIMPenSetup::styleClicked( int id ) |
153 | { | 160 | { |
154 | style = id; | 161 | style = id; |
155 | } | 162 | } |
156 | 163 | ||
157 | void QIMPenSetup::multiTimeoutChanged( int v ) | 164 | void QIMPenSetup::multiTimeoutChanged( int v ) |
158 | { | 165 | { |
159 | multiTimeout = v; | 166 | multiTimeout = v; |
160 | pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) ); | 167 | pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) ); |
161 | } | 168 | } |
162 | 169 | ||
163 | void QIMPenSetup::selectProfile( const QString &p ) | 170 | void QIMPenSetup::selectProfile( const QString &p ) |
164 | { | 171 | { |
165 | if ( p == profile->name() ) | 172 | if ( p == profile->name() ) |
166 | return; | 173 | return; |
167 | 174 | ||
168 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); | 175 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); |
169 | profile->setMultiStrokeTimeout( multiTimeout ); | 176 | profile->setMultiStrokeTimeout( multiTimeout ); |
170 | 177 | ||
171 | for ( int i = 0; i < (int)profileList.count(); i++ ) { | 178 | for ( int i = 0; i < (int)profileList.count(); i++ ) { |
172 | if ( profileList.at(i)->name() == p ) { | 179 | if ( profileList.at(i)->name() == p ) { |
173 | profile = profileList.at(i); | 180 | profile = profileList.at(i); |
174 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; | 181 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; |
175 | pref->inputStyle->setButton( style ); | 182 | pref->inputStyle->setButton( style ); |
176 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); | 183 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); |
177 | multiTimeout = profile->multiStrokeTimeout(); | 184 | multiTimeout = profile->multiStrokeTimeout(); |
178 | pref->multiStrokeSlider->setValue( multiTimeout ); | 185 | pref->multiStrokeSlider->setValue( multiTimeout ); |
179 | multiTimeoutChanged( multiTimeout ); | 186 | multiTimeoutChanged( multiTimeout ); |
180 | edit->setProfile( profile ); | 187 | edit->setProfile( profile ); |
181 | break; | 188 | break; |
182 | } | 189 | } |
183 | } | 190 | } |
184 | } | 191 | } |
185 | 192 | ||
186 | void QIMPenSetup::accept() | 193 | void QIMPenSetup::accept() |
187 | { | 194 | { |
188 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); | 195 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); |
189 | profile->setMultiStrokeTimeout( multiTimeout ); | 196 | profile->setMultiStrokeTimeout( multiTimeout ); |
190 | // Save current profile | 197 | // Save current profile |
191 | if ( profileCombo ) { | 198 | if ( profileCombo ) { |
192 | Config config( "handwriting" ); | 199 | Config config( "handwriting" ); |
193 | config.setGroup( "Settings" ); | 200 | config.setGroup( "Settings" ); |
194 | config.writeEntry( "Profile", profileCombo->currentText() ); | 201 | config.writeEntry( "Profile", profileCombo->currentText() ); |
195 | } | 202 | } |
196 | // Save charsets | 203 | // Save charsets |
197 | bool ok = TRUE; | 204 | bool ok = TRUE; |
198 | for ( int i = 0; i < (int)profileList.count(); i++ ) { | 205 | for ( int i = 0; i < (int)profileList.count(); i++ ) { |
199 | QIMPenProfile *prof = profileList.at(i); | 206 | QIMPenProfile *prof = profileList.at(i); |
200 | QIMPenCharSetIterator it(prof->charSets()); | 207 | QIMPenCharSetIterator it(prof->charSets()); |
201 | for ( ; it.current(); ++it ) { | 208 | for ( ; it.current(); ++it ) { |
202 | if ( !(it.current()->save( QIMPenCharSet::User )) ) { | 209 | if ( !(it.current()->save( QIMPenCharSet::User )) ) { |
203 | ok = FALSE; | 210 | ok = FALSE; |
204 | break; | 211 | break; |
205 | } | 212 | } |
206 | } | 213 | } |
207 | } | 214 | } |
208 | if ( !ok ) { | 215 | if ( !ok ) { |
209 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 216 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
210 | tr("Unable to save information.\n" | 217 | tr("Unable to save information.\n" |
211 | "Free up some space\n" | 218 | "Free up some space\n" |
212 | "and try again.\n" | 219 | "and try again.\n" |
213 | "\nQuit anyway?"), | 220 | "\nQuit anyway?"), |
214 | QMessageBox::Yes|QMessageBox::Escape, | 221 | QMessageBox::Yes|QMessageBox::Escape, |
215 | QMessageBox::No|QMessageBox::Default ) | 222 | QMessageBox::No|QMessageBox::Default ) |
216 | != QMessageBox::No ) { | 223 | != QMessageBox::No ) { |
217 | QDialog::accept(); | 224 | QDialog::accept(); |
218 | } | 225 | } |
219 | } else { | 226 | } else { |
220 | QDialog::accept(); | 227 | QDialog::accept(); |
221 | } | 228 | } |
222 | } | 229 | } |
223 | 230 | ||
224 | //--------------------------------------------------------------------------- | 231 | //--------------------------------------------------------------------------- |
225 | 232 | ||
226 | QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name, | 233 | QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name, |
227 | bool modal, int WFlags) | 234 | bool modal, int WFlags) |
228 | : QDialog( parent, name, modal, WFlags ) | 235 | : QDialog( parent, name, modal, WFlags ) |
229 | { | 236 | { |
230 | setCaption( tr("Enter new character") ); | 237 | setCaption( tr("Enter new character") ); |
231 | uni = 0; | 238 | uni = 0; |
232 | 239 | ||
233 | QVBoxLayout *vb = new QVBoxLayout( this, 10 ); | 240 | QVBoxLayout *vb = new QVBoxLayout( this, 10 ); |
234 | 241 | ||
235 | QHBoxLayout *hb = new QHBoxLayout(); | 242 | QHBoxLayout *hb = new QHBoxLayout(); |
236 | vb->addLayout( hb ); | 243 | vb->addLayout( hb ); |
237 | 244 | ||
238 | QLabel *label = new QLabel( tr("Character:"), this ); | 245 | QLabel *label = new QLabel( tr("Character:"), this ); |
239 | hb->addWidget( label ); | 246 | hb->addWidget( label ); |
240 | 247 | ||
241 | QComboBox *cb = new QComboBox( TRUE, this ); | 248 | QComboBox *cb = new QComboBox( TRUE, this ); |
242 | connect( cb, SIGNAL(activated(int)), SLOT(setSpecial(int)) ); | 249 | connect( cb, SIGNAL(activated(int)), SLOT(setSpecial(int)) ); |
243 | connect( cb, SIGNAL(textChanged(const QString &)), | 250 | connect( cb, SIGNAL(textChanged(const QString &)), |
244 | SLOT(setCharacter(const QString &)) ); | 251 | SLOT(setCharacter(const QString &)) ); |
245 | addSpecial( cb ); | 252 | addSpecial( cb ); |
246 | cb->setEditText( "" ); | 253 | cb->setEditText( "" ); |
247 | hb->addWidget( cb ); | 254 | hb->addWidget( cb ); |
248 | 255 | ||
249 | hb = new QHBoxLayout(); | 256 | hb = new QHBoxLayout(); |
250 | vb->addLayout( hb ); | 257 | vb->addLayout( hb ); |
251 | 258 | ||
252 | QPushButton *pb = new QPushButton( "OK", this ); | 259 | QPushButton *pb = new QPushButton( "OK", this ); |
253 | connect( pb, SIGNAL(clicked()), SLOT(accept())); | 260 | connect( pb, SIGNAL(clicked()), SLOT(accept())); |
254 | hb->addWidget( pb ); | 261 | hb->addWidget( pb ); |
255 | pb = new QPushButton( "Cancel", this ); | 262 | pb = new QPushButton( "Cancel", this ); |
256 | connect( pb, SIGNAL(clicked()), SLOT(reject())); | 263 | connect( pb, SIGNAL(clicked()), SLOT(reject())); |
257 | hb->addWidget( pb ); | 264 | hb->addWidget( pb ); |
258 | 265 | ||
259 | cb->setFocus(); | 266 | cb->setFocus(); |
260 | } | 267 | } |
261 | 268 | ||
262 | void QIMPenInputCharDlg::addSpecial( QComboBox *cb ) | 269 | void QIMPenInputCharDlg::addSpecial( QComboBox *cb ) |
263 | { | 270 | { |
264 | int i = 0; | 271 | int i = 0; |
265 | while ( qimpen_specialKeys[i].code != Key_unknown ) { | 272 | while ( qimpen_specialKeys[i].code != Key_unknown ) { |
266 | cb->insertItem( qimpen_specialKeys[i].name ); | 273 | cb->insertItem( qimpen_specialKeys[i].name ); |
267 | i++; | 274 | i++; |
268 | } | 275 | } |
269 | } | 276 | } |
270 | 277 | ||
271 | void QIMPenInputCharDlg::setSpecial( int sp ) | 278 | void QIMPenInputCharDlg::setSpecial( int sp ) |
272 | { | 279 | { |
273 | uni = qimpen_specialKeys[sp].code << 16; | 280 | uni = qimpen_specialKeys[sp].code << 16; |
274 | } | 281 | } |
275 | 282 | ||
276 | void QIMPenInputCharDlg::setCharacter( const QString &string ) | 283 | void QIMPenInputCharDlg::setCharacter( const QString &string ) |
277 | { | 284 | { |
278 | uni = string[0].unicode(); | 285 | uni = string[0].unicode(); |
279 | } | 286 | } |
280 | 287 | ||
281 | //--------------------------------------------------------------------------- | 288 | //--------------------------------------------------------------------------- |
282 | 289 | ||
283 | class CharListItem : public QListBoxText | 290 | class CharListItem : public QListBoxText |
284 | { | 291 | { |
285 | public: | 292 | public: |
286 | CharListItem( const QString &text, uint c ) | 293 | CharListItem( const QString &text, uint c ) |
287 | : QListBoxText( text ) | 294 | : QListBoxText( text ) |
288 | { | 295 | { |
289 | _code = c; | 296 | _code = c; |
290 | } | 297 | } |
291 | 298 | ||
292 | uint code() const { return _code; } | 299 | uint code() const { return _code; } |
293 | 300 | ||
294 | protected: | 301 | protected: |
295 | uint _code; | 302 | uint _code; |
296 | }; | 303 | }; |
297 | 304 | ||
298 | /*! | 305 | /*! |
299 | \class QIMPenEdit qimpensetup.h | 306 | \class QIMPenEdit qimpensetup.h |
300 | 307 | ||
301 | Class to allow users to input totally useless character definitions | 308 | Class to allow users to input totally useless character definitions |
302 | which could match any number of the default set. | 309 | which could match any number of the default set. |
303 | */ | 310 | */ |
304 | 311 | ||
305 | QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, | 312 | QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, |
306 | const char *name ) | 313 | const char *name ) |
307 | : QWidget( parent, name ), profile(p) | 314 | : QWidget( parent, name ), profile(p) |
308 | { | 315 | { |
309 | currentChar = 0; | 316 | currentChar = 0; |
310 | currentCode = 0; | 317 | currentCode = 0; |
311 | inputChar = new QIMPenChar(); | 318 | inputChar = new QIMPenChar(); |
312 | 319 | ||
313 | QVBoxLayout *tvb = new QVBoxLayout( this, 5 ); | 320 | QVBoxLayout *tvb = new QVBoxLayout( this, 5 ); |
314 | 321 | ||
315 | QGridLayout *gl = new QGridLayout( tvb, 4, 2 ); | 322 | QGridLayout *gl = new QGridLayout( tvb, 4, 2 ); |
316 | gl->setRowStretch( 1, 1 ); | 323 | gl->setRowStretch( 1, 1 ); |
317 | gl->addRowSpacing( 2, 35 ); | 324 | gl->addRowSpacing( 2, 35 ); |
318 | gl->addRowSpacing( 3, 35 ); | 325 | gl->addRowSpacing( 3, 35 ); |
319 | 326 | ||
320 | charSetCombo = new QComboBox( this ); | 327 | charSetCombo = new QComboBox( this ); |
321 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); | 328 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); |
322 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); | 329 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); |
323 | QIMPenCharSetIterator it( profile->charSets() ); | 330 | QIMPenCharSetIterator it( profile->charSets() ); |
324 | for ( ; it.current(); ++it ) { | 331 | for ( ; it.current(); ++it ) { |
325 | charSetCombo->insertItem( it.current()->description() ); | 332 | charSetCombo->insertItem( it.current()->description() ); |
326 | } | 333 | } |
327 | 334 | ||
328 | charList = new QListBox( this ); | 335 | charList = new QListBox( this ); |
329 | charList->setMinimumHeight( charList->sizeHint().height() ); | 336 | charList->setMinimumHeight( charList->sizeHint().height() ); |
330 | connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) ); | 337 | connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) ); |
331 | gl->addWidget( charList, 1, 0 ); | 338 | gl->addWidget( charList, 1, 0 ); |
332 | 339 | ||
333 | pw = new QIMPenWidget( this ); | 340 | pw = new QIMPenWidget( this ); |
334 | pw->setFixedHeight( 75 ); | 341 | pw->setFixedHeight( 75 ); |
335 | gl->addMultiCellWidget( pw, 2, 3, 0, 0 ); | 342 | gl->addMultiCellWidget( pw, 2, 3, 0, 0 ); |
336 | connect( pw, SIGNAL(stroke(QIMPenStroke *)), | 343 | connect( pw, SIGNAL(stroke(QIMPenStroke *)), |
337 | SLOT(newStroke(QIMPenStroke *)) ); | 344 | SLOT(newStroke(QIMPenStroke *)) ); |
338 | 345 | ||
339 | QVBoxLayout *vb = new QVBoxLayout(); | 346 | QVBoxLayout *vb = new QVBoxLayout(); |
340 | gl->addLayout( vb, 1, 1 ); | 347 | gl->addLayout( vb, 1, 1 ); |
341 | newBtn = new QPushButton( tr("New..."), this ); | 348 | newBtn = new QPushButton( tr("New..."), this ); |
342 | connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) ); | 349 | connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) ); |
343 | vb->addWidget( newBtn ); | 350 | vb->addWidget( newBtn ); |
344 | 351 | ||
345 | addBtn = new QPushButton( tr("Add"), this ); | 352 | addBtn = new QPushButton( tr("Add"), this ); |
346 | connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) ); | 353 | connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) ); |
347 | vb->addWidget( addBtn ); | 354 | vb->addWidget( addBtn ); |
348 | 355 | ||
349 | removeBtn = new QPushButton( tr("Remove"), this ); | 356 | removeBtn = new QPushButton( tr("Remove"), this ); |
350 | connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) ); | 357 | connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) ); |
351 | vb->addWidget( removeBtn ); | 358 | vb->addWidget( removeBtn ); |
352 | 359 | ||
353 | QPushButton *pb = new QPushButton( tr("Default"), this ); | 360 | QPushButton *pb = new QPushButton( tr("Default"), this ); |
354 | connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) ); | 361 | connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) ); |
355 | vb->addWidget( pb ); | 362 | vb->addWidget( pb ); |
356 | 363 | ||
357 | QHBoxLayout *hb = new QHBoxLayout(); | 364 | QHBoxLayout *hb = new QHBoxLayout(); |
358 | gl->addLayout( hb, 2, 1 ); | 365 | gl->addLayout( hb, 2, 1 ); |
359 | prevBtn = new QPushButton( this ); | 366 | prevBtn = new QPushButton( this ); |
360 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); | 367 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); |
361 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); | 368 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); |
362 | hb->addWidget( prevBtn ); | 369 | hb->addWidget( prevBtn ); |
363 | 370 | ||
364 | nextBtn = new QPushButton( this ); | 371 | nextBtn = new QPushButton( this ); |
365 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); | 372 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); |
366 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); | 373 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); |
367 | hb->addWidget( nextBtn ); | 374 | hb->addWidget( nextBtn ); |
368 | 375 | ||
369 | pb = new QPushButton( tr("Clear"), this ); | 376 | pb = new QPushButton( tr("Clear"), this ); |
370 | connect( pb, SIGNAL(clicked()), SLOT(clearChar()) ); | 377 | connect( pb, SIGNAL(clicked()), SLOT(clearChar()) ); |
371 | gl->addWidget( pb, 3, 1 ); | 378 | gl->addWidget( pb, 3, 1 ); |
372 | 379 | ||
373 | //-- | 380 | //-- |
374 | #if !defined(Q_WS_QWS) | 381 | #if !defined(Q_WS_QWS) |
375 | hb = new QHBoxLayout( tvb ); | 382 | hb = new QHBoxLayout( tvb ); |
376 | pb = new QPushButton( tr("OK"), this ); | 383 | pb = new QPushButton( tr("OK"), this ); |
377 | connect( pb, SIGNAL(clicked()), SLOT(accept()) ); | 384 | connect( pb, SIGNAL(clicked()), SLOT(accept()) ); |
378 | hb->addWidget( pb ); | 385 | hb->addWidget( pb ); |
379 | 386 | ||
380 | pb = new QPushButton( tr("Cancel"), this ); | 387 | pb = new QPushButton( tr("Cancel"), this ); |
381 | connect( pb, SIGNAL(clicked()), SLOT(reject()) ); | 388 | connect( pb, SIGNAL(clicked()), SLOT(reject()) ); |
382 | hb->addWidget( pb ); | 389 | hb->addWidget( pb ); |
383 | #endif | 390 | #endif |
384 | selectCharSet( 0 ); | 391 | selectCharSet( 0 ); |
385 | charList->setFocus(); | 392 | charList->setFocus(); |
386 | 393 | ||
387 | resize( minimumSize() ); | 394 | resize( minimumSize() ); |
388 | enableButtons(); | 395 | enableButtons(); |
389 | } | 396 | } |
390 | 397 | ||
391 | void QIMPenEdit::setProfile( QIMPenProfile *p ) | 398 | void QIMPenEdit::setProfile( QIMPenProfile *p ) |
392 | { | 399 | { |
393 | profile = p; | 400 | profile = p; |
394 | charSetCombo->clear(); | 401 | charSetCombo->clear(); |
395 | QIMPenCharSetIterator it( profile->charSets() ); | 402 | QIMPenCharSetIterator it( profile->charSets() ); |
396 | for ( ; it.current(); ++it ) { | 403 | for ( ; it.current(); ++it ) { |
397 | charSetCombo->insertItem( it.current()->description() ); | 404 | charSetCombo->insertItem( it.current()->description() ); |
398 | } | 405 | } |
399 | selectCharSet( 0 ); | 406 | selectCharSet( 0 ); |
400 | charList->setFocus(); | 407 | charList->setFocus(); |
401 | enableButtons(); | 408 | enableButtons(); |
402 | } | 409 | } |
403 | 410 | ||
404 | void QIMPenEdit::selectCharSet( QIMPenCharSet *c ) | 411 | void QIMPenEdit::selectCharSet( QIMPenCharSet *c ) |
405 | { | 412 | { |
406 | int i = 0; | 413 | int i = 0; |
407 | QIMPenCharSetIterator it( profile->charSets() ); | 414 | QIMPenCharSetIterator it( profile->charSets() ); |
408 | for ( ; it.current(); ++it, i++ ) { | 415 | for ( ; it.current(); ++it, i++ ) { |
409 | if ( it.current() == c ) { | 416 | if ( it.current() == c ) { |
410 | charSetCombo->setCurrentItem( i ); | 417 | charSetCombo->setCurrentItem( i ); |
411 | selectCharSet( i ); | 418 | selectCharSet( i ); |
412 | } | 419 | } |
413 | } | 420 | } |
414 | } | 421 | } |
415 | 422 | ||
416 | 423 | ||
417 | /*! | 424 | /*! |
418 | Fill the character list box with the characters. Duplicates are not | 425 | Fill the character list box with the characters. Duplicates are not |
419 | inserted. | 426 | inserted. |
420 | */ | 427 | */ |
421 | void QIMPenEdit::fillCharList() | 428 | void QIMPenEdit::fillCharList() |
422 | { | 429 | { |
423 | charList->clear(); | 430 | charList->clear(); |
424 | QIMPenCharIterator it( currentSet->characters() ); | 431 | QIMPenCharIterator it( currentSet->characters() ); |
425 | CharListItem *li = 0; | 432 | CharListItem *li = 0; |
426 | for ( ; it.current(); ++it ) { | 433 | for ( ; it.current(); ++it ) { |
427 | uint ch = it.current()->character(); | 434 | uint ch = it.current()->character(); |
428 | QString n = it.current()->name(); | 435 | QString n = it.current()->name(); |
429 | if ( !n.isEmpty() ) | 436 | if ( !n.isEmpty() ) |
430 | li = new CharListItem( n, ch ); | 437 | li = new CharListItem( n, ch ); |
431 | if ( li ) { | 438 | if ( li ) { |
432 | CharListItem *i = (CharListItem *)charList->findItem( li->text() ); | 439 | CharListItem *i = (CharListItem *)charList->findItem( li->text() ); |
433 | if ( !i || i->code() != ch ) { | 440 | if ( !i || i->code() != ch ) { |
434 | charList->insertItem( li ); | 441 | charList->insertItem( li ); |
435 | } else { | 442 | } else { |
436 | delete li; | 443 | delete li; |
437 | li = 0; | 444 | li = 0; |
438 | } | 445 | } |
439 | } | 446 | } |
440 | } | 447 | } |
441 | currentChar = 0; | 448 | currentChar = 0; |
442 | } | 449 | } |
443 | 450 | ||
444 | void QIMPenEdit::enableButtons() | 451 | void QIMPenEdit::enableButtons() |
445 | { | 452 | { |
446 | bool add = !inputChar->isEmpty(); | 453 | bool add = !inputChar->isEmpty(); |
447 | newBtn->setEnabled( add ); | 454 | newBtn->setEnabled( add ); |
448 | addBtn->setEnabled( add ); | 455 | addBtn->setEnabled( add ); |
449 | removeBtn->setEnabled( currentChar ); | 456 | removeBtn->setEnabled( currentChar ); |
450 | } | 457 | } |
451 | 458 | ||
452 | /*! | 459 | /*! |
453 | Find the previous character with the same code as the current one. | 460 | Find the previous character with the same code as the current one. |
454 | returns 0 if there is no previous character. | 461 | returns 0 if there is no previous character. |
455 | */ | 462 | */ |
456 | QIMPenChar *QIMPenEdit::findPrev() | 463 | QIMPenChar *QIMPenEdit::findPrev() |
457 | { | 464 | { |
458 | if ( !currentChar ) | 465 | if ( !currentChar ) |
459 | return 0; | 466 | return 0; |
460 | QIMPenCharIterator it( currentSet->characters() ); | 467 | QIMPenCharIterator it( currentSet->characters() ); |
461 | bool found = FALSE; | 468 | bool found = FALSE; |
462 | for ( it.toLast(); it.current(); --it ) { | 469 | for ( it.toLast(); it.current(); --it ) { |
463 | if ( !found && it.current() == currentChar ) | 470 | if ( !found && it.current() == currentChar ) |
464 | found = TRUE; | 471 | found = TRUE; |
465 | else if ( found && it.current()->character() == currentCode && | 472 | else if ( found && it.current()->character() == currentCode && |
466 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { | 473 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { |
467 | return it.current(); | 474 | return it.current(); |
468 | } | 475 | } |
469 | } | 476 | } |
470 | 477 | ||
471 | return 0; | 478 | return 0; |
472 | } | 479 | } |
473 | 480 | ||
474 | /*! | 481 | /*! |
475 | Find the next character with the same code as the current one. | 482 | Find the next character with the same code as the current one. |
476 | returns 0 if there is no next character. | 483 | returns 0 if there is no next character. |
477 | */ | 484 | */ |
478 | QIMPenChar *QIMPenEdit::findNext() | 485 | QIMPenChar *QIMPenEdit::findNext() |
479 | { | 486 | { |
480 | if ( !currentChar ) | 487 | if ( !currentChar ) |
481 | return 0; | 488 | return 0; |
482 | QIMPenCharIterator it( currentSet->characters() ); | 489 | QIMPenCharIterator it( currentSet->characters() ); |
483 | bool found = FALSE; | 490 | bool found = FALSE; |
484 | for ( ; it.current(); ++it ) { | 491 | for ( ; it.current(); ++it ) { |
485 | if ( !found && it.current() == currentChar ) | 492 | if ( !found && it.current() == currentChar ) |
486 | found = TRUE; | 493 | found = TRUE; |
487 | else if ( found && it.current()->character() == currentCode && | 494 | else if ( found && it.current()->character() == currentCode && |
488 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { | 495 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { |
489 | return it.current(); | 496 | return it.current(); |
490 | } | 497 | } |
491 | } | 498 | } |
492 | 499 | ||
493 | return 0; | 500 | return 0; |
494 | } | 501 | } |
495 | 502 | ||
496 | void QIMPenEdit::setCurrentChar( QIMPenChar *pc ) | 503 | void QIMPenEdit::setCurrentChar( QIMPenChar *pc ) |
497 | { | 504 | { |
498 | currentChar = pc; | 505 | currentChar = pc; |
499 | pw->showCharacter( currentChar ); | 506 | pw->showCharacter( currentChar ); |
500 | if ( currentChar ) { | 507 | if ( currentChar ) { |
501 | prevBtn->setEnabled( findPrev() != 0 ); | 508 | prevBtn->setEnabled( findPrev() != 0 ); |
502 | nextBtn->setEnabled( findNext() != 0 ); | 509 | nextBtn->setEnabled( findNext() != 0 ); |
503 | } | 510 | } |
504 | } | 511 | } |
505 | 512 | ||
506 | void QIMPenEdit::prevChar() | 513 | void QIMPenEdit::prevChar() |
507 | { | 514 | { |
508 | QIMPenChar *pc = findPrev(); | 515 | QIMPenChar *pc = findPrev(); |
509 | if ( pc ) | 516 | if ( pc ) |
510 | setCurrentChar( pc ); | 517 | setCurrentChar( pc ); |
511 | } | 518 | } |
512 | 519 | ||
513 | void QIMPenEdit::nextChar() | 520 | void QIMPenEdit::nextChar() |
514 | { | 521 | { |
515 | QIMPenChar *pc = findNext(); | 522 | QIMPenChar *pc = findNext(); |
516 | if ( pc ) | 523 | if ( pc ) |
517 | setCurrentChar( pc ); | 524 | setCurrentChar( pc ); |
518 | } | 525 | } |
519 | 526 | ||
520 | void QIMPenEdit::clearChar() | 527 | void QIMPenEdit::clearChar() |
521 | { | 528 | { |
522 | inputChar->clear(); | 529 | inputChar->clear(); |
523 | pw->clear(); | 530 | pw->clear(); |
524 | enableButtons(); | 531 | enableButtons(); |
525 | } | 532 | } |
526 | 533 | ||
527 | void QIMPenEdit::selectChar( int i ) | 534 | void QIMPenEdit::selectChar( int i ) |
528 | { | 535 | { |
529 | currentChar = 0; | 536 | currentChar = 0; |
530 | currentCode = ((CharListItem *)charList->item(i))->code(); | 537 | currentCode = ((CharListItem *)charList->item(i))->code(); |
531 | QIMPenCharIterator it(currentSet->characters() ); | 538 | QIMPenCharIterator it(currentSet->characters() ); |
532 | for ( ; it.current(); ++it ) { | 539 | for ( ; it.current(); ++it ) { |
533 | if ( it.current()->character() == currentCode && | 540 | if ( it.current()->character() == currentCode && |
534 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { | 541 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { |
535 | setCurrentChar( it.current() ); | 542 | setCurrentChar( it.current() ); |
536 | break; | 543 | break; |
537 | } | 544 | } |
538 | } | 545 | } |
539 | if ( !it.current() ) | 546 | if ( !it.current() ) |
540 | setCurrentChar( 0 ); | 547 | setCurrentChar( 0 ); |
541 | inputChar->clear(); | 548 | inputChar->clear(); |
542 | } | 549 | } |
543 | 550 | ||
544 | void QIMPenEdit::selectCharSet( int i ) | 551 | void QIMPenEdit::selectCharSet( int i ) |
545 | { | 552 | { |
546 | if ( currentSet ) | 553 | if ( currentSet ) |
547 | pw->removeCharSet( 0 ); | 554 | pw->removeCharSet( 0 ); |
548 | currentSet = profile->charSets().at( i ); | 555 | currentSet = profile->charSets().at( i ); |
549 | fillCharList(); | 556 | fillCharList(); |
550 | pw->insertCharSet( currentSet ); | 557 | pw->insertCharSet( currentSet ); |
551 | inputChar->clear(); | 558 | inputChar->clear(); |
552 | if ( charList->count() ) { | 559 | if ( charList->count() ) { |
553 | charList->setSelected( 0, TRUE ); | 560 | charList->setSelected( 0, TRUE ); |
554 | selectChar(0); | 561 | selectChar(0); |
555 | } | 562 | } |
556 | } | 563 | } |
557 | 564 | ||
558 | void QIMPenEdit::addChar() | 565 | void QIMPenEdit::addChar() |
559 | { | 566 | { |
560 | if ( !inputChar->isEmpty() ) { | 567 | if ( !inputChar->isEmpty() ) { |
561 | QIMPenChar *pc = new QIMPenChar( *inputChar ); | 568 | QIMPenChar *pc = new QIMPenChar( *inputChar ); |
562 | pc->setCharacter( currentCode ); | 569 | pc->setCharacter( currentCode ); |
563 | 570 | ||
564 | // User characters override all matching system characters. | 571 | // User characters override all matching system characters. |
565 | // Copy and mark deleted identical system characters. | 572 | // Copy and mark deleted identical system characters. |
573 | |||
566 | QIMPenCharIterator it(currentSet->characters() ); | 574 | QIMPenCharIterator it(currentSet->characters() ); |
567 | QIMPenChar *sc = 0; | 575 | QIMPenChar *sc = 0; |
568 | while ( (sc = it.current()) != 0 ) { | 576 | while ( (sc = it.current()) != 0 ) { |
569 | ++it; | 577 | ++it; |
570 | if ( sc->character() == currentCode && | 578 | if ( sc->character() == currentCode && |
571 | sc->testFlag( QIMPenChar::System ) && | 579 | sc->testFlag( QIMPenChar::System ) && |
572 | !sc->testFlag( QIMPenChar::Deleted ) ) { | 580 | !sc->testFlag( QIMPenChar::Deleted ) ) { |
573 | QIMPenChar *cc = new QIMPenChar( *sc ); | 581 | QIMPenChar *cc = new QIMPenChar( *sc ); |
574 | cc->clearFlag( QIMPenChar::System ); | 582 | cc->clearFlag( QIMPenChar::System ); |
575 | currentSet->addChar( cc ); | 583 | currentSet->addChar( cc ); |
576 | sc->setFlag( QIMPenChar::Deleted ); | 584 | sc->setFlag( QIMPenChar::Deleted ); |
577 | } | 585 | } |
578 | } | 586 | } |
579 | 587 | ||
580 | currentSet->addChar( pc ); | 588 | currentSet->addChar( pc ); |
581 | setCurrentChar( pc ); | 589 | setCurrentChar( pc ); |
582 | inputChar->clear(); | 590 | inputChar->clear(); |
583 | } | 591 | } |
584 | } | 592 | } |
585 | 593 | ||
586 | void QIMPenEdit::addNewChar() | 594 | void QIMPenEdit::addNewChar() |
587 | { | 595 | { |
588 | if ( !inputChar->isEmpty() ) { | 596 | if ( !inputChar->isEmpty() ) { |
589 | QIMPenInputCharDlg dlg( 0, 0, TRUE ); | 597 | QIMPenInputCharDlg dlg( 0, 0, TRUE ); |
590 | if ( dlg.exec() ) { | 598 | if ( dlg.exec() ) { |
591 | currentCode = dlg.unicode(); | 599 | currentCode = dlg.unicode(); |
592 | addChar(); | 600 | addChar(); |
593 | fillCharList(); | 601 | fillCharList(); |
594 | for ( unsigned int i = 0; i < charList->count(); i++ ) { | 602 | for ( unsigned int i = 0; i < charList->count(); i++ ) { |
595 | CharListItem *li = (CharListItem *)charList->item(i); | 603 | CharListItem *li = (CharListItem *)charList->item(i); |
596 | if ( li->code() == dlg.unicode() ) { | 604 | if ( li->code() == dlg.unicode() ) { |
597 | charList->setSelected( i, TRUE ); | 605 | charList->setSelected( i, TRUE ); |
598 | break; | 606 | break; |
599 | } | 607 | } |
600 | } | 608 | } |
601 | } | 609 | } |
602 | } | 610 | } |
603 | } | 611 | } |
604 | 612 | ||
605 | void QIMPenEdit::removeChar() | 613 | void QIMPenEdit::removeChar() |
606 | { | 614 | { |
607 | if ( currentChar ) { | 615 | if ( currentChar ) { |
608 | QIMPenChar *pc = findPrev(); | 616 | QIMPenChar *pc = findPrev(); |
609 | if ( !pc ) pc = findNext(); | 617 | if ( !pc ) pc = findNext(); |
610 | if ( currentChar->testFlag( QIMPenChar::System ) ) | 618 | if ( currentChar->testFlag( QIMPenChar::System ) ) |
611 | currentChar->setFlag( QIMPenChar::Deleted ); | 619 | currentChar->setFlag( QIMPenChar::Deleted ); |
612 | else | 620 | else |
613 | currentSet->removeChar( currentChar ); | 621 | currentSet->removeChar( currentChar ); |
614 | setCurrentChar( pc ); | 622 | setCurrentChar( pc ); |
615 | } | 623 | } |
616 | } | 624 | } |
617 | 625 | ||
618 | void QIMPenEdit::defaultChars() | 626 | void QIMPenEdit::defaultChars() |
619 | { | 627 | { |
620 | if ( currentCode ) { | 628 | if ( currentCode ) { |
621 | currentChar = 0; | 629 | currentChar = 0; |
622 | bool haveSystem = FALSE; | 630 | bool haveSystem = FALSE; |
623 | QIMPenCharIterator it(currentSet->characters() ); | 631 | QIMPenCharIterator it(currentSet->characters() ); |
624 | for ( ; it.current(); ++it ) { | 632 | for ( ; it.current(); ++it ) { |
625 | if ( it.current()->character() == currentCode && | 633 | if ( it.current()->character() == currentCode && |
626 | it.current()->testFlag( QIMPenChar::System ) ) { | 634 | it.current()->testFlag( QIMPenChar::System ) ) { |
627 | haveSystem = TRUE; | 635 | haveSystem = TRUE; |
628 | break; | 636 | break; |
629 | } | 637 | } |
630 | } | 638 | } |
631 | if ( haveSystem ) { | 639 | if ( haveSystem ) { |
632 | it.toFirst(); | 640 | it.toFirst(); |
633 | while ( it.current() ) { | 641 | while ( it.current() ) { |
634 | QIMPenChar *pc = it.current(); | 642 | QIMPenChar *pc = it.current(); |
635 | ++it; | 643 | ++it; |
636 | if ( pc->character() == currentCode ) { | 644 | if ( pc->character() == currentCode ) { |
637 | if ( pc->testFlag( QIMPenChar::System ) ) { | 645 | if ( pc->testFlag( QIMPenChar::System ) ) { |
638 | pc->clearFlag( QIMPenChar::Deleted ); | 646 | pc->clearFlag( QIMPenChar::Deleted ); |
639 | if ( !currentChar ) | 647 | if ( !currentChar ) |
640 | currentChar = pc; | 648 | currentChar = pc; |
641 | } else { | 649 | } else { |
642 | currentSet->removeChar( pc ); | 650 | currentSet->removeChar( pc ); |
643 | } | 651 | } |
644 | } | 652 | } |
645 | } | 653 | } |
646 | setCurrentChar( currentChar ); | 654 | setCurrentChar( currentChar ); |
647 | } | 655 | } |
648 | } | 656 | } |
649 | } | 657 | } |
650 | 658 | ||
651 | void QIMPenEdit::newStroke( QIMPenStroke *st ) | 659 | void QIMPenEdit::newStroke( QIMPenStroke *st ) |
652 | { | 660 | { |
653 | inputChar->addStroke( st ); | 661 | inputChar->addStroke( st ); |
654 | enableButtons(); | 662 | enableButtons(); |
655 | } | 663 | } |
656 | 664 | ||