summaryrefslogtreecommitdiff
path: root/inputmethods/multikey
authormickeyl <mickeyl>2004-04-24 15:51:18 (UTC)
committer mickeyl <mickeyl>2004-04-24 15:51:18 (UTC)
commit629ced22fc26892442be433403a9cfa9f662f08a (patch) (unidiff)
tree830973cb7ba701b0a897220e1307ad3f1243384b /inputmethods/multikey
parentf7b5905d990f374dd6cb177b7a03628cc593b7cf (diff)
downloadopie-629ced22fc26892442be433403a9cfa9f662f08a.zip
opie-629ced22fc26892442be433403a9cfa9f662f08a.tar.gz
opie-629ced22fc26892442be433403a9cfa9f662f08a.tar.bz2
gcc 3.4 fixes
Diffstat (limited to 'inputmethods/multikey') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 4f4f25f..7ddfd3e 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -1,350 +1,350 @@
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 20
21#include "keyboard.h" 21#include "keyboard.h"
22#include "configdlg.h" 22#include "configdlg.h"
23 23
24#include <qpe/global.h> 24#include <qpe/global.h>
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26 26
27#include <qwindowsystem_qws.h> 27#include <qwindowsystem_qws.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qfontmetrics.h> 29#include <qfontmetrics.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <ctype.h> 33#include <ctype.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qstringlist.h> 36#include <qstringlist.h>
37 37
38#include <sys/utsname.h> 38#include <sys/utsname.h>
39 39
40using namespace MultiKey; 40using namespace MultiKey;
41 41
42static const char * const kb_config_xpm[] = { 42static const char * const kb_config_xpm[] = {
43"13 7 2 1", 43"13 7 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/* Keyboard::Keyboard {{{1 */ 54/* Keyboard::Keyboard {{{1 */
55Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 55Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
56 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), 56 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0),
57 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), 57 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0),
58 useLargeKeys(TRUE), usePicks(0), useRepeat(0), 58 useLargeKeys(TRUE), usePicks(0), useRepeat(0),
59 pressedKeyRow(-1), pressedKeyCol(-1), 59 pressedKeyRow(-1), pressedKeyCol(-1),
60 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 60 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
61 configdlg(0) 61 configdlg(0)
62 62
63{ 63{
64 64
65 // get the default font 65 // get the default font
66 Config *config = new Config( "qpe" ); 66 Config *config = new Config( "qpe" );
67 config->setGroup( "Appearance" ); 67 config->setGroup( "Appearance" );
68 QString familyStr = config->readEntry( "FontFamily", "smallsmooth" ); 68 QString familyStr = config->readEntry( "FontFamily", "smallsmooth" );
69 delete config; 69 delete config;
70 70
71 config = new Config("multikey"); 71 config = new Config("multikey");
72 config->setGroup ("general"); 72 config->setGroup ("general");
73 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed 73 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed
74 useRepeat = config->readBoolEntry ("useRepeat", 1); 74 useRepeat = config->readBoolEntry ("useRepeat", 1);
75 delete config; 75 delete config;
76 76
77 77
78 setFont( QFont( familyStr, 10 ) ); 78 setFont( QFont( familyStr, 10 ) );
79 79
80 picks = new KeyboardPicks( this ); 80 picks = new KeyboardPicks( this );
81 picks->setFont( QFont( familyStr, 10 ) ); 81 picks->setFont( QFont( familyStr, 10 ) );
82 picks->initialise(); 82 picks->initialise();
83 if (usePicks) { 83 if (usePicks) {
84 84
85 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 85 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
86 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 86 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
87 87
88 } else picks->hide(); 88 } else picks->hide();
89 89
90 loadKeyboardColors(); 90 loadKeyboardColors();
91 91
92 keys = new Keys(); 92 keys = new Keys();
93 93
94 repeatTimer = new QTimer( this ); 94 repeatTimer = new QTimer( this );
95 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 95 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
96 96
97 QCopChannel* kbdChannel = new QCopChannel("MultiKey/Keyboard", this); 97 QCopChannel* kbdChannel = new QCopChannel("MultiKey/Keyboard", this);
98 connect(kbdChannel, SIGNAL(received(const QCString&,const QByteArray&)), 98 connect(kbdChannel, SIGNAL(received(const QCString&,const QByteArray&)),
99 this, SLOT(receive(const QCString&,const QByteArray&))); 99 this, SLOT(receive(const QCString&,const QByteArray&)));
100} 100}
101 101
102Keyboard::~Keyboard() { 102Keyboard::~Keyboard() {
103 103
104 if ( configdlg ) { 104 if ( configdlg ) {
105 delete configdlg; 105 delete configdlg;
106 configdlg = 0; 106 configdlg = 0;
107 } 107 }
108 108
109} 109}
110 110
111/* Keyboard::resizeEvent {{{1 */ 111/* Keyboard::resizeEvent {{{1 */
112void Keyboard::resizeEvent(QResizeEvent*) 112void Keyboard::resizeEvent(QResizeEvent*)
113{ 113{
114 int ph = picks->sizeHint().height(); 114 int ph = picks->sizeHint().height();
115 picks->setGeometry( 0, 0, width(), ph ); 115 picks->setGeometry( 0, 0, width(), ph );
116 keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); 116 keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1);
117 117
118 int nk; // number of keys? 118 int nk; // number of keys?
119 if ( useLargeKeys ) { 119 if ( useLargeKeys ) {
120 nk = 15; 120 nk = 15;
121 } else { 121 } else {
122 nk = 19; 122 nk = 19;
123 } 123 }
124 defaultKeyWidth = (width()/nk)/2; 124 defaultKeyWidth = (width()/nk)/2;
125 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 125 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
126 126
127} 127}
128 128
129/* KeyboardPicks::initialize {{{1 */ 129/* KeyboardPicks::initialize {{{1 */
130void KeyboardPicks::initialise() 130void KeyboardPicks::initialise()
131{ 131{
132 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 132 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
133 mode = 0; 133 mode = 0;
134 dc = new KeyboardConfig(this); 134 dc = new KeyboardConfig(this);
135 configs.append(dc); 135 configs.append(dc);
136} 136}
137 137
138/* KeyboardPicks::sizeHint {{{1 */ 138/* KeyboardPicks::sizeHint {{{1 */
139QSize KeyboardPicks::sizeHint() const 139QSize KeyboardPicks::sizeHint() const
140{ 140{
141 return QSize(240,fontMetrics().lineSpacing()); 141 return QSize(240,fontMetrics().lineSpacing());
142} 142}
143 143
144 144
145/* KeyboardConfig::generateText {{{1 */ 145/* KeyboardConfig::generateText {{{1 */
146void KeyboardConfig::generateText(const QString &s) 146void KeyboardConfig::generateText(const QString &s)
147{ 147{
148#if defined(Q_WS_QWS) || defined(_WS_QWS_) 148#if defined(Q_WS_QWS) || defined(_WS_QWS_)
149 for (int i=0; i<(int)backspaces; i++) { 149 for (int i=0; i<(int)backspaces; i++) {
150 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 150 parent->emitKey( 0, ::Qt::Key_Backspace, 0, true, false );
151 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 151 parent->emitKey( 0, ::Qt::Key_Backspace, 0, false, false );
152 } 152 }
153 for (int i=0; i<(int)s.length(); i++) { 153 for (int i=0; i<(int)s.length(); i++) {
154 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 154 parent->emitKey( s[i].unicode(), 0, 0, true, false );
155 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 155 parent->emitKey( s[i].unicode(), 0, 0, false, false );
156 } 156 }
157 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 157 parent->emitKey( 0, ::Qt::Key_Space, 0, true, false );
158 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 158 parent->emitKey( 0, ::Qt::Key_Space, 0, false, false );
159 backspaces = 0; 159 backspaces = 0;
160#endif 160#endif
161} 161}
162 162
163 163
164 164
165 165
166/* Keyboard::paintEvent {{{1 */ 166/* Keyboard::paintEvent {{{1 */
167void Keyboard::paintEvent(QPaintEvent* e) 167void Keyboard::paintEvent(QPaintEvent* e)
168{ 168{
169 QPainter painter(this); 169 QPainter painter(this);
170 painter.setClipRect(e->rect()); 170 painter.setClipRect(e->rect());
171 drawKeyboard( painter ); 171 drawKeyboard( painter );
172 picks->dc->draw( &painter ); 172 picks->dc->draw( &painter );
173} 173}
174 174
175 175
176/* Keyboard::drawKeyboard {{{1 */ 176/* Keyboard::drawKeyboard {{{1 */
177 177
178void Keyboard::drawKeyboard(QPainter &p, int row, int col) 178void Keyboard::drawKeyboard(QPainter &p, int row, int col)
179{ 179{
180 180
181 181
182 if (row != -1 && col != -1) { //just redraw one key 182 if (row != -1 && col != -1) { //just redraw one key
183 183
184 int x = 0; 184 int x = 0;
185 for (int i = 0; i < col; i++) { 185 for (int i = 0; i < col; i++) {
186 186
187 x += keys->width(row, i) * defaultKeyWidth; 187 x += keys->width(row, i) * defaultKeyWidth;
188 } 188 }
189 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 189 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
190 190
191 int keyWidth = keys->width(row, col); 191 int keyWidth = keys->width(row, col);
192 192
193 p.fillRect(x + 1, y + 1, 193 p.fillRect(x + 1, y + 1,
194 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 194 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
195 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 195 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
196 196
197 QImage *pix = keys->pix(row,col); 197 QImage *pix = keys->pix(row,col);
198 198
199 ushort c = keys->uni(row, col); 199 ushort c = keys->uni(row, col);
200 200
201 p.setPen(textcolor); 201 p.setPen(textcolor);
202 if (!pix) { 202 if (!pix) {
203 if ((shift || lock) && keys->shift(c)) 203 if ((shift || lock) && keys->shift(c))
204 204
205 if (circumflex && keys->circumflex(keys->shift(c))) 205 if (circumflex && keys->circumflex(keys->shift(c)))
206 c = keys->circumflex(keys->shift(c)); 206 c = keys->circumflex(keys->shift(c));
207 else if (diaeresis && keys->diaeresis(keys->shift(c))) 207 else if (diaeresis && keys->diaeresis(keys->shift(c)))
208 c = keys->diaeresis(keys->shift(c)); 208 c = keys->diaeresis(keys->shift(c));
209 else if (baccent && keys->baccent(keys->shift(c))) 209 else if (baccent && keys->baccent(keys->shift(c)))
210 c = keys->baccent(keys->shift(c)); 210 c = keys->baccent(keys->shift(c));
211 else if (accent && keys->accent(keys->shift(c))) 211 else if (accent && keys->accent(keys->shift(c)))
212 c = keys->accent(keys->shift(c)); 212 c = keys->accent(keys->shift(c));
213 else if (meta && keys->meta(keys->shift(c))) 213 else if (meta && keys->meta(keys->shift(c)))
214 c = keys->meta(keys->shift(c)); 214 c = keys->meta(keys->shift(c));
215 else 215 else
216 c = keys->shift(c); 216 c = keys->shift(c);
217 217
218 else if (meta && keys->meta(c)) 218 else if (meta && keys->meta(c))
219 c = keys->meta(c); 219 c = keys->meta(c);
220 else if (circumflex && keys->circumflex(c)) 220 else if (circumflex && keys->circumflex(c))
221 c = keys->circumflex(c); 221 c = keys->circumflex(c);
222 else if (baccent && keys->baccent(c)) 222 else if (baccent && keys->baccent(c))
223 c = keys->baccent(c); 223 c = keys->baccent(c);
224 else if (accent && keys->accent(c)) 224 else if (accent && keys->accent(c))
225 c = keys->accent(c); 225 c = keys->accent(c);
226 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 226 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
227 227
228 // the diaeresis key itself has to be in the diaeresisMap, 228 // the diaeresis key itself has to be in the diaeresisMap,
229 // or just do this to make it display the diaeresis char. 229 // or just do this to make it display the diaeresis char.
230 230
231 if (c == 0x2c6) 231 if (c == 0x2c6)
232 c = 0xa8; 232 c = 0xa8;
233 else 233 else
234 c = keys->diaeresis(c); 234 c = keys->diaeresis(c);
235 } 235 }
236 236
237 p.drawText(x, y, 237 p.drawText(x, y,
238 defaultKeyWidth * keyWidth + 3, keyHeight, 238 defaultKeyWidth * keyWidth + 3, keyHeight,
239 AlignCenter, (QChar)c); 239 AlignCenter, (QChar)c);
240 } 240 }
241 else 241 else
242 // center the image in the middle of the key 242 // center the image in the middle of the key
243 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, 243 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1,
244 y + (keyHeight - pix->height())/2 + 1, 244 y + (keyHeight - pix->height())/2 + 1,
245 *pix ); 245 *pix );
246 246
247 // this fixes the problem that the very right end of the board's vertical line 247 // this fixes the problem that the very right end of the board's vertical line
248 // gets painted over, because it's one pixel shorter than all other keys 248 // gets painted over, because it's one pixel shorter than all other keys
249 p.setPen(keycolor_lines); 249 p.setPen(keycolor_lines);
250 p.drawLine(width() - 1, 0, width() - 1, height()); 250 p.drawLine(width() - 1, 0, width() - 1, height());
251 251
252 } else { 252 } else {
253 253
254 254
255 p.fillRect(0, 0, width(), height(), keycolor); 255 p.fillRect(0, 0, width(), height(), keycolor);
256 256
257 for (row = 1; row <= keys->rows(); row++) { 257 for (row = 1; row <= keys->rows(); row++) {
258 258
259 int x = 0; 259 int x = 0;
260 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 260 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
261 261
262 p.setPen(keycolor_lines); 262 p.setPen(keycolor_lines);
263 p.drawLine(x, y, x + width(), y); 263 p.drawLine(x, y, x + width(), y);
264 264
265 for (int col = 0; col < keys->numKeys(row); col++) { 265 for (int col = 0; col < keys->numKeys(row); col++) {
266 266
267 QImage *pix = keys->pix(row, col); 267 QImage *pix = keys->pix(row, col);
268 int keyWidth = keys->width(row, col); 268 int keyWidth = keys->width(row, col);
269 269
270 270
271 int keyWidthPix = defaultKeyWidth * keyWidth; 271 int keyWidthPix = defaultKeyWidth * keyWidth;
272 272
273 if (keys->pressed(row, col)) 273 if (keys->pressed(row, col))
274 p.fillRect(x+1, y+1, keyWidthPix - 1, 274 p.fillRect(x+1, y+1, keyWidthPix - 1,
275 keyHeight - 1, keycolor_pressed); 275 keyHeight - 1, keycolor_pressed);
276 276
277 ushort c = keys->uni(row, col); 277 ushort c = keys->uni(row, col);
278 278
279 p.setPen(textcolor); 279 p.setPen(textcolor);
280 if (!pix) { 280 if (!pix) {
281 if ((shift || lock) && keys->shift(c)) 281 if ((shift || lock) && keys->shift(c))
282 282
283 if (circumflex && keys->circumflex(keys->shift(c))) 283 if (circumflex && keys->circumflex(keys->shift(c)))
284 c = keys->circumflex(keys->shift(c)); 284 c = keys->circumflex(keys->shift(c));
285 else if (diaeresis && keys->diaeresis(keys->shift(c))) 285 else if (diaeresis && keys->diaeresis(keys->shift(c)))
286 c = keys->diaeresis(keys->shift(c)); 286 c = keys->diaeresis(keys->shift(c));
287 else if (baccent && keys->baccent(keys->shift(c))) 287 else if (baccent && keys->baccent(keys->shift(c)))
288 c = keys->baccent(keys->shift(c)); 288 c = keys->baccent(keys->shift(c));
289 else if (accent && keys->accent(keys->shift(c))) 289 else if (accent && keys->accent(keys->shift(c)))
290 c = keys->accent(keys->shift(c)); 290 c = keys->accent(keys->shift(c));
291 else if (meta && keys->meta(keys->shift(c))) 291 else if (meta && keys->meta(keys->shift(c)))
292 c = keys->meta(keys->shift(c)); 292 c = keys->meta(keys->shift(c));
293 else 293 else
294 c = keys->shift(c); 294 c = keys->shift(c);
295 295
296 else if (meta && keys->meta(c)) 296 else if (meta && keys->meta(c))
297 c = keys->meta(c); 297 c = keys->meta(c);
298 else if (circumflex && keys->circumflex(c)) 298 else if (circumflex && keys->circumflex(c))
299 c = keys->circumflex(c); 299 c = keys->circumflex(c);
300 else if (baccent && keys->baccent(c)) 300 else if (baccent && keys->baccent(c))
301 c = keys->baccent(c); 301 c = keys->baccent(c);
302 else if (accent && keys->accent(c)) 302 else if (accent && keys->accent(c))
303 c = keys->accent(c); 303 c = keys->accent(c);
304 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 304 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
305 305
306 if (c == 0x2c6) 306 if (c == 0x2c6)
307 c = 0xa8; 307 c = 0xa8;
308 else 308 else
309 c = keys->diaeresis(c); 309 c = keys->diaeresis(c);
310 } 310 }
311 311
312 p.drawText(x, y, 312 p.drawText(x, y,
313 keyWidthPix + 3, keyHeight, 313 keyWidthPix + 3, keyHeight,
314 AlignCenter, (QChar)c); 314 AlignCenter, (QChar)c);
315 } 315 }
316 else { 316 else {
317 // center the image in the middle of the key 317 // center the image in the middle of the key
318 pix->setColor(1, textcolor.rgb()); 318 pix->setColor(1, textcolor.rgb());
319 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, 319 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1,
320 y + (keyHeight - pix->height())/2 + 1, 320 y + (keyHeight - pix->height())/2 + 1,
321 QImage(*pix) ); 321 QImage(*pix) );
322 } 322 }
323 323
324 p.setPen(keycolor_lines); 324 p.setPen(keycolor_lines);
325 p.drawLine(x, y, x, y + keyHeight); 325 p.drawLine(x, y, x, y + keyHeight);
326 326
327 x += keyWidthPix; 327 x += keyWidthPix;
328 } 328 }
329 329
330 330
331 } 331 }
332 p.setPen(keycolor_lines); 332 p.setPen(keycolor_lines);
333 p.drawLine(0, height() - 1, width(), height() - 1); 333 p.drawLine(0, height() - 1, width(), height() - 1);
334 p.drawLine(width() - 1, 0, width() - 1, height()); 334 p.drawLine(width() - 1, 0, width() - 1, height());
335 } 335 }
336 336
337} 337}
338 338
339 339
340/* Keyboard::mousePressEvent {{{1 */ 340/* Keyboard::mousePressEvent {{{1 */
341void Keyboard::mousePressEvent(QMouseEvent *e) 341void Keyboard::mousePressEvent(QMouseEvent *e)
342{ 342{
343 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 343 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
344 if (row > 5) row = 5; 344 if (row > 5) row = 5;
345 345
346 // figure out the column 346 // figure out the column
347 int col = 0; 347 int col = 0;
348 for (int w = 0; e->x() >= w; col++) 348 for (int w = 0; e->x() >= w; col++)
349 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 349 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
350 w += keys->width(row,col) * defaultKeyWidth; 350 w += keys->width(row,col) * defaultKeyWidth;