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

akonadi

  • akonadi
  • contact
  • editor
customfieldeditordialog.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 "customfieldeditordialog.h"
23 
24 #include <kcombobox.h>
25 #include <klineedit.h>
26 #include <klocale.h>
27 
28 #include <QCheckBox>
29 #include <QFormLayout>
30 #include <QRegExpValidator>
31 
32 CustomFieldEditorDialog::CustomFieldEditorDialog( QWidget *parent )
33  : KDialog( parent )
34 {
35  setCaption( i18n( "Edit Custom Field" ) );
36  setButtons( Ok | Cancel | Details );
37 
38  QWidget *widget = new QWidget( this );
39  setMainWidget( widget );
40 
41  QFormLayout *layout = new QFormLayout( widget );
42 
43  mKey = new KLineEdit;
44  mTitle = new KLineEdit;
45  mType = new KComboBox;
46  mScope = new QCheckBox( i18n( "Use field for all contacts" ) );
47 
48  layout->addRow( i18nc( "The title of a custom field", "Title" ), mTitle );
49  layout->addRow( i18nc( "The type of a custom field", "Type" ), mType );
50  layout->addRow( QString(), mScope );
51 
52  QWidget *detailsWidget = new QWidget;
53  QFormLayout *detailsLayout = new QFormLayout( detailsWidget );
54  detailsLayout->addRow( i18n( "Key" ), mKey );
55 
56  setDetailsWidget( detailsWidget );
57  setButtonText( Details, i18nc( "@label Opens the advanced dialog", "Advanced" ) );
58 
59  mType->addItem( i18n( "Text" ), CustomField::TextType );
60  mType->addItem( i18n( "Numeric" ), CustomField::NumericType );
61  mType->addItem( i18n( "Boolean" ), CustomField::BooleanType );
62  mType->addItem( i18n( "Date" ), CustomField::DateType );
63  mType->addItem( i18n( "Time" ), CustomField::TimeType );
64  mType->addItem( i18n( "DateTime" ), CustomField::DateTimeType );
65 
66  mKey->setValidator( new QRegExpValidator( QRegExp( QLatin1String( "[a-zA-Z0-9\\-]+" ) ), this ) );
67  mTitle->setFocus();
68 }
69 
70 void CustomFieldEditorDialog::setCustomField( const CustomField &field )
71 {
72  mCustomField = field;
73 
74  mKey->setText( mCustomField.key() );
75  mTitle->setText( mCustomField.title() );
76  mType->setCurrentIndex( mType->findData( mCustomField.type() ) );
77  mScope->setChecked( ( mCustomField.scope() == CustomField::GlobalScope ) );
78 }
79 
80 CustomField CustomFieldEditorDialog::customField() const
81 {
82  CustomField customField( mCustomField );
83 
84  customField.setKey( mKey->text() );
85  customField.setTitle( mTitle->text() );
86  customField.setType( static_cast<CustomField::Type>( mType->itemData( mType->currentIndex() ).toInt() ) );
87 
88  if ( customField.scope() != CustomField::ExternalScope ) {
89  // do not change the scope for externally defined custom fields
90  customField.setScope( mScope->isChecked() ? CustomField::GlobalScope : CustomField::LocalScope );
91  }
92 
93  return customField;
94 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:35 by doxygen 1.8.3.1 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.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • 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