Akonadi Contacts

emailaddressselection.cpp
1 /*
2  This file is part of Akonadi Contact.
3 
4  SPDX-FileCopyrightText: 2010 KDAB
5  SPDX-FileContributor: Tobias Koenig <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #include "emailaddressselection.h"
11 #include "emailaddressselection_p.h"
12 
13 #include <kcontacts/contactgroup.h>
14 #include <kmime/kmime_header_parsing.h>
15 
16 using namespace Akonadi;
17 
18 EmailAddressSelection::Private::Private()
19  : QSharedData()
20 {
21 }
22 
23 EmailAddressSelection::Private::Private(const Private &other)
24  : QSharedData(other)
25 {
26  mName = other.mName;
27  mEmailAddress = other.mEmailAddress;
28  mItem = other.mItem;
29 }
30 
32  : d(new Private)
33 {
34 }
35 
37  : d(other.d)
38 {
39 }
40 
42 {
43  if (this != &other) {
44  d = other.d;
45  }
46 
47  return *this;
48 }
49 
51 {
52 }
53 
55 {
56  return d->mItem.isValid();
57 }
58 
60 {
61  return d->mName;
62 }
63 
65 {
66  return d->mEmailAddress;
67 }
68 
70 {
71  if (d->mItem.hasPayload<KContacts::ContactGroup>()) {
72  if (d->mEmailAddress == d->mName) {
73  return d->mName;
74  }
75  }
76 
77  KMime::Types::Mailbox mailbox;
78  mailbox.setAddress(d->mEmailAddress.toUtf8());
79  mailbox.setName(d->mName);
80 
82 }
83 
85 {
86  return d->mItem;
87 }
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-2021 The KDE developers.
Generated on Wed Jun 23 2021 23:09:24 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.