• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.9.4 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 
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  if ( type == QLatin1String( "numeric" ) )
107  return CustomField::NumericType;
108  if ( type == QLatin1String( "boolean" ) )
109  return CustomField::BooleanType;
110  if ( type == QLatin1String( "date" ) )
111  return CustomField::DateType;
112  if ( type == QLatin1String( "time" ) )
113  return CustomField::TimeType;
114  if ( type == QLatin1String( "datetime" ) )
115  return CustomField::DateTimeType;
116 
117  return CustomField::TextType;
118 }
119 
120 QString CustomField::typeToString( CustomField::Type type )
121 {
122  switch ( type ) {
123  case CustomField::TextType:
124  default:
125  return QLatin1String( "text" );
126  break;
127  case CustomField::NumericType:
128  return QLatin1String( "numeric" );
129  break;
130  case CustomField::BooleanType:
131  return QLatin1String( "boolean" );
132  break;
133  case CustomField::DateType:
134  return QLatin1String( "date" );
135  break;
136  case CustomField::TimeType:
137  return QLatin1String( "time" );
138  break;
139  case CustomField::DateTimeType:
140  return QLatin1String( "datetime" );
141  break;
142  }
143 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Tue Dec 11 2012 12:14:31 by doxygen 1.8.1.2 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.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