#include <QtGui>
#include "IdDoAutomovelDialog.h"
IdDoAutomovelDialog
:: IdDoAutomovelDialog(QWidget *parent
) : QDialog(parent
){ setupUi(this);
//Validar a matrÃ*cula introduzida ( http://pt.wikipedia.org/wiki/Matr%C3%ADculas_autom%C3%B3veis_em_Portugal )
listaMatriculasValidas->operator <<("[A-Za-z]{2,2}-[0-9]{2,2}-[0-9]{2,2}");
listaMatriculasValidas->operator <<("[0-9]{2,2}-[0-9]{2,2}-[A-Za-z]{2,2}");
listaMatriculasValidas->operator <<("[0-9]{2,2}-[A-Za-z]{2,2}-[0-9]{2,2}");
QRegExp regExp
(listaMatriculasValidas
->join
("|"));
//Definir acções
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
void IdDoAutomovelDialog::on_lineEdit_textChanged(){
okButton->setEnabled(lineEdit->hasAcceptableInput());
////////////////////////////
// //
// X marks the spot
// //
////////////////////////////
//Limpar chapa
labelDescSerie->setText("?");
//Verificar qual a série de matrÃ*cula
newlineEdit.setText(lineEdit->text());
serie.setPattern("[A-Za-z]{2,2}-[0-9]{2,2}-[0-9]{2,2}");
//Chapa de modelo anterior a 1992
newlineEdit.setValidator(&validator);
if(newlineEdit.hasAcceptableInput())
labelDescSerie->setText("Chapa de modelo anterior a 1992");
//Chapa de modelo utilizado entre 1992 e 2005
serie.setPattern("[0-9]{2,2}-[0-9]{2,2}-[A-Za-z]{2,2}");
validator.setRegExp(serie);
if(newlineEdit.hasAcceptableInput())
labelDescSerie->setText("Chapa de modelo utilizado entre 1992 e 2005");
//Chapa de modelo posterior a 2005
serie.setPattern("[0-9]{2,2}-[A-Za-z]{2,2}-[0-9]{2,2}");
validator.setRegExp(serie);
if(newlineEdit.hasAcceptableInput())
labelDescSerie->setText("Chapa de modelo posterior a 2005");
}
#include <QtGui>
#include "IdDoAutomovelDialog.h"
IdDoAutomovelDialog:: IdDoAutomovelDialog(QWidget *parent) : QDialog(parent){
setupUi(this);
//Validar a matrÃ*cula introduzida ( http://pt.wikipedia.org/wiki/Matr%C3%ADculas_autom%C3%B3veis_em_Portugal )
QStringList *listaMatriculasValidas = new QStringList;
listaMatriculasValidas->operator <<("[A-Za-z]{2,2}-[0-9]{2,2}-[0-9]{2,2}");
listaMatriculasValidas->operator <<("[0-9]{2,2}-[0-9]{2,2}-[A-Za-z]{2,2}");
listaMatriculasValidas->operator <<("[0-9]{2,2}-[A-Za-z]{2,2}-[0-9]{2,2}");
QRegExp regExp(listaMatriculasValidas->join("|"));
lineEdit->setValidator(new QRegExpValidator(regExp, this));
//Definir acções
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
void IdDoAutomovelDialog::on_lineEdit_textChanged(){
okButton->setEnabled(lineEdit->hasAcceptableInput());
////////////////////////////
// //
// X marks the spot
// //
////////////////////////////
//Limpar chapa
labelDescSerie->setText("?");
//Verificar qual a série de matrÃ*cula
QLineEdit newlineEdit;
newlineEdit.setText(lineEdit->text());
QRegExp serie;
serie.setPattern("[A-Za-z]{2,2}-[0-9]{2,2}-[0-9]{2,2}");
QRegExpValidator validator(serie,this);
//Chapa de modelo anterior a 1992
newlineEdit.setValidator(&validator);
if(newlineEdit.hasAcceptableInput())
labelDescSerie->setText("Chapa de modelo anterior a 1992");
//Chapa de modelo utilizado entre 1992 e 2005
serie.setPattern("[0-9]{2,2}-[0-9]{2,2}-[A-Za-z]{2,2}");
validator.setRegExp(serie);
if(newlineEdit.hasAcceptableInput())
labelDescSerie->setText("Chapa de modelo utilizado entre 1992 e 2005");
//Chapa de modelo posterior a 2005
serie.setPattern("[0-9]{2,2}-[A-Za-z]{2,2}-[0-9]{2,2}");
validator.setRegExp(serie);
if(newlineEdit.hasAcceptableInput())
labelDescSerie->setText("Chapa de modelo posterior a 2005");
}
To copy to clipboard, switch view to plain text mode
Bookmarks