forked from osmocom/wireshark
Qt: Construct QRegExp only once
In Interface Toolbar lineedit the QRegExp only needs to be constructed once, not for every validity check. Change-Id: I39e9ab9c57b4ac64a0b9b601fa72646d8c420274 Reviewed-on: https://code.wireshark.org/review/23425 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
parent
b57010039b
commit
d38197bb67
|
@ -33,7 +33,7 @@
|
|||
|
||||
InterfaceToolbarLineEdit::InterfaceToolbarLineEdit(QWidget *parent, QString validation_regex, bool is_required) :
|
||||
QLineEdit(parent),
|
||||
validation_regex_(validation_regex),
|
||||
regex_expr_(validation_regex),
|
||||
is_required_(is_required),
|
||||
text_edited_(false)
|
||||
{
|
||||
|
@ -95,10 +95,9 @@ bool InterfaceToolbarLineEdit::isValid()
|
|||
valid = false;
|
||||
}
|
||||
|
||||
if (!validation_regex_.isEmpty() && text().length() > 0)
|
||||
if (!regex_expr_.isEmpty() && text().length() > 0)
|
||||
{
|
||||
QRegExp expr(validation_regex_);
|
||||
if (!expr.isValid() || expr.indexIn(text(), 0) == -1)
|
||||
if (!regex_expr_.isValid() || regex_expr_.indexIn(text(), 0) == -1)
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
void updateStyleSheet(bool is_valid);
|
||||
|
||||
StockIconToolButton *apply_button_;
|
||||
QString validation_regex_;
|
||||
QRegExp regex_expr_;
|
||||
bool is_required_;
|
||||
bool text_edited_;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue