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

akonadi/kmime

  • sources
  • kde-4.12
  • kdepimlibs
  • 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 
22 using namespace Akonadi;
23 
24 class Akonadi::MessageThreadingAttribute::Private
25 {
26  public:
27  QList<Item::Id> perfectParents;
28  QList<Item::Id> unperfectParents;
29  QList<Item::Id> subjectParents;
30 };
31 
32 MessageThreadingAttribute::MessageThreadingAttribute() :
33  d( new Private )
34 {
35 }
36 
37 MessageThreadingAttribute::MessageThreadingAttribute(const MessageThreadingAttribute & other) :
38  Attribute( other ),
39  d( new Private( *(other.d) ) )
40 {
41 }
42 
43 MessageThreadingAttribute::~ MessageThreadingAttribute()
44 {
45  delete d;
46 }
47 
48 QByteArray MessageThreadingAttribute::type() const
49 {
50  return "MESSAGETHREADING";
51 }
52 
53 MessageThreadingAttribute * MessageThreadingAttribute::clone() const
54 {
55  return new MessageThreadingAttribute( *this );
56 }
57 
58 QByteArray MessageThreadingAttribute::serialized() const
59 {
60  QByteArray rv;
61  foreach ( const Item::Id id, d->perfectParents )
62  rv += QByteArray::number( id ) + ',';
63  if ( !d->perfectParents.isEmpty() )
64  rv[rv.size() - 1] = ';';
65  else
66  rv += ';';
67  foreach ( const Item::Id id, d->unperfectParents )
68  rv += QByteArray::number( id ) + ',';
69  if ( !d->unperfectParents.isEmpty() )
70  rv[rv.size() - 1] = ';';
71  else
72  rv += ';';
73  foreach ( const Item::Id id, d->subjectParents )
74  rv += QByteArray::number( id ) + ',';
75  if ( !d->perfectParents.isEmpty() )
76  rv.chop( 1 );
77 
78  return rv;
79 }
80 
81 static void parseIdList( const QByteArray &data, QList<Item::Id> &result )
82 {
83  bool ok = false;
84  foreach( const QByteArray &s, data.split( ',' ) ) {
85  Item::Id id = s.toLongLong( &ok );
86  if ( !ok )
87  continue;
88  result << id;
89  }
90 }
91 
92 void MessageThreadingAttribute::deserialize(const QByteArray & data)
93 {
94  d->perfectParents.clear();
95  d->unperfectParents.clear();
96  d->subjectParents.clear();
97 
98  QList<QByteArray> lists = data.split( ';' );
99  if ( lists.size() != 3 )
100  return;
101 
102  parseIdList( lists[0], d->perfectParents );
103  parseIdList( lists[1], d->unperfectParents );
104  parseIdList( lists[2], d->subjectParents );
105 }
106 
107 QList< Item::Id > MessageThreadingAttribute::perfectParents() const
108 {
109  return d->perfectParents;
110 }
111 
112 void MessageThreadingAttribute::setPerfectParents(const QList< Item::Id > & parents)
113 {
114  d->perfectParents = parents;
115 }
116 
117 QList< Item::Id > MessageThreadingAttribute::unperfectParents() const
118 {
119  return d->unperfectParents;
120 }
121 
122 void MessageThreadingAttribute::setUnperfectParents(const QList< Item::Id > & parents)
123 {
124  d->unperfectParents = parents;
125 }
126 
127 QList< Item::Id > MessageThreadingAttribute::subjectParents() const
128 {
129  return d->subjectParents;
130 }
131 
132 void MessageThreadingAttribute::setSubjectParents(const QList< Item::Id > & parents)
133 {
134  d->subjectParents = parents;
135 }
Akonadi::MessageThreadingAttribute::setUnperfectParents
void setUnperfectParents(const QList< Item::Id > &parents)
Sets the list of non-perfect parent message ids.
Definition: messagethreadingattribute.cpp:122
Akonadi::MessageThreadingAttribute::subjectParents
QList< Item::Id > subjectParents() const
Returns the list of possible parent message ids based on analyzing the subject.
Definition: messagethreadingattribute.cpp:127
Akonadi::MessageThreadingAttribute
Message threading information.
Definition: messagethreadingattribute.h:34
Akonadi::MessageThreadingAttribute::~MessageThreadingAttribute
~MessageThreadingAttribute()
Destructor.
Definition: messagethreadingattribute.cpp:43
Akonadi::MessageThreadingAttribute::setPerfectParents
void setPerfectParents(const QList< Item::Id > &parents)
Sets the list of perfect parent message ids.
Definition: messagethreadingattribute.cpp:112
Akonadi::MessageThreadingAttribute::perfectParents
QList< Item::Id > perfectParents() const
Returns the list of perfect parent message ids.
Definition: messagethreadingattribute.cpp:107
Akonadi::MessageThreadingAttribute::unperfectParents
QList< Item::Id > unperfectParents() const
Returns the list of non-perfect parent message ids.
Definition: messagethreadingattribute.cpp:117
Akonadi::MessageThreadingAttribute::MessageThreadingAttribute
MessageThreadingAttribute()
Creates an empty threading attribute.
Definition: messagethreadingattribute.cpp:32
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:132
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:55 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi/kmime

Skip menu "akonadi/kmime"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Members
  • File List
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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