From a89153adc8e5d4548913c01271ba585fb4dd2a92 Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Sat, 7 Mar 2015 17:47:29 +0300 Subject: [PATCH] Better EEPROM input validation --- eepromwindow.cpp | 5 ++--- mainwindow.cpp | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/eepromwindow.cpp b/eepromwindow.cpp index bf08766..7ef6151 100644 --- a/eepromwindow.cpp +++ b/eepromwindow.cpp @@ -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); diff --git a/mainwindow.cpp b/mainwindow.cpp index 77f5db0..c02146e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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);