• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

akonadi

messagethreadingattribute.cpp

00001 /*
00002     Copyright (c) 2008 Volker Krause <vkrause@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #include "messagethreadingattribute.h"
00021 
00022 using namespace Akonadi;
00023 
00024 class Akonadi::MessageThreadingAttribute::Private
00025 {
00026   public:
00027     QList<Item::Id> perfectParents;
00028     QList<Item::Id> unperfectParents;
00029     QList<Item::Id> subjectParents;
00030 };
00031 
00032 MessageThreadingAttribute::MessageThreadingAttribute() :
00033     d( new Private )
00034 {
00035 }
00036 
00037 MessageThreadingAttribute::MessageThreadingAttribute(const MessageThreadingAttribute & other) :
00038     Attribute( other ),
00039     d( new Private( *(other.d) ) )
00040 {
00041 }
00042 
00043 MessageThreadingAttribute::~ MessageThreadingAttribute()
00044 {
00045   delete d;
00046 }
00047 
00048 QByteArray MessageThreadingAttribute::type() const
00049 {
00050   return "MESSAGETHREADING";
00051 }
00052 
00053 MessageThreadingAttribute * MessageThreadingAttribute::clone() const
00054 {
00055   return new MessageThreadingAttribute( *this );
00056 }
00057 
00058 QByteArray MessageThreadingAttribute::serialized() const
00059 {
00060   QByteArray rv;
00061   foreach ( const Item::Id id, d->perfectParents )
00062     rv += QByteArray::number( id ) + ',';
00063   if ( !d->perfectParents.isEmpty() )
00064     rv[rv.size() - 1] = ';';
00065   else
00066     rv += ';';
00067   foreach ( const Item::Id id, d->unperfectParents )
00068     rv += QByteArray::number( id ) + ',';
00069   if ( !d->unperfectParents.isEmpty() )
00070     rv[rv.size() - 1] = ';';
00071   else
00072     rv += ';';
00073   foreach ( const Item::Id id, d->subjectParents )
00074     rv += QByteArray::number( id ) + ',';
00075   if ( !d->perfectParents.isEmpty() )
00076     rv.chop( 1 );
00077 
00078   return rv;
00079 }
00080 
00081 static void parseIdList( const QByteArray &data, QList<Item::Id> &result )
00082 {
00083   bool ok = false;
00084   foreach( const QByteArray &s, data.split( ',' ) ) {
00085     Item::Id id = s.toLongLong( &ok );
00086     if( !ok )
00087       continue;
00088     result << id;
00089   }
00090 }
00091 
00092 void MessageThreadingAttribute::deserialize(const QByteArray & data)
00093 {
00094   d->perfectParents.clear();
00095   d->unperfectParents.clear();
00096   d->subjectParents.clear();
00097 
00098   QList<QByteArray> lists = data.split( ';' );
00099   if ( lists.size() != 3 )
00100     return;
00101 
00102   parseIdList( lists[0], d->perfectParents );
00103   parseIdList( lists[1], d->unperfectParents );
00104   parseIdList( lists[2], d->subjectParents );
00105 }
00106 
00107 QList< Item::Id > MessageThreadingAttribute::perfectParents() const
00108 {
00109   return d->perfectParents;
00110 }
00111 
00112 void MessageThreadingAttribute::setPerfectParents(const QList< Item::Id > & parents)
00113 {
00114   d->perfectParents = parents;
00115 }
00116 
00117 QList< Item::Id > MessageThreadingAttribute::unperfectParents() const
00118 {
00119   return d->unperfectParents;
00120 }
00121 
00122 void MessageThreadingAttribute::setUnperfectParents(const QList< Item::Id > & parents)
00123 {
00124   d->unperfectParents = parents;
00125 }
00126 
00127 QList< Item::Id > MessageThreadingAttribute::subjectParents() const
00128 {
00129   return d->subjectParents;
00130 }
00131 
00132 void MessageThreadingAttribute::setSubjectParents(const QList< Item::Id > & parents)
00133 {
00134   d->subjectParents = parents;
00135 }

akonadi

Skip menu "akonadi"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal