Akonadi Contacts

emailaddressselection.cpp
1 /*
2  This file is part of Akonadi Contact.
3 
4  Copyright (c) 2010 KDAB
5  Author: Tobias Koenig <[email protected]>
6 
7  This library is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Library General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version.
11 
12  This library is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15  License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to the
19  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  02110-1301, USA.
21 */
22 
23 #include "emailaddressselection.h"
24 #include "emailaddressselection_p.h"
25 
26 #include <kcontacts/contactgroup.h>
27 #include <kmime/kmime_header_parsing.h>
28 
29 using namespace Akonadi;
30 
31 EmailAddressSelection::Private::Private()
32  : QSharedData()
33 {
34 }
35 
36 EmailAddressSelection::Private::Private(const Private &other)
37  : QSharedData(other)
38 {
39  mName = other.mName;
40  mEmailAddress = other.mEmailAddress;
41  mItem = other.mItem;
42 }
43 
45  : d(new Private)
46 {
47 }
48 
50  : d(other.d)
51 {
52 }
53 
55 {
56  if (this != &other) {
57  d = other.d;
58  }
59 
60  return *this;
61 }
62 
64 {
65 }
66 
68 {
69  return d->mItem.isValid();
70 }
71 
73 {
74  return d->mName;
75 }
76 
78 {
79  return d->mEmailAddress;
80 }
81 
83 {
84  if (d->mItem.hasPayload<KContacts::ContactGroup>()) {
85  if (d->mEmailAddress == d->mName) {
86  return d->mName;
87  }
88  }
89 
90  KMime::Types::Mailbox mailbox;
91  mailbox.setAddress(d->mEmailAddress.toUtf8());
92  mailbox.setName(d->mName);
93 
95 }
96 
97 Akonadi::Item EmailAddressSelection::item() const
98 {
99  return d->mItem;
100 }
Akonadi::Item item() const
Returns the Akonadi item that is associated with the selected email address.
An selection of an email address and corresponding name.
QString name() const
Returns the name that is associated with the selected email address.
EmailAddressSelection()
Creates a new email address selection.
QString prettyAddress(Quoting quoting=QuoteNever) const
EmailAddressSelection & operator=(const EmailAddressSelection &other)
Replaces this email address selection with the other selection.
bool isValid() const
Returns whether the selection is valid.
~EmailAddressSelection()
Destroys the email address selection.
void setAddress(const AddrSpec &addr)
QString email() const
Returns the address part of the selected email address.
QString quotedEmail() const
Returns the name and email address together, properly quoted if needed.
void setName(const QString &name)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 5 2020 23:05:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.