00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 }