File indexing completed on 2024-05-05 04:49:26

0001 /****************************************************************************************
0002  * Copyright (c) 2009 Seb Ruiz <ruiz@kde.org>                                           *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #include "LineEdit.h"
0018 
0019 #include <QKeyEvent>
0020 
0021 namespace Amarok
0022 {
0023 
0024 LineEdit::LineEdit( QWidget *parent )
0025    : QLineEdit( parent )
0026 {
0027 }
0028 
0029 void LineEdit::keyPressEvent( QKeyEvent *event )
0030 {
0031     if( event->key() == Qt::Key_Escape )
0032     {
0033         event->accept();
0034         clear();
0035         return;
0036     }
0037     else if( event->key() == Qt::Key_Down )
0038     {
0039         event->accept();
0040         Q_EMIT downPressed();
0041         return;
0042     }
0043     else if ( event->key() == Qt::Key_Up )
0044     {
0045         event->accept();
0046         Q_EMIT upPressed();
0047         return;
0048     }
0049     QLineEdit::keyPressEvent( event );
0050 }
0051 
0052 }
0053