22 #include "customfields_p.h"
24 CustomField::CustomField()
25 : mType( TextType ), mScope( LocalScope )
29 CustomField::CustomField(
const QString &key,
const QString &title, Type type, Scope scope )
30 : mKey( key ), mTitle( title ), mType( type ), mScope( scope )
34 CustomField CustomField::fromVariantMap(
const QVariantMap &map, Scope scope )
36 return CustomField( map.value( QLatin1String(
"key" ) ).toString(),
37 map.value( QLatin1String(
"title" ) ).toString(),
38 stringToType( map.value( QLatin1String(
"type" ) ).toString() ),
42 void CustomField::setKey(
const QString &key )
47 QString CustomField::key()
const
52 void CustomField::setTitle(
const QString &title )
57 QString CustomField::title()
const
62 void CustomField::setType( Type type )
67 CustomField::Type CustomField::type()
const
72 void CustomField::setScope( Scope scope )
82 void CustomField::setValue(
const QString &value )
87 QString CustomField::value()
const
92 QVariantMap CustomField::toVariantMap()
const
95 map.insert( QLatin1String(
"key" ), mKey );
96 map.insert( QLatin1String(
"title" ), mTitle );
97 map.insert( QLatin1String(
"type" ), typeToString( mType ) );
102 CustomField::Type CustomField::stringToType(
const QString &type )
104 if ( type == QLatin1String(
"text" ) ) {
105 return CustomField::TextType;
107 if ( type == QLatin1String(
"numeric" ) ) {
108 return CustomField::NumericType;
110 if ( type == QLatin1String(
"boolean" ) ) {
111 return CustomField::BooleanType;
113 if ( type == QLatin1String(
"date" ) ) {
114 return CustomField::DateType;
116 if ( type == QLatin1String(
"time" ) ) {
117 return CustomField::TimeType;
119 if ( type == QLatin1String(
"datetime" ) ) {
120 return CustomField::DateTimeType;
122 if ( type == QLatin1String(
"url" ) ) {
123 return CustomField::UrlType;
126 return CustomField::TextType;
129 QString CustomField::typeToString( CustomField::Type type )
132 case CustomField::TextType:
134 return QLatin1String(
"text" );
136 case CustomField::NumericType:
137 return QLatin1String(
"numeric" );
139 case CustomField::BooleanType:
140 return QLatin1String(
"boolean" );
142 case CustomField::DateType:
143 return QLatin1String(
"date" );
145 case CustomField::TimeType:
146 return QLatin1String(
"time" );
148 case CustomField::DateTimeType:
149 return QLatin1String(
"datetime" );
151 case CustomField::UrlType:
152 return QLatin1String(
"url" );
A class that represents non-standard contact fields.