File indexing completed on 2024-11-24 04:39:32
0001 /* 0002 This file is part of Contact Editor. 0003 0004 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #include "utils.h" 0010 0011 #include <KContacts/Addressee> 0012 0013 void Akonadi::Utils::splitCustomField(const QString &str, QString &app, QString &name, QString &value) 0014 { 0015 const int colon = str.indexOf(QLatin1Char(':')); 0016 if (colon != -1) { 0017 const QString tmp = str.left(colon); 0018 value = str.mid(colon + 1); 0019 0020 const int dash = tmp.indexOf(QLatin1Char('-')); 0021 if (dash != -1) { 0022 app = tmp.left(dash); 0023 name = tmp.mid(dash + 1); 0024 } 0025 } 0026 } 0027 0028 QString Akonadi::Utils::loadCustom(const KContacts::Addressee &contact, const QString &key) 0029 { 0030 return contact.custom(QStringLiteral("KADDRESSBOOK"), key); 0031 } 0032 0033 void Akonadi::Utils::storeCustom(KContacts::Addressee &contact, const QString &key, const QString &value) 0034 { 0035 if (value.isEmpty()) { 0036 contact.removeCustom(QStringLiteral("KADDRESSBOOK"), key); 0037 } else { 0038 contact.insertCustom(QStringLiteral("KADDRESSBOOK"), key, value); 0039 } 0040 }