Akonadi Contacts

utils.cpp
1/*
2 This file is part of Contact Editor.
3
4 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#include "utils.h"
10
11#include <KContacts/Addressee>
12
13void Akonadi::Utils::splitCustomField(const QString &str, QString &app, QString &name, QString &value)
14{
15 const int colon = str.indexOf(QLatin1Char(':'));
16 if (colon != -1) {
17 const QString tmp = str.left(colon);
18 value = str.mid(colon + 1);
19
20 const int dash = tmp.indexOf(QLatin1Char('-'));
21 if (dash != -1) {
22 app = tmp.left(dash);
23 name = tmp.mid(dash + 1);
24 }
25 }
26}
27
28QString Akonadi::Utils::loadCustom(const KContacts::Addressee &contact, const QString &key)
29{
30 return contact.custom(QStringLiteral("KADDRESSBOOK"), key);
31}
32
33void Akonadi::Utils::storeCustom(KContacts::Addressee &contact, const QString &key, const QString &value)
34{
35 if (value.isEmpty()) {
36 contact.removeCustom(QStringLiteral("KADDRESSBOOK"), key);
37 } else {
38 contact.insertCustom(QStringLiteral("KADDRESSBOOK"), key, value);
39 }
40}
void insertCustom(const QString &app, const QString &name, const QString &value)
QString custom(const QString &app, const QString &name) const
void removeCustom(const QString &app, const QString &name)
QString name(StandardAction id)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
QString left(qsizetype n) const const
QString mid(qsizetype position, qsizetype n) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.