summaryrefslogtreecommitdiff
path: root/inputmethods
authormickeyl <mickeyl>2004-04-24 15:46:03 (UTC)
committer mickeyl <mickeyl>2004-04-24 15:46:03 (UTC)
commitf7b5905d990f374dd6cb177b7a03628cc593b7cf (patch) (unidiff)
treed4b2dc324fc54131dea3460462850cec786b8a88 /inputmethods
parent186c4d03ea8bf3aee4c535453409f1234442bff3 (diff)
downloadopie-f7b5905d990f374dd6cb177b7a03628cc593b7cf.zip
opie-f7b5905d990f374dd6cb177b7a03628cc593b7cf.tar.gz
opie-f7b5905d990f374dd6cb177b7a03628cc593b7cf.tar.bz2
gcc 3.4 fixes
Diffstat (limited to 'inputmethods') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/pickboard/pickboardcfg.cpp10
-rw-r--r--inputmethods/pickboard/pickboardcfg.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/inputmethods/pickboard/pickboardcfg.cpp b/inputmethods/pickboard/pickboardcfg.cpp
index e8b47cb..d500266 100644
--- a/inputmethods/pickboard/pickboardcfg.cpp
+++ b/inputmethods/pickboard/pickboardcfg.cpp
@@ -33,260 +33,260 @@
33#include <qpopupmenu.h> 33#include <qpopupmenu.h>
34#include <qhbuttongroup.h> 34#include <qhbuttongroup.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38 38
39static const char * pickboard_help = 39static const char * pickboard_help =
40 "<h1>The Pickboard</h1>" 40 "<h1>The Pickboard</h1>"
41 "<i>The smallest and fastest way to type.</i>" 41 "<i>The smallest and fastest way to type.</i>"
42 "<p>" 42 "<p>"
43 "Enter a word by tapping letter-groups and picking the word." 43 "Enter a word by tapping letter-groups and picking the word."
44 "<br>Enter spaces with \"Space\", or other keys through \"KEY\"." 44 "<br>Enter spaces with \"Space\", or other keys through \"KEY\"."
45 "<br>Use \"Shift\" to capitalize words that are not normally capitalized." 45 "<br>Use \"Shift\" to capitalize words that are not normally capitalized."
46 "<br>Press \"Shift\" twice for an all-capitals word." 46 "<br>Press \"Shift\" twice for an all-capitals word."
47 "<br>Add custom words by picking them, then selecting \"Add...\" from the menu on the right." 47 "<br>Add custom words by picking them, then selecting \"Add...\" from the menu on the right."
48 ; 48 ;
49 49
50const int intermatchmargin=5; 50const int intermatchmargin=5;
51 51
52 52
53PickboardConfig::~PickboardConfig() { } 53PickboardConfig::~PickboardConfig() { }
54 54
55void PickboardConfig::updateRows(int from, int to) 55void PickboardConfig::updateRows(int from, int to)
56{ 56{
57 if ( from != to ) { // (all) 57 if ( from != to ) { // (all)
58 parent->update(); 58 parent->update();
59 } else { 59 } else {
60 QFontMetrics fm = parent->fontMetrics(); 60 QFontMetrics fm = parent->fontMetrics();
61 parent->update(QRect(0,1+fm.descent() + from * fm.lineSpacing(), parent->width(), 61 parent->update(QRect(0,1+fm.descent() + from * fm.lineSpacing(), parent->width(),
62 fm.lineSpacing())); 62 fm.lineSpacing()));
63 } 63 }
64} 64}
65 65
66void PickboardConfig::updateItem(int r, int) 66void PickboardConfig::updateItem(int r, int)
67{ 67{
68 updateRows(r,r); 68 updateRows(r,r);
69} 69}
70 70
71void PickboardConfig::changeMode(int m) 71void PickboardConfig::changeMode(int m)
72{ 72{
73 parent->setMode(m); 73 parent->setMode(m);
74} 74}
75void PickboardConfig::generateText(const QString& s) 75void PickboardConfig::generateText(const QString& s)
76{ 76{
77#if defined(Q_WS_QWS) || defined(_WS_QWS_) 77#if defined(Q_WS_QWS) || defined(_WS_QWS_)
78 for (int i=0; i<(int)s.length(); i++) { 78 for (int i=0; i<(int)s.length(); i++) {
79 parent->emitKey(s[i].unicode(), 0, 0, true, false); 79 parent->emitKey(s[i].unicode(), 0, 0, true, false);
80 parent->emitKey(s[i].unicode(), 0, 0, false, false); 80 parent->emitKey(s[i].unicode(), 0, 0, false, false);
81 } 81 }
82#endif 82#endif
83} 83}
84void PickboardConfig::generateKey( int k ) 84void PickboardConfig::generateKey( int k )
85{ 85{
86#if defined(Q_WS_QWS) || defined(_WS_QWS_) 86#if defined(Q_WS_QWS) || defined(_WS_QWS_)
87 parent->emitKey(0, k, 0, true, false); 87 parent->emitKey(0, k, 0, true, false);
88 parent->emitKey(0, k, 0, false, false); 88 parent->emitKey(0, k, 0, false, false);
89#endif 89#endif
90} 90}
91 91
92void PickboardConfig::pickPoint(const QPoint& p, bool press) 92void PickboardConfig::pickPoint(const QPoint& p, bool press)
93{ 93{
94 if ( press ) { 94 if ( press ) {
95 int ls=parent->height()/nrows; 95 int ls=parent->height()/nrows;
96 int y=0; 96 int y=0;
97 pressx = -1; 97 pressx = -1;
98 for (int r=0; r<nrows; r++) { 98 for (int r=0; r<nrows; r++) {
99 if ( p.y() >= y && p.y() < y+ls ) { 99 if ( p.y() >= y && p.y() < y+ls ) {
100 pressrow = r; 100 pressrow = r;
101 pressx = p.x(); 101 pressx = p.x();
102 pickInRow( pressrow, pressx, TRUE ); 102 pickInRow( pressrow, pressx, TRUE );
103 return; 103 return;
104 } 104 }
105 y += ls; 105 y += ls;
106 } 106 }
107 } else if ( pressx >= 0 ) { 107 } else if ( pressx >= 0 ) {
108 pickInRow( pressrow, pressx, FALSE ); 108 pickInRow( pressrow, pressx, FALSE );
109 pressx = -1; 109 pressx = -1;
110 } 110 }
111} 111}
112 112
113void PickboardConfig::fillMenu(QPopupMenu& menu) 113void PickboardConfig::fillMenu(QPopupMenu& menu)
114{ 114{
115 menu.insertItem("Reset",100); 115 menu.insertItem("Reset",100);
116 menu.insertSeparator(); 116 menu.insertSeparator();
117 menu.insertItem("Help",1); 117 menu.insertItem("Help",1);
118} 118}
119 119
120void PickboardConfig::doMenu(int i) 120void PickboardConfig::doMenu(int i)
121{ 121{
122 switch (i) { 122 switch (i) {
123 case 100: 123 case 100:
124 if ( parent->currentMode() ) { 124 if ( parent->currentMode() ) {
125 changeMode(0); 125 changeMode(0);
126 updateRows(0,1); 126 updateRows(0,1);
127 } 127 }
128 break; 128 break;
129 case 1: { 129 case 1: {
130 QMessageBox help("Pickboard Help", pickboard_help, 130 QMessageBox help("Pickboard Help", pickboard_help,
131 QMessageBox::NoIcon, 1, 0, 0); 131 QMessageBox::NoIcon, 1, 0, 0);
132 help.showMaximized(); 132 help.showMaximized();
133 help.exec(); 133 help.exec();
134 } 134 }
135 } 135 }
136} 136}
137 137
138void StringConfig::draw(QPainter* p) 138void StringConfig::draw(QPainter* p)
139{ 139{
140 QFontMetrics fm = p->fontMetrics(); 140 QFontMetrics fm = p->fontMetrics();
141 141
142 for (int r=0; r<nrows; r++) { 142 for (int r=0; r<nrows; r++) {
143 p->translate(0,fm.lineSpacing()); 143 p->translate(0,fm.lineSpacing());
144 p->setPen(rowColor(r)); 144 p->setPen(rowColor(r));
145 145
146 int tw=0; 146 int tw=0;
147 QString s; 147 QString s;
148 int i=0; 148 int i=0;
149 for (; !(s=text(r,i)).isNull(); ++i) { 149 for (; !(s=text(r,i)).isNull(); ++i) {
150 int w = fm.width(s); 150 int w = fm.width(s);
151 tw += w; 151 tw += w;
152 } 152 }
153 bool spread = spreadRow(r);// && parent->width() > tw; 153 bool spread = spreadRow(r);// && parent->width() > tw;
154 int xw = spread ? (parent->width()-tw)/(i-1) : 3; 154 int xw = spread ? (parent->width()-tw)/(i-1) : 3;
155 int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2; 155 int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2;
156 156
157 i=0; 157 i=0;
158 for (; !(s=text(r,i)).isNull(); ++i) { 158 for (; !(s=text(r,i)).isNull(); ++i) {
159 int w = fm.width(s)+xw; 159 int w = fm.width(s)+xw;
160 if ( highlight(r,i) ) { 160 if ( highlight(r,i) ) {
161 p->fillRect(x-xw/2,1+fm.descent()-fm.lineSpacing(),w,fm.lineSpacing(),Qt::black); 161 p->fillRect(x-xw/2,1+fm.descent()-fm.lineSpacing(),w,fm.lineSpacing(),::Qt::black);
162 p->setPen(Qt::white); 162 p->setPen(::Qt::white);
163 }else{ 163 }else{
164 p->setPen(Qt::black); 164 p->setPen(::Qt::black);
165 } 165 }
166 p->drawText(x,-fm.descent()-1,s); 166 p->drawText(x,-fm.descent()-1,s);
167 x += w; 167 x += w;
168 } 168 }
169 } 169 }
170} 170}
171 171
172void StringConfig::pickInRow(int r, int xpos, bool press) 172void StringConfig::pickInRow(int r, int xpos, bool press)
173{ 173{
174 QFontMetrics fm = parent->fontMetrics(); 174 QFontMetrics fm = parent->fontMetrics();
175 175
176 int tw=0; 176 int tw=0;
177 QString s; 177 QString s;
178 int i=0; 178 int i=0;
179 for (; !(s=text(r,i)).isNull(); ++i) { 179 for (; !(s=text(r,i)).isNull(); ++i) {
180 int w = fm.width(s); 180 int w = fm.width(s);
181 tw += w; 181 tw += w;
182 } 182 }
183 bool spread = spreadRow(r) && parent->width() > tw; 183 bool spread = spreadRow(r) && parent->width() > tw;
184 int xw = spread ? (parent->width()-tw)/(i-1) : 3; 184 int xw = spread ? (parent->width()-tw)/(i-1) : 3;
185 int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2; 185 int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2;
186 186
187 i=0; 187 i=0;
188 for (; !(s=text(r,i)).isNull(); ++i) { 188 for (; !(s=text(r,i)).isNull(); ++i) {
189 int x2 = x + fm.width(s)+xw; 189 int x2 = x + fm.width(s)+xw;
190 if ( xpos >= x && xpos < x2 ) { 190 if ( xpos >= x && xpos < x2 ) {
191 pick(press, r, i); 191 pick(press, r, i);
192 return; 192 return;
193 } 193 }
194 x = x2; 194 x = x2;
195 } 195 }
196} 196}
197 197
198void StringConfig::updateItem(int r, int item) 198void StringConfig::updateItem(int r, int item)
199{ 199{
200 QFontMetrics fm = parent->fontMetrics(); 200 QFontMetrics fm = parent->fontMetrics();
201 201
202 int y = r * fm.lineSpacing(); 202 int y = r * fm.lineSpacing();
203 203
204 int tw=0; 204 int tw=0;
205 QString s; 205 QString s;
206 int i=0; 206 int i=0;
207 for (; !(s=text(r,i)).isNull(); ++i) { 207 for (; !(s=text(r,i)).isNull(); ++i) {
208 int w = fm.width(s); 208 int w = fm.width(s);
209 tw += w; 209 tw += w;
210 } 210 }
211 bool spread = spreadRow(r) && parent->width() > tw; 211 bool spread = spreadRow(r) && parent->width() > tw;
212 int xw = spread ? (parent->width()-tw)/(i-1) : 3; 212 int xw = spread ? (parent->width()-tw)/(i-1) : 3;
213 int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2; 213 int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2;
214 214
215 i=0; 215 i=0;
216 for (; !(s=text(r,i)).isNull(); ++i) { 216 for (; !(s=text(r,i)).isNull(); ++i) {
217 int w = fm.width(s)+xw; 217 int w = fm.width(s)+xw;
218 if ( i == item ) { 218 if ( i == item ) {
219 parent->update(QRect(x-xw/2,y+1+fm.descent(),w,fm.lineSpacing())); 219 parent->update(QRect(x-xw/2,y+1+fm.descent(),w,fm.lineSpacing()));
220 return; 220 return;
221 } 221 }
222 x += w; 222 x += w;
223 } 223 }
224} 224}
225 225
226bool StringConfig::highlight(int,int) const 226bool StringConfig::highlight(int,int) const
227{ 227{
228 return FALSE; 228 return FALSE;
229} 229}
230 230
231LetterButton::LetterButton(const QChar& letter, QWidget* parent) : 231LetterButton::LetterButton(const QChar& letter, QWidget* parent) :
232 QPushButton(letter,parent) 232 QPushButton(letter,parent)
233{ 233{
234 setToggleButton(TRUE); 234 setToggleButton(TRUE);
235 setAutoDefault(FALSE); 235 setAutoDefault(FALSE);
236 connect(this,SIGNAL(clicked()),this,SLOT(toggleCase())); 236 connect(this,SIGNAL(clicked()),this,SLOT(toggleCase()));
237 skip=TRUE; 237 skip=TRUE;
238} 238}
239 239
240void LetterButton::toggleCase() 240void LetterButton::toggleCase()
241{ 241{
242 if ( skip ) { 242 if ( skip ) {
243 // Don't toggle case the first time 243 // Don't toggle case the first time
244 skip=FALSE; 244 skip=FALSE;
245 return; 245 return;
246 } 246 }
247 247
248 QChar ch = text()[0]; 248 QChar ch = text()[0];
249 QChar nch = ch.lower(); 249 QChar nch = ch.lower();
250 if ( ch == nch ) 250 if ( ch == nch )
251 nch = ch.upper(); 251 nch = ch.upper();
252 setText(nch); 252 setText(nch);
253} 253}
254 254
255LetterChoice::LetterChoice(QWidget* parent, const QString& set) : 255LetterChoice::LetterChoice(QWidget* parent, const QString& set) :
256 QButtonGroup(parent) 256 QButtonGroup(parent)
257{ 257{
258 QHBoxLayout *l = new QHBoxLayout(this); 258 QHBoxLayout *l = new QHBoxLayout(this);
259 setFrameStyle(0); 259 setFrameStyle(0);
260 setExclusive(TRUE); 260 setExclusive(TRUE);
261 for (int i=0; i<(int)set.length(); i++) { 261 for (int i=0; i<(int)set.length(); i++) {
262 LetterButton* b = new LetterButton(set[i],this); 262 LetterButton* b = new LetterButton(set[i],this);
263 l->addWidget(b,1,AlignCenter); 263 l->addWidget(b,1,AlignCenter);
264 connect(b,SIGNAL(clicked()),this,SLOT(change())); 264 connect(b,SIGNAL(clicked()),this,SLOT(change()));
265 } 265 }
266} 266}
267 267
268void LetterChoice::change() 268void LetterChoice::change()
269{ 269{
270 LetterButton* b = (LetterButton*)sender(); 270 LetterButton* b = (LetterButton*)sender();
271 ch = b->text()[0]; 271 ch = b->text()[0];
272 emit changed(); 272 emit changed();
273} 273}
274 274
275 275
276PickboardAdd::PickboardAdd(QWidget* owner, const QStringList& setlist) : 276PickboardAdd::PickboardAdd(QWidget* owner, const QStringList& setlist) :
277 QDialog( owner, 0, TRUE ) 277 QDialog( owner, 0, TRUE )
278{ 278{
279 QVBoxLayout* l = new QVBoxLayout(this); 279 QVBoxLayout* l = new QVBoxLayout(this);
280 l->setAutoAdd(TRUE); 280 l->setAutoAdd(TRUE);
281 281
282 QScrollView *sv = new QScrollView(this); 282 QScrollView *sv = new QScrollView(this);
283 sv->setResizePolicy(QScrollView::AutoOneFit); 283 sv->setResizePolicy(QScrollView::AutoOneFit);
284 setMaximumHeight(200); // ### QDialog shouldn't allow us to be bigger than the screen 284 setMaximumHeight(200); // ### QDialog shouldn't allow us to be bigger than the screen
285 QVBox *letters = new QVBox(sv); 285 QVBox *letters = new QVBox(sv);
286 letters->setSpacing(0); 286 letters->setSpacing(0);
287 lc = new LetterChoice*[setlist.count()]; 287 lc = new LetterChoice*[setlist.count()];
288 nlc = (int)setlist.count(); 288 nlc = (int)setlist.count();
289 for (int i=0; i<nlc; i++) { 289 for (int i=0; i<nlc; i++) {
290 lc[i] = new LetterChoice(letters,setlist[i]); 290 lc[i] = new LetterChoice(letters,setlist[i]);
291 connect(lc[i],SIGNAL(changed()),this,SLOT(checkAllDone())); 291 connect(lc[i],SIGNAL(changed()),this,SLOT(checkAllDone()));
292 } 292 }
@@ -306,260 +306,260 @@ PickboardAdd::~PickboardAdd()
306} 306}
307 307
308QString PickboardAdd::word() const 308QString PickboardAdd::word() const
309{ 309{
310 QString str; 310 QString str;
311 for (int i=0; i<nlc; i++) { 311 for (int i=0; i<nlc; i++) {
312 str += lc[i]->choice(); 312 str += lc[i]->choice();
313 } 313 }
314 return str; 314 return str;
315} 315}
316 316
317bool PickboardAdd::exec() 317bool PickboardAdd::exec()
318{ 318{
319 QPoint pos = parentWidget()->mapToGlobal(QPoint(0,0)); 319 QPoint pos = parentWidget()->mapToGlobal(QPoint(0,0));
320 pos.ry() -= height(); 320 pos.ry() -= height();
321 if ( QDialog::exec() ) { 321 if ( QDialog::exec() ) {
322 Global::addWords(QStringList(word())); 322 Global::addWords(QStringList(word()));
323 return TRUE; 323 return TRUE;
324 } else { 324 } else {
325 return FALSE; 325 return FALSE;
326 } 326 }
327} 327}
328 328
329void PickboardAdd::checkAllDone() 329void PickboardAdd::checkAllDone()
330{ 330{
331 if ( !yes->isEnabled() ) { 331 if ( !yes->isEnabled() ) {
332 for (int i=0; i<nlc; i++) { 332 for (int i=0; i<nlc; i++) {
333 if ( lc[i]->choice().isNull() ) 333 if ( lc[i]->choice().isNull() )
334 return; 334 return;
335 } 335 }
336 yes->setEnabled(TRUE); 336 yes->setEnabled(TRUE);
337 } 337 }
338} 338}
339 339
340 340
341void DictFilterConfig::doMenu(int i) 341void DictFilterConfig::doMenu(int i)
342{ 342{
343 switch (i) { 343 switch (i) {
344 case 300: 344 case 300:
345 if ( input.count() == 0 ) { 345 if ( input.count() == 0 ) {
346 QMessageBox::information(0, "Adding Words", 346 QMessageBox::information(0, "Adding Words",
347 "To add words, pick the letters,\nthen " 347 "To add words, pick the letters,\nthen "
348 "open the Add dialog. In that\ndialog, tap " 348 "open the Add dialog. In that\ndialog, tap "
349 "the correct letters\nfrom the list " 349 "the correct letters\nfrom the list "
350 "(tap twice for\ncapitals)."); 350 "(tap twice for\ncapitals).");
351 } else { 351 } else {
352 PickboardAdd add(parent,capitalize(input)); 352 PickboardAdd add(parent,capitalize(input));
353 if ( add.exec() ) 353 if ( add.exec() )
354 generateText(add.word()); 354 generateText(add.word());
355 input.clear(); 355 input.clear();
356 matches.clear(); 356 matches.clear();
357 updateRows(0,0); 357 updateRows(0,0);
358 } 358 }
359 break; 359 break;
360 case 100: 360 case 100:
361 if ( !input.isEmpty() ) { 361 if ( !input.isEmpty() ) {
362 input.clear(); 362 input.clear();
363 matches.clear(); 363 matches.clear();
364 StringConfig::doMenu(i); 364 StringConfig::doMenu(i);
365 updateRows(0,1); 365 updateRows(0,1);
366 break; 366 break;
367 } // else fall through 367 } // else fall through
368 default: 368 default:
369 StringConfig::doMenu(i); 369 StringConfig::doMenu(i);
370 } 370 }
371 shift = 0; 371 shift = 0;
372 lit0 = -1; 372 lit0 = -1;
373} 373}
374 374
375QString DictFilterConfig::text(int r, int i) 375QString DictFilterConfig::text(int r, int i)
376{ 376{
377 QStringList l = r ? sets : input.isEmpty() ? othermodes : matches; 377 QStringList l = r ? sets : input.isEmpty() ? othermodes : matches;
378 return i < (int)l.count() ? 378 return i < (int)l.count() ?
379 (input.isEmpty() ? l[i] : capitalize(l[i])) 379 (input.isEmpty() ? l[i] : capitalize(l[i]))
380 : QString::null; 380 : QString::null;
381} 381}
382 382
383bool DictFilterConfig::spreadRow(int r) 383bool DictFilterConfig::spreadRow(int r)
384{ 384{
385 return r ? TRUE : input.isEmpty() ? TRUE : FALSE; 385 return r ? TRUE : input.isEmpty() ? TRUE : FALSE;
386} 386}
387 387
388QStringList DictFilterConfig::capitalize(const QStringList& l) 388QStringList DictFilterConfig::capitalize(const QStringList& l)
389{ 389{
390 switch ( shift ) { 390 switch ( shift ) {
391 case 1: { 391 case 1: {
392 QStringList r; 392 QStringList r;
393 QStringList::ConstIterator it = l.begin(); 393 QStringList::ConstIterator it = l.begin();
394 r.append((*it).upper()); 394 r.append((*it).upper());
395 for (++it; it != l.end(); ++it) 395 for (++it; it != l.end(); ++it)
396 r.append(*it); 396 r.append(*it);
397 return r; 397 return r;
398 } case 2: { 398 } case 2: {
399 QStringList r; 399 QStringList r;
400 for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) 400 for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it)
401 r.append((*it).upper()); 401 r.append((*it).upper());
402 return r; 402 return r;
403 } 403 }
404 } 404 }
405 return l; 405 return l;
406} 406}
407 407
408QString DictFilterConfig::capitalize(const QString& s) 408QString DictFilterConfig::capitalize(const QString& s)
409{ 409{
410 switch ( shift ) { 410 switch ( shift ) {
411 case 1: { 411 case 1: {
412 QString u = s; 412 QString u = s;
413 u[0] = u[0].upper(); 413 u[0] = u[0].upper();
414 return u; 414 return u;
415 break; 415 break;
416 } case 2: 416 } case 2:
417 return s.upper(); 417 return s.upper();
418 break; 418 break;
419 } 419 }
420 return s; 420 return s;
421} 421}
422 422
423void DictFilterConfig::pick(bool press, int row, int item) 423void DictFilterConfig::pick(bool press, int row, int item)
424{ 424{
425 if ( row == 0 ) { 425 if ( row == 0 ) {
426 if ( press ) { 426 if ( press ) {
427 if ( input.isEmpty() ) { 427 if ( input.isEmpty() ) {
428 lit0 = item; 428 lit0 = item;
429 if ( othermodes[item] == "Space" ) { 429 if ( othermodes[item] == "Space" ) {
430 updateItem(row,item); 430 updateItem(row,item);
431 generateText(" "); 431 generateText(" ");
432 } else if ( othermodes[item] == "Back" ) { 432 } else if ( othermodes[item] == "Back" ) {
433 updateItem(row,item); 433 updateItem(row,item);
434 generateKey(Qt::Key_Backspace); 434 generateKey(::Qt::Key_Backspace);
435 } else if ( othermodes[item] == "Enter" ) { 435 } else if ( othermodes[item] == "Enter" ) {
436 updateItem(row,item); 436 updateItem(row,item);
437 generateKey(Qt::Key_Return); 437 generateKey(::Qt::Key_Return);
438 } else if ( othermodes[item] == "Shift" ) { 438 } else if ( othermodes[item] == "Shift" ) {
439 updateItem(row,item); 439 updateItem(row,item);
440 shift = (shift+1)%3; 440 shift = (shift+1)%3;
441 } 441 }
442 } 442 }
443 } else { 443 } else {
444 if ( !input.isEmpty() ) { 444 if ( !input.isEmpty() ) {
445 input.clear(); 445 input.clear();
446 if ( item>=0 ) { 446 if ( item>=0 ) {
447 generateText(capitalize(matches[item])); 447 generateText(capitalize(matches[item]));
448 } 448 }
449 shift = 0; 449 shift = 0;
450 matches.clear(); 450 matches.clear();
451 updateRows(0,0); 451 updateRows(0,0);
452 } else if ( item < 3 ) { 452 } else if ( item < 3 ) {
453 lit0 = -1; 453 lit0 = -1;
454 changeMode(item+1); // I'm mode 0! #### 454 changeMode(item+1); // I'm mode 0! ####
455 updateRows(0,1); 455 updateRows(0,1);
456 } 456 }
457 if ( lit0 >= 0 ) { 457 if ( lit0 >= 0 ) {
458 if ( !shift || othermodes[lit0] != "Shift" ) { 458 if ( !shift || othermodes[lit0] != "Shift" ) {
459 updateItem(0,lit0); 459 updateItem(0,lit0);
460 lit0 = -1; 460 lit0 = -1;
461 } 461 }
462 } 462 }
463 } 463 }
464 } else { 464 } else {
465 lit0 = -1; 465 lit0 = -1;
466 if ( press && item >= 0 ) { 466 if ( press && item >= 0 ) {
467 lit1 = item; 467 lit1 = item;
468 add(sets[item]); 468 add(sets[item]);
469 updateItem(1,item); 469 updateItem(1,item);
470 updateRows(0,0); 470 updateRows(0,0);
471 } else { 471 } else {
472 updateItem(1,lit1); 472 updateItem(1,lit1);
473 lit1 = -1; 473 lit1 = -1;
474 } 474 }
475 } 475 }
476} 476}
477 477
478bool DictFilterConfig::scanMatch(const QString& set, const QChar& l) const 478bool DictFilterConfig::scanMatch(const QString& set, const QChar& l) const
479{ 479{
480 return set == "?" || set == "*" || set.contains(l); 480 return set == "?" || set == "*" || set.contains(l);
481} 481}
482 482
483//static int visit=0; 483//static int visit=0;
484//static int lvisit=0; 484//static int lvisit=0;
485 485
486void DictFilterConfig::scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend) 486void DictFilterConfig::scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend)
487{ 487{
488 if ( n ) { 488 if ( n ) {
489 do { 489 do {
490//visit++; 490//visit++;
491 bool pastend = ipos >= (int)input.count(); 491 bool pastend = ipos >= (int)input.count();
492 if ( pastend && extend || !pastend && scanMatch(input[ipos],n->letter().lower()) ) { 492 if ( pastend && extend || !pastend && scanMatch(input[ipos],n->letter().lower()) ) {
493 if ( length>1 ) { 493 if ( length>1 ) {
494 if ( !pastend && input[ipos] == "*" ) { 494 if ( !pastend && input[ipos] == "*" ) {
495 scan(n->jump(),ipos+1,str+n->letter(),length-1,FALSE); 495 scan(n->jump(),ipos+1,str+n->letter(),length-1,FALSE);
496 scan(n->jump(),ipos,str+n->letter(),length,FALSE); 496 scan(n->jump(),ipos,str+n->letter(),length,FALSE);
497 } else { 497 } else {
498 scan(n->jump(),ipos+1,str+n->letter(),length-1,extend); 498 scan(n->jump(),ipos+1,str+n->letter(),length-1,extend);
499 } 499 }
500 } else { 500 } else {
501 if ( n->isWord() ) { 501 if ( n->isWord() ) {
502 matches.append(str+n->letter()); 502 matches.append(str+n->letter());
503 } 503 }
504 } 504 }
505 } 505 }
506 n = n->next(); 506 n = n->next();
507 } while (n); 507 } while (n);
508 } 508 }
509} 509}
510 510
511void DictFilterConfig::scanLengths(const QDawg::Node* n, int ipos, int& length_bitarray) 511void DictFilterConfig::scanLengths(const QDawg::Node* n, int ipos, int& length_bitarray)
512{ 512{
513 if ( n ) { 513 if ( n ) {
514 do { 514 do {
515//lvisit++; 515//lvisit++;
516 bool pastend = ipos >= (int)input.count(); 516 bool pastend = ipos >= (int)input.count();
517 if ( pastend || scanMatch(input[ipos],n->letter().lower()) ) { 517 if ( pastend || scanMatch(input[ipos],n->letter().lower()) ) {
518 scanLengths(n->jump(),ipos+1,length_bitarray); 518 scanLengths(n->jump(),ipos+1,length_bitarray);
519 if ( n->isWord() ) 519 if ( n->isWord() )
520 length_bitarray |= (1<<(ipos+1)); 520 length_bitarray |= (1<<(ipos+1));
521 } 521 }
522 n = n->next(); 522 n = n->next();
523 } while (n); 523 } while (n);
524 } 524 }
525} 525}
526 526
527void DictFilterConfig::add(const QString& set) 527void DictFilterConfig::add(const QString& set)
528{ 528{
529 QFontMetrics fm = parent->fontMetrics(); 529 QFontMetrics fm = parent->fontMetrics();
530 input.append(set.lower()); 530 input.append(set.lower());
531 matches.clear(); 531 matches.clear();
532//visit=0; 532//visit=0;
533//lvisit=0; 533//lvisit=0;
534 int length_bitarray = 0; 534 int length_bitarray = 0;
535 if ( input.count() > 4 ) { 535 if ( input.count() > 4 ) {
536 scanLengths(Global::addedDawg().root(),0,length_bitarray); 536 scanLengths(Global::addedDawg().root(),0,length_bitarray);
537 scanLengths(Global::fixedDawg().root(),0,length_bitarray); 537 scanLengths(Global::fixedDawg().root(),0,length_bitarray);
538 } else { 538 } else {
539 length_bitarray = 0xffffffff; 539 length_bitarray = 0xffffffff;
540 } 540 }
541 for (int len=input.count(); len<22 /* 32 */; ++len) { 541 for (int len=input.count(); len<22 /* 32 */; ++len) {
542 if ( length_bitarray & (1<<len) ) { 542 if ( length_bitarray & (1<<len) ) {
543 scan(Global::addedDawg().root(),0,"",len,TRUE); 543 scan(Global::addedDawg().root(),0,"",len,TRUE);
544 scan(Global::fixedDawg().root(),0,"",len,TRUE); 544 scan(Global::fixedDawg().root(),0,"",len,TRUE);
545 int x = 2; 545 int x = 2;
546 for (QStringList::Iterator it=matches.begin(); it!=matches.end(); ++it) { 546 for (QStringList::Iterator it=matches.begin(); it!=matches.end(); ++it) {
547 x += fm.width(*it)+intermatchmargin; 547 x += fm.width(*it)+intermatchmargin;
548 if ( x >= parent->width() ) { 548 if ( x >= parent->width() ) {
549//qDebug("%d+%d visits",lvisit,visit); 549//qDebug("%d+%d visits",lvisit,visit);
550 return; // RETURN - No point finding more 550 return; // RETURN - No point finding more
551 } 551 }
552 } 552 }
553 } 553 }
554 if ( len == 1 && input.count() == 1 ) { 554 if ( len == 1 && input.count() == 1 ) {
555 // Allow all single-characters to show as "matches" 555 // Allow all single-characters to show as "matches"
556 for ( int i=0; i<(int)set.length(); i++ ) { 556 for ( int i=0; i<(int)set.length(); i++ ) {
557 QChar ch = set[i].lower(); 557 QChar ch = set[i].lower();
558 matches.append(ch); 558 matches.append(ch);
559 } 559 }
560 } 560 }
561 } 561 }
562//qDebug("%d+%d visits",lvisit,visit); 562//qDebug("%d+%d visits",lvisit,visit);
563} 563}
564 564
565bool DictFilterConfig::highlight(int r,int c) const 565bool DictFilterConfig::highlight(int r,int c) const
diff --git a/inputmethods/pickboard/pickboardcfg.h b/inputmethods/pickboard/pickboardcfg.h
index e0dc0dd..b1913df 100644
--- a/inputmethods/pickboard/pickboardcfg.h
+++ b/inputmethods/pickboard/pickboardcfg.h
@@ -1,213 +1,213 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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#ifndef PICKBOARDCFG_H 20#ifndef PICKBOARDCFG_H
21#define PICKBOARDCFG_H 21#define PICKBOARDCFG_H
22 22
23#include <qpe/qdawg.h> 23#include <qpe/qdawg.h>
24 24
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qhbuttongroup.h> 26#include <qhbuttongroup.h>
27#include <qdialog.h> 27#include <qdialog.h>
28#include <qlist.h> 28#include <qlist.h>
29 29
30// Internal stuff... 30// Internal stuff...
31 31
32class PickboardPicks; 32class PickboardPicks;
33 33
34class LetterButton : public QPushButton { 34class LetterButton : public QPushButton {
35 Q_OBJECT 35 Q_OBJECT
36public: 36public:
37 LetterButton(const QChar& letter, QWidget* parent); 37 LetterButton(const QChar& letter, QWidget* parent);
38private slots: 38private slots:
39 void toggleCase(); 39 void toggleCase();
40private: 40private:
41 bool skip; 41 bool skip;
42}; 42};
43 43
44class LetterChoice : public QButtonGroup { 44class LetterChoice : public QButtonGroup {
45 Q_OBJECT 45 Q_OBJECT
46public: 46public:
47 LetterChoice(QWidget* parent, const QString& set); 47 LetterChoice(QWidget* parent, const QString& set);
48 48
49 QChar choice() { return ch; } 49 QChar choice() { return ch; }
50 50
51signals: 51signals:
52 void changed(); 52 void changed();
53 53
54private slots: 54private slots:
55 void change(); 55 void change();
56 56
57private: 57private:
58 QChar ch; 58 QChar ch;
59}; 59};
60 60
61class PickboardAdd : public QDialog { 61class PickboardAdd : public QDialog {
62 Q_OBJECT 62 Q_OBJECT
63public: 63public:
64 PickboardAdd(QWidget* owner, const QStringList& setlist); 64 PickboardAdd(QWidget* owner, const QStringList& setlist);
65 ~PickboardAdd(); 65 ~PickboardAdd();
66 66
67 QString word() const; 67 QString word() const;
68 bool exec(); 68 bool exec();
69 69
70private slots: 70private slots:
71 void checkAllDone(); 71 void checkAllDone();
72 72
73private: 73private:
74 QPushButton *yes; 74 QPushButton *yes;
75 LetterChoice **lc; 75 LetterChoice **lc;
76 int nlc; 76 int nlc;
77}; 77};
78 78
79class PickboardConfig : QObject { 79class PickboardConfig : QObject {
80public: 80public:
81 PickboardConfig(PickboardPicks* p) : parent(p), nrows(2), pressx(-1) { } 81 PickboardConfig(PickboardPicks* p) : parent(p), nrows(2), pressx(-1) { }
82 virtual ~PickboardConfig(); 82 virtual ~PickboardConfig();
83 virtual void pickPoint(const QPoint& p, bool press); 83 virtual void pickPoint(const QPoint& p, bool press);
84 virtual void draw(QPainter*)=0; 84 virtual void draw(QPainter*)=0;
85 virtual void fillMenu(QPopupMenu&); 85 virtual void fillMenu(QPopupMenu&);
86 virtual void doMenu(int); 86 virtual void doMenu(int);
87 87
88protected: 88protected:
89 void updateRows(int from, int to); 89 void updateRows(int from, int to);
90 virtual void updateItem(int r, int i); 90 virtual void updateItem(int r, int i);
91 virtual void pickInRow(int r, int xpos, bool press)=0; 91 virtual void pickInRow(int r, int xpos, bool press)=0;
92 92
93 void changeMode(int m); 93 void changeMode(int m);
94 virtual void generateText(const QString& s); 94 virtual void generateText(const QString& s);
95 void generateKey( int k ); 95 void generateKey( int k );
96 96
97 virtual void pick(bool press, int row, int item)=0; 97 virtual void pick(bool press, int row, int item)=0;
98 98
99protected: 99protected:
100 PickboardPicks* parent; 100 PickboardPicks* parent;
101 int nrows; 101 int nrows;
102private: 102private:
103 int pressrow, pressx; 103 int pressrow, pressx;
104}; 104};
105 105
106class StringConfig : public PickboardConfig { 106class StringConfig : public PickboardConfig {
107public: 107public:
108 StringConfig(PickboardPicks* p) : PickboardConfig(p) { } 108 StringConfig(PickboardPicks* p) : PickboardConfig(p) { }
109 109
110 void draw(QPainter* p); 110 void draw(QPainter* p);
111 111
112protected: 112protected:
113 virtual QString text(int r, int i)=0; 113 virtual QString text(int r, int i)=0;
114 virtual bool spreadRow(int i)=0; 114 virtual bool spreadRow(int i)=0;
115 virtual QColor rowColor(int) { return Qt::black; } 115 virtual QColor rowColor(int) { return ::Qt::black; }
116 virtual void pickInRow(int r, int xpos, bool press); 116 virtual void pickInRow(int r, int xpos, bool press);
117 virtual void updateItem(int r, int i); 117 virtual void updateItem(int r, int i);
118 virtual bool highlight(int,int) const; 118 virtual bool highlight(int,int) const;
119}; 119};
120 120
121class CharStringConfig : public StringConfig { 121class CharStringConfig : public StringConfig {
122 QString input; 122 QString input;
123 QStringList chars; 123 QStringList chars;
124public: 124public:
125 CharStringConfig(PickboardPicks* p) : StringConfig(p) { } 125 CharStringConfig(PickboardPicks* p) : StringConfig(p) { }
126 126
127 void addChar(const QString& s); 127 void addChar(const QString& s);
128 virtual void doMenu(int); 128 virtual void doMenu(int);
129 129
130protected: 130protected:
131 QString text(int r, int i); 131 QString text(int r, int i);
132 bool spreadRow(int i); 132 bool spreadRow(int i);
133 void pick(bool press, int row, int item); 133 void pick(bool press, int row, int item);
134}; 134};
135 135
136class DictFilterConfig : public StringConfig { 136class DictFilterConfig : public StringConfig {
137 QStringList matches; 137 QStringList matches;
138 QStringList sets; 138 QStringList sets;
139 QStringList othermodes; 139 QStringList othermodes;
140 int lit0; 140 int lit0;
141 int lit1; 141 int lit1;
142 int shift; 142 int shift;
143 QString capitalize(const QString& s); 143 QString capitalize(const QString& s);
144 QStringList capitalize(const QStringList& s); 144 QStringList capitalize(const QStringList& s);
145 145
146public: 146public:
147 QStringList input; 147 QStringList input;
148 DictFilterConfig(PickboardPicks* p) : StringConfig(p) 148 DictFilterConfig(PickboardPicks* p) : StringConfig(p)
149 { 149 {
150 shift = 0; 150 shift = 0;
151 lit0 = -1; 151 lit0 = -1;
152 lit1 = -1; 152 lit1 = -1;
153 } 153 }
154 154
155 void addSet(const QString& s); 155 void addSet(const QString& s);
156 void addMode(const QString& s); 156 void addMode(const QString& s);
157 157
158 void fillMenu(QPopupMenu& menu); 158 void fillMenu(QPopupMenu& menu);
159 void doMenu(int i); 159 void doMenu(int i);
160 160
161 void add(const QString& set); 161 void add(const QString& set);
162 162
163protected: 163protected:
164 QString text(int r, int i); 164 QString text(int r, int i);
165 165
166 bool spreadRow(int i); 166 bool spreadRow(int i);
167 167
168 void pick(bool press, int row, int item); 168 void pick(bool press, int row, int item);
169 169
170 bool scanMatch(const QString& set, const QChar& l) const; 170 bool scanMatch(const QString& set, const QChar& l) const;
171 void scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend); 171 void scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend);
172 void scanLengths(const QDawg::Node* n, int ipos, int& bitarray); 172 void scanLengths(const QDawg::Node* n, int ipos, int& bitarray);
173 173
174 bool highlight(int r,int c) const; 174 bool highlight(int r,int c) const;
175}; 175};
176 176
177class CharConfig : public StringConfig { 177class CharConfig : public StringConfig {
178 QStringList chars1; 178 QStringList chars1;
179 QStringList chars2; 179 QStringList chars2;
180public: 180public:
181 CharConfig(PickboardPicks* p) : StringConfig(p) { } 181 CharConfig(PickboardPicks* p) : StringConfig(p) { }
182 void addChar(int r, const QString& s); 182 void addChar(int r, const QString& s);
183 183
184protected: 184protected:
185 QString text(int r, int i); 185 QString text(int r, int i);
186 bool spreadRow(int); 186 bool spreadRow(int);
187 void pick(bool press, int row, int item); 187 void pick(bool press, int row, int item);
188}; 188};
189 189
190class KeycodeConfig : public PickboardConfig { 190class KeycodeConfig : public PickboardConfig {
191 QValueList<int> keys1; 191 QValueList<int> keys1;
192 QValueList<int> keys2; 192 QValueList<int> keys2;
193 QValueList<QPixmap> keypm1; 193 QValueList<QPixmap> keypm1;
194 QValueList<QPixmap> keypm2; 194 QValueList<QPixmap> keypm2;
195 static const int xw = 8; 195 static const int xw = 8;
196 static const int xmarg = 8; 196 static const int xmarg = 8;
197 197
198public: 198public:
199 KeycodeConfig(PickboardPicks* p) : PickboardConfig(p) { } 199 KeycodeConfig(PickboardPicks* p) : PickboardConfig(p) { }
200 void addKey(int r, const QPixmap& pm, int code); 200 void addKey(int r, const QPixmap& pm, int code);
201 void addGap(int r, int w); 201 void addGap(int r, int w);
202 202
203 void draw(QPainter* p); 203 void draw(QPainter* p);
204 204
205protected: 205protected:
206 void pickInRow(int r, int xpos, bool press); 206 void pickInRow(int r, int xpos, bool press);
207 QValueList<QPixmap> row(int i); 207 QValueList<QPixmap> row(int i);
208 208
209 void pick(bool press, int row, int item); 209 void pick(bool press, int row, int item);
210}; 210};
211 211
212 212
213#endif 213#endif