File indexing completed on 2024-11-24 04:39:34

0001 /*
0002     This file is part of Contact Editor.
0003 
0004     SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #include "contactmetadatabase_p.h"
0010 
0011 using namespace Akonadi;
0012 
0013 class Akonadi::ContactMetaDataBasePrivate
0014 {
0015 public:
0016     int mDisplayNameMode = -1;
0017     QVariantList mCustomFieldDescriptions;
0018 };
0019 
0020 ContactMetaDataBase::ContactMetaDataBase()
0021     : d(new ContactMetaDataBasePrivate)
0022 {
0023 }
0024 
0025 ContactMetaDataBase::~ContactMetaDataBase() = default;
0026 
0027 void ContactMetaDataBase::loadMetaData(const QVariantMap &metaData)
0028 {
0029     d->mDisplayNameMode = metaData.value(QStringLiteral("DisplayNameMode"), -1).toInt();
0030 
0031     d->mCustomFieldDescriptions = metaData.value(QStringLiteral("CustomFieldDescriptions")).toList();
0032 }
0033 
0034 QVariantMap ContactMetaDataBase::storeMetaData() const
0035 {
0036     QVariantMap metaData;
0037     if (d->mDisplayNameMode != -1) {
0038         metaData.insert(QStringLiteral("DisplayNameMode"), QVariant(d->mDisplayNameMode));
0039     }
0040 
0041     if (!d->mCustomFieldDescriptions.isEmpty()) {
0042         metaData.insert(QStringLiteral("CustomFieldDescriptions"), d->mCustomFieldDescriptions);
0043     }
0044     return metaData;
0045 }
0046 
0047 void ContactMetaDataBase::setDisplayNameMode(int mode)
0048 {
0049     d->mDisplayNameMode = mode;
0050 }
0051 
0052 int ContactMetaDataBase::displayNameMode() const
0053 {
0054     return d->mDisplayNameMode;
0055 }
0056 
0057 void ContactMetaDataBase::setCustomFieldDescriptions(const QVariantList &descriptions)
0058 {
0059     d->mCustomFieldDescriptions = descriptions;
0060 }
0061 
0062 QVariantList ContactMetaDataBase::customFieldDescriptions() const
0063 {
0064     return d->mCustomFieldDescriptions;
0065 }