KDevelop API Documentation

parts/quickopen/quickopendialog.cpp

Go to the documentation of this file.
00001 /* 00002 * Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) 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 "quickopendialog.h" 00022 #include "quickopen_part.h" 00023 00024 #include <kdevproject.h> 00025 #include <kdevpartcontroller.h> 00026 00027 #include "doclineedit.h" 00028 00029 #include <klistbox.h> 00030 #include <klocale.h> 00031 #include <kdebug.h> 00032 00033 #include <qregexp.h> 00034 #include <qlabel.h> 00035 00036 QuickOpenDialog::QuickOpenDialog(QuickOpenPart* part, QWidget* parent, const char* name, bool modal, WFlags fl) 00037 : QuickOpenDialogBase( parent, name, modal, fl ), m_part( part ) 00038 { 00039 nameLabel->setText( i18n("File &name:") ); 00040 itemListLabel->setText( i18n("File &list:") ); 00041 00042 m_fileList = m_part->project()->allFiles(); 00043 00044 m_completion = new KCompletion(); 00045 m_completion->insertItems( m_fileList ); 00046 m_completion->setIgnoreCase( true ); 00047 00048 nameEdit->setFocus(); 00049 00050 itemList->insertStringList( m_fileList ); 00051 itemList->setCurrentItem(0); 00052 00053 connect(nameEdit, SIGNAL(upPressed()), this, SLOT(moveUpInList())); 00054 connect(nameEdit, SIGNAL(downPressed()), this, SLOT(moveDownInList())); 00055 connect(nameEdit, SIGNAL(pgupPressed()), this, SLOT(scrollUpInList())); 00056 connect(nameEdit, SIGNAL(pgdownPressed()), this, SLOT(scrollDownInList())); 00057 connect(nameEdit, SIGNAL(homePressed()), this, SLOT(goToBegin())); 00058 connect(nameEdit, SIGNAL(endPressed()), this, SLOT(goToEnd())); 00059 } 00060 00061 QuickOpenDialog::~QuickOpenDialog() 00062 { 00063 delete( m_completion ); 00064 m_completion = 0; 00065 } 00066 00067 /*$SPECIALIZATION$*/ 00068 void QuickOpenDialog::slotExecuted( QListBoxItem* item ) 00069 { 00070 m_part->partController()->editDocument( m_part->project()->projectDirectory() + "/" + item->text() ); 00071 accept(); 00072 } 00073 00074 void QuickOpenDialog::reject() 00075 { 00076 QDialog::reject(); 00077 } 00078 00079 void QuickOpenDialog::accept() 00080 { 00081 QDialog::accept(); 00082 } 00083 00084 void QuickOpenDialog::slotReturnPressed( ) 00085 { 00086 /* if( m_fileList.contains(nameEdit->text()) ) { 00087 m_part->partController()->editDocument( m_part->project()->projectDirectory() + "/" + nameEdit->text() ); 00088 accept(); 00089 }*/ 00090 if( itemList->currentItem() != -1 ) { 00091 m_part->partController()->editDocument( m_part->project()->projectDirectory() + "/" + itemList->currentText() ); 00092 accept(); 00093 } 00094 } 00095 00096 void QuickOpenDialog::slotTextChanged( const QString & text ) 00097 { 00098 itemList->clear(); 00099 itemList->insertStringList( m_completion->substringCompletion(text) ); 00100 itemList->setCurrentItem(0); 00101 } 00102 00103 void QuickOpenDialog::moveUpInList( ) 00104 { 00105 if (itemList->currentItem() == -1) 00106 itemList->setCurrentItem(itemList->count() - 1); 00107 else 00108 itemList->setCurrentItem(itemList->currentItem() - 1); 00109 itemList->ensureCurrentVisible(); 00110 } 00111 00112 void QuickOpenDialog::moveDownInList( ) 00113 { 00114 if (itemList->currentItem() == -1) 00115 itemList->setCurrentItem(0); 00116 else 00117 itemList->setCurrentItem(itemList->currentItem() + 1); 00118 itemList->ensureCurrentVisible(); 00119 } 00120 00121 void QuickOpenDialog::scrollUpInList( ) 00122 { 00123 if (itemList->currentItem() == -1) 00124 itemList->setCurrentItem(itemList->count() - 1); 00125 else 00126 itemList->setCurrentItem(itemList->currentItem() - (itemList->numItemsVisible()-1)); 00127 itemList->ensureCurrentVisible(); 00128 } 00129 00130 void QuickOpenDialog::scrollDownInList( ) 00131 { 00132 if (itemList->currentItem() == -1) 00133 itemList->setCurrentItem(0); 00134 else 00135 itemList->setCurrentItem(itemList->currentItem() + (itemList->numItemsVisible()-1)); 00136 itemList->ensureCurrentVisible(); 00137 } 00138 00139 void QuickOpenDialog::goToBegin( ) 00140 { 00141 itemList->setCurrentItem(0); 00142 } 00143 00144 void QuickOpenDialog::goToEnd( ) 00145 { 00146 itemList->setCurrentItem(itemList->count()-1); 00147 } 00148 00149 00150 #include "quickopendialog.moc" 00151
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Oct 19 08:01:52 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003