20#include "tagattribute.h"
22#include "imapparser_p.h"
28class TagAttribute::Private
38 QColor backgroundColor;
46TagAttribute::TagAttribute()
51TagAttribute::~TagAttribute()
78 static const QByteArray sType(
"TAG" );
85 attr->d->name = d->name;
86 attr->d->icon = d->icon;
87 attr->d->backgroundColor = d->backgroundColor;
88 attr->d->textColor = d->textColor;
89 attr->d->font = d->font;
90 attr->d->inToolbar = d->inToolbar;
91 attr->d->shortcut = d->shortcut;
99 l << ImapParser::quote(d->name.toUtf8());
100 l << ImapParser::quote(d->icon.toUtf8());
101 l << ImapParser::quote(d->font.toUtf8());
102 l << ImapParser::quote(d->shortcut.toUtf8());
103 l << ImapParser::quote(QString::number(d->inToolbar).toUtf8());
105 QList<QByteArray> components;
106 if (d->backgroundColor.isValid()) {
107 components = QList<QByteArray>() << QByteArray::number(d->backgroundColor.red())
108 << QByteArray::number(d->backgroundColor.green())
109 << QByteArray::number(d->backgroundColor.blue())
110 << QByteArray::number(d->backgroundColor.alpha());
112 l <<
'(' + ImapParser::join(components,
" ") +
')';
115 QList<QByteArray> components;
116 if (d->textColor.isValid()) {
117 components = QList<QByteArray>() << QByteArray::number(d->textColor.red())
118 << QByteArray::number(d->textColor.green())
119 << QByteArray::number(d->textColor.blue())
120 << QByteArray::number(d->textColor.alpha());
122 l <<
'(' + ImapParser::join(components,
" ") +
')';
124 l << ImapParser::quote(QString::number(d->priority).toUtf8());
125 return '(' + ImapParser::join(l,
" ") +
')';
128static QColor parseColor(
const QByteArray &data)
130 QList<QByteArray> componentData;
131 ImapParser::parseParenthesizedList(data, componentData);
132 if (componentData.size() != 4) {
135 QList<int> components;
137 for (
int i = 0; i <= 3; ++i) {
138 components << componentData.at(i).toInt(&ok);
143 return QColor(components.at(0), components.at(1), components.at(2), components.at(3));
149 ImapParser::parseParenthesizedList(data, l);
152 d->name = QString::fromUtf8(l[0]);
153 d->icon = QString::fromUtf8(l[1]);
154 d->font = QString::fromUtf8(l[2]);
155 d->shortcut = QString::fromUtf8(l[3]);
156 d->inToolbar = QString::fromUtf8(l[4]).toInt();
157 if (!l[5].isEmpty()) {
158 d->backgroundColor = parseColor(l[5]);
160 if (!l[6].isEmpty()) {
161 d->textColor = parseColor(l[6]);
164 d->priority = QString::fromUtf8(l[7]).toInt();
168QColor TagAttribute::backgroundColor()
const
170 return d->backgroundColor;
173void TagAttribute::setBackgroundColor(
const QColor &color)
175 d->backgroundColor = color;
178void TagAttribute::setTextColor(
const QColor &color)
180 d->textColor = color;
183QColor TagAttribute::textColor()
const
188void TagAttribute::setFont(
const QString &font)
193QString TagAttribute::font()
const
198void TagAttribute::setInToolbar(
bool inToolbar)
200 d->inToolbar = inToolbar;
203bool TagAttribute::inToolbar()
const
208void TagAttribute::setShortcut(
const QString &shortcut)
210 d->shortcut = shortcut;
213QString TagAttribute::shortcut()
const
Attribute that stores the properties that are used to display a tag.
QString displayName() const
Returns the name that should be used for display.
void setDisplayName(const QString &name)
Sets the name that should be used for display.
void setIconName(const QString &name)
Sets the icon name for the default icon.
TagAttribute * clone() const
Creates a copy of this attribute.
QByteArray type() const
Returns the type of the attribute.
void setPriority(int priority)
Sets the priority of the tag.
void deserialize(const QByteArray &data)
Sets the data of this attribute, using the same encoding as returned by toByteArray().
QByteArray serialized() const
Returns a QByteArray representation of the attribute which will be storaged.
QString iconName() const
Returns the icon name of the icon returned by icon().
int priority() const
Returns the priority of the tag.
FreeBusyManager::Singleton.