Libksieve

lineeditvalidator.cpp
1 /*
2  SPDX-FileCopyrightText: 2017-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "lineeditvalidator.h"
8 #include <QRegularExpression>
9 #include <QRegularExpressionValidator>
10 
11 using namespace KSieveUi;
12 
13 LineEditValidator::LineEditValidator(QWidget *parent)
14  : QLineEdit(parent)
15 {
16  initialize();
17 }
18 
19 LineEditValidator::~LineEditValidator()
20 {
21 }
22 
23 void LineEditValidator::initialize()
24 {
25  QRegularExpression rx(QStringLiteral("^[^\"]*$"));
26  mValidator = new QRegularExpressionValidator(rx, this);
27  setValidator(mValidator);
28 }
29 
30 bool LineEditValidator::setRegularExpressionPattern(const QString &pattern)
31 {
32  QRegularExpression rx(pattern);
33  if (rx.isValid()) {
34  delete mValidator;
35  mValidator = new QRegularExpressionValidator(rx, this);
36  setValidator(mValidator);
37  return true;
38  }
39  return false;
40 }
KCRASH_EXPORT void initialize()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 11 2021 23:09:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.