diff --git a/src/qtgui/ssearch_w.cpp b/src/qtgui/ssearch_w.cpp index 9f5b43b2..fb858dd2 100644 --- a/src/qtgui/ssearch_w.cpp +++ b/src/qtgui/ssearch_w.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.9 2006-10-30 12:59:44 dockes Exp $ (C) 2006 J.F.Dockes"; +static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.10 2006-11-04 14:49:46 dockes Exp $ (C) 2006 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -46,6 +46,9 @@ void SSearch::init() connect(clearqPB, SIGNAL(clicked()), queryText->lineEdit(), SLOT(clear())); connect(searchPB, SIGNAL(clicked()), this, SLOT(startSimpleSearch())); + + queryText->lineEdit()->installEventFilter(this); + m_escape = false; } void SSearch::searchTextChanged( const QString & text ) @@ -201,18 +204,28 @@ void SSearch::completion() } } -// Handle CTRL-TAB to mean completion -bool SSearch::event( QEvent *evt ) + +bool SSearch::eventFilter(QObject *target, QEvent *event) { - if ( evt->type() == QEvent::KeyPress ) { - QKeyEvent *ke = (QKeyEvent *)evt; - if ( ke->key() == Key_Tab && (ke->state() & Qt::ControlButton)) { - // special tab handling here - completion(); + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = (QKeyEvent *)event; + LOGDEB1(("SSearch::eventFilter: keyPress escape %d key %d\n", + m_escape, ke->key())); + if (ke->key() == Key_Escape) { + LOGDEB(("Escape\n")); + m_escape = true; + return true; + } else if (m_escape && ke->key() == Key_Space) { + LOGDEB(("Escape space\n")); ke->accept(); - return TRUE; + completion(); + m_escape = false; + return true; + } else { + m_escape = false; } } - return QWidget::event( evt ); + return QWidget::eventFilter(target, event); } + diff --git a/src/qtgui/ssearch_w.h b/src/qtgui/ssearch_w.h index d65b3878..56268ccd 100644 --- a/src/qtgui/ssearch_w.h +++ b/src/qtgui/ssearch_w.h @@ -1,4 +1,4 @@ -/* @(#$Id: ssearch_w.h,v 1.1 2006-09-04 15:13:02 dockes Exp $ (C) 2006 J.F.Dockes */ +/* @(#$Id: ssearch_w.h,v 1.2 2006-11-04 14:49:46 dockes Exp $ (C) 2006 J.F.Dockes */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ public: virtual void init(); virtual void setAnyTermMode(); virtual void completion(); - virtual bool event( QEvent * evt ); + virtual bool eventFilter(QObject *target, QEvent *event); public slots: virtual void searchTextChanged( const QString & text ); @@ -45,6 +45,8 @@ public slots: signals: void startSearch(Rcl::AdvSearchData); void clearSearch(); + private: + bool m_escape; };