Switch to unified view

a/src/qtgui/ssearch_w.cpp b/src/qtgui/ssearch_w.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.20 2007-02-06 10:19:40 dockes Exp $ (C) 2006 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.21 2007-06-12 10:33:48 dockes Exp $ (C) 2006 J.F.Dockes";
3
#endif
3
#endif
4
/*
4
/*
5
 *   This program is free software; you can redistribute it and/or modify
5
 *   This program is free software; you can redistribute it and/or modify
6
 *   it under the terms of the GNU General Public License as published by
6
 *   it under the terms of the GNU General Public License as published by
7
 *   the Free Software Foundation; either version 2 of the License, or
7
 *   the Free Software Foundation; either version 2 of the License, or
...
...
54
        this, SLOT(searchTextChanged(const QString&)));
54
        this, SLOT(searchTextChanged(const QString&)));
55
    connect(clearqPB, SIGNAL(clicked()), 
55
    connect(clearqPB, SIGNAL(clicked()), 
56
        queryText->lineEdit(), SLOT(clear()));
56
        queryText->lineEdit(), SLOT(clear()));
57
    connect(searchPB, SIGNAL(clicked()), this, SLOT(startSimpleSearch()));
57
    connect(searchPB, SIGNAL(clicked()), this, SLOT(startSimpleSearch()));
58
58
59
#if QT_VERSION >= 0x040000
60
    queryText->installEventFilter(this);
61
#else
59
    queryText->lineEdit()->installEventFilter(this);
62
    queryText->lineEdit()->installEventFilter(this);
63
#endif
60
    m_escape = false;
64
    m_escape = false;
61
}
65
}
62
66
63
void SSearch::searchTextChanged( const QString & text )
67
void SSearch::searchTextChanged( const QString & text )
64
{
68
{
...
...
246
    } else {
250
    } else {
247
    return;
251
    return;
248
    }
252
    }
249
}
253
}
250
254
255
#undef SHOWEVENTS
256
#if defined(SHOWEVENTS)
257
#if QT_VERSION < 0x040000
258
static const char *eventTypeToStr(int tp)
259
{
260
    switch (tp) {
261
    case 0: return "None";
262
    case 1: return "Timer";
263
    case 2: return "MouseButtonPress";
264
    case 3: return "MouseButtonRelease";
265
    case 4: return "MouseButtonDblClick";
266
    case 5: return "MouseMove";
267
    case 6: return "KeyPress";
268
    case 7: return "KeyRelease";
269
    case 8: return "FocusIn";
270
    case 9: return "FocusOut";
271
    case 10: return "Enter";
272
    case 11: return "Leave";
273
    case 12: return "Paint";
274
    case 13: return "Move";
275
    case 14: return "Resize";
276
    case 15: return "Create";
277
    case 16: return "Destroy";
278
    case 17: return "Show";
279
    case 18: return "Hide";
280
    case 19: return "Close";
281
    case 20: return "Quit";
282
    case 21: return "Reparent";
283
    case 22: return "ShowMinimized";
284
    case 23: return "ShowNormal";
285
    case 24: return "WindowActivate";
286
    case 25: return "WindowDeactivate";
287
    case 26: return "ShowToParent";
288
    case 27: return "HideToParent";
289
    case 28: return "ShowMaximized";
290
    case 29: return "ShowFullScreen";
291
    case 30: return "Accel";
292
    case 31: return "Wheel";
293
    case 32: return "AccelAvailable";
294
    case 33: return "CaptionChange";
295
    case 34: return "IconChange";
296
    case 35: return "ParentFontChange";
297
    case 36: return "ApplicationFontChange";
298
    case 37: return "ParentPaletteChange";
299
    case 38: return "ApplicationPaletteChange";
300
    case 39: return "PaletteChange";
301
    case 40: return "Clipboard";
302
    case 42: return "Speech";
303
    case 50: return "SockAct";
304
    case 51: return "AccelOverride";
305
    case 52: return "DeferredDelete";
306
    case 60: return "DragEnter";
307
    case 61: return "DragMove";
308
    case 62: return "DragLeave";
309
    case 63: return "Drop";
310
    case 64: return "DragResponse";
311
    case 70: return "ChildInserted";
312
    case 71: return "ChildRemoved";
313
    case 72: return "LayoutHint";
314
    case 73: return "ShowWindowRequest";
315
    case 74: return "WindowBlocked";
316
    case 75: return "WindowUnblocked";
317
    case 80: return "ActivateControl";
318
    case 81: return "DeactivateControl";
319
    case 82: return "ContextMenu";
320
    case 83: return "IMStart";
321
    case 84: return "IMCompose";
322
    case 85: return "IMEnd";
323
    case 86: return "Accessibility";
324
    case 87: return "TabletMove";
325
    case 88: return "LocaleChange";
326
    case 89: return "LanguageChange";
327
    case 90: return "LayoutDirectionChange";
328
    case 91: return "Style";
329
    case 92: return "TabletPress";
330
    case 93: return "TabletRelease";
331
    case 94: return "OkRequest";
332
    case 95: return "HelpRequest";
333
    case 96: return "WindowStateChange";
334
    case 97: return "IconDrag";
335
    case 1000: return "User";
336
    case 65535: return "MaxUser";
337
    default: return "Unknown";
338
    }
339
}
340
#else
341
static const char *eventTypeToStr(int tp)
342
{
343
    switch (tp) {
344
    case  0: return "None";
345
    case  1: return "Timer";
346
    case  2: return "MouseButtonPress";
347
    case  3: return "MouseButtonRelease";
348
    case  4: return "MouseButtonDblClick";
349
    case  5: return "MouseMove";
350
    case  6: return "KeyPress";
351
    case  7: return "KeyRelease";
352
    case  8: return "FocusIn";
353
    case  9: return "FocusOut";
354
    case  10: return "Enter";
355
    case  11: return "Leave";
356
    case  12: return "Paint";
357
    case  13: return "Move";
358
    case  14: return "Resize";
359
    case  15: return "Create";
360
    case  16: return "Destroy";
361
    case  17: return "Show";
362
    case  18: return "Hide";
363
    case  19: return "Close";
364
    case  20: return "Quit";
365
    case  21: return "ParentChange";
366
    case  131: return "ParentAboutToChange";
367
    case  22: return "ThreadChange";
368
    case  24: return "WindowActivate";
369
    case  25: return "WindowDeactivate";
370
    case  26: return "ShowToParent";
371
    case  27: return "HideToParent";
372
    case  31: return "Wheel";
373
    case  33: return "WindowTitleChange";
374
    case  34: return "WindowIconChange";
375
    case  35: return "ApplicationWindowIconChange";
376
    case  36: return "ApplicationFontChange";
377
    case  37: return "ApplicationLayoutDirectionChange";
378
    case  38: return "ApplicationPaletteChange";
379
    case  39: return "PaletteChange";
380
    case  40: return "Clipboard";
381
    case  42: return "Speech";
382
    case   43: return "MetaCall";
383
    case  50: return "SockAct";
384
    case  132: return "WinEventAct";
385
    case  52: return "DeferredDelete";
386
    case  60: return "DragEnter";
387
    case  61: return "DragMove";
388
    case  62: return "DragLeave";
389
    case  63: return "Drop";
390
    case  64: return "DragResponse";
391
    case  68: return "ChildAdded";
392
    case  69: return "ChildPolished";
393
    case  70: return "ChildInserted";
394
    case  72: return "LayoutHint";
395
    case  71: return "ChildRemoved";
396
    case  73: return "ShowWindowRequest";
397
    case  74: return "PolishRequest";
398
    case  75: return "Polish";
399
    case  76: return "LayoutRequest";
400
    case  77: return "UpdateRequest";
401
    case  78: return "UpdateLater";
402
    case  79: return "EmbeddingControl";
403
    case  80: return "ActivateControl";
404
    case  81: return "DeactivateControl";
405
    case  82: return "ContextMenu";
406
    case  83: return "InputMethod";
407
    case  86: return "AccessibilityPrepare";
408
    case  87: return "TabletMove";
409
    case  88: return "LocaleChange";
410
    case  89: return "LanguageChange";
411
    case  90: return "LayoutDirectionChange";
412
    case  91: return "Style";
413
    case  92: return "TabletPress";
414
    case  93: return "TabletRelease";
415
    case  94: return "OkRequest";
416
    case  95: return "HelpRequest";
417
    case  96: return "IconDrag";
418
    case  97: return "FontChange";
419
    case  98: return "EnabledChange";
420
    case  99: return "ActivationChange";
421
    case  100: return "StyleChange";
422
    case  101: return "IconTextChange";
423
    case  102: return "ModifiedChange";
424
    case  109: return "MouseTrackingChange";
425
    case  103: return "WindowBlocked";
426
    case  104: return "WindowUnblocked";
427
    case  105: return "WindowStateChange";
428
    case  110: return "ToolTip";
429
    case  111: return "WhatsThis";
430
    case  112: return "StatusTip";
431
    case  113: return "ActionChanged";
432
    case  114: return "ActionAdded";
433
    case  115: return "ActionRemoved";
434
    case  116: return "FileOpen";
435
    case  117: return "Shortcut";
436
    case  51: return "ShortcutOverride";
437
    case  30: return "Accel";
438
    case  32: return "AccelAvailable";
439
    case  118: return "WhatsThisClicked";
440
    case  120: return "ToolBarChange";
441
    case  121: return "ApplicationActivated";
442
    case  122: return "ApplicationDeactivated";
443
    case  123: return "QueryWhatsThis";
444
    case  124: return "EnterWhatsThisMode";
445
    case  125: return "LeaveWhatsThisMode";
446
    case  126: return "ZOrderChange";
447
    case  127: return "HoverEnter";
448
    case  128: return "HoverLeave";
449
    case  129: return "HoverMove";
450
    case  119: return "AccessibilityHelp";
451
    case  130: return "AccessibilityDescription";
452
    case  150: return "EnterEditFocus";
453
    case  151: return "LeaveEditFocus";
454
    case  152: return "AcceptDropsChange";
455
    case  153: return "MenubarUpdated";
456
    case  154: return "ZeroTimerEvent";
457
    case  155: return "GraphicsSceneMouseMove";
458
    case  156: return "GraphicsSceneMousePress";
459
    case  157: return "GraphicsSceneMouseRelease";
460
    case  158: return "GraphicsSceneMouseDoubleClick";
461
    case  159: return "GraphicsSceneContextMenu";
462
    case  160: return "GraphicsSceneHoverEnter";
463
    case  161: return "GraphicsSceneHoverMove";
464
    case  162: return "GraphicsSceneHoverLeave";
465
    case  163: return "GraphicsSceneHelp";
466
    case  164: return "GraphicsSceneDragEnter";
467
    case  165: return "GraphicsSceneDragMove";
468
    case  166: return "GraphicsSceneDragLeave";
469
    case  167: return "GraphicsSceneDrop";
470
    case  168: return "GraphicsSceneWheel";
471
    case  169: return "KeyboardLayoutChange";
472
    case  170: return "DynamicPropertyChange";
473
    case  171: return "TabletEnterProximity";
474
    case  172: return "TabletLeaveProximity";
475
    default: return "UnknownEvent";
476
    }
477
}
478
#endif
479
#endif
251
480
252
bool SSearch::eventFilter(QObject *target, QEvent *event)
481
bool SSearch::eventFilter(QObject *target, QEvent *event)
253
{
482
{
483
#if defined(SHOWEVENTS)
484
    if (event->type() == QEvent::Timer || 
485
  event->type() == QEvent::UpdateRequest ||
486
  event->type() == QEvent::Paint)
487
  return false;
488
    LOGDEB2(("SSearch::eventFilter: target %p (%p) type %s\n", 
489
      target, queryText->lineEdit(),
490
      eventTypeToStr(event->type())));
491
#endif
492
254
    if (event->type() == QEvent::KeyPress)  {
493
    if (event->type() == QEvent::KeyPress)  {
255
    QKeyEvent *ke = (QKeyEvent *)event;
494
    QKeyEvent *ke = (QKeyEvent *)event;
256
    LOGDEB1(("SSearch::eventFilter: keyPress escape %d key %d\n", 
495
    LOGDEB1(("SSearch::eventFilter: keyPress (m_escape %d) key %d\n", 
257
         m_escape, ke->key()));
496
         m_escape, ke->key()));
258
    if (ke->key() == Qt::Key_Escape) {
497
    if (ke->key() == Qt::Key_Escape) {
259
        LOGDEB(("Escape\n"));
498
        LOGDEB(("Escape\n"));
260
        m_escape = true;
499
        m_escape = true;
261
        return true;
500
        return true;
...
...
269
        if (prefs.autoSearchOnWS)
508
        if (prefs.autoSearchOnWS)
270
        startSimpleSearch();
509
        startSimpleSearch();
271
    }
510
    }
272
    m_escape = false;
511
    m_escape = false;
273
    }
512
    }
274
    return QWidget::eventFilter(target, event);
513
    return false;
275
}
514
}