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

kopete/libkopete

addressbooklinkwidget.cpp

Go to the documentation of this file.
00001 /*
00002     AddressBookLinkWidget
00003 
00004     A compact widget for showing and changing which address book item a
00005     particular Kopete::MetaContact is related to.
00006 
00007     Comprises a label showing the contact's name, a Clear button, and a Change
00008     button that usually invokes the AddressBookSelectorWidget.
00009 
00010     Copyright (c) 2006 by Will Stephenson <wstephenson@kde.org>
00011 
00012     Kopete    (c) 2002-2006 by the Kopete developers  <kopete-devel@kde.org>
00013 
00014     *************************************************************************
00015     *                                                                       *
00016     * This program is free software; you can redistribute it and/or modify  *
00017     * it under the terms of the GNU General Public License as published by  *
00018     * the Free Software Foundation; either version 2 of the License, or     *
00019     * (at your option) any later version.                                   *
00020     *                                                                       *
00021     *************************************************************************
00022 */
00023 
00024 #include <qapplication.h>
00025 #include <klineedit.h>
00026 #include <klocale.h>
00027 #include <kpushbutton.h>
00028 
00029 #include <kiconloader.h>
00030 
00031 #include <kopetemetacontact.h>
00032 
00033 #include "addressbooklinkwidget.h"
00034 #include "addressbookselectordialog.h"
00035 #include "addressbookselectorwidget.h"
00036 
00037 namespace Kopete {
00038 namespace UI {
00039 
00040 
00041 AddressBookLinkWidget::AddressBookLinkWidget( QWidget * parent, const char * name ) : QWidget(parent), Ui::AddressBookLinkWidgetBase(), mMetaContact( 0 )
00042 {
00043     setObjectName(name);
00044     setupUi(this);
00045 
00046     btnClear->setIcon( KIcon( (QApplication::layoutDirection() == Qt::RightToLeft) ? QString::fromLatin1( "edit-clear-locationbar-ltr" ) : QString::fromLatin1( "edit-clear-locationbar-rtl") ) );
00047     connect( btnClear, SIGNAL( clicked() ), this, SLOT( slotClearAddressee() ) );
00048     connect( btnSelectAddressee, SIGNAL( clicked() ), SLOT( slotSelectAddressee() ) );
00049 }
00050 
00051 void AddressBookLinkWidget::setAddressee( const KABC::Addressee& addr )
00052 {
00053     edtAddressee->setText( addr.realName() );
00054     btnClear->setEnabled( !addr.isEmpty() );
00055 }
00056 
00057 void AddressBookLinkWidget::setMetaContact( const Kopete::MetaContact * mc )
00058 {
00059     mMetaContact = mc;
00060 }
00061 
00062 QString AddressBookLinkWidget::uid() const
00063 {
00064     return mSelectedUid;
00065 }
00066 
00067 void AddressBookLinkWidget::slotClearAddressee()
00068 {
00069     edtAddressee->clear();
00070     btnClear->setEnabled( false );
00071     KABC::Addressee mrEmpty;
00072     mSelectedUid.clear();
00073     emit addresseeChanged( mrEmpty );
00074 }
00075 
00076 void AddressBookLinkWidget::slotSelectAddressee()
00077 {
00078     QString message;
00079     if ( mMetaContact )
00080         message = i18n("Choose the corresponding entry for '%1'", mMetaContact->displayName() );
00081     else
00082         message = i18n("Choose the corresponding entry in the address book" );
00083 
00084     Kopete::UI::AddressBookSelectorDialog dialog( i18n("Addressbook Association"), message, ( mMetaContact ? mMetaContact->metaContactId() : QString::null ), this );   //krazy:exclude=nullstrassign for old broken gcc
00085     int result = dialog.exec();
00086 
00087     KABC::Addressee addr;
00088     if ( result == QDialog::Accepted )
00089     {
00090         addr = dialog.addressBookSelectorWidget()->addressee();
00091 
00092         edtAddressee->setText( addr.realName() );
00093         btnClear->setEnabled( !addr.isEmpty() );
00094         mSelectedUid = ( addr.isEmpty() ? QString::null : addr.uid() ); //krazy:exclude=nullstrassign for old broken gcc
00095         emit addresseeChanged( addr );
00096     }
00097 }
00098 
00099 } // end namespace UI
00100 } // end namespace Kopete
00101 
00102 #include "addressbooklinkwidget.moc"

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdenetwork

Skip menu "kdenetwork"
  • kget
  • kopete
  •   kopete
  •   libkopete
  •       libpapillon
  • krfb
Generated for kdenetwork 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