File indexing completed on 2024-11-24 04:50:40
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 "contactmetadataattribute_p.h" 0010 0011 #include <QDataStream> 0012 #include <QIODevice> 0013 0014 class ContactMetaDataAttributePrivate 0015 { 0016 public: 0017 QVariantMap mData; 0018 }; 0019 0020 ContactMetaDataAttribute::ContactMetaDataAttribute() 0021 : d(new ContactMetaDataAttributePrivate) 0022 { 0023 } 0024 0025 ContactMetaDataAttribute::~ContactMetaDataAttribute() = default; 0026 0027 void ContactMetaDataAttribute::setMetaData(const QVariantMap &data) 0028 { 0029 d->mData = data; 0030 } 0031 0032 QVariantMap ContactMetaDataAttribute::metaData() const 0033 { 0034 return d->mData; 0035 } 0036 0037 QByteArray ContactMetaDataAttribute::type() const 0038 { 0039 static const QByteArray sType("contactmetadata"); 0040 return sType; 0041 } 0042 0043 Akonadi::Attribute *ContactMetaDataAttribute::clone() const 0044 { 0045 auto copy = new ContactMetaDataAttribute; 0046 copy->setMetaData(d->mData); 0047 0048 return copy; 0049 } 0050 0051 QByteArray ContactMetaDataAttribute::serialized() const 0052 { 0053 QByteArray data; 0054 QDataStream s(&data, QIODevice::WriteOnly); 0055 s.setVersion(QDataStream::Qt_4_5); 0056 s << d->mData; 0057 0058 return data; 0059 } 0060 0061 void ContactMetaDataAttribute::deserialize(const QByteArray &data) 0062 { 0063 QDataStream s(data); 0064 s.setVersion(QDataStream::Qt_4_5); 0065 s >> d->mData; 0066 }