Skip to content

Commit

Permalink
fix #1376
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9532 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Oct 24, 2008
1 parent b182a5e commit b564b8c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
43 changes: 42 additions & 1 deletion src/app/qgspythondialog.cpp
Expand Up @@ -30,6 +30,8 @@ QgsPythonDialog::QgsPythonDialog( QgisInterface* pIface, QgsPythonUtils* pythonU
#endif
mIface = pIface;
mPythonUtils = pythonUtils;

pos = 0;
}

QgsPythonDialog::~QgsPythonDialog()
Expand All @@ -41,11 +43,50 @@ QString QgsPythonDialog::escapeHtml( QString text )
return text.replace( "<", "&lt;" ).replace( ">", "&gt;" );
}

void QgsPythonDialog::keyPressEvent( QKeyEvent *ev )
{
switch( ev->key() )
{
case Qt::Key_Up:
{
if(pos>0)
{
if( pos==history.size() )
history << edtCmdLine->text();
else
history[pos] = edtCmdLine->text();
pos--;
edtCmdLine->setText(history[pos]);
}
}
break;
case Qt::Key_Down:
{
if( pos<history.size()-1 )
{
history[pos] = edtCmdLine->text();
pos++;
edtCmdLine->setText(history[pos]);
}
}
break;
default:
QWidget::keyPressEvent(ev);
break;
}
}

void QgsPythonDialog::on_edtCmdLine_returnPressed()
{
QString command = edtCmdLine->text();
QString output;

if( !command.isEmpty() )
{
history << command;
pos = history.size();
}

QString output;

// when using Py_single_input the return value will be always null
// we're using custom hooks for output and exceptions to show output in console
Expand Down
8 changes: 6 additions & 2 deletions src/app/qgspythondialog.h
Expand Up @@ -41,13 +41,17 @@ class QgsPythonDialog : public QDialog, private Ui::QgsPythonDialog

protected:

void closeEvent( QCloseEvent* event );
void showEvent( QShowEvent* event );
void keyPressEvent( QKeyEvent *event );
void closeEvent( QCloseEvent *event );
void showEvent( QShowEvent *event );

private:

QgisInterface* mIface;
QgsPythonUtils* mPythonUtils;

QStringList history;
int pos;
};

#endif

0 comments on commit b564b8c

Please sign in to comment.