File indexing completed on 2024-11-17 04:40:41

0001 /*
0002     This file is part of Akonadi Contact.
0003 
0004     SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #include "contactmetadataakonadi_p.h"
0010 
0011 #include "attributes/contactmetadataattribute_p.h"
0012 
0013 #include <Akonadi/Item>
0014 
0015 using namespace Akonadi;
0016 
0017 ContactMetaDataAkonadi::ContactMetaDataAkonadi() = default;
0018 
0019 ContactMetaDataAkonadi::~ContactMetaDataAkonadi() = default;
0020 
0021 void ContactMetaDataAkonadi::load(const Akonadi::Item &contact)
0022 {
0023     if (!contact.hasAttribute("contactmetadata")) {
0024         return;
0025     }
0026     const auto attribute = contact.attribute<Akonadi::ContactMetaDataAttribute>();
0027     const QVariantMap metaData = attribute->metaData();
0028     loadMetaData(metaData);
0029 }
0030 
0031 void ContactMetaDataAkonadi::store(Akonadi::Item &contact)
0032 {
0033     auto attribute = contact.attribute<Akonadi::ContactMetaDataAttribute>(Akonadi::Item::AddIfMissing);
0034 
0035     attribute->setMetaData(storeMetaData());
0036 }