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

akonadi

  • home
  • ichiro
  • data
  • ssd
  • Momonga
  • trunk
  • pkgs
  • kdepimlibs
  • BUILD
  • kdepimlibs-4.14.3
  • 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 
26 using namespace Akonadi;
27 
28 class EntityDisplayAttribute::Private
29 {
30 public:
31  Private()
32  : hidden(false)
33  {
34  }
35  QString name;
36  QString icon;
37  QString activeIcon;
38  QColor backgroundColor;
39  bool hidden;
40 };
41 
42 EntityDisplayAttribute::EntityDisplayAttribute()
43  : d(new Private)
44 {
45 }
46 
47 EntityDisplayAttribute::~ EntityDisplayAttribute()
48 {
49  delete d;
50 }
51 
52 QString EntityDisplayAttribute::displayName() const
53 {
54  return d->name;
55 }
56 
57 void EntityDisplayAttribute::setDisplayName(const QString &name)
58 {
59  d->name = name;
60 }
61 
62 KIcon EntityDisplayAttribute::icon() const
63 {
64  return KIcon(d->icon);
65 }
66 
67 QString EntityDisplayAttribute::iconName() const
68 {
69  return d->icon;
70 }
71 
72 void EntityDisplayAttribute::setIconName(const QString &icon)
73 {
74  d->icon = icon;
75 }
76 
77 QByteArray Akonadi::EntityDisplayAttribute::type() const
78 {
79  return "ENTITYDISPLAY";
80 }
81 
82 EntityDisplayAttribute *EntityDisplayAttribute::clone() const
83 {
84  EntityDisplayAttribute *attr = new EntityDisplayAttribute();
85  attr->d->name = d->name;
86  attr->d->icon = d->icon;
87  attr->d->activeIcon = d->activeIcon;
88  attr->d->backgroundColor = d->backgroundColor;
89  return attr;
90 }
91 
92 QByteArray EntityDisplayAttribute::serialized() const
93 {
94  QList<QByteArray> l;
95  l << ImapParser::quote(d->name.toUtf8());
96  l << ImapParser::quote(d->icon.toUtf8());
97  l << ImapParser::quote(d->activeIcon.toUtf8());
98  QList<QByteArray> components;
99  if (d->backgroundColor.isValid()) {
100  components = QList<QByteArray>() << QByteArray::number(d->backgroundColor.red())
101  << QByteArray::number(d->backgroundColor.green())
102  << QByteArray::number(d->backgroundColor.blue())
103  << QByteArray::number(d->backgroundColor.alpha());
104  }
105  l << '(' + ImapParser::join(components, " ") + ')';
106  return '(' + ImapParser::join(l, " ") + ')';
107 }
108 
109 void EntityDisplayAttribute::deserialize(const QByteArray &data)
110 {
111  QList<QByteArray> l;
112  ImapParser::parseParenthesizedList(data, l);
113  int size = l.size();
114  Q_ASSERT(size >= 2);
115  d->name = QString::fromUtf8(l[0]);
116  d->icon = QString::fromUtf8(l[1]);
117  if (size >= 3) {
118  d->activeIcon = QString::fromUtf8(l[2]);
119  }
120  if (size >= 4) {
121  if (!l[3].isEmpty()) {
122  QList<QByteArray> componentData;
123  ImapParser::parseParenthesizedList(l[3], componentData);
124  if (componentData.size() != 4) {
125  return;
126  }
127  QList<int> components;
128 
129  bool ok;
130  for (int i = 0; i <= 3; ++i) {
131  components << componentData.at(i).toInt(&ok);
132  if (!ok) {
133  return;
134  }
135  }
136  d->backgroundColor = QColor(components.at(0), components.at(1), components.at(2), components.at(3));
137  }
138  }
139 }
140 
141 void EntityDisplayAttribute::setActiveIconName(const QString &name)
142 {
143  d->activeIcon = name;
144 }
145 
146 KIcon EntityDisplayAttribute::activeIcon() const
147 {
148  return KIcon(d->activeIcon);
149 }
150 
151 QString EntityDisplayAttribute::activeIconName() const
152 {
153  return d->activeIcon;
154 }
155 
156 QColor EntityDisplayAttribute::backgroundColor() const
157 {
158  return d->backgroundColor;
159 }
160 
161 void EntityDisplayAttribute::setBackgroundColor(const QColor &color)
162 {
163  d->backgroundColor = color;
164 }
Akonadi::EntityDisplayAttribute::clone
EntityDisplayAttribute * clone() const
Creates a copy of this attribute.
Definition: entitydisplayattribute.cpp:82
Akonadi::EntityDisplayAttribute::setActiveIconName
void setActiveIconName(const QString &name)
Sets the icon name for the active icon.
Definition: entitydisplayattribute.cpp:141
Akonadi::EntityDisplayAttribute::activeIconName
QString activeIconName() const
Returns the icon name of an active item.
Definition: entitydisplayattribute.cpp:151
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:161
Akonadi::EntityDisplayAttribute::setDisplayName
void setDisplayName(const QString &name)
Sets the name that should be used for display.
Definition: entitydisplayattribute.cpp:57
Akonadi::EntityDisplayAttribute::serialized
QByteArray serialized() const
Returns a QByteArray representation of the attribute which will be storaged.
Definition: entitydisplayattribute.cpp:92
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:109
Akonadi::EntityDisplayAttribute::EntityDisplayAttribute
EntityDisplayAttribute()
Creates a new entity display attribute.
Definition: entitydisplayattribute.cpp:42
Akonadi::EntityDisplayAttribute::displayName
QString displayName() const
Returns the name that should be used for display.
Definition: entitydisplayattribute.cpp:52
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
Akonadi::EntityDisplayAttribute::activeIcon
KIcon activeIcon() const
Returns the icon that should be used for this collection or item when active.
Definition: entitydisplayattribute.cpp:146
Akonadi::EntityDisplayAttribute::icon
KIcon icon() const
Returns the icon that should be used for this collection or item.
Definition: entitydisplayattribute.cpp:62
Akonadi::EntityDisplayAttribute
Attribute that stores the properties that are used to display an entity.
Definition: entitydisplayattribute.h:39
Akonadi::EntityDisplayAttribute::iconName
QString iconName() const
Returns the icon name of the icon returned by icon().
Definition: entitydisplayattribute.cpp:67
Akonadi::EntityDisplayAttribute::type
QByteArray type() const
Returns the type of the attribute.
Definition: entitydisplayattribute.cpp:77
Akonadi::EntityDisplayAttribute::backgroundColor
QColor backgroundColor() const
Returns the backgroundColor or an invalid color if none is set.
Definition: entitydisplayattribute.cpp:156
This file is part of the KDE documentation.
Documentation copyright © 1996-2018 The KDE developers.
Generated on Fri Oct 19 2018 17:57:18 by doxygen 1.8.13 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
  • Modules
  • Related Pages

kdepimlibs-4.14.3 API Reference

Skip menu "kdepimlibs-4.14.3 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