Attica

privatedata.cpp
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: Martin Sandsmark <[email protected]>
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 
13 using namespace Attica;
14 
15 class Q_DECL_HIDDEN PrivateData::Private : public QSharedData
16 {
17 public:
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 
29 PrivateData::PrivateData()
30  : d(new Private)
31 {
32 }
33 
34 PrivateData::PrivateData(const PrivateData &other)
35  : d(other.d)
36 {
37 }
38 
39 PrivateData &PrivateData::operator=(const Attica::PrivateData &other)
40 {
41  d = other.d;
42  return *this;
43 }
44 
45 PrivateData::~PrivateData()
46 {
47 }
48 
49 void PrivateData::setAttribute(const QString &key, const QString &value)
50 {
51  d->m_attributes[key] = value;
52  d->m_attributesTimestamp[key] = QDateTime::currentDateTime();
53 }
54 
56 {
57  return d->m_attributes[key];
58 }
59 
61 {
62  return d->m_attributesTimestamp[key];
63 }
64 
66 {
67  return d->m_attributes.keys();
68 }
69 
70 void PrivateData::setTimestamp(const QString &key, const QDateTime &when)
71 {
72  d->m_attributesTimestamp[key] = when;
73 }
QDateTime currentDateTime()
void setTimestamp(const QString &key, const QDateTime &when)
Sets when an attribute last was changed (mostly for internal use).
Definition: privatedata.cpp:70
QString attribute(const QString &key) const
Returns an attribute referenced by \key.
Definition: privatedata.cpp:55
void setAttribute(const QString &key, const QString &value)
Sets an attribute referenced by \key to \value.
Definition: privatedata.cpp:49
QDateTime timestamp(const QString &key) const
Returns the date and time an attribute last was changed.
Definition: privatedata.cpp:60
QStringList keys() const
Returns a list of fetched keys.
Definition: privatedata.cpp:65
The Attica namespace,.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 04:08:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.