• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

kpimutils

  • sources
  • kde-4.14
  • kdepimlibs
  • kpimutils
emailvalidator.cpp
1 /*
2  Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com>
3  Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
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 #include "email.h"
23 
24 using namespace KPIMUtils;
25 
26 EmailValidator::EmailValidator( QObject *parent ) : QValidator( parent )
27 {
28 }
29 
30 QValidator::State EmailValidator::validate( QString &str, int &pos ) const
31 {
32  Q_UNUSED( pos );
33 
34  if ( KPIMUtils::isValidSimpleAddress( str ) ) {
35  return QValidator::Acceptable;
36  }
37 
38  // we'll say any string that doesn't have whitespace
39  // is an intermediate email string
40  if ( QRegExp( QLatin1String("\\s") ).indexIn( str ) > -1 ) {
41  return QValidator::Invalid;
42  }
43 
44  return QValidator::Intermediate;
45 }
46 
47 void EmailValidator::fixup( QString &str ) const
48 {
49  str = str.trimmed();
50 }
KPIMUtils::isValidSimpleAddress
bool isValidSimpleAddress(const QString &aStr)
Validates an email address in the form of joe@example.org.
Definition: email.cpp:609
QRegExp
email.h
This file is part of the KDEPIM Utilities library and provides static methods for email address valid...
QObject
QString::trimmed
QString trimmed() const
QString
QLatin1String
QValidator
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:37:25 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kpimutils

Skip menu "kpimutils"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal