20 #include "tagattribute.h"
22 #include "imapparser_p.h"
28 class TagAttribute::Private
38 QColor backgroundColor;
46 TagAttribute::TagAttribute()
51 TagAttribute::~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,
" ") +
')';
128 static 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();
168 QColor TagAttribute::backgroundColor()
const
170 return d->backgroundColor;
173 void TagAttribute::setBackgroundColor(
const QColor &color)
175 d->backgroundColor = color;
178 void TagAttribute::setTextColor(
const QColor &color)
180 d->textColor = color;
183 QColor TagAttribute::textColor()
const
188 void TagAttribute::setFont(
const QString &font)
193 QString TagAttribute::font()
const
198 void TagAttribute::setInToolbar(
bool inToolbar)
200 d->inToolbar = inToolbar;
203 bool TagAttribute::inToolbar()
const
208 void TagAttribute::setShortcut(
const QString &shortcut)
210 d->shortcut = shortcut;
213 QString TagAttribute::shortcut()
const
QByteArray type() const
Returns the type of the attribute.
void setPriority(int priority)
Sets the priority of the tag.
QByteArray serialized() const
Returns a QByteArray representation of the attribute which will be storaged.
void setDisplayName(const QString &name)
Sets the name that should be used for display.
int priority() const
Returns the priority of the tag.
QString iconName() const
Returns the icon name of the icon returned by icon().
void deserialize(const QByteArray &data)
Sets the data of this attribute, using the same encoding as returned by toByteArray().
QString displayName() const
Returns the name that should be used for display.
Attribute that stores the properties that are used to display a tag.
void setIconName(const QString &name)
Sets the icon name for the default icon.
FreeBusyManager::Singleton.
TagAttribute * clone() const
Creates a copy of this attribute.