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

akonadi

entitydisplayattribute.cpp
00001 /*
00002     Copyright (c) 2008 Volker Krause <vkrause@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #include "entitydisplayattribute.h"
00021 
00022 #include "imapparser_p.h"
00023 
00024 #include <KIcon>
00025 
00026 using namespace Akonadi;
00027 
00028 class EntityDisplayAttribute::Private
00029 {
00030   public:
00031     Private() : hidden( false ) {}
00032     QString name;
00033     QString icon;
00034     QString activeIcon;
00035     QColor backgroundColor;
00036     bool hidden;
00037 };
00038 
00039 EntityDisplayAttribute::EntityDisplayAttribute() :
00040     d( new Private )
00041 {
00042 }
00043 
00044 EntityDisplayAttribute::~ EntityDisplayAttribute()
00045 {
00046   delete d;
00047 }
00048 
00049 QString EntityDisplayAttribute::displayName() const
00050 {
00051   return d->name;
00052 }
00053 
00054 void EntityDisplayAttribute::setDisplayName(const QString & name)
00055 {
00056   d->name = name;
00057 }
00058 
00059 KIcon EntityDisplayAttribute::icon() const
00060 {
00061   return KIcon( d->icon );
00062 }
00063 
00064 QString EntityDisplayAttribute::iconName() const
00065 {
00066   return d->icon;
00067 }
00068 
00069 void EntityDisplayAttribute::setIconName(const QString & icon)
00070 {
00071   d->icon = icon;
00072 }
00073 
00074 QByteArray Akonadi::EntityDisplayAttribute::type() const
00075 {
00076   return "ENTITYDISPLAY";
00077 }
00078 
00079 EntityDisplayAttribute * EntityDisplayAttribute::clone() const
00080 {
00081   EntityDisplayAttribute *attr = new EntityDisplayAttribute();
00082   attr->d->name = d->name;
00083   attr->d->icon = d->icon;
00084   attr->d->activeIcon = d->activeIcon;
00085   attr->d->backgroundColor = d->backgroundColor;
00086   return attr;
00087 }
00088 
00089 QByteArray EntityDisplayAttribute::serialized() const
00090 {
00091   QList<QByteArray> l;
00092   l << ImapParser::quote( d->name.toUtf8() );
00093   l << ImapParser::quote( d->icon.toUtf8() );
00094   l << ImapParser::quote( d->activeIcon.toUtf8() );
00095   QList<QByteArray> components;
00096   if ( d->backgroundColor.isValid() )
00097   {
00098     components = QList<QByteArray>() << QByteArray::number( d->backgroundColor.red() )
00099                                      << QByteArray::number( d->backgroundColor.green() )
00100                                      << QByteArray::number( d->backgroundColor.blue() )
00101                                      << QByteArray::number( d->backgroundColor.alpha() );
00102   }
00103   l << '(' + ImapParser::join( components, " " ) + ')';
00104   return '(' + ImapParser::join( l, " " ) + ')';
00105 }
00106 
00107 void EntityDisplayAttribute::deserialize(const QByteArray &data)
00108 {
00109   QList<QByteArray> l;
00110   ImapParser::parseParenthesizedList( data, l );
00111   int size = l.size();
00112   Q_ASSERT( size >= 2 );
00113   d->name = QString::fromUtf8( l[0] );
00114   d->icon = QString::fromUtf8( l[1] );
00115   if ( size >= 3 ) {
00116     d->activeIcon = QString::fromUtf8( l[2] );
00117   }
00118   if ( size >= 4 )
00119   {
00120     if ( !l[3].isEmpty() )
00121     {
00122       QList<QByteArray> componentData;
00123       ImapParser::parseParenthesizedList( l[3], componentData );
00124       if ( componentData.size() != 4 )
00125         return;
00126       QList<int> components;
00127 
00128       bool ok;
00129       for ( int i = 0; i <= 3; ++i )
00130       {
00131         components << componentData.at( i ).toInt( &ok );
00132         if ( !ok )
00133           return;
00134       }
00135       d->backgroundColor = QColor( components.at( 0 ), components.at( 1 ), components.at( 2 ), components.at( 3 ) );
00136     }
00137   }
00138 }
00139 
00140 void EntityDisplayAttribute::setActiveIconName( const QString &name )
00141 {
00142   d->activeIcon = name;
00143 }
00144 
00145 KIcon EntityDisplayAttribute::activeIcon() const
00146 {
00147   return KIcon( d->activeIcon );
00148 }
00149 
00150 QString EntityDisplayAttribute::activeIconName() const
00151 {
00152   return d->activeIcon;
00153 }
00154 
00155 QColor EntityDisplayAttribute::backgroundColor() const
00156 {
00157   return d->backgroundColor;
00158 }
00159 
00160 void EntityDisplayAttribute::setBackgroundColor( const QColor &color )
00161 {
00162   d->backgroundColor = color;
00163 }
00164 
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:49:15 by doxygen 1.8.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
  • Modules
  • Related Pages

kdepimlibs-4.8.3 API Reference

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