Regexp validator

This commit is contained in:
Aditya Kulkarni 2018-11-22 08:31:35 -08:00
parent 0871eb38e6
commit 533dead402
4 changed files with 10 additions and 0 deletions

View File

@ -98,6 +98,9 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) {
ab.setupUi(&d);
Settings::saveRestore(&d);
QRegExpValidator v(QRegExp(Settings::labelRegExp), ab.label);
ab.label->setValidator(&v);
AddressBookModel model(ab.addresses);
ab.addresses->setModel(&model);

View File

@ -1045,6 +1045,10 @@ void MainWindow::setupRecieveTab() {
}
});
// Validator for label
QRegExpValidator* v = new QRegExpValidator(QRegExp(Settings::labelRegExp), ui->rcvLabel);
ui->rcvLabel->setValidator(v);
// Select item in address list
QObject::connect(ui->listRecieveAddresses,
QOverload<int>::of(&QComboBox::currentIndexChanged), [=] (int index) {

View File

@ -204,3 +204,4 @@ bool Settings::isValidAddress(QString addr) {
ztsexp.exactMatch(addr) || zsexp.exactMatch(addr);
}
const QString Settings::labelRegExp("[a-zA-Z0-9\\-_]{0,40}");

View File

@ -73,6 +73,8 @@ public:
static bool isValidAddress(QString addr);
static const QString labelRegExp;
static const int updateSpeed = 20 * 1000; // 20 sec
static const int quickUpdateSpeed = 5 * 1000; // 5 sec
static const int priceRefreshSpeed = 60 * 60 * 1000; // 1 hr