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

akonadi

  • akonadi
  • kmime
messagethreadingattribute.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 "messagethreadingattribute.h"
21
22using namespace Akonadi;
23
24class Akonadi::MessageThreadingAttribute::Private
25{
26public:
27 QList<Item::Id> perfectParents;
28 QList<Item::Id> unperfectParents;
29 QList<Item::Id> subjectParents;
30};
31
32MessageThreadingAttribute::MessageThreadingAttribute()
33 : d(new Private)
34{
35}
36
37MessageThreadingAttribute::MessageThreadingAttribute(const MessageThreadingAttribute &other)
38 : Attribute(other)
39 , d(new Private(*(other.d)))
40{
41}
42
43MessageThreadingAttribute::~ MessageThreadingAttribute()
44{
45 delete d;
46}
47
48QByteArray MessageThreadingAttribute::type() const
49{
50 static const QByteArray sType( "MESSAGETHREADING" );
51 return sType;
52}
53
54MessageThreadingAttribute *MessageThreadingAttribute::clone() const
55{
56 return new MessageThreadingAttribute(*this);
57}
58
59QByteArray MessageThreadingAttribute::serialized() const
60{
61 QByteArray rv;
62 foreach (const Item::Id id, d->perfectParents) {
63 rv += QByteArray::number(id) + ',';
64 }
65 if (!d->perfectParents.isEmpty()) {
66 rv[rv.size() - 1] = ';';
67 } else {
68 rv += ';';
69 }
70 foreach (const Item::Id id, d->unperfectParents) {
71 rv += QByteArray::number(id) + ',';
72 }
73 if (!d->unperfectParents.isEmpty()) {
74 rv[rv.size() - 1] = ';';
75 } else {
76 rv += ';';
77 }
78 foreach (const Item::Id id, d->subjectParents) {
79 rv += QByteArray::number(id) + ',';
80 }
81 if (!d->perfectParents.isEmpty()) {
82 rv.chop(1);
83 }
84
85 return rv;
86}
87
88static void parseIdList(const QByteArray &data, QList<Item::Id> &result)
89{
90 bool ok = false;
91 foreach (const QByteArray &s, data.split(',')) {
92 Item::Id id = s.toLongLong(&ok);
93 if (!ok) {
94 continue;
95 }
96 result << id;
97 }
98}
99
100void MessageThreadingAttribute::deserialize(const QByteArray &data)
101{
102 d->perfectParents.clear();
103 d->unperfectParents.clear();
104 d->subjectParents.clear();
105
106 QList<QByteArray> lists = data.split(';');
107 if (lists.size() != 3) {
108 return;
109 }
110
111 parseIdList(lists[0], d->perfectParents);
112 parseIdList(lists[1], d->unperfectParents);
113 parseIdList(lists[2], d->subjectParents);
114}
115
116QList< Item::Id > MessageThreadingAttribute::perfectParents() const
117{
118 return d->perfectParents;
119}
120
121void MessageThreadingAttribute::setPerfectParents(const QList< Item::Id > &parents)
122{
123 d->perfectParents = parents;
124}
125
126QList< Item::Id > MessageThreadingAttribute::unperfectParents() const
127{
128 return d->unperfectParents;
129}
130
131void MessageThreadingAttribute::setUnperfectParents(const QList< Item::Id > &parents)
132{
133 d->unperfectParents = parents;
134}
135
136QList< Item::Id > MessageThreadingAttribute::subjectParents() const
137{
138 return d->subjectParents;
139}
140
141void MessageThreadingAttribute::setSubjectParents(const QList< Item::Id > &parents)
142{
143 d->subjectParents = parents;
144}
Akonadi::Attribute
Provides interface for custom attributes for Entity.
Definition: attribute.h:139
Akonadi::MessageThreadingAttribute
Message threading information.
Definition: messagethreadingattribute.h:35
Akonadi::MessageThreadingAttribute::serialized
QByteArray serialized() const
Returns a QByteArray representation of the attribute which will be storaged.
Definition: messagethreadingattribute.cpp:59
Akonadi::MessageThreadingAttribute::setUnperfectParents
void setUnperfectParents(const QList< Item::Id > &parents)
Sets the list of non-perfect parent message ids.
Definition: messagethreadingattribute.cpp:131
Akonadi::MessageThreadingAttribute::subjectParents
QList< Item::Id > subjectParents() const
Returns the list of possible parent message ids based on analyzing the subject.
Definition: messagethreadingattribute.cpp:136
Akonadi::MessageThreadingAttribute::setSubjectParents
void setSubjectParents(const QList< Item::Id > &parents)
Sets the list of possible parent message ids based on analyzing the subject.
Definition: messagethreadingattribute.cpp:141
Akonadi::MessageThreadingAttribute::clone
MessageThreadingAttribute * clone() const
Creates a copy of this attribute.
Definition: messagethreadingattribute.cpp:54
Akonadi::MessageThreadingAttribute::perfectParents
QList< Item::Id > perfectParents() const
Returns the list of perfect parent message ids.
Definition: messagethreadingattribute.cpp:116
Akonadi::MessageThreadingAttribute::unperfectParents
QList< Item::Id > unperfectParents() const
Returns the list of non-perfect parent message ids.
Definition: messagethreadingattribute.cpp:126
Akonadi::MessageThreadingAttribute::deserialize
void deserialize(const QByteArray &data)
Sets the data of this attribute, using the same encoding as returned by toByteArray().
Definition: messagethreadingattribute.cpp:100
Akonadi::MessageThreadingAttribute::setPerfectParents
void setPerfectParents(const QList< Item::Id > &parents)
Sets the list of perfect parent message ids.
Definition: messagethreadingattribute.cpp:121
Akonadi::MessageThreadingAttribute::type
QByteArray type() const
Returns the type of the attribute.
Definition: messagethreadingattribute.cpp:48
Akonadi::MessageThreadingAttribute::MessageThreadingAttribute
MessageThreadingAttribute()
Creates an empty threading attribute.
Definition: messagethreadingattribute.cpp:32
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