1/*
2 This file is part of KDE.
3
4 SPDX-FileCopyrightText: Martin Sandsmark <martin.sandsmark@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8
9#include "privatedata.h"
10
11#include <QStringList>
12
13using namespace Attica;
14
15class Q_DECL_HIDDEN PrivateData::Private : public QSharedData
16{
17public:
18 QMap<QString, QString> m_attributes;
19 QMap<QString, QDateTime> m_attributesTimestamp;
20
21 Provider *m_provider;
22
23 Private()
24 : m_provider(nullptr)
25 {
26 }
27};
28
29PrivateData::PrivateData()
30 : d(new Private)
31{
32}
33
34PrivateData::PrivateData(const PrivateData &other)
35 : d(other.d)
36{
37}
38
39PrivateData &PrivateData::operator=(const Attica::PrivateData &other)
40{
41 d = other.d;
42 return *this;
43}
44
45PrivateData::~PrivateData()
46{
47}
48
49void PrivateData::setAttribute(const QString &key, const QString &value)
50{
51 d->m_attributes[key] = value;
52 d->m_attributesTimestamp[key] = QDateTime::currentDateTime();
53}
54
55QString PrivateData::attribute(const QString &key) const
56{
57 return d->m_attributes[key];
58}
59
60QDateTime PrivateData::timestamp(const QString &key) const
61{
62 return d->m_attributesTimestamp[key];
63}
64
65QStringList PrivateData::keys() const
66{
67 return d->m_attributes.keys();
68}
69
70void PrivateData::setTimestamp(const QString &key, const QDateTime &when)
71{
72 d->m_attributesTimestamp[key] = when;
73}
74

source code of attica/src/privatedata.cpp