Skip to content

Commit e8d1090

Browse files
author
jef
committedOct 24, 2008
fix #1376
git-svn-id: http://svn.osgeo.org/qgis/trunk@9532 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 4daf5e4 commit e8d1090

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed
 

‎src/app/qgspythondialog.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ QgsPythonDialog::QgsPythonDialog( QgisInterface* pIface, QgsPythonUtils* pythonU
3030
#endif
3131
mIface = pIface;
3232
mPythonUtils = pythonUtils;
33+
34+
pos = 0;
3335
}
3436

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

46+
void QgsPythonDialog::keyPressEvent( QKeyEvent *ev )
47+
{
48+
switch( ev->key() )
49+
{
50+
case Qt::Key_Up:
51+
{
52+
if(pos>0)
53+
{
54+
if( pos==history.size() )
55+
history << edtCmdLine->text();
56+
else
57+
history[pos] = edtCmdLine->text();
58+
pos--;
59+
edtCmdLine->setText(history[pos]);
60+
}
61+
}
62+
break;
63+
case Qt::Key_Down:
64+
{
65+
if( pos<history.size()-1 )
66+
{
67+
history[pos] = edtCmdLine->text();
68+
pos++;
69+
edtCmdLine->setText(history[pos]);
70+
}
71+
}
72+
break;
73+
default:
74+
QWidget::keyPressEvent(ev);
75+
break;
76+
}
77+
}
78+
4479
void QgsPythonDialog::on_edtCmdLine_returnPressed()
4580
{
4681
QString command = edtCmdLine->text();
47-
QString output;
4882

83+
if( !command.isEmpty() )
84+
{
85+
history << command;
86+
pos = history.size();
87+
}
88+
89+
QString output;
4990

5091
// when using Py_single_input the return value will be always null
5192
// we're using custom hooks for output and exceptions to show output in console

‎src/app/qgspythondialog.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@ class QgsPythonDialog : public QDialog, private Ui::QgsPythonDialog
4141

4242
protected:
4343

44-
void closeEvent( QCloseEvent* event );
45-
void showEvent( QShowEvent* event );
44+
void keyPressEvent( QKeyEvent *event );
45+
void closeEvent( QCloseEvent *event );
46+
void showEvent( QShowEvent *event );
4647

4748
private:
4849

4950
QgisInterface* mIface;
5051
QgsPythonUtils* mPythonUtils;
52+
53+
QStringList history;
54+
int pos;
5155
};
5256

5357
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.