Better EEPROM input validation

This commit is contained in:
NeoTheFox 2015-03-07 17:47:29 +03:00
parent d50d077508
commit a89153adc8
2 changed files with 7 additions and 4 deletions

View File

@ -40,19 +40,18 @@ EEPROMWindow::EEPROMWindow(QStringList eepromLines, QWidget *parent) :
edit->setObjectName("e"+QString::number(j));
QIntValidator *intvalidator = new QIntValidator(this);
QRegExpValidator *doublevalidator = new QRegExpValidator(
QRegExp("^\\-?\\d+\\.?\\d+(e\\-?\\d+)?$",
Qt::CaseInsensitive), this);
intvalidator->setLocale(QLocale::English);
doublevalidator->setLocale(QLocale::English);
switch(currentLine.T) // set right validator for the line
{
case 0:
edit->setValidator(new QIntValidator(-128, 255, this));
case 1:
case 2:
edit->setValidator(intvalidator);
edit->setValidator(new QIntValidator(this));
break;
case 3:
edit->setValidator(doublevalidator);

View File

@ -140,7 +140,11 @@ void MainWindow::open()
if(!recentFiles.contains(filename))
{
if(recentFiles.size() < 5) recentFiles.append(filename);
else recentFiles.push_front(filename);
else
{
recentFiles.push_front(filename);
recentFiles.removeAt(5);
}
}
parseFile(gfile);