Changeset View
Changeset View
Standalone View
Standalone View
src/core/tag.cpp
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 113 | { | |||
---|---|---|---|---|---|
117 | QUrl url; | 117 | QUrl url; | ||
118 | url.setScheme(QStringLiteral("akonadi")); | 118 | url.setScheme(QStringLiteral("akonadi")); | ||
119 | url.setQuery(query); | 119 | url.setQuery(query); | ||
120 | return url; | 120 | return url; | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | void Tag::addAttribute(Attribute *attr) | 123 | void Tag::addAttribute(Attribute *attr) | ||
124 | { | 124 | { | ||
125 | const QByteArray typeAttr = attr->type(); | 125 | d_ptr->mAttributeStorage.addAttribute(attr); | ||
126 | Attribute *existing = d_ptr->mAttributes.value(typeAttr); | | |||
127 | if (existing) { | | |||
128 | if (attr == existing) { | | |||
129 | return; | | |||
130 | } | | |||
131 | d_ptr->mAttributes.remove(typeAttr); | | |||
132 | delete existing; | | |||
133 | } | | |||
134 | d_ptr->mAttributes.insert(typeAttr, attr); | | |||
135 | d_ptr->mDeletedAttributes.remove(typeAttr); | | |||
136 | } | 126 | } | ||
137 | 127 | | |||
138 | void Tag::removeAttribute(const QByteArray &type) | 128 | void Tag::removeAttribute(const QByteArray &type) | ||
139 | { | 129 | { | ||
140 | d_ptr->mDeletedAttributes.insert(type); | 130 | d_ptr->mAttributeStorage.removeAttribute(type); | ||
141 | delete d_ptr->mAttributes.take(type); | | |||
142 | } | 131 | } | ||
143 | 132 | | |||
144 | bool Tag::hasAttribute(const QByteArray &type) const | 133 | bool Tag::hasAttribute(const QByteArray &type) const | ||
145 | { | 134 | { | ||
146 | return d_ptr->mAttributes.contains(type); | 135 | return d_ptr->mAttributeStorage.hasAttribute(type); | ||
147 | } | 136 | } | ||
148 | 137 | | |||
149 | Attribute::List Tag::attributes() const | 138 | Attribute::List Tag::attributes() const | ||
150 | { | 139 | { | ||
151 | return d_ptr->mAttributes.values(); | 140 | return d_ptr->mAttributeStorage.attributes(); | ||
152 | } | 141 | } | ||
153 | 142 | | |||
154 | void Tag::clearAttributes() | 143 | void Tag::clearAttributes() | ||
155 | { | 144 | { | ||
156 | for (Attribute *attr : qAsConst(d_ptr->mAttributes)) { | 145 | d_ptr->mAttributeStorage.clearAttributes(); | ||
157 | d_ptr->mDeletedAttributes.insert(attr->type()); | | |||
158 | delete attr; | | |||
159 | } | | |||
160 | d_ptr->mAttributes.clear(); | | |||
161 | } | 146 | } | ||
162 | 147 | | |||
163 | Attribute *Tag::attribute(const QByteArray &type) const | 148 | Attribute *Tag::attribute(const QByteArray &type) const | ||
164 | { | 149 | { | ||
165 | return d_ptr->mAttributes.value(type); | 150 | return d_ptr->mAttributeStorage.attribute(type); | ||
166 | } | 151 | } | ||
167 | 152 | | |||
168 | void Tag::setId(Tag::Id identifier) | 153 | void Tag::setId(Tag::Id identifier) | ||
169 | { | 154 | { | ||
170 | d_ptr->id = identifier; | 155 | d_ptr->id = identifier; | ||
171 | } | 156 | } | ||
172 | 157 | | |||
173 | Tag::Id Tag::id() const | 158 | Tag::Id Tag::id() const | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | |||||
263 | { | 248 | { | ||
264 | if (attr) { | 249 | if (attr) { | ||
265 | return true; | 250 | return true; | ||
266 | } | 251 | } | ||
267 | qCWarning(AKONADICORE_LOG) << "Found attribute of unknown type" << type | 252 | qCWarning(AKONADICORE_LOG) << "Found attribute of unknown type" << type | ||
268 | << ". Did you forget to call AttributeFactory::registerAttribute()?"; | 253 | << ". Did you forget to call AttributeFactory::registerAttribute()?"; | ||
269 | return false; | 254 | return false; | ||
270 | } | 255 | } | ||
256 | | ||||
257 | void Tag::markAttributeModified(const QByteArray &type) | ||||
258 | { | ||||
259 | d_ptr->mAttributeStorage.markAttributeModified(type); | ||||
260 | } |