File indexing completed on 2024-04-14 03:49:33

0001 /*
0002     This file is part of KDE.
0003 
0004     SPDX-FileCopyrightText: Martin Sandsmark <martin.sandsmark@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #include "privatedata.h"
0010 
0011 #include <QStringList>
0012 
0013 using namespace Attica;
0014 
0015 class Q_DECL_HIDDEN PrivateData::Private : public QSharedData
0016 {
0017 public:
0018     QMap<QString, QString> m_attributes;
0019     QMap<QString, QDateTime> m_attributesTimestamp;
0020 
0021     Provider *m_provider;
0022 
0023     Private()
0024         : m_provider(nullptr)
0025     {
0026     }
0027 };
0028 
0029 PrivateData::PrivateData()
0030     : d(new Private)
0031 {
0032 }
0033 
0034 PrivateData::PrivateData(const PrivateData &other)
0035     : d(other.d)
0036 {
0037 }
0038 
0039 PrivateData &PrivateData::operator=(const Attica::PrivateData &other)
0040 {
0041     d = other.d;
0042     return *this;
0043 }
0044 
0045 PrivateData::~PrivateData()
0046 {
0047 }
0048 
0049 void PrivateData::setAttribute(const QString &key, const QString &value)
0050 {
0051     d->m_attributes[key] = value;
0052     d->m_attributesTimestamp[key] = QDateTime::currentDateTime();
0053 }
0054 
0055 QString PrivateData::attribute(const QString &key) const
0056 {
0057     return d->m_attributes[key];
0058 }
0059 
0060 QDateTime PrivateData::timestamp(const QString &key) const
0061 {
0062     return d->m_attributesTimestamp[key];
0063 }
0064 
0065 QStringList PrivateData::keys() const
0066 {
0067     return d->m_attributes.keys();
0068 }
0069 
0070 void PrivateData::setTimestamp(const QString &key, const QDateTime &when)
0071 {
0072     d->m_attributesTimestamp[key] = when;
0073 }