Akonadi Contacts

emailaddressselection.cpp
1/*
2 This file is part of Akonadi Contact.
3
4 SPDX-FileCopyrightText: 2010 KDAB
5 SPDX-FileContributor: Tobias Koenig <tokoe@kde.org>
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
16using namespace Akonadi;
17
18EmailAddressSelectionPrivate::EmailAddressSelectionPrivate()
19 : QSharedData()
20{
21}
22
23EmailAddressSelectionPrivate::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
39{
40 if (this != &other) {
41 d = other.d;
42 }
43
44 return *this;
45}
46
48
50{
51 return d->mItem.isValid();
52}
53
55{
56 return d->mName;
57}
58
59void EmailAddressSelection::setName(const QString &name)
60{
61 d->mName = name;
62}
63
65{
66 return d->mEmailAddress;
67}
68
69void EmailAddressSelection::setEmail(const QString &email)
70{
71 d->mEmailAddress = email;
72}
73
75{
76 if (d->mItem.hasPayload<KContacts::ContactGroup>()) {
77 if (d->mEmailAddress == d->mName) {
78 return d->mName;
79 }
80 }
81
83 mailbox.setAddress(d->mEmailAddress.toUtf8());
84 mailbox.setName(d->mName);
85
87}
88
90{
91 return d->mItem;
92}
93
94void EmailAddressSelection::setItem(const Item &item)
95{
96 d->mItem = item;
97}
An selection of an email address and corresponding name.
~EmailAddressSelection()
Destroys the email address selection.
Akonadi::Item item() const
Returns the Akonadi item that is associated with the selected email address.
QString quotedEmail() const
Returns the name and email address together, properly quoted if needed.
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.
EmailAddressSelection()
Creates a new email address selection.
QString email() const
Returns the address part of the selected email address.
bool isValid() const
Returns whether the selection is valid.
void setName(const QString &name)
QString prettyAddress(Quoting quoting=QuoteNever) const
void setAddress(const AddrSpec &addr)
A widget for editing the display name of a contact.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:20 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.