Akonadi Contacts

contactmetadatabase.cpp
1 /*
2  This file is part of Contact Editor.
3 
4  Copyright (C) 2017-2020 Laurent Montel <[email protected]>
5 
6  This library is free software; you can redistribute it and/or modify it
7  under the terms of the GNU Library General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or (at your
9  option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14  License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301, USA.
20 */
21 
22 #include "contactmetadatabase_p.h"
23 
24 using namespace ContactEditor;
25 
26 class Q_DECL_HIDDEN ContactMetaDataBase::Private
27 {
28 public:
29  Private()
30  : mDisplayNameMode(-1)
31  {
32  }
33 
34  int mDisplayNameMode;
35  QVariantList mCustomFieldDescriptions;
36 };
37 
38 ContactMetaDataBase::ContactMetaDataBase()
39  : d(new Private)
40 {
41 }
42 
43 ContactMetaDataBase::~ContactMetaDataBase()
44 {
45  delete d;
46 }
47 
48 void ContactMetaDataBase::loadMetaData(const QVariantMap &metaData)
49 {
50  d->mDisplayNameMode = metaData.value(QStringLiteral("DisplayNameMode"), -1).toInt();
51 
52  d->mCustomFieldDescriptions = metaData.value(QStringLiteral("CustomFieldDescriptions")).toList();
53 }
54 
55 QVariantMap ContactMetaDataBase::storeMetaData() const
56 {
57  QVariantMap metaData;
58  if (d->mDisplayNameMode != -1) {
59  metaData.insert(QStringLiteral("DisplayNameMode"), QVariant(d->mDisplayNameMode));
60  }
61 
62  if (!d->mCustomFieldDescriptions.isEmpty()) {
63  metaData.insert(QStringLiteral("CustomFieldDescriptions"), d->mCustomFieldDescriptions);
64  }
65  return metaData;
66 }
67 
68 void ContactMetaDataBase::setDisplayNameMode(int mode)
69 {
70  d->mDisplayNameMode = mode;
71 }
72 
73 int ContactMetaDataBase::displayNameMode() const
74 {
75  return d->mDisplayNameMode;
76 }
77 
78 void ContactMetaDataBase::setCustomFieldDescriptions(const QVariantList &descriptions)
79 {
80  d->mCustomFieldDescriptions = descriptions;
81 }
82 
83 QVariantList ContactMetaDataBase::customFieldDescriptions() const
84 {
85  return d->mCustomFieldDescriptions;
86 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 30 2020 22:39:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.