• Skip to content
  • Skip to link menu
KDE 4.7 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

akonadi

customfields.cpp
00001 /*
00002     This file is part of Akonadi Contact.
00003 
00004     Copyright (c) 2010 Tobias Koenig <tokoe@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or modify it
00007     under the terms of the GNU Library General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or (at your
00009     option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful, but WITHOUT
00012     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014     License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to the
00018     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019     02110-1301, USA.
00020 */
00021 
00022 #include "customfields_p.h"
00023 
00024 CustomField::CustomField()
00025   : mType( TextType ), mScope( LocalScope )
00026 {
00027 }
00028 
00029 CustomField::CustomField( const QString &key, const QString &title, Type type, Scope scope )
00030   : mKey( key ), mTitle( title ), mType( type ), mScope( scope )
00031 {
00032 }
00033 
00034 CustomField CustomField::fromVariantMap( const QVariantMap &map, Scope scope )
00035 {
00036   return CustomField( map.value( QLatin1String( "key" ) ).toString(),
00037                       map.value( QLatin1String( "title" ) ).toString(),
00038                       stringToType( map.value( QLatin1String( "type" ) ).toString() ),
00039                       scope );
00040 }
00041 
00042 void CustomField::setKey( const QString &key )
00043 {
00044   mKey = key;
00045 }
00046 
00047 QString CustomField::key() const
00048 {
00049   return mKey;
00050 }
00051 
00052 void CustomField::setTitle( const QString &title )
00053 {
00054   mTitle = title;
00055 }
00056 
00057 QString CustomField::title() const
00058 {
00059   return mTitle;
00060 }
00061 
00062 void CustomField::setType( Type type )
00063 {
00064   mType = type;
00065 }
00066 
00067 CustomField::Type CustomField::type() const
00068 {
00069   return mType;
00070 }
00071 
00072 void CustomField::setScope( Scope scope )
00073 {
00074   mScope = scope;
00075 }
00076 
00077 CustomField::Scope CustomField::scope() const
00078 {
00079   return mScope;
00080 }
00081 
00082 void CustomField::setValue( const QString &value )
00083 {
00084   mValue = value;
00085 }
00086 
00087 QString CustomField::value() const
00088 {
00089   return mValue;
00090 }
00091 
00092 QVariantMap CustomField::toVariantMap() const
00093 {
00094   QVariantMap map;
00095   map.insert( QLatin1String( "key" ), mKey );
00096   map.insert( QLatin1String( "title" ), mTitle );
00097   map.insert( QLatin1String( "type" ), typeToString( mType ) );
00098 
00099   return map;
00100 }
00101 
00102 CustomField::Type CustomField::stringToType( const QString &type )
00103 {
00104   if ( type == QLatin1String( "text" ) )
00105     return CustomField::TextType;
00106   if ( type == QLatin1String( "numeric" ) )
00107     return CustomField::NumericType;
00108   if ( type == QLatin1String( "boolean" ) )
00109     return CustomField::BooleanType;
00110   if ( type == QLatin1String( "date" ) )
00111     return CustomField::DateType;
00112   if ( type == QLatin1String( "time" ) )
00113     return CustomField::TimeType;
00114   if ( type == QLatin1String( "datetime" ) )
00115     return CustomField::DateTimeType;
00116 
00117   return CustomField::TextType;
00118 }
00119 
00120 QString CustomField::typeToString( CustomField::Type type )
00121 {
00122   switch ( type ) {
00123     case CustomField::TextType:
00124     default:
00125       return QLatin1String( "text" );
00126       break;
00127     case CustomField::NumericType:
00128       return QLatin1String( "numeric" );
00129       break;
00130     case CustomField::BooleanType:
00131       return QLatin1String( "boolean" );
00132       break;
00133     case CustomField::DateType:
00134       return QLatin1String( "date" );
00135       break;
00136     case CustomField::TimeType:
00137       return QLatin1String( "time" );
00138       break;
00139     case CustomField::DateTimeType:
00140       return QLatin1String( "datetime" );
00141       break;
00142   }
00143 }

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • 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
Generated for KDE-PIM Libraries by doxygen 1.7.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal