KIdentityManagement

identityeditorbackend.cpp
1// SPDX-FileCopyrightText: 2023 Claudio Cambra <claudio.cambra@kde.org>
2// SPDX-License-Identifier: LGPL-2.0-or-later
3
4#include "identityeditorbackend.h"
5
6using namespace KIdentityManagementQuick;
7IdentityEditorBackend::Mode IdentityEditorBackend::mode() const
8{
9 return mMode;
10}
11
12void IdentityEditorBackend::setMode(Mode mode)
13{
14 if (mMode == mode) {
15 return;
16 }
17
18 mMode = mode;
19 Q_EMIT modeChanged();
20}
21
22KIdentityManagementCore::Identity IdentityEditorBackend::identity() const
23{
24 return mIdentity;
25}
26
27void IdentityEditorBackend::setIdentity(const KIdentityManagementCore::Identity &identity)
28{
29 if (mIdentity == identity) {
30 return;
31 }
32
33 mIdentity = identity;
34 Q_EMIT identityChanged();
35}
36
37uint IdentityEditorBackend::identityUoid() const
38{
39 return mIdentity.uoid();
40}
41
42void IdentityEditorBackend::setIdentityUoid(uint identityUoid)
43{
44 if (mIdentity.uoid() == identityUoid) {
45 return;
46 }
47
48 const auto &identity = mIdentityManager->modifyIdentityForUoid(identityUoid);
49 setIdentity(identity);
50}
51
52void IdentityEditorBackend::saveIdentity(const KIdentityManagementCore::Identity &modifiedIdentity)
53{
54 mIdentityManager->saveIdentity(modifiedIdentity);
55}
56
57void IdentityEditorBackend::addEmailAlias(const QString &alias)
58{
59 auto aliases = mIdentity.emailAliases();
60 aliases.append(alias);
61 mIdentity.setEmailAliases(aliases);
62}
63
64void IdentityEditorBackend::modifyEmailAlias(const QString &originalAlias, const QString &modifiedAlias)
65{
66 auto aliases = mIdentity.emailAliases();
67 std::replace(aliases.begin(), aliases.end(), originalAlias, modifiedAlias);
68 mIdentity.setEmailAliases(aliases);
69}
70
71void IdentityEditorBackend::removeEmailAlias(const QString &alias)
72{
73 auto aliases = mIdentity.emailAliases();
74 aliases.removeAll(alias);
75 mIdentity.setEmailAliases(aliases);
76}
77
78#include "moc_identityeditorbackend.cpp"
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Mar 28 2025 12:00:17 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.