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

mailcommon

  • sources
  • kde-4.12
  • kdepim
  • mailcommon
  • collectionpage
collectionannotationsattribute.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 Omat Holding B.V. <info@omat.nl>
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 "collectionannotationsattribute.h"
21 
22 #include <QByteArray>
23 
24 using namespace MailCommon;
25 
26 CollectionAnnotationsAttribute::CollectionAnnotationsAttribute()
27 {
28 }
29 
30 CollectionAnnotationsAttribute::CollectionAnnotationsAttribute(
31  const QMap<QByteArray, QByteArray> &annotations )
32  : mAnnotations( annotations )
33 {
34 }
35 
36 void CollectionAnnotationsAttribute::setAnnotations(
37  const QMap<QByteArray, QByteArray> &annotations )
38 {
39  mAnnotations = annotations;
40 }
41 
42 QMap<QByteArray, QByteArray> CollectionAnnotationsAttribute::annotations() const
43 {
44  return mAnnotations;
45 }
46 
47 QByteArray CollectionAnnotationsAttribute::type() const
48 {
49  return "collectionannotations";
50 }
51 
52 Akonadi::Attribute *CollectionAnnotationsAttribute::clone() const
53 {
54  return new CollectionAnnotationsAttribute( mAnnotations );
55 }
56 
57 QByteArray CollectionAnnotationsAttribute::serialized() const
58 {
59  QByteArray result = "";
60 
61  foreach ( const QByteArray &key, mAnnotations.keys() ) {
62  result += key;
63  result += ' ';
64  result += mAnnotations[key];
65  result += " % "; // We use this separator as '%' is not allowed in keys or values
66  }
67  result.chop( 3 );
68 
69  return result;
70 }
71 
72 void CollectionAnnotationsAttribute::deserialize( const QByteArray &data )
73 {
74  mAnnotations.clear();
75  const QList<QByteArray> lines = data.split( '%' );
76 
77  for ( int i = 0; i < lines.size(); ++i ) {
78  QByteArray line = lines[i];
79  if ( i != 0 && line.startsWith( ' ' ) ) {
80  line = line.mid( 1 );
81  }
82  if ( i != lines.size() - 1 && line.endsWith( ' ' ) ) {
83  line.chop( 1 );
84  }
85  if ( line.trimmed().isEmpty() ) {
86  continue;
87  }
88  int wsIndex = line.indexOf( ' ' );
89  if ( wsIndex > 0 ) {
90  const QByteArray key = line.mid( 0, wsIndex );
91  const QByteArray value = line.mid( wsIndex+1 );
92  mAnnotations[key] = value;
93  } else {
94  mAnnotations.insert( line, QByteArray() );
95  }
96  }
97 }
MailCommon::CollectionAnnotationsAttribute::serialized
QByteArray serialized() const
Definition: collectionannotationsattribute.cpp:57
MailCommon::CollectionAnnotationsAttribute::deserialize
void deserialize(const QByteArray &data)
Definition: collectionannotationsattribute.cpp:72
MailCommon::CollectionAnnotationsAttribute::clone
Attribute * clone() const
Definition: collectionannotationsattribute.cpp:52
collectionannotationsattribute.h
MailCommon::CollectionAnnotationsAttribute::CollectionAnnotationsAttribute
CollectionAnnotationsAttribute()
Definition: collectionannotationsattribute.cpp:26
MailCommon::CollectionAnnotationsAttribute::setAnnotations
void setAnnotations(const QMap< QByteArray, QByteArray > &annotations)
Definition: collectionannotationsattribute.cpp:36
MailCommon::CollectionAnnotationsAttribute::type
QByteArray type() const
Definition: collectionannotationsattribute.cpp:47
MailCommon::CollectionAnnotationsAttribute::annotations
QMap< QByteArray, QByteArray > annotations() const
Definition: collectionannotationsattribute.cpp:42
QList
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

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

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

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