akonadi
21 #include <akonadi/tagattribute.h>
27 struct Akonadi::Tag::Private {
38 QScopedPointer<Tag> parent;
56 Tag::Tag(
const QString &name)
60 d->gid = name.toUtf8();
65 Tag::Tag(
const Tag &other)
76 Tag &Tag::operator=(
const Tag &other)
79 d->gid = other.d->gid;
80 d->remoteId = other.d->remoteId;
81 d->type = other.d->type;
82 if (other.d->parent) {
83 d->parent.reset(
new Tag(*other.d->parent));
85 AttributeEntity::operator=(other);
91 return operator=(*
static_cast<const Tag *
>(&other));
94 bool Tag::operator==(
const Tag &other)
const
96 if (isValid() && other.isValid()) {
97 return d->id == other.d->id;
99 return d->gid == other.d->gid;
102 Tag Tag::fromUrl(
const KUrl &url)
104 if (
url.protocol() != QLatin1String(
"akonadi")) {
108 const QString tagStr =
url.queryItem(QLatin1String(
"tag"));
110 Tag::Id itemId = tagStr.toLongLong(&ok);
121 url.setProtocol(QString::fromLatin1(
"akonadi"));
122 url.addQueryItem(QLatin1String(
"tag"), QString::number(
id()));
136 void Tag::setGid(
const QByteArray &gid)
const
141 QByteArray Tag::gid()
const
146 void Tag::setRemoteId(
const QByteArray &remoteId)
const
148 d->remoteId = remoteId;
151 QByteArray Tag::remoteId()
const
156 void Tag::setName(
const QString &name)
158 if (!name.isEmpty()) {
164 QString Tag::name()
const
166 const TagAttribute *
const attr = attribute<TagAttribute>();
167 const QString displayName = attr ? attr->
displayName() : QString();
168 return !displayName.isEmpty() ? displayName : QString::fromUtf8(d->gid);
171 void Tag::setParent(
const Tag &parent)
173 if (parent.isValid()) {
174 d->parent.reset(
new Tag(parent));
178 Tag Tag::parent()
const
186 void Tag::setType(
const QByteArray &type)
const
191 QByteArray Tag::type()
const
196 bool Tag::isValid()
const
203 return (d->type.isEmpty() || d->type ==
PLAIN);
206 uint qHash(
const Tag &tag)
208 return qHash(tag.id());
211 QDebug &operator<<(QDebug &debug,
const Tag &tag)
213 debug <<
"Akonadi::Tag( ID " << tag.id() <<
", GID " << tag.gid() <<
", parent" << tag.parent().id() <<
")";
void setDisplayName(const QString &name)
Sets the name that should be used for display.
QString displayName() const
Returns the name that should be used for display.
KUrl url() const
Returns the url of the tag.
static const char * PLAIN
The PLAIN type has the following properties:
@ AddIfMissing
Creates the attribute if it is missing.
Id id() const
Returns the unique identifier of the tag.
void setId(Id identifier)
Sets the unique identifier of the tag.
bool isImmutable() const
Returns true if the tag is immutable (cannot be modified after creation).
Parent class for entities that can have attributes.
Attribute that stores the properties that are used to display a tag.
FreeBusyManager::Singleton.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Jan 29 2020 00:00:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.