added eventFilters and changed the behaviour of the return-key-pressed

This commit is contained in:
nemu 2009-04-20 07:46:50 +00:00
parent 01ee7c0196
commit 61f6fd1b9c
5 changed files with 32 additions and 2 deletions

View File

@ -33,6 +33,7 @@
#include <qlineedit.h> #include <qlineedit.h>
#include <qmessagebox.h> #include <qmessagebox.h>
#include <qregexp.h> #include <qregexp.h>
#include <qevent.h>
#include "PGetFunctionsBlockDialog.h" #include "PGetFunctionsBlockDialog.h"

View File

@ -44,6 +44,9 @@
*/ */
PGetPlotDialog::PGetPlotDialog() PGetPlotDialog::PGetPlotDialog()
{ {
// setup event filter
installEventFilter(this);
fXRangeLow_lineEdit->setValidator( new QDoubleValidator(fXRangeLow_lineEdit) ); fXRangeLow_lineEdit->setValidator( new QDoubleValidator(fXRangeLow_lineEdit) );
fXRangeUp_lineEdit->setValidator( new QDoubleValidator(fXRangeUp_lineEdit) ); fXRangeUp_lineEdit->setValidator( new QDoubleValidator(fXRangeUp_lineEdit) );
fYRangeLow_lineEdit->setValidator( new QDoubleValidator(fYRangeLow_lineEdit) ); fYRangeLow_lineEdit->setValidator( new QDoubleValidator(fYRangeLow_lineEdit) );
@ -144,6 +147,29 @@ void PGetPlotDialog::addPlot()
fRunList_lineEdit->setFocus(); fRunList_lineEdit->setFocus();
} }
//----------------------------------------------------------------------------------------------------
/**
* <p>This event filter is filtering out the return key, and if present adds the current plot.
*/
bool PGetPlotDialog::eventFilter( QObject *obj, QEvent *ev )
{
if (obj == this) {
if (ev->type() == QEvent::KeyPress) {
QKeyEvent *k = (QKeyEvent*)ev;
if (k->key() == Qt::Key_Return) {
addPlot();
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// END // END
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------

View File

@ -43,6 +43,9 @@ class PGetPlotDialog : public PGetPlotDialogBase
public slots: public slots:
void addPlot(); void addPlot();
protected:
bool eventFilter( QObject *obj, QEvent *ev );
}; };
#endif // _PGETPLOTDIALOG_H_ #endif // _PGETPLOTDIALOG_H_

View File

@ -240,7 +240,7 @@ FUNCTIONS
<connections> <connections>
<connection> <connection>
<sender>buttonOk</sender> <sender>buttonOk</sender>
<signal>clicked()</signal> <signal>released()</signal>
<receiver>PGetFunctionsBlockDialogBase</receiver> <receiver>PGetFunctionsBlockDialogBase</receiver>
<slot>accept()</slot> <slot>accept()</slot>
</connection> </connection>

View File

@ -314,7 +314,7 @@
<connections> <connections>
<connection> <connection>
<sender>fOk_button</sender> <sender>fOk_button</sender>
<signal>clicked()</signal> <signal>released()</signal>
<receiver>PGetPlotDialogBase</receiver> <receiver>PGetPlotDialogBase</receiver>
<slot>accept()</slot> <slot>accept()</slot>
</connection> </connection>