]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QCommandEdit.C
enable Font cache only for MacOSX and inline width() for other platform.
[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 signal
33                 escapePressed();
34                 break;
35
36         case Qt::Key_Up:
37                 // emit signal
38                 upPressed();
39                 break;
40
41         case Qt::Key_Down:
42                 // emit signal
43                 downPressed();
44                 break;
45
46         default:
47                 QLineEdit::keyPressEvent(e);
48                 break;
49         }
50 }
51
52
53 bool QCommandEdit::event(QEvent * e)
54 {
55         if (e->type() != QEvent::KeyPress)
56                 return QLineEdit::event(e);
57
58         QKeyEvent * ev = (QKeyEvent *)e;
59
60         if (ev->key() != Qt::Key_Tab)
61                 return QLineEdit::event(e);
62
63         // emit signal
64         tabPressed();
65         return true;
66 }
67
68 } // namespace frontend
69 } // namespace lyx
70
71 #include "QCommandEdit_moc.cpp"