Libksieve

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

KDE's Doxygen guidelines are available online.