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

akonadi

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

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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