• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
entitydisplayattribute.cpp
1/*
2 Copyright (c) 2008 Volker Krause <vkrause@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#include "entitydisplayattribute.h"
21
22#include "imapparser_p.h"
23
24#include <KIcon>
25
26using namespace Akonadi;
27
28class EntityDisplayAttribute::Private
29{
30public:
31 Private()
32 : hidden(false)
33 {
34 }
35 QString name;
36 QString icon;
37 QString activeIcon;
38 QColor backgroundColor;
39 bool hidden;
40};
41
42EntityDisplayAttribute::EntityDisplayAttribute()
43 : d(new Private)
44{
45}
46
47EntityDisplayAttribute::~ EntityDisplayAttribute()
48{
49 delete d;
50}
51
52QString EntityDisplayAttribute::displayName() const
53{
54 return d->name;
55}
56
57void EntityDisplayAttribute::setDisplayName(const QString &name)
58{
59 d->name = name;
60}
61
62KIcon EntityDisplayAttribute::icon() const
63{
64 return KIcon(d->icon);
65}
66
67QString EntityDisplayAttribute::iconName() const
68{
69 return d->icon;
70}
71
72void EntityDisplayAttribute::setIconName(const QString &icon)
73{
74 d->icon = icon;
75}
76
77QByteArray Akonadi::EntityDisplayAttribute::type() const
78{
79 static const QByteArray sType( "ENTITYDISPLAY" );
80 return sType;
81}
82
83EntityDisplayAttribute *EntityDisplayAttribute::clone() const
84{
85 EntityDisplayAttribute *attr = new EntityDisplayAttribute();
86 attr->d->name = d->name;
87 attr->d->icon = d->icon;
88 attr->d->activeIcon = d->activeIcon;
89 attr->d->backgroundColor = d->backgroundColor;
90 return attr;
91}
92
93QByteArray EntityDisplayAttribute::serialized() const
94{
95 QList<QByteArray> l;
96 l << ImapParser::quote(d->name.toUtf8());
97 l << ImapParser::quote(d->icon.toUtf8());
98 l << ImapParser::quote(d->activeIcon.toUtf8());
99 QList<QByteArray> components;
100 if (d->backgroundColor.isValid()) {
101 components = QList<QByteArray>() << QByteArray::number(d->backgroundColor.red())
102 << QByteArray::number(d->backgroundColor.green())
103 << QByteArray::number(d->backgroundColor.blue())
104 << QByteArray::number(d->backgroundColor.alpha());
105 }
106 l << '(' + ImapParser::join(components, " ") + ')';
107 return '(' + ImapParser::join(l, " ") + ')';
108}
109
110void EntityDisplayAttribute::deserialize(const QByteArray &data)
111{
112 QList<QByteArray> l;
113 ImapParser::parseParenthesizedList(data, l);
114 int size = l.size();
115 Q_ASSERT(size >= 2);
116 d->name = QString::fromUtf8(l[0]);
117 d->icon = QString::fromUtf8(l[1]);
118 if (size >= 3) {
119 d->activeIcon = QString::fromUtf8(l[2]);
120 }
121 if (size >= 4) {
122 if (!l[3].isEmpty()) {
123 QList<QByteArray> componentData;
124 ImapParser::parseParenthesizedList(l[3], componentData);
125 if (componentData.size() != 4) {
126 return;
127 }
128 QList<int> components;
129
130 bool ok;
131 for (int i = 0; i <= 3; ++i) {
132 components << componentData.at(i).toInt(&ok);
133 if (!ok) {
134 return;
135 }
136 }
137 d->backgroundColor = QColor(components.at(0), components.at(1), components.at(2), components.at(3));
138 }
139 }
140}
141
142void EntityDisplayAttribute::setActiveIconName(const QString &name)
143{
144 d->activeIcon = name;
145}
146
147KIcon EntityDisplayAttribute::activeIcon() const
148{
149 return KIcon(d->activeIcon);
150}
151
152QString EntityDisplayAttribute::activeIconName() const
153{
154 return d->activeIcon;
155}
156
157QColor EntityDisplayAttribute::backgroundColor() const
158{
159 return d->backgroundColor;
160}
161
162void EntityDisplayAttribute::setBackgroundColor(const QColor &color)
163{
164 d->backgroundColor = color;
165}
Akonadi::EntityDisplayAttribute
Attribute that stores the properties that are used to display an entity.
Definition entitydisplayattribute.h:40
Akonadi::EntityDisplayAttribute::setIconName
void setIconName(const QString &name)
Sets the icon name for the default icon.
Definition entitydisplayattribute.cpp:72
Akonadi::EntityDisplayAttribute::setBackgroundColor
void setBackgroundColor(const QColor &color)
Sets the backgroundColor to color.
Definition entitydisplayattribute.cpp:162
Akonadi::EntityDisplayAttribute::activeIcon
KIcon activeIcon() const
Returns the icon that should be used for this collection or item when active.
Definition entitydisplayattribute.cpp:147
Akonadi::EntityDisplayAttribute::setActiveIconName
void setActiveIconName(const QString &name)
Sets the icon name for the active icon.
Definition entitydisplayattribute.cpp:142
Akonadi::EntityDisplayAttribute::type
QByteArray type() const
Returns the type of the attribute.
Definition entitydisplayattribute.cpp:77
Akonadi::EntityDisplayAttribute::EntityDisplayAttribute
EntityDisplayAttribute()
Creates a new entity display attribute.
Definition entitydisplayattribute.cpp:42
Akonadi::EntityDisplayAttribute::backgroundColor
QColor backgroundColor() const
Returns the backgroundColor or an invalid color if none is set.
Definition entitydisplayattribute.cpp:157
Akonadi::EntityDisplayAttribute::clone
EntityDisplayAttribute * clone() const
Creates a copy of this attribute.
Definition entitydisplayattribute.cpp:83
Akonadi::EntityDisplayAttribute::displayName
QString displayName() const
Returns the name that should be used for display.
Definition entitydisplayattribute.cpp:52
Akonadi::EntityDisplayAttribute::deserialize
void deserialize(const QByteArray &data)
Sets the data of this attribute, using the same encoding as returned by toByteArray().
Definition entitydisplayattribute.cpp:110
Akonadi::EntityDisplayAttribute::setDisplayName
void setDisplayName(const QString &name)
Sets the name that should be used for display.
Definition entitydisplayattribute.cpp:57
Akonadi::EntityDisplayAttribute::activeIconName
QString activeIconName() const
Returns the icon name of an active item.
Definition entitydisplayattribute.cpp:152
Akonadi::EntityDisplayAttribute::icon
KIcon icon() const
Returns the icon that should be used for this collection or item.
Definition entitydisplayattribute.cpp:62
Akonadi::EntityDisplayAttribute::serialized
QByteArray serialized() const
Returns a QByteArray representation of the attribute which will be storaged.
Definition entitydisplayattribute.cpp:93
Akonadi::EntityDisplayAttribute::iconName
QString iconName() const
Returns the icon name of the icon returned by icon().
Definition entitydisplayattribute.cpp:67
Akonadi
FreeBusyManager::Singleton.
Definition actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal