00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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
00087
00088
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