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

akonadi

  • akonadi
tagattribute.cpp
1/*
2 Copyright (c) 2008 Volker Krause <vkrause@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#include "tagattribute.h"
21
22#include "imapparser_p.h"
23
24#include <KIcon>
25
26using namespace Akonadi;
27
28class TagAttribute::Private
29{
30public:
31 Private()
32 : inToolbar(false)
33 , priority(-1)
34 {}
35
36 QString name;
37 QString icon;
38 QColor backgroundColor;
39 QColor textColor;
40 QString font;
41 bool inToolbar;
42 QString shortcut;
43 int priority;
44};
45
46TagAttribute::TagAttribute()
47 : d(new Private)
48{
49}
50
51TagAttribute::~TagAttribute()
52{
53 delete d;
54}
55
56QString TagAttribute::displayName() const
57{
58 return d->name;
59}
60
61void TagAttribute::setDisplayName(const QString &name)
62{
63 d->name = name;
64}
65
66QString TagAttribute::iconName() const
67{
68 return d->icon;
69}
70
71void TagAttribute::setIconName(const QString &icon)
72{
73 d->icon = icon;
74}
75
76QByteArray Akonadi::TagAttribute::type() const
77{
78 static const QByteArray sType( "TAG" );
79 return sType;
80}
81
82TagAttribute *TagAttribute::clone() const
83{
84 TagAttribute *attr = new TagAttribute();
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;
92 attr->d->priority = d->priority;
93 return attr;
94}
95
96QByteArray TagAttribute::serialized() const
97{
98 QList<QByteArray> l;
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());
104 {
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());
111 }
112 l << '(' + ImapParser::join(components, " ") + ')';
113 }
114 {
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());
121 }
122 l << '(' + ImapParser::join(components, " ") + ')';
123 }
124 l << ImapParser::quote(QString::number(d->priority).toUtf8());
125 return '(' + ImapParser::join(l, " ") + ')';
126}
127
128static QColor parseColor(const QByteArray &data)
129{
130 QList<QByteArray> componentData;
131 ImapParser::parseParenthesizedList(data, componentData);
132 if (componentData.size() != 4) {
133 return QColor();
134 }
135 QList<int> components;
136 bool ok;
137 for (int i = 0; i <= 3; ++i) {
138 components << componentData.at(i).toInt(&ok);
139 if (!ok) {
140 return QColor();
141 }
142 }
143 return QColor(components.at(0), components.at(1), components.at(2), components.at(3));
144}
145
146void TagAttribute::deserialize(const QByteArray &data)
147{
148 QList<QByteArray> l;
149 ImapParser::parseParenthesizedList(data, l);
150 int size = l.size();
151 Q_ASSERT(size >= 7);
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]);
159 }
160 if (!l[6].isEmpty()) {
161 d->textColor = parseColor(l[6]);
162 }
163 if (l.size() >= 8) {
164 d->priority = QString::fromUtf8(l[7]).toInt();
165 }
166}
167
168QColor TagAttribute::backgroundColor() const
169{
170 return d->backgroundColor;
171}
172
173void TagAttribute::setBackgroundColor(const QColor &color)
174{
175 d->backgroundColor = color;
176}
177
178void TagAttribute::setTextColor(const QColor &color)
179{
180 d->textColor = color;
181}
182
183QColor TagAttribute::textColor() const
184{
185 return d->textColor;
186}
187
188void TagAttribute::setFont(const QString &font)
189{
190 d->font = font;
191}
192
193QString TagAttribute::font() const
194{
195 return d->font;
196}
197
198void TagAttribute::setInToolbar(bool inToolbar)
199{
200 d->inToolbar = inToolbar;
201}
202
203bool TagAttribute::inToolbar() const
204{
205 return d->inToolbar;
206}
207
208void TagAttribute::setShortcut(const QString &shortcut)
209{
210 d->shortcut = shortcut;
211}
212
213QString TagAttribute::shortcut() const
214{
215 return d->shortcut;
216}
217
218void TagAttribute::setPriority(int priority)
219{
220 d->priority = priority;
221}
222
223int TagAttribute::priority() const
224{
225 return d->priority;
226}
Akonadi::TagAttribute
Attribute that stores the properties that are used to display a tag.
Definition: tagattribute.h:39
Akonadi::TagAttribute::displayName
QString displayName() const
Returns the name that should be used for display.
Definition: tagattribute.cpp:56
Akonadi::TagAttribute::setDisplayName
void setDisplayName(const QString &name)
Sets the name that should be used for display.
Definition: tagattribute.cpp:61
Akonadi::TagAttribute::setIconName
void setIconName(const QString &name)
Sets the icon name for the default icon.
Definition: tagattribute.cpp:71
Akonadi::TagAttribute::clone
TagAttribute * clone() const
Creates a copy of this attribute.
Definition: tagattribute.cpp:82
Akonadi::TagAttribute::type
QByteArray type() const
Returns the type of the attribute.
Definition: tagattribute.cpp:76
Akonadi::TagAttribute::setPriority
void setPriority(int priority)
Sets the priority of the tag.
Definition: tagattribute.cpp:218
Akonadi::TagAttribute::deserialize
void deserialize(const QByteArray &data)
Sets the data of this attribute, using the same encoding as returned by toByteArray().
Definition: tagattribute.cpp:146
Akonadi::TagAttribute::serialized
QByteArray serialized() const
Returns a QByteArray representation of the attribute which will be storaged.
Definition: tagattribute.cpp:96
Akonadi::TagAttribute::iconName
QString iconName() const
Returns the icon name of the icon returned by icon().
Definition: tagattribute.cpp:66
Akonadi::TagAttribute::priority
int priority() const
Returns the priority of the tag.
Definition: tagattribute.cpp:223
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 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.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • 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