Akonadi

itemchangelog.cpp
1 /*
2  * Copyright 2015 Daniel Vrátil <[email protected]>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License or (at your option) version 3 or any later version
8  * accepted by the membership of KDE e.V. (or its successor approved
9  * by the membership of KDE e.V.), which shall act as a proxy
10  * defined in Section 14 of version 3 of the license.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #include "itemchangelog_p.h"
23 
24 using namespace Akonadi;
25 
26 ItemChangeLog *ItemChangeLog::sInstance = nullptr;
27 
28 ItemChangeLog *ItemChangeLog::instance()
29 {
30  if (!sInstance) {
31  sInstance = new ItemChangeLog;
32  }
33  return sInstance;
34 }
35 
36 ItemChangeLog::ItemChangeLog()
37 {
38 }
39 
40 Item::Flags &ItemChangeLog::addedFlags(const ItemPrivate *priv)
41 {
42  return m_addedFlags[const_cast<ItemPrivate *>(priv)];
43 }
44 
45 Item::Flags &ItemChangeLog::deletedFlags(const ItemPrivate *priv)
46 {
47  return m_deletedFlags[const_cast<ItemPrivate *>(priv)];
48 }
49 
50 Tag::List &ItemChangeLog::addedTags(const ItemPrivate *priv)
51 {
52  return m_addedTags[const_cast<ItemPrivate *>(priv)];
53 }
54 
55 Tag::List &ItemChangeLog::deletedTags(const ItemPrivate *priv)
56 {
57  return m_deletedTags[const_cast<ItemPrivate *>(priv)];
58 }
59 
60 AttributeStorage &ItemChangeLog::attributeStorage(ItemPrivate *priv)
61 {
62  return m_attributeStorage[priv];
63 }
64 
65 const AttributeStorage &ItemChangeLog::attributeStorage(const ItemPrivate *priv)
66 {
67  return m_attributeStorage[const_cast<ItemPrivate *>(priv)];
68 }
69 
70 void ItemChangeLog::removeItem(const ItemPrivate *priv)
71 {
72  ItemPrivate *p = const_cast<ItemPrivate *>(priv);
73  m_addedFlags.remove(p);
74  m_deletedFlags.remove(p);
75  m_addedTags.remove(p);
76  m_deletedTags.remove(p);
77  m_attributeStorage.remove(p);
78 }
79 
80 void ItemChangeLog::clearItemChangelog(const ItemPrivate *priv)
81 {
82  ItemPrivate *p = const_cast<ItemPrivate *>(priv);
83  m_addedFlags.remove(p);
84  m_deletedFlags.remove(p);
85  m_addedTags.remove(p);
86  m_deletedTags.remove(p);
87  m_attributeStorage[p].resetChangeLog(); // keep the attributes
88 }
void remove(int i)
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed May 27 2020 22:43:39 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.