From 50a6c7b65d56635ed09b62919601c673fcb7c368 Mon Sep 17 00:00:00 2001 From: andreas <andreas@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Tue, 8 Jun 2010 14:31:28 +0000 Subject: [PATCH] added directory separator to path completion for dirs (thanks Marco for the code) git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/branches/new_shell@2361 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/gui/src/python_shell/completer_base.cc | 2 +- modules/gui/src/python_shell/python_shell_widget.cc | 9 ++++++++- modules/gui/src/python_shell/python_shell_widget.hh | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/gui/src/python_shell/completer_base.cc b/modules/gui/src/python_shell/completer_base.cc index 03c574c6d..3194eb53c 100644 --- a/modules/gui/src/python_shell/completer_base.cc +++ b/modules/gui/src/python_shell/completer_base.cc @@ -71,7 +71,7 @@ QString OstCompleterBase::GetCommonMatch() } QStringList matches; for(int i=0;i<completionCount();++i){ - setCurrentRow(i); + setCurrentRow(i); matches.append(currentCompletion().remove(0,completionPrefix().length())); } QString common_match; diff --git a/modules/gui/src/python_shell/python_shell_widget.cc b/modules/gui/src/python_shell/python_shell_widget.cc index 3462ffc87..f86d0fc53 100644 --- a/modules/gui/src/python_shell/python_shell_widget.cc +++ b/modules/gui/src/python_shell/python_shell_widget.cc @@ -100,7 +100,7 @@ PythonShellWidget::PythonShellWidget(QWidget* parent): SLOT(SetCompletionPrefix(const QString&))); path_completer_->setWidget(viewport()); connect(path_completer_,SIGNAL(activated(const QString&)),this, - SLOT(InsertCompletion(const QString&))); + SLOT(InsertPathCompletion(const QString&))); connect(path_completer_,SIGNAL(recomplete(const QString&)),this, SLOT(Recomplete(const QString&))); connect(this,SIGNAL(RequestPathCompletion(const QRect&,bool)),path_completer_, @@ -361,6 +361,13 @@ void PythonShellWidget::InsertCompletion(const QString& completion) tc.insertText(completion); setTextCursor(tc); } +void PythonShellWidget::InsertPathCompletion(const QString& completion) +{ + InsertCompletion(completion); + if(QFileInfo(completion).isDir()){ + textCursor().insertText(QDir::separator()); + } +} void PythonShellWidget::AppendOutput(unsigned int id,const QString& output) diff --git a/modules/gui/src/python_shell/python_shell_widget.hh b/modules/gui/src/python_shell/python_shell_widget.hh index 233279982..3bcb20f77 100644 --- a/modules/gui/src/python_shell/python_shell_widget.hh +++ b/modules/gui/src/python_shell/python_shell_widget.hh @@ -67,6 +67,7 @@ signals: public slots: void InsertCompletion(const QString& completion); + void InsertPathCompletion(const QString& completion); void AppendOutput(unsigned int id,const QString& output); void AppendError(unsigned int id,const QString& output); void OutputFinished(unsigned int id, bool error); -- GitLab