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

akonadi

  • 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
28using namespace Akonadi;
29
30class ContactMetaData::Private
31{
32 public:
33 Private()
34 : mDisplayNameMode( -1 )
35 {
36 }
37
38 int mDisplayNameMode;
39 QVariantList mCustomFieldDescriptions;
40};
41
42ContactMetaData::ContactMetaData()
43 : d( new Private )
44{
45}
46
47ContactMetaData::~ContactMetaData()
48{
49 delete d;
50}
51
52void ContactMetaData::load( const Akonadi::Item &contact )
53{
54 if ( !contact.hasAttribute( "contactmetadata" ) ) {
55 return;
56 }
57
58 ContactMetaDataAttribute *attribute = contact.attribute<ContactMetaDataAttribute>();
59 const QVariantMap metaData = attribute->metaData();
60
61 if ( metaData.contains( QLatin1String( "DisplayNameMode" ) ) ) {
62 d->mDisplayNameMode = metaData.value( QLatin1String( "DisplayNameMode" ) ).toInt();
63 } else {
64 d->mDisplayNameMode = -1;
65 }
66
67 d->mCustomFieldDescriptions = metaData.value( QLatin1String( "CustomFieldDescriptions" ) ).toList();
68}
69
70void ContactMetaData::store( Akonadi::Item &contact )
71{
72 ContactMetaDataAttribute *attribute = contact.attribute<ContactMetaDataAttribute>( Item::AddIfMissing );
73
74 QVariantMap metaData;
75 if ( d->mDisplayNameMode != -1 ) {
76 metaData.insert( QLatin1String( "DisplayNameMode" ), QVariant( d->mDisplayNameMode ) );
77 }
78
79 if ( !d->mCustomFieldDescriptions.isEmpty() ) {
80 metaData.insert( QLatin1String( "CustomFieldDescriptions" ), d->mCustomFieldDescriptions );
81 }
82
83 attribute->setMetaData( metaData );
84}
85
86void ContactMetaData::setDisplayNameMode( int mode )
87{
88 d->mDisplayNameMode = mode;
89}
90
91int ContactMetaData::displayNameMode() const
92{
93 return d->mDisplayNameMode;
94}
95
96void ContactMetaData::setCustomFieldDescriptions( const QVariantList &descriptions )
97{
98 d->mCustomFieldDescriptions = descriptions;
99}
100
101QVariantList ContactMetaData::customFieldDescriptions() const
102{
103 return d->mCustomFieldDescriptions;
104}
Akonadi::ContactMetaDataAttribute
Attribute to store contact specific meta data.
Definition contactmetadataattribute_p.h:39
Akonadi::ContactMetaData::displayNameMode
int displayNameMode() const
Returns the mode that is used for the display name of that contact.
Definition contactmetadata.cpp:91
Akonadi::ContactMetaData::ContactMetaData
ContactMetaData()
Creates a contact meta data object.
Definition contactmetadata.cpp:42
Akonadi::ContactMetaData::setCustomFieldDescriptions
void setCustomFieldDescriptions(const QVariantList &descriptions)
Sets the descriptions of the custom fields of that contact.
Definition contactmetadata.cpp:96
Akonadi::ContactMetaData::store
void store(Akonadi::Item &contact)
Stores the meta data to the given contact.
Definition contactmetadata.cpp:70
Akonadi::ContactMetaData::customFieldDescriptions
QVariantList customFieldDescriptions() const
Returns the descriptions of the custom fields of the contact.
Definition contactmetadata.cpp:101
Akonadi::ContactMetaData::~ContactMetaData
~ContactMetaData()
Destroys the contact meta data object.
Definition contactmetadata.cpp:47
Akonadi::ContactMetaData::setDisplayNameMode
void setDisplayNameMode(int mode)
Sets the mode that is used for the display name of that contact.
Definition contactmetadata.cpp:86
Akonadi::ContactMetaData::load
void load(const Akonadi::Item &contact)
Loads the meta data for the given contact.
Definition contactmetadata.cpp:52
Akonadi
FreeBusyManager::Singleton.
Definition actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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
  • 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