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 QString name; 00032 QString icon; 00033 }; 00034 00035 EntityDisplayAttribute::EntityDisplayAttribute() : 00036 d( new Private ) 00037 { 00038 } 00039 00040 EntityDisplayAttribute::~ EntityDisplayAttribute() 00041 { 00042 delete d; 00043 } 00044 00045 QString EntityDisplayAttribute::displayName() const 00046 { 00047 return d->name; 00048 } 00049 00050 void EntityDisplayAttribute::setDisplayName(const QString & name) 00051 { 00052 d->name = name; 00053 } 00054 00055 KIcon EntityDisplayAttribute::icon() const 00056 { 00057 return KIcon( d->icon ); 00058 } 00059 00060 QString EntityDisplayAttribute::iconName() const 00061 { 00062 return d->icon; 00063 } 00064 00065 void EntityDisplayAttribute::setIconName(const QString & icon) 00066 { 00067 d->icon = icon; 00068 } 00069 00070 QByteArray Akonadi::EntityDisplayAttribute::type() const 00071 { 00072 return "ENTITYDISPLAY"; 00073 } 00074 00075 EntityDisplayAttribute * EntityDisplayAttribute::clone() const 00076 { 00077 EntityDisplayAttribute *attr = new EntityDisplayAttribute(); 00078 attr->d->name = d->name; 00079 attr->d->icon = d->icon; 00080 return attr; 00081 } 00082 00083 QByteArray EntityDisplayAttribute::serialized() const 00084 { 00085 QList<QByteArray> l; 00086 l << ImapParser::quote( d->name.toUtf8() ); 00087 l << ImapParser::quote( d->icon.toUtf8() ); 00088 return '(' + ImapParser::join( l, " " ) + ')'; 00089 } 00090 00091 void EntityDisplayAttribute::deserialize(const QByteArray &data) 00092 { 00093 QList<QByteArray> l; 00094 ImapParser::parseParenthesizedList( data, l ); 00095 Q_ASSERT( l.count() >= 2 ); 00096 d->name = QString::fromUtf8( l[0] ); 00097 d->icon = QString::fromUtf8( l[1] ); 00098 }