quickopendialog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
This file is part of the documentation for KDevelop Version 3.1.2.