Akonadi
8 #include "akonadicore_debug.h"
11 #include "tagattribute.h"
20 uint Akonadi::qHash(
const Tag &tag)
22 return ::qHash(tag.
id());
26 : d_ptr(new TagPrivate)
31 : d_ptr(new TagPrivate)
37 : d_ptr(new TagPrivate)
39 d_ptr->gid = name.
toUtf8();
43 Tag::Tag(
const Tag &) =
default;
44 Tag::Tag(
Tag &&) noexcept = default;
47 Tag &
Tag::operator=(const
Tag &) = default;
48 Tag &
Tag::operator=(
Tag &&) noexcept = default;
50 bool Tag::operator==(const
Tag &other)
const
53 if (isValid() && other.isValid()) {
54 return d_ptr->
id == other.d_ptr->id;
58 if (!d_ptr->gid.isEmpty() || !other.d_ptr->gid.isEmpty()) {
59 return d_ptr->gid == other.d_ptr->gid;
63 return !isValid() && !other.isValid();
66 bool Tag::operator!=(
const Tag &other)
const
68 return !operator==(other);
71 Tag Tag::fromUrl(
const QUrl &url)
100 d_ptr->mAttributeStorage.addAttribute(attr);
105 d_ptr->mAttributeStorage.removeAttribute(type);
110 return d_ptr->mAttributeStorage.hasAttribute(type);
115 return d_ptr->mAttributeStorage.attributes();
120 d_ptr->mAttributeStorage.clearAttributes();
125 return d_ptr->mAttributeStorage.attribute(type);
130 markAttributeModified(type);
131 return d_ptr->mAttributeStorage.attribute(type);
136 d_ptr->id = identifier;
154 void Tag::setRemoteId(
const QByteArray &remoteId)
156 d_ptr->remoteId = remoteId;
161 return d_ptr->remoteId;
164 void Tag::setName(
const QString &name)
168 attr->setDisplayName(name);
174 const auto *
const attr = attribute<TagAttribute>();
179 void Tag::setParent(
const Tag &parent)
181 d_ptr->parent.reset(
new Tag(parent));
184 Tag Tag::parent()
const
186 if (!d_ptr->parent) {
189 return *d_ptr->parent;
202 bool Tag::isValid()
const
204 return d_ptr->id >= 0;
209 return (d_ptr->type.isEmpty() || d_ptr->type ==
PLAIN);
215 debug.
nospace() <<
"Akonadi::Tag(ID " << tag.
id() <<
", GID " << tag.gid() <<
", parent tag ID " << tag.parent().
id() <<
")";
233 qCWarning(AKONADICORE_LOG) <<
"Found attribute of unknown type" << type <<
". Did you forget to call AttributeFactory::registerAttribute()?";
237 void Tag::markAttributeModified(
const QByteArray &type)
239 d_ptr->mAttributeStorage.markAttributeModified(type);
QString number(int n, int base)
QString fromUtf8(const char *str, int size)
QString scheme() const const
qlonglong toLongLong(bool *ok, int base) const const
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
QUrl url() const
Returns the url of the tag.
Provides interface for custom attributes for Entity.
static Tag genericTag(const QString &name)
Returns a GENERIC tag with the given name and a valid gid.
static const char GENERIC[]
The GENERIC type has the following properties:
const T * attribute() const
Returns the attribute of the requested type or 0 if it is not available.
void setScheme(const QString &scheme)
static const char PLAIN[]
The PLAIN type has the following properties:
@ AddIfMissing
Creates the attribute if it is missing.
QByteArray mid(int pos, int len) const const
bool isEmpty() const const
QByteArray toUtf8() const const
bool hasAttribute() const
Returns whether the entity has an attribute of the requested type.
void clearAttributes()
Removes and deletes all attributes of the entity.
AKONADI_CALENDAR_EXPORT QString displayName(Akonadi::ETMCalendar *calendar, const Akonadi::Collection &collection)
void setQuery(const QString &query, QUrl::ParsingMode mode)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
void addAttribute(Attribute *attribute)
Adds an attribute to the entity.
QByteArray toByteArray() const const
Id id() const
Returns the unique identifier of the tag.
void setId(Id identifier)
Sets the unique identifier of the tag.
QString name(StandardShortcut id)
bool isImmutable() const
Returns true if the tag is immutable (cannot be modified after creation).
QString queryItemValue(const QString &key, QUrl::ComponentFormattingOptions encoding) const const
void removeAttribute()
Removes and deletes the attribute of the requested type.
Helper integration between Akonadi and Qt.
Attribute::List attributes() const
Returns a list of all attributes of the entity.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Sep 25 2023 03:49:15 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.