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>
14 #include <KMime/HeaderParsing>
15 
16 using namespace Akonadi;
17 
18 EmailAddressSelectionPrivate::EmailAddressSelectionPrivate()
19  : QSharedData()
20 {
21 }
22 
23 EmailAddressSelectionPrivate::EmailAddressSelectionPrivate(const EmailAddressSelectionPrivate &other)
24  : QSharedData(other)
25 {
26  mName = other.mName;
27  mEmailAddress = other.mEmailAddress;
28  mItem = other.mItem;
29 }
30 
32  : d(new EmailAddressSelectionPrivate)
33 {
34 }
35 
37 
38  = default;
39 
41 {
42  if (this != &other) {
43  d = other.d;
44  }
45 
46  return *this;
47 }
48 
50 
52 {
53  return d->mItem.isValid();
54 }
55 
57 {
58  return d->mName;
59 }
60 
62 {
63  return d->mEmailAddress;
64 }
65 
67 {
68  if (d->mItem.hasPayload<KContacts::ContactGroup>()) {
69  if (d->mEmailAddress == d->mName) {
70  return d->mName;
71  }
72  }
73 
74  KMime::Types::Mailbox mailbox;
75  mailbox.setAddress(d->mEmailAddress.toUtf8());
76  mailbox.setName(d->mName);
77 
79 }
80 
82 {
83  return d->mItem;
84 }
An selection of an email address and corresponding name.
~EmailAddressSelection()
Destroys the email address selection.
EmailAddressSelection & operator=(const EmailAddressSelection &other)
Replaces this email address selection with the other selection.
QString name() const
Returns the name that is associated with the selected email address.
Akonadi::Item item() const
Returns the Akonadi item that is associated with the selected email address.
EmailAddressSelection()
Creates a new email address selection.
void setName(const QString &name)
void setAddress(const AddrSpec &addr)
QString quotedEmail() const
Returns the name and email address together, properly quoted if needed.
QString email() const
Returns the address part of the selected email address.
bool isValid() const
Returns whether the selection is valid.
QString prettyAddress(Quoting quoting=QuoteNever) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 03:57:18 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.