20 #include "entitydisplayattribute.h"
22 #include "imapparser_p.h"
26 using namespace Akonadi;
28 class EntityDisplayAttribute::Private
31 Private() : hidden( false ) {}
35 QColor backgroundColor;
39 EntityDisplayAttribute::EntityDisplayAttribute() :
44 EntityDisplayAttribute::~ EntityDisplayAttribute()
49 QString EntityDisplayAttribute::displayName()
const
54 void EntityDisplayAttribute::setDisplayName(
const QString & name)
59 KIcon EntityDisplayAttribute::icon()
const
61 return KIcon( d->icon );
64 QString EntityDisplayAttribute::iconName()
const
69 void EntityDisplayAttribute::setIconName(
const QString & icon)
76 return "ENTITYDISPLAY";
82 attr->d->name = d->name;
83 attr->d->
icon = d->icon;
89 QByteArray EntityDisplayAttribute::serialized()
const
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() )
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() );
103 l <<
'(' + ImapParser::join( components,
" " ) +
')';
104 return '(' + ImapParser::join( l,
" " ) +
')';
107 void EntityDisplayAttribute::deserialize(
const QByteArray &data)
110 ImapParser::parseParenthesizedList( data, l );
112 Q_ASSERT( size >= 2 );
113 d->name = QString::fromUtf8( l[0] );
114 d->icon = QString::fromUtf8( l[1] );
116 d->activeIcon = QString::fromUtf8( l[2] );
120 if ( !l[3].isEmpty() )
122 QList<QByteArray> componentData;
123 ImapParser::parseParenthesizedList( l[3], componentData );
124 if ( componentData.size() != 4 )
126 QList<int> components;
129 for (
int i = 0; i <= 3; ++i )
131 components << componentData.at( i ).toInt( &ok );
135 d->backgroundColor = QColor( components.at( 0 ), components.at( 1 ), components.at( 2 ), components.at( 3 ) );
140 void EntityDisplayAttribute::setActiveIconName(
const QString &name )
142 d->activeIcon = name;
145 KIcon EntityDisplayAttribute::activeIcon()
const
147 return KIcon( d->activeIcon );
150 QString EntityDisplayAttribute::activeIconName()
const
152 return d->activeIcon;
155 QColor EntityDisplayAttribute::backgroundColor()
const
157 return d->backgroundColor;
160 void EntityDisplayAttribute::setBackgroundColor(
const QColor &color )
162 d->backgroundColor = color;