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

akonadi/contact

  • akonadi
  • contact
contactmetadata.cpp
1 /*
2  This file is part of Akonadi Contact.
3 
4  Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
5 
6  This library is free software; you can redistribute it and/or modify it
7  under the terms of the GNU Library General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or (at your
9  option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14  License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301, USA.
20 */
21 
22 #include "contactmetadata_p.h"
23 
24 #include "contactmetadataattribute_p.h"
25 
26 #include <akonadi/item.h>
27 
28 using namespace Akonadi;
29 
30 class ContactMetaData::Private
31 {
32  public:
33  Private()
34  : mDisplayNameMode( -1 )
35  {
36  }
37 
38  int mDisplayNameMode;
39  QVariantList mCustomFieldDescriptions;
40 };
41 
42 ContactMetaData::ContactMetaData()
43  : d( new Private )
44 {
45 }
46 
47 ContactMetaData::~ContactMetaData()
48 {
49  delete d;
50 }
51 
52 void ContactMetaData::load( const Akonadi::Item &contact )
53 {
54  if ( !contact.hasAttribute( "contactmetadata" ) )
55  return;
56 
57  ContactMetaDataAttribute *attribute = contact.attribute<ContactMetaDataAttribute>();
58  const QVariantMap metaData = attribute->metaData();
59 
60  if ( metaData.contains( QLatin1String( "DisplayNameMode" ) ) )
61  d->mDisplayNameMode = metaData.value( QLatin1String( "DisplayNameMode" ) ).toInt();
62  else
63  d->mDisplayNameMode = -1;
64 
65  d->mCustomFieldDescriptions = metaData.value( QLatin1String( "CustomFieldDescriptions" ) ).toList();
66 }
67 
68 void ContactMetaData::store( Akonadi::Item &contact )
69 {
70  ContactMetaDataAttribute *attribute = contact.attribute<ContactMetaDataAttribute>( Item::AddIfMissing );
71 
72  QVariantMap metaData;
73  if ( d->mDisplayNameMode != -1 )
74  metaData.insert( QLatin1String( "DisplayNameMode" ), QVariant( d->mDisplayNameMode ) );
75 
76  if ( !d->mCustomFieldDescriptions.isEmpty() )
77  metaData.insert( QLatin1String( "CustomFieldDescriptions" ), d->mCustomFieldDescriptions );
78 
79  attribute->setMetaData( metaData );
80 }
81 
82 void ContactMetaData::setDisplayNameMode( int mode )
83 {
84  d->mDisplayNameMode = mode;
85 }
86 
87 int ContactMetaData::displayNameMode() const
88 {
89  return d->mDisplayNameMode;
90 }
91 
92 void ContactMetaData::setCustomFieldDescriptions( const QVariantList &descriptions )
93 {
94  d->mCustomFieldDescriptions = descriptions;
95 }
96 
97 QVariantList ContactMetaData::customFieldDescriptions() const
98 {
99  return d->mCustomFieldDescriptions;
100 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Tue Dec 4 2012 14:36:30 by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi/contact

Skip menu "akonadi/contact"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.9.4 API Reference

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