KDevelop API Documentation

quickopendialog.cpp

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) KDevelop Authors <kdevelop-devel@kdevelop.org>, (C) 2004
00003  *
00004  *  This program is free software; you can redistribute it and/or
00005  *  modify it under the terms of the GNU General Public
00006  *  License as published by the Free Software Foundation; either
00007  *  version 2 of the License, or (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  *  Boston, MA 02111-1307, USA.
00018  *
00019  */
00020 
00021 #include <qapplication.h>
00022  
00023 #include <klistbox.h>
00024 #include <klineedit.h>
00025 #include <kcompletion.h>
00026 
00027 #include "quickopendialog.h"
00028 
00029 QuickOpenDialog::QuickOpenDialog(QuickOpenPart* part, QWidget* parent, const char* name, bool modal, WFlags fl)
00030     : QuickOpenDialogBase( parent, name, modal, fl ), m_part( part )
00031 {
00032     nameEdit->installEventFilter(this);
00033 }
00034 
00035 QuickOpenDialog::~QuickOpenDialog()
00036 {
00037 }
00038 
00039 void QuickOpenDialog::slotTextChanged(const QString & text)
00040 {
00041     itemList->clear();
00042     itemList->insertStringList( m_completion->substringCompletion(text) );
00043     itemList->setCurrentItem(0);
00044 }
00045 
00046 bool QuickOpenDialog::eventFilter( QObject * watched, QEvent * e )
00047 {
00048     if (!watched || !e)
00049         return true;
00050 
00051     if ((watched == nameEdit) && (e->type() == QEvent::KeyPress))
00052     {
00053         QKeyEvent *ke = (QKeyEvent*)e;
00054         if (ke->key() == Key_Up)
00055         {
00056             int i = itemList->currentItem();
00057             if (--i >= 0)
00058             {
00059                 itemList->setCurrentItem(i);
00060                 nameEdit->blockSignals(true);
00061                 nameEdit->setText(itemList->currentText());
00062                 nameEdit->blockSignals(false);
00063             }
00064             return true;
00065         } else if (ke->key() == Key_Down)
00066         {
00067             int i = itemList->currentItem();
00068             if ( ++i < int(itemList->count()) ) 
00069             {
00070                 itemList->setCurrentItem(i);
00071                 nameEdit->blockSignals(true);
00072                 nameEdit->setText(itemList->currentText());
00073                 nameEdit->blockSignals(false);
00074             }
00075             return true;
00076         } else if ((ke->key() == Key_Next) || (ke->key() == Key_Prior))
00077         {
00078             QApplication::sendEvent(itemList, e);
00079             nameEdit->blockSignals(true);
00080             nameEdit->setText(itemList->currentText());
00081             nameEdit->blockSignals(false);
00082         }
00083     }
00084 
00085     return QWidget::eventFilter(watched, e);    
00086 }
00087 
00088 #include "quickopendialog.moc"
00089 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:57 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003