Akonadi Contacts

utils.cpp
1 /*
2  This file is part of Contact Editor.
3 
4  SPDX-FileCopyrightText: 2016-2023 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
bool isEmpty() const const
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
void insertCustom(const QString &app, const QString &name, const QString &value)
QString left(int n) const const
const char * name(StandardAction id)
void removeCustom(const QString &app, const QString &name)
QString mid(int position, int n) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Apr 1 2023 04:09:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.