Akonadi

collectioncolorattribute.cpp
1 /*
2  * SPDX-FileCopyrightText: 2015 Sandro KnauƟ <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 #include "collectioncolorattribute.h"
8 
9 #include <QByteArray>
10 #include <QString>
11 
12 using namespace Akonadi;
13 
14 CollectionColorAttribute::CollectionColorAttribute(const QColor &color)
15  : mColor(color)
16 {
17 }
18 
19 void CollectionColorAttribute::setColor(const QColor &color)
20 {
21  mColor = color;
22 }
23 
24 QColor CollectionColorAttribute::color() const
25 {
26  return mColor;
27 }
28 
30 {
31  return QByteArrayLiteral("collectioncolor");
32 }
33 
35 {
36  return new CollectionColorAttribute(mColor);
37 }
38 
40 {
41  return mColor.isValid() ? mColor.name(QColor::HexArgb).toUtf8() : "";
42 }
43 
45 {
46  mColor = QColor(QString::fromUtf8(data));
47 }
QString fromUtf8(const char *str, int size)
QString name() const const
QByteArray serialized() const override
Returns a QByteArray representation of the attribute which will be storaged.
QByteArray type() const override
Returns the type of the attribute.
CollectionColorAttribute * clone() const override
Creates a copy of this attribute.
QByteArray toUtf8() const const
Attribute that stores colors of a collection.
void deserialize(const QByteArray &data) override
Sets the data of this attribute, using the same encoding as returned by toByteArray().
bool isValid() const const
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:00:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.