• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.9.4 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 
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  {
98  components = QList<QByteArray>() << QByteArray::number( d->backgroundColor.red() )
99  << QByteArray::number( d->backgroundColor.green() )
100  << QByteArray::number( d->backgroundColor.blue() )
101  << QByteArray::number( d->backgroundColor.alpha() );
102  }
103  l << '(' + ImapParser::join( components, " " ) + ')';
104  return '(' + ImapParser::join( l, " " ) + ')';
105 }
106 
107 void EntityDisplayAttribute::deserialize(const QByteArray &data)
108 {
109  QList<QByteArray> l;
110  ImapParser::parseParenthesizedList( data, l );
111  int size = l.size();
112  Q_ASSERT( size >= 2 );
113  d->name = QString::fromUtf8( l[0] );
114  d->icon = QString::fromUtf8( l[1] );
115  if ( size >= 3 ) {
116  d->activeIcon = QString::fromUtf8( l[2] );
117  }
118  if ( size >= 4 )
119  {
120  if ( !l[3].isEmpty() )
121  {
122  QList<QByteArray> componentData;
123  ImapParser::parseParenthesizedList( l[3], componentData );
124  if ( componentData.size() != 4 )
125  return;
126  QList<int> components;
127 
128  bool ok;
129  for ( int i = 0; i <= 3; ++i )
130  {
131  components << componentData.at( i ).toInt( &ok );
132  if ( !ok )
133  return;
134  }
135  d->backgroundColor = QColor( components.at( 0 ), components.at( 1 ), components.at( 2 ), components.at( 3 ) );
136  }
137  }
138 }
139 
140 void EntityDisplayAttribute::setActiveIconName( const QString &name )
141 {
142  d->activeIcon = name;
143 }
144 
145 KIcon EntityDisplayAttribute::activeIcon() const
146 {
147  return KIcon( d->activeIcon );
148 }
149 
150 QString EntityDisplayAttribute::activeIconName() const
151 {
152  return d->activeIcon;
153 }
154 
155 QColor EntityDisplayAttribute::backgroundColor() const
156 {
157  return d->backgroundColor;
158 }
159 
160 void EntityDisplayAttribute::setBackgroundColor( const QColor &color )
161 {
162  d->backgroundColor = color;
163 }
164 
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Dec 10 2012 13:48:09 by doxygen 1.8.1.2 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.9.4 API Reference

Skip menu "kdepimlibs-4.9.4 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • 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