check autotype syntax, high repetion, reformat code

TODO: specify what should happen when autotypesyntax incorrect
This commit is contained in:
Marco 2017-05-14 18:25:43 +02:00 committed by thez3ro
parent 45cb97ec85
commit 4fcedc2187
No known key found for this signature in database
GPG key ID: F628F9E41DD7C073
2 changed files with 66 additions and 49 deletions

View file

@ -764,6 +764,20 @@ void EditEntryWidget::updateEntryData(Entry* entry) const
entry->setDefaultAutoTypeSequence(QString());
}
else {
QRegExp autoTypeSyntax("(\\{[A-Z]*(\\s[0-9]*){0,1}\\})*");
autoTypeSyntax.setCaseSensitivity(Qt::CaseInsensitive);
autoTypeSyntax.setPatternSyntax(QRegExp::RegExp);
QRegExp highRepetition(".*[0-9]{3,}.*"); //the 3 means 3 digitnumbers are too much
highRepetition.setPatternSyntax(QRegExp::RegExp);
if (!autoTypeSyntax.exactMatch(m_autoTypeUi->sequenceEdit->text())) {
//@TODO handle wrong syntax
}
if (!highRepetition.exactMatch(m_autoTypeUi->sequenceEdit->text())) {
//@TODO handle too much repetition
}
entry->setDefaultAutoTypeSequence(m_autoTypeUi->sequenceEdit->text());
}