]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QCommandEdit.C
Get rid of the static_casts.
[lyx.git] / src / frontends / qt2 / QCommandEdit.C
1 /**
2  * \file QCommandEdit.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #include "QCommandEdit.h"
14
15 QCommandEdit::QCommandEdit(QWidget * parent)
16         : QLineEdit(parent)
17 {
18         setFocusPolicy(QWidget::ClickFocus);
19 }
20
21
22 void QCommandEdit::keyPressEvent(QKeyEvent * e)
23 {
24         switch (e->key()) {
25         case Key_Escape:
26                 emit escapePressed();
27                 break;
28
29         case Key_Up:
30                 emit upPressed();
31                 break;
32
33         case Key_Down:
34                 emit downPressed();
35                 break;
36
37         default:
38                 QLineEdit::keyPressEvent(e);
39                 break;
40         }
41 }
42
43
44 bool QCommandEdit::event(QEvent * e)
45 {
46         if (e->type() != QEvent::KeyPress)
47                 return QLineEdit::event(e);
48
49         QKeyEvent * ev = (QKeyEvent *)e;
50
51         if (ev->key() != Key_Tab)
52                 return QLineEdit::event(e);
53
54         emit tabPressed();
55         return true;
56 }