• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

akonadi/contact

contactgroupeditordialog.cpp

00001 /*
00002     This file is part of Akonadi Contact.
00003 
00004     Copyright (c) 2007-2009 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 "contactgroupeditordialog.h"
00023 
00024 #include "contactgroupeditor.h"
00025 
00026 #include <akonadi/collectioncombobox.h>
00027 #include <akonadi/item.h>
00028 #include <kabc/contactgroup.h>
00029 #include <klocale.h>
00030 #include <kpushbutton.h>
00031 
00032 #include <QtGui/QGridLayout>
00033 #include <QtGui/QLabel>
00034 
00035 using namespace Akonadi;
00036 
00037 class ContactGroupEditorDialog::Private
00038 {
00039   public:
00040     Private( ContactGroupEditorDialog::Mode mode )
00041       : mAddressBookBox( 0 ), mMode( mode )
00042     {
00043     }
00044 
00045     CollectionComboBox *mAddressBookBox;
00046     ContactGroupEditor *mEditor;
00047     ContactGroupEditorDialog::Mode mMode;
00048 };
00049 
00050 ContactGroupEditorDialog::ContactGroupEditorDialog( Mode mode, QWidget *parent )
00051   : KDialog( parent ), d( new Private( mode ) )
00052 {
00053   KGlobal::locale()->insertCatalog( QLatin1String( "akonadicontact" ) );
00054   setCaption( mode == CreateMode ? i18n( "New Contact Group" ) : i18n( "Edit Contact Group" ) );
00055   setButtons( Ok | Cancel );
00056 
00057   // Disable default button, so that finish editing of
00058   // a member with the Enter key does not close the dialog
00059   button( Ok )->setAutoDefault( false );
00060   button( Cancel )->setAutoDefault( false );
00061 
00062   QWidget *mainWidget = new QWidget( this );
00063   setMainWidget( mainWidget );
00064 
00065   QGridLayout *layout = new QGridLayout( mainWidget );
00066 
00067   d->mEditor = new Akonadi::ContactGroupEditor( mode == CreateMode ?
00068                                                 Akonadi::ContactGroupEditor::CreateMode : Akonadi::ContactGroupEditor::EditMode,
00069                                                 this );
00070 
00071   if ( mode == CreateMode ) {
00072     QLabel *label = new QLabel( i18n( "Add to:" ), mainWidget );
00073 
00074     d->mAddressBookBox = new CollectionComboBox( mainWidget );
00075     d->mAddressBookBox->setMimeTypeFilter( QStringList() << KABC::ContactGroup::mimeType() );
00076     d->mAddressBookBox->setAccessRightsFilter( Collection::CanCreateItem );
00077 
00078     layout->addWidget( label, 0, 0 );
00079     layout->addWidget( d->mAddressBookBox, 0, 1 );
00080   }
00081 
00082   layout->addWidget( d->mEditor, 1, 0, 1, 2 );
00083   layout->setColumnStretch( 1, 1 );
00084 
00085   connect( d->mEditor, SIGNAL( contactGroupStored( const Akonadi::Item& ) ),
00086            this, SIGNAL( contactGroupStored( const Akonadi::Item& ) ) );
00087 
00088   setInitialSize( QSize( 470, 400 ) );
00089 }
00090 
00091 ContactGroupEditorDialog::~ContactGroupEditorDialog()
00092 {
00093   delete d;
00094 }
00095 
00096 void ContactGroupEditorDialog::setContactGroup( const Akonadi::Item &group )
00097 {
00098   d->mEditor->loadContactGroup( group );
00099 }
00100 
00101 void ContactGroupEditorDialog::setDefaultAddressBook( const Akonadi::Collection &addressbook )
00102 {
00103   if ( d->mMode == EditMode )
00104     return;
00105 
00106   d->mAddressBookBox->setDefaultCollection( addressbook );
00107 }
00108 
00109 ContactGroupEditor* ContactGroupEditorDialog::editor() const
00110 {
00111   return d->mEditor;
00112 }
00113 
00114 void ContactGroupEditorDialog::slotButtonClicked( int button )
00115 {
00116   if ( button == KDialog::Ok ) {
00117     if ( d->mAddressBookBox )
00118       d->mEditor->setDefaultAddressBook( d->mAddressBookBox->currentCollection() );
00119 
00120     if ( d->mEditor->saveContactGroup() )
00121       accept();
00122   } else if ( button == KDialog::Cancel ) {
00123     reject();
00124   }
00125 }
00126 
00127 #include "contactgroupeditordialog.moc"

akonadi/contact

Skip menu "akonadi/contact"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.2-20100208
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