• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

akonadi/kabc

contacteditordialog.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of KContactManager.
00003 
00004     Copyright (c) 2007 Tobias Koenig <tokoe@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License along
00017     with this program; if not, write to the Free Software Foundation, Inc.,
00018     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "contacteditordialog.h"
00022 
00023 #include "kabc/kabcitemeditor.h"
00024 
00025 #include "collectioncombobox.h"
00026 #include <akonadi/item.h>
00027 
00028 #include <klocale.h>
00029 
00030 #include <QtGui/QGridLayout>
00031 #include <QtGui/QLabel>
00032 
00033 ContactEditorDialog::ContactEditorDialog( Mode mode, QAbstractItemModel *collectionModel, QWidget *parent )
00034   : KDialog( parent )
00035 {
00036   setCaption( mode == CreateMode ? i18n( "New Contact" ) : i18n( "Edit Contact" ) );
00037   setButtons( Ok | Cancel );
00038 
00039   QWidget *mainWidget = new QWidget( this );
00040   setMainWidget( mainWidget );
00041 
00042   QGridLayout *layout = new QGridLayout( mainWidget );
00043 
00044   mEditor = new Akonadi::KABCItemEditor( mode == CreateMode ? Akonadi::KABCItemEditor::CreateMode : Akonadi::KABCItemEditor::EditMode, this );
00045 
00046   if ( mode == CreateMode ) {
00047      QLabel *label = new QLabel( i18n( "Add to:" ), mainWidget );
00048      KABC::CollectionComboBox *box = new KABC::CollectionComboBox( mainWidget );
00049      if ( collectionModel )
00050        box->setModel( collectionModel );
00051 
00052      layout->addWidget( label, 0, 0 );
00053      layout->addWidget( box, 0, 1 );
00054 
00055      connect( box, SIGNAL( selectionChanged( const Akonadi::Collection& ) ),
00056               mEditor, SLOT( setDefaultCollection( const Akonadi::Collection& ) ) );
00057 
00058      mEditor->setDefaultCollection( box->selectedCollection() );
00059   }
00060 
00061   layout->addWidget( mEditor, 1, 0, 1, 2 );
00062   layout->setColumnStretch( 1, 1 );
00063 
00064   connect( mEditor, SIGNAL( contactStored( const Akonadi::Item& ) ),
00065            this, SIGNAL( contactStored( const Akonadi::Item& ) ) );
00066 
00067   connect( this, SIGNAL( okClicked() ), this, SLOT( slotOkClicked() ) );
00068   connect( this, SIGNAL( cancelClicked() ), this, SLOT( slotCancelClicked() ) );
00069 }
00070 
00071 ContactEditorDialog::~ContactEditorDialog()
00072 {
00073 }
00074 
00075 void ContactEditorDialog::setContact( const Akonadi::Item &contact )
00076 {
00077   mEditor->loadContact( contact );
00078 }
00079 
00080 void ContactEditorDialog::slotOkClicked()
00081 {
00082   mEditor->saveContact();
00083 
00084   accept();
00085 }
00086 
00087 void ContactEditorDialog::slotCancelClicked()
00088 {
00089   reject();
00090 }
00091 
00092 #include "contacteditordialog.moc"

akonadi/kabc

Skip menu "akonadi/kabc"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
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