akonadi/contact
emailaddressselection.cpp
00001 /* 00002 This file is part of Akonadi Contact. 00003 00004 Copyright (c) 2010 KDAB 00005 Author: Tobias Koenig <tokoe@kde.org> 00006 00007 This library is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU Library General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or (at your 00010 option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00015 License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to the 00019 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00020 02110-1301, USA. 00021 */ 00022 00023 #include "emailaddressselection.h" 00024 #include "emailaddressselection_p.h" 00025 00026 #include <kabc/contactgroup.h> 00027 #include <kmime/kmime_header_parsing.h> 00028 00029 using namespace Akonadi; 00030 00031 EmailAddressSelection::Private::Private() 00032 : QSharedData() 00033 { 00034 } 00035 00036 EmailAddressSelection::Private::Private( const Private &other ) 00037 : QSharedData( other ) 00038 { 00039 mName = other.mName; 00040 mEmailAddress = other.mEmailAddress; 00041 mItem = other.mItem; 00042 } 00043 00044 00045 EmailAddressSelection::EmailAddressSelection() 00046 : d( new Private ) 00047 { 00048 } 00049 00050 EmailAddressSelection::EmailAddressSelection( const EmailAddressSelection &other ) 00051 : d( other.d ) 00052 { 00053 } 00054 00055 EmailAddressSelection& EmailAddressSelection::operator=( const EmailAddressSelection &other ) 00056 { 00057 if ( this != &other ) 00058 d = other.d; 00059 00060 return *this; 00061 } 00062 00063 EmailAddressSelection::~EmailAddressSelection() 00064 { 00065 } 00066 00067 bool EmailAddressSelection::isValid() const 00068 { 00069 return d->mItem.isValid(); 00070 } 00071 00072 QString EmailAddressSelection::name() const 00073 { 00074 return d->mName; 00075 } 00076 00077 QString EmailAddressSelection::email() const 00078 { 00079 return d->mEmailAddress; 00080 } 00081 00082 QString EmailAddressSelection::quotedEmail() const 00083 { 00084 if ( d->mItem.hasPayload<KABC::ContactGroup>() ) { 00085 if ( d->mEmailAddress == d->mName ) 00086 return d->mName; 00087 } 00088 00089 KMime::Types::Mailbox mailbox; 00090 mailbox.setAddress( d->mEmailAddress.toUtf8() ); 00091 mailbox.setName( d->mName ); 00092 00093 return mailbox.prettyAddress( KMime::Types::Mailbox::QuoteWhenNecessary ); 00094 } 00095 00096 Akonadi::Item EmailAddressSelection::item() const 00097 { 00098 return d->mItem; 00099 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu May 10 2012 22:19:26 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu May 10 2012 22:19:26 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.