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

akonadi

  • akonadi
  • contact
customfields.cpp
1/*
2 This file is part of Akonadi Contact.
3
4 Copyright (c) 2010 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 "customfields_p.h"
23
24CustomField::CustomField()
25 : mType( TextType ), mScope( LocalScope )
26{
27}
28
29CustomField::CustomField( const QString &key, const QString &title, Type type, Scope scope )
30 : mKey( key ), mTitle( title ), mType( type ), mScope( scope )
31{
32}
33
34CustomField CustomField::fromVariantMap( const QVariantMap &map, Scope scope )
35{
36 return CustomField( map.value( QLatin1String( "key" ) ).toString(),
37 map.value( QLatin1String( "title" ) ).toString(),
38 stringToType( map.value( QLatin1String( "type" ) ).toString() ),
39 scope );
40}
41
42void CustomField::setKey( const QString &key )
43{
44 mKey = key;
45}
46
47QString CustomField::key() const
48{
49 return mKey;
50}
51
52void CustomField::setTitle( const QString &title )
53{
54 mTitle = title;
55}
56
57QString CustomField::title() const
58{
59 return mTitle;
60}
61
62void CustomField::setType( Type type )
63{
64 mType = type;
65}
66
67CustomField::Type CustomField::type() const
68{
69 return mType;
70}
71
72void CustomField::setScope( Scope scope )
73{
74 mScope = scope;
75}
76
77CustomField::Scope CustomField::scope() const
78{
79 return mScope;
80}
81
82void CustomField::setValue( const QString &value )
83{
84 mValue = value;
85}
86
87QString CustomField::value() const
88{
89 return mValue;
90}
91
92QVariantMap CustomField::toVariantMap() const
93{
94 QVariantMap map;
95 map.insert( QLatin1String( "key" ), mKey );
96 map.insert( QLatin1String( "title" ), mTitle );
97 map.insert( QLatin1String( "type" ), typeToString( mType ) );
98
99 return map;
100}
101
102CustomField::Type CustomField::stringToType( const QString &type )
103{
104 if ( type == QLatin1String( "text" ) ) {
105 return CustomField::TextType;
106 }
107 if ( type == QLatin1String( "numeric" ) ) {
108 return CustomField::NumericType;
109 }
110 if ( type == QLatin1String( "boolean" ) ) {
111 return CustomField::BooleanType;
112 }
113 if ( type == QLatin1String( "date" ) ) {
114 return CustomField::DateType;
115 }
116 if ( type == QLatin1String( "time" ) ) {
117 return CustomField::TimeType;
118 }
119 if ( type == QLatin1String( "datetime" ) ) {
120 return CustomField::DateTimeType;
121 }
122 if ( type == QLatin1String( "url" ) ) {
123 return CustomField::UrlType;
124 }
125
126 return CustomField::TextType;
127}
128
129QString CustomField::typeToString( CustomField::Type type )
130{
131 switch ( type ) {
132 case CustomField::TextType:
133 default:
134 return QLatin1String( "text" );
135 break;
136 case CustomField::NumericType:
137 return QLatin1String( "numeric" );
138 break;
139 case CustomField::BooleanType:
140 return QLatin1String( "boolean" );
141 break;
142 case CustomField::DateType:
143 return QLatin1String( "date" );
144 break;
145 case CustomField::TimeType:
146 return QLatin1String( "time" );
147 break;
148 case CustomField::DateTimeType:
149 return QLatin1String( "datetime" );
150 break;
151 case CustomField::UrlType:
152 return QLatin1String( "url" );
153 break;
154
155 }
156}
CustomField
A class that represents non-standard contact fields.
Definition: customfields_p.h:48
CustomField::Scope
Scope
Definition: customfields_p.h:62
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 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
  • Modules
  • 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