]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QCommandEdit.C
rename LFUN enum values according to their command (as used in th minibuffer/bind...
[lyx.git] / src / frontends / qt4 / 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 //Added by qt3to4:
15 #include <QKeyEvent>
16 #include <QEvent>
17
18 namespace lyx {
19 namespace frontend {
20
21 QCommandEdit::QCommandEdit(QWidget * parent)
22         : QLineEdit(parent)
23 {
24         setFocusPolicy(Qt::ClickFocus);
25 }
26
27
28 void QCommandEdit::keyPressEvent(QKeyEvent * e)
29 {
30         switch (e->key()) {
31         case Qt::Key_Escape:
32                 emit escapePressed();
33                 break;
34
35         case Qt::Key_Up:
36                 emit upPressed();
37                 break;
38
39         case Qt::Key_Down:
40                 emit downPressed();
41                 break;
42
43         default:
44                 QLineEdit::keyPressEvent(e);
45                 break;
46         }
47 }
48
49
50 bool QCommandEdit::event(QEvent * e)
51 {
52         if (e->type() != QEvent::KeyPress)
53                 return QLineEdit::event(e);
54
55         QKeyEvent * ev = (QKeyEvent *)e;
56
57         if (ev->key() != Qt::Key_Tab)
58                 return QLineEdit::event(e);
59
60         emit tabPressed();
61         return true;
62 }
63
64 } // namespace frontend
65 } // namespace lyx