Akonadi Contacts

utils.cpp
1 /*
2  This file is part of Contact Editor.
3 
4  SPDX-FileCopyrightText: 2016-2021 Laurent Montel <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #include "utils.h"
10 
11 #include <KContacts/Addressee>
12 
13 void ContactEditor::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 
28 QString ContactEditor::Utils::loadCustom(const KContacts::Addressee &contact, const QString &key)
29 {
30  return contact.custom(QStringLiteral("KADDRESSBOOK"), key);
31 }
32 
33 void ContactEditor::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 }
QString custom(const QString &app, const QString &name) const
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
void insertCustom(const QString &app, const QString &name, const QString &value)
QString mid(int position, int n) const const
QString left(int n) const const
void removeCustom(const QString &app, const QString &name)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jun 23 2021 23:09:25 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.