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
6namespace KIdentityManagementQuick
7{
8IdentityEditorBackend::Mode IdentityEditorBackend::mode() const
9{
10 return mMode;
11}
12
13void IdentityEditorBackend::setMode(Mode mode)
14{
15 if (mMode == mode) {
16 return;
17 }
18
19 mMode = mode;
20 Q_EMIT modeChanged();
21}
22
23KIdentityManagementCore::Identity IdentityEditorBackend::identity() const
24{
25 return mIdentity;
26}
27
28void IdentityEditorBackend::setIdentity(const KIdentityManagementCore::Identity &identity)
29{
30 if (mIdentity == identity) {
31 return;
32 }
33
34 mIdentity = identity;
35 Q_EMIT identityChanged();
36}
37
38uint IdentityEditorBackend::identityUoid() const
39{
40 return mIdentity.uoid();
41}
42
43void IdentityEditorBackend::setIdentityUoid(uint identityUoid)
44{
45 if (mIdentity.uoid() == identityUoid) {
46 return;
47 }
48
49 const auto &identity = mIdentityManager->modifyIdentityForUoid(identityUoid);
50 setIdentity(identity);
51}
52
53void IdentityEditorBackend::saveIdentity(const KIdentityManagementCore::Identity &modifiedIdentity)
54{
55 mIdentityManager->saveIdentity(modifiedIdentity);
56}
57
58void IdentityEditorBackend::addEmailAlias(const QString &alias)
59{
60 auto aliases = mIdentity.emailAliases();
61 aliases.append(alias);
62 mIdentity.setEmailAliases(aliases);
63}
64
65void IdentityEditorBackend::modifyEmailAlias(const QString &originalAlias, const QString &modifiedAlias)
66{
67 auto aliases = mIdentity.emailAliases();
68 std::replace(aliases.begin(), aliases.end(), originalAlias, modifiedAlias);
69 mIdentity.setEmailAliases(aliases);
70}
71
72void IdentityEditorBackend::removeEmailAlias(const QString &alias)
73{
74 auto aliases = mIdentity.emailAliases();
75 aliases.removeAll(alias);
76 mIdentity.setEmailAliases(aliases);
77}
78}
79
80#include "moc_identityeditorbackend.cpp"
Identity & modifyIdentityForUoid(uint uoid)
void saveIdentity(const Identity &ident)
Store a new identity or modify an existing identity based on an independent identity object.
User identity information.
Definition identity.h:74
void append(QList< T > &&value)
qsizetype removeAll(const AT &t)
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:04:54 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.