]> git.cworth.org Git - apitrace/blob - gui/jumpwidget.cpp
Use skiplist-based FastCallSet within trace::CallSet
[apitrace] / gui / jumpwidget.cpp
1 #include "jumpwidget.h"
2
3 #include <QDebug>
4 #include <QKeyEvent>
5
6 JumpWidget::JumpWidget(QWidget *parent )
7     : QWidget(parent)
8 {
9     m_ui.setupUi(this);
10
11     connect(m_ui.jumpButton, SIGNAL(clicked()),
12             SLOT(slotJump()));
13     connect(m_ui.spinBox, SIGNAL(editingFinished()),
14             SLOT(slotJump()));
15     connect(m_ui.cancelButton, SIGNAL(clicked()),
16             SLOT(slotCancel()));
17
18     installEventFilter(this);
19 }
20
21 void JumpWidget::slotJump()
22 {
23     if (isVisible()) {
24         emit jumpTo(m_ui.spinBox->value());
25     }
26     hide();
27 }
28
29 void JumpWidget::slotCancel()
30 {
31     hide();
32 }
33
34 void JumpWidget::showEvent(QShowEvent *event)
35 {
36     m_ui.spinBox->setFocus(Qt::ShortcutFocusReason);
37     return QWidget::showEvent(event);
38 }
39
40 bool JumpWidget::eventFilter(QObject *object, QEvent* event)
41 {
42     if (event->type() == QEvent::KeyPress) {
43         if ((static_cast<QKeyEvent*>(event))->key() == Qt::Key_Escape) {
44             hide();
45         }
46     }
47     return QWidget::eventFilter(object, event);
48 }
49
50 #include "jumpwidget.moc"