Akonadi

itemchangelog.cpp
1 /*
2  * SPDX-FileCopyrightText: 2015 Daniel Vr├ítil <[email protected]>
3  *
4  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5  *
6  */
7 
8 #include "itemchangelog_p.h"
9 
10 using namespace Akonadi;
11 
12 ItemChangeLog *ItemChangeLog::sInstance = nullptr;
13 
14 ItemChangeLog *ItemChangeLog::instance()
15 {
16  if (!sInstance) {
17  sInstance = new ItemChangeLog;
18  }
19  return sInstance;
20 }
21 
22 ItemChangeLog::ItemChangeLog()
23 {
24 }
25 
26 Item::Flags &ItemChangeLog::addedFlags(const ItemPrivate *priv)
27 {
28  return m_addedFlags[const_cast<ItemPrivate *>(priv)];
29 }
30 
31 Item::Flags &ItemChangeLog::deletedFlags(const ItemPrivate *priv)
32 {
33  return m_deletedFlags[const_cast<ItemPrivate *>(priv)];
34 }
35 
36 Tag::List &ItemChangeLog::addedTags(const ItemPrivate *priv)
37 {
38  return m_addedTags[const_cast<ItemPrivate *>(priv)];
39 }
40 
41 Tag::List &ItemChangeLog::deletedTags(const ItemPrivate *priv)
42 {
43  return m_deletedTags[const_cast<ItemPrivate *>(priv)];
44 }
45 
46 AttributeStorage &ItemChangeLog::attributeStorage(ItemPrivate *priv)
47 {
48  return m_attributeStorage[priv];
49 }
50 
51 const AttributeStorage &ItemChangeLog::attributeStorage(const ItemPrivate *priv)
52 {
53  return m_attributeStorage[const_cast<ItemPrivate *>(priv)];
54 }
55 
56 void ItemChangeLog::removeItem(const ItemPrivate *priv)
57 {
58  auto p = const_cast<ItemPrivate *>(priv);
59  m_addedFlags.remove(p);
60  m_deletedFlags.remove(p);
61  m_addedTags.remove(p);
62  m_deletedTags.remove(p);
63  m_attributeStorage.remove(p);
64 }
65 
66 void ItemChangeLog::clearItemChangelog(const ItemPrivate *priv)
67 {
68  auto p = const_cast<ItemPrivate *>(priv);
69  m_addedFlags.remove(p);
70  m_deletedFlags.remove(p);
71  m_addedTags.remove(p);
72  m_deletedTags.remove(p);
73  m_attributeStorage[p].resetChangeLog(); // keep the attributes
74 }
QSet< QByteArray > Flags
Describes a set of flag names.
Definition: item.h:125
void remove(int i)
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.