• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

kpimutils

emailvalidator.cpp
00001 /*
00002   Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com>
00003   Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
00004 
00005   This library is free software; you can redistribute it and/or modify it
00006   under the terms of the GNU Library General Public License as published by
00007   the Free Software Foundation; either version 2 of the License, or (at your
00008   option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful, but WITHOUT
00011   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013   License for more details.
00014 
00015   You should have received a copy of the GNU Library General Public License
00016   along with this library; see the file COPYING.LIB.  If not, write to the
00017   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018   02110-1301, USA.
00019 */
00020 
00021 #include "emailvalidator.h"
00022 #include "email.h"
00023 
00024 using namespace KPIMUtils;
00025 
00026 EmailValidator::EmailValidator( QObject *parent ) : QValidator( parent )
00027 {
00028 }
00029 
00030 QValidator::State EmailValidator::validate( QString &str, int &pos ) const
00031 {
00032   Q_UNUSED( pos );
00033 
00034   if ( KPIMUtils::isValidSimpleAddress( str ) ) {
00035     return QValidator::Acceptable;
00036   }
00037 
00038   // we'll say any string that doesn't have whitespace
00039   // is an intermediate email string
00040   if ( QRegExp( "\\s" ).indexIn( str ) > -1 ) {
00041     return QValidator::Invalid;
00042   }
00043 
00044   return QValidator::Intermediate;
00045 }
00046 
00047 void EmailValidator::fixup( QString &str ) const
00048 {
00049   str = str.trimmed();
00050 }

kpimutils

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal