Libkdepim

emailvalidator.cpp
1 /*
2  Copyright (C) 2010 Casey Link <[email protected]>
3  Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <[email protected]>
4 
5  This library is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or (at your
8  option) any later version.
9 
10  This library is distributed in the hope that it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13  License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to the
17  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301, USA.
19 */
20 
21 #include "emailvalidator.h"
22 
23 #include <KEmailAddress>
24 #include <QRegularExpression>
25 
26 using namespace KPIM;
27 
28 EmailValidator::EmailValidator(QObject *parent) : QValidator(parent)
29 {
30 }
31 
32 QValidator::State EmailValidator::validate(QString &str, int &pos) const
33 {
34  Q_UNUSED(pos);
35 
37  return QValidator::Acceptable;
38  }
39  QRegularExpression re(QStringLiteral("\\s"));
40  QRegularExpressionMatch match = re.match(str);
41  if (match.hasMatch()) {
42  return QValidator::Invalid;
43  }
44  return QValidator::Intermediate;
45 }
46 
47 void EmailValidator::fixup(QString &str) const
48 {
49  str = str.trimmed();
50 }
KCODECS_EXPORT bool isValidSimpleAddress(const QString &aStr)
QString trimmed() const const
QPoint pos() const const
bool hasMatch() const const
Class KCheckComboBox::Private.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun May 31 2020 22:39:20 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.