Akonadi

itemchangelog.cpp
1/*
2 * SPDX-FileCopyrightText: 2015 Daniel Vrátil <dvratil@kde.org>
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
10using namespace Akonadi;
11
12ItemChangeLog *ItemChangeLog::sInstance = nullptr;
13
14ItemChangeLog *ItemChangeLog::instance()
15{
16 if (!sInstance) {
17 sInstance = new ItemChangeLog;
18 }
19 return sInstance;
20}
21
22ItemChangeLog::ItemChangeLog()
23{
24}
25
26Item::Flags &ItemChangeLog::addedFlags(ItemPrivate *priv)
27{
28 return m_addedFlags[priv];
29}
30
31Item::Flags ItemChangeLog::addedFlags(const ItemPrivate *priv) const
32{
33 return m_addedFlags[const_cast<ItemPrivate *>(priv)];
34}
35
36Item::Flags &ItemChangeLog::deletedFlags(ItemPrivate *priv)
37{
38 return m_deletedFlags[priv];
39}
40
41Item::Flags ItemChangeLog::deletedFlags(const ItemPrivate *priv) const
42{
43 return m_deletedFlags[const_cast<ItemPrivate *>(priv)];
44}
45
46Tag::List &ItemChangeLog::addedTags(ItemPrivate *priv)
47{
48 return m_addedTags[priv];
49}
50
51Tag::List ItemChangeLog::addedTags(const ItemPrivate *priv) const
52{
53 return m_addedTags[const_cast<ItemPrivate *>(priv)];
54}
55
56Tag::List &ItemChangeLog::deletedTags(ItemPrivate *priv)
57{
58 return m_deletedTags[priv];
59}
60
61Tag::List ItemChangeLog::deletedTags(const ItemPrivate *priv) const
62{
63 return m_deletedTags[const_cast<ItemPrivate *>(priv)];
64}
65
66AttributeStorage &ItemChangeLog::attributeStorage(ItemPrivate *priv)
67{
68 return m_attributeStorage[priv];
69}
70
71AttributeStorage ItemChangeLog::attributeStorage(const ItemPrivate *priv) const
72{
73 return m_attributeStorage[const_cast<ItemPrivate *>(priv)];
74}
75
76void ItemChangeLog::removeItem(const ItemPrivate *priv)
77{
78 auto p = const_cast<ItemPrivate *>(priv);
79 m_addedFlags.remove(p);
80 m_deletedFlags.remove(p);
81 m_addedTags.remove(p);
82 m_deletedTags.remove(p);
83 m_attributeStorage.remove(p);
84}
85
86void ItemChangeLog::clearItemChangelog(const ItemPrivate *priv)
87{
88 auto p = const_cast<ItemPrivate *>(priv);
89 m_addedFlags.remove(p);
90 m_deletedFlags.remove(p);
91 m_addedTags.remove(p);
92 m_deletedTags.remove(p);
93 m_attributeStorage[p].resetChangeLog(); // keep the attributes
94}
Helper integration between Akonadi and Qt.
void remove(qsizetype i, qsizetype n)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:00:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.