Changeset View
Changeset View
Standalone View
Standalone View
src/core/collection_p.h
Show All 17 Lines | |||||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #ifndef AKONADI_COLLECTION_P_H | 20 | #ifndef AKONADI_COLLECTION_P_H | ||
21 | #define AKONADI_COLLECTION_P_H | 21 | #define AKONADI_COLLECTION_P_H | ||
22 | 22 | | |||
23 | #include "collection.h" | 23 | #include "collection.h" | ||
24 | #include "cachepolicy.h" | 24 | #include "cachepolicy.h" | ||
25 | #include "collectionstatistics.h" | 25 | #include "collectionstatistics.h" | ||
26 | #include "attributestorage_p.h" | ||||
26 | 27 | | |||
27 | #include "qstringlist.h" | 28 | #include "qstringlist.h" | ||
28 | 29 | | |||
29 | #include <QSharedData> | 30 | #include <QSharedData> | ||
30 | 31 | | |||
31 | using namespace Akonadi; | 32 | using namespace Akonadi; | ||
32 | 33 | | |||
33 | /** | 34 | /** | ||
Show All 9 Lines | 40 | CollectionPrivate(Collection::Id id = -1) | |||
43 | , indexPreference(Collection::ListDefault) | 44 | , indexPreference(Collection::ListDefault) | ||
44 | , listPreferenceChanged(false) | 45 | , listPreferenceChanged(false) | ||
45 | , enabled(true) | 46 | , enabled(true) | ||
46 | , enabledChanged(false) | 47 | , enabledChanged(false) | ||
47 | , referenced(false) | 48 | , referenced(false) | ||
48 | , referencedChanged(false) | 49 | , referencedChanged(false) | ||
49 | , contentTypesChanged(false) | 50 | , contentTypesChanged(false) | ||
50 | , cachePolicyChanged(false) | 51 | , cachePolicyChanged(false) | ||
51 | , attributesChanged(false) | | |||
52 | , isVirtual(false) | 52 | , isVirtual(false) | ||
53 | , mId(id) | 53 | , mId(id) | ||
54 | , mParent(nullptr) | 54 | , mParent(nullptr) | ||
55 | { | 55 | { | ||
56 | } | 56 | } | ||
57 | 57 | | |||
58 | CollectionPrivate(const CollectionPrivate &other) | 58 | CollectionPrivate(const CollectionPrivate &other) | ||
59 | : QSharedData(other) | 59 | : QSharedData(other) | ||
60 | , mParent(nullptr) | 60 | , mParent(nullptr) | ||
61 | { | 61 | { | ||
62 | mId = other.mId; | 62 | mId = other.mId; | ||
63 | mRemoteId = other.mRemoteId; | 63 | mRemoteId = other.mRemoteId; | ||
64 | mRemoteRevision = other.mRemoteRevision; | 64 | mRemoteRevision = other.mRemoteRevision; | ||
65 | for (Attribute *attr : qAsConst(other.mAttributes)) { | 65 | mAttributeStorage = other.mAttributeStorage; | ||
66 | mAttributes.insert(attr->type(), attr->clone()); | | |||
67 | } | | |||
68 | mDeletedAttributes = other.mDeletedAttributes; | | |||
69 | if (other.mParent) { | 66 | if (other.mParent) { | ||
70 | mParent = new Collection(*(other.mParent)); | 67 | mParent = new Collection(*(other.mParent)); | ||
71 | } | 68 | } | ||
72 | name = other.name; | 69 | name = other.name; | ||
73 | resource = other.resource; | 70 | resource = other.resource; | ||
74 | statistics = other.statistics; | 71 | statistics = other.statistics; | ||
75 | contentTypes = other.contentTypes; | 72 | contentTypes = other.contentTypes; | ||
76 | cachePolicy = other.cachePolicy; | 73 | cachePolicy = other.cachePolicy; | ||
77 | contentTypesChanged = other.contentTypesChanged; | 74 | contentTypesChanged = other.contentTypesChanged; | ||
78 | cachePolicyChanged = other.cachePolicyChanged; | 75 | cachePolicyChanged = other.cachePolicyChanged; | ||
79 | isVirtual = other.isVirtual; | 76 | isVirtual = other.isVirtual; | ||
80 | enabled = other.enabled; | 77 | enabled = other.enabled; | ||
81 | enabledChanged = other.enabledChanged; | 78 | enabledChanged = other.enabledChanged; | ||
82 | displayPreference = other.displayPreference; | 79 | displayPreference = other.displayPreference; | ||
83 | syncPreference = other.syncPreference; | 80 | syncPreference = other.syncPreference; | ||
84 | indexPreference = other.indexPreference; | 81 | indexPreference = other.indexPreference; | ||
85 | listPreferenceChanged = other.listPreferenceChanged; | 82 | listPreferenceChanged = other.listPreferenceChanged; | ||
86 | referenced = other.referenced; | 83 | referenced = other.referenced; | ||
87 | referencedChanged = other.referencedChanged; | 84 | referencedChanged = other.referencedChanged; | ||
88 | keepLocalChanges = other.keepLocalChanges; | 85 | keepLocalChanges = other.keepLocalChanges; | ||
89 | attributesChanged = other.attributesChanged; | | |||
90 | } | 86 | } | ||
91 | 87 | | |||
92 | ~CollectionPrivate() | 88 | ~CollectionPrivate() | ||
93 | { | 89 | { | ||
94 | qDeleteAll(mAttributes); | | |||
95 | delete mParent; | 90 | delete mParent; | ||
96 | } | 91 | } | ||
97 | 92 | | |||
98 | void resetChangeLog() | 93 | void resetChangeLog() | ||
99 | { | 94 | { | ||
100 | contentTypesChanged = false; | 95 | contentTypesChanged = false; | ||
101 | cachePolicyChanged = false; | 96 | cachePolicyChanged = false; | ||
102 | enabledChanged = false; | 97 | enabledChanged = false; | ||
103 | listPreferenceChanged = false; | 98 | listPreferenceChanged = false; | ||
104 | referencedChanged = false; | 99 | referencedChanged = false; | ||
105 | attributesChanged = false; | 100 | mAttributeStorage.resetChangeLog(); | ||
106 | mDeletedAttributes.clear(); | | |||
107 | } | 101 | } | ||
108 | 102 | | |||
109 | static Collection newRoot() | 103 | static Collection newRoot() | ||
110 | { | 104 | { | ||
111 | Collection rootCollection(0); | 105 | Collection rootCollection(0); | ||
112 | rootCollection.setContentMimeTypes({ Collection::mimeType() }); | 106 | rootCollection.setContentMimeTypes({ Collection::mimeType() }); | ||
113 | return rootCollection; | 107 | return rootCollection; | ||
114 | } | 108 | } | ||
115 | 109 | | |||
116 | // Make use of the 4-bytes padding from QSharedData | 110 | // Make use of the 4-bytes padding from QSharedData | ||
117 | Collection::ListPreference displayPreference: 2; | 111 | Collection::ListPreference displayPreference: 2; | ||
118 | Collection::ListPreference syncPreference: 2; | 112 | Collection::ListPreference syncPreference: 2; | ||
119 | Collection::ListPreference indexPreference: 2; | 113 | Collection::ListPreference indexPreference: 2; | ||
120 | bool listPreferenceChanged: 1; | 114 | bool listPreferenceChanged: 1; | ||
121 | bool enabled: 1; | 115 | bool enabled: 1; | ||
122 | bool enabledChanged: 1; | 116 | bool enabledChanged: 1; | ||
123 | bool referenced: 1; | 117 | bool referenced: 1; | ||
124 | bool referencedChanged: 1; | 118 | bool referencedChanged: 1; | ||
125 | bool contentTypesChanged: 1; | 119 | bool contentTypesChanged: 1; | ||
126 | bool cachePolicyChanged: 1; | 120 | bool cachePolicyChanged: 1; | ||
127 | bool attributesChanged : 1; | | |||
128 | bool isVirtual: 1; | 121 | bool isVirtual: 1; | ||
129 | // 2 bytes padding here | 122 | // 2 bytes padding here | ||
130 | 123 | | |||
131 | Collection::Id mId; | 124 | Collection::Id mId; | ||
132 | QString mRemoteId; | 125 | QString mRemoteId; | ||
133 | QString mRemoteRevision; | 126 | QString mRemoteRevision; | ||
134 | QHash<QByteArray, Attribute *> mAttributes; | | |||
135 | QSet<QByteArray> mDeletedAttributes; | | |||
136 | mutable Collection *mParent; | 127 | mutable Collection *mParent; | ||
128 | AttributeStorage mAttributeStorage; | ||||
137 | QString name; | 129 | QString name; | ||
138 | QString resource; | 130 | QString resource; | ||
139 | CollectionStatistics statistics; | 131 | CollectionStatistics statistics; | ||
140 | QStringList contentTypes; | 132 | QStringList contentTypes; | ||
141 | static const Collection root; | 133 | static const Collection root; | ||
142 | CachePolicy cachePolicy; | 134 | CachePolicy cachePolicy; | ||
143 | QSet<QByteArray> keepLocalChanges; | 135 | QSet<QByteArray> keepLocalChanges; | ||
144 | 136 | | |||
145 | }; | 137 | }; | ||
146 | 138 | | |||
147 | #endif | 139 | #endif |