<commit_before>#include "boundtextbox.h"



#include <boost/foreach.hpp>

#include <QIntValidator>
#include <QDoubleValidator>
#include <QKeyEvent>

BoundTextBox::BoundTextBox(QWidget *parent) :
	QLineEdit(parent)
{
	_integer = NULL;
	_integerArray = NULL;
	_number = NULL;

	//connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEditedHandler(QString)));
}

void BoundTextBox::bindTo(Option *option)
{
	_integer = dynamic_cast<OptionInteger *>(option);

	if (_integer != NULL)
	{
		this->setValidator(new QIntValidator(this));
		this->setText(QString::number(_integer->value()));
		return;
	}

	_integerArray = dynamic_cast<OptionIntegerArray *>(option);

	if (_integerArray != NULL)
	{
		this->setValidator(new QIntArrayValidator());
		return;
	}

	_number = dynamic_cast<OptionNumber *>(option);

	if (_number != NULL)
	{
		this->setValidator(new QDoubleValidator(_number->min(), _number->max(), 4, this));
		this->setText(QString::number(_number->value()));
		return;
	}

}

void BoundTextBox::keyPressEvent(QKeyEvent *event)
{
	QLineEdit::keyPressEvent(event);
	if (event->key() == Qt::Key_Return)
		finalise();
}

void BoundTextBox::focusOutEvent(QFocusEvent *event)
{
	QLineEdit::focusOutEvent(event);
	finalise();
}

void BoundTextBox::finalise()
{
	QString value = text();

	while (value.endsWith(","))
		value = value.left(value.length() - 1);
<commit_msg>BoundTextBox now response to keypad enter<commit_after>#include "boundtextbox.h"



#include <boost/foreach.hpp>

#include <QIntValidator>
#include <QDoubleValidator>
#include <QKeyEvent>

BoundTextBox::BoundTextBox(QWidget *parent) :
	QLineEdit(parent)
{
	_integer = NULL;
	_integerArray = NULL;
	_number = NULL;

	//connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEditedHandler(QString)));
}

void BoundTextBox::bindTo(Option *option)
{
	_integer = dynamic_cast<OptionInteger *>(option);

	if (_integer != NULL)
	{
		this->setValidator(new QIntValidator(this));
		this->setText(QString::number(_integer->value()));
		return;
	}

	_integerArray = dynamic_cast<OptionIntegerArray *>(option);

	if (_integerArray != NULL)
	{
		this->setValidator(new QIntArrayValidator());
		return;
	}

	_number = dynamic_cast<OptionNumber *>(option);

	if (_number != NULL)
	{
		this->setValidator(new QDoubleValidator(_number->min(), _number->max(), 4, this));
		this->setText(QString::number(_number->value()));
		return;
	}

}

void BoundTextBox::keyPressEvent(QKeyEvent *event)
{
	QLineEdit::keyPressEvent(event);
	if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
		finalise();
}

void BoundTextBox::focusOutEvent(QFocusEvent *event)
{
	QLineEdit::focusOutEvent(event);
	finalise();
}

void BoundTextBox::finalise()
{
	QString value = text();

	while (value.endsWith(","))
		value = value.left(value.length() - 1);

{'fraction_non_alphanumeric': 0.16470588235294117, 'fraction_numerical': 0.00142602495543672, 'mean_word_length': 6.213367609254499, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5091639', 'n_tokens_mistral': 1006, 'n_tokens_neox': 954, 'n_words': 169}