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

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • 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 
24 CustomField::CustomField()
25  : mType( TextType ), mScope( LocalScope )
26 {
27 }
28 
29 CustomField::CustomField( const QString &key, const QString &title, Type type, Scope scope )
30  : mKey( key ), mTitle( title ), mType( type ), mScope( scope )
31 {
32 }
33 
34 CustomField 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 
42 void CustomField::setKey( const QString &key )
43 {
44  mKey = key;
45 }
46 
47 QString CustomField::key() const
48 {
49  return mKey;
50 }
51 
52 void CustomField::setTitle( const QString &title )
53 {
54  mTitle = title;
55 }
56 
57 QString CustomField::title() const
58 {
59  return mTitle;
60 }
61 
62 void CustomField::setType( Type type )
63 {
64  mType = type;
65 }
66 
67 CustomField::Type CustomField::type() const
68 {
69  return mType;
70 }
71 
72 void CustomField::setScope( Scope scope )
73 {
74  mScope = scope;
75 }
76 
77 CustomField::Scope CustomField::scope() const
78 {
79  return mScope;
80 }
81 
82 void CustomField::setValue( const QString &value )
83 {
84  mValue = value;
85 }
86 
87 QString CustomField::value() const
88 {
89  return mValue;
90 }
91 
92 QVariantMap 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 
102 CustomField::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 
129 QString 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:47
CustomField::Scope
Scope
Definition: customfields_p.h:62
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:27 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

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