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

akonadi

customfieldeditordialog.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 "customfieldeditordialog.h"
00023 
00024 #include <kcombobox.h>
00025 #include <klineedit.h>
00026 #include <klocale.h>
00027 
00028 #include <QtGui/QCheckBox>
00029 #include <QtGui/QFormLayout>
00030 #include <QtGui/QRegExpValidator>
00031 
00032 CustomFieldEditorDialog::CustomFieldEditorDialog( QWidget *parent )
00033   : KDialog( parent )
00034 {
00035   setCaption( i18n( "Edit Custom Field" ) );
00036   setButtons( Ok | Cancel | Details );
00037 
00038   QWidget *widget = new QWidget( this );
00039   setMainWidget( widget );
00040 
00041   QFormLayout *layout = new QFormLayout( widget );
00042 
00043   mKey = new KLineEdit;
00044   mTitle = new KLineEdit;
00045   mType = new KComboBox;
00046   mScope = new QCheckBox( i18n( "Use field for all contacts" ) );
00047 
00048   layout->addRow( i18nc( "The title of a custom field", "Title" ), mTitle );
00049   layout->addRow( i18nc( "The type of a custom field", "Type" ), mType );
00050   layout->addRow( QString(), mScope );
00051 
00052   QWidget *detailsWidget = new QWidget;
00053   QFormLayout *detailsLayout = new QFormLayout( detailsWidget );
00054   detailsLayout->addRow( i18n( "Key" ), mKey );
00055 
00056   setDetailsWidget( detailsWidget );
00057   setButtonText( Details, i18nc( "@label Opens the advanced dialog", "Advanced" ) );
00058 
00059   mType->addItem( i18n( "Text" ), CustomField::TextType );
00060   mType->addItem( i18n( "Numeric" ), CustomField::NumericType );
00061   mType->addItem( i18n( "Boolean" ), CustomField::BooleanType );
00062   mType->addItem( i18n( "Date" ), CustomField::DateType );
00063   mType->addItem( i18n( "Time" ), CustomField::TimeType );
00064   mType->addItem( i18n( "DateTime" ), CustomField::DateTimeType );
00065 
00066   mKey->setValidator( new QRegExpValidator( QRegExp( QLatin1String( "[a-zA-Z0-9\\-]+" ) ), this ) );
00067 }
00068 
00069 void CustomFieldEditorDialog::setCustomField( const CustomField &field )
00070 {
00071   mCustomField = field;
00072 
00073   mKey->setText( mCustomField.key() );
00074   mTitle->setText( mCustomField.title() );
00075   mType->setCurrentIndex( mType->findData( mCustomField.type() ) );
00076   mScope->setChecked( (mCustomField.scope() == CustomField::GlobalScope) );
00077 }
00078 
00079 CustomField CustomFieldEditorDialog::customField() const
00080 {
00081   CustomField customField( mCustomField );
00082 
00083   customField.setKey( mKey->text() );
00084   customField.setTitle( mTitle->text() );
00085   customField.setType( static_cast<CustomField::Type>( mType->itemData( mType->currentIndex() ).toInt() ) );
00086 
00087   if ( customField.scope() != CustomField::ExternalScope ) {
00088     // do not change the scope for externally defined custom fields
00089     customField.setScope( mScope->isChecked() ? CustomField::GlobalScope : CustomField::LocalScope );
00090   }
00091 
00092   return customField;
00093 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon May 14 2012 04:52:54 by doxygen 1.7.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.8.3 API Reference

Skip menu "kdepimlibs-4.8.3 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