From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kopete/libkopete/ui/addressbooklinkwidget.cpp | 99 +++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 kopete/libkopete/ui/addressbooklinkwidget.cpp (limited to 'kopete/libkopete/ui/addressbooklinkwidget.cpp') diff --git a/kopete/libkopete/ui/addressbooklinkwidget.cpp b/kopete/libkopete/ui/addressbooklinkwidget.cpp new file mode 100644 index 00000000..a6aff32b --- /dev/null +++ b/kopete/libkopete/ui/addressbooklinkwidget.cpp @@ -0,0 +1,99 @@ +/* + AddressBookLinkWidget + + A compact widget for showing and changing which address book item a + particular Kopete::MetaContact is related to. + + Comprises a label showing the contact's name, a Clear button, and a Change + button that usually invokes the AddressBookSelectorWidget. + + Copyright (c) 2006 by Will Stephenson + + Kopete (c) 2002-2006 by the Kopete developers + + ************************************************************************* + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ************************************************************************* +*/ + +#include +#include +#include +#include + +#include + +#include + +#include "addressbooklinkwidget.h" +#include "addressbookselectordialog.h" +#include "addressbookselectorwidget.h" + +namespace Kopete { +namespace UI { + + +AddressBookLinkWidget::AddressBookLinkWidget( QWidget * parent, const char * name ) : AddressBookLinkWidgetBase( parent, name ), mMetaContact( 0 ) +{ + btnClear->setIconSet( SmallIconSet( QApplication::reverseLayout() ? QString::fromLatin1( "locationbar_erase" ) : QString::fromLatin1( "clear_left") ) ); + connect( btnClear, SIGNAL( clicked() ), this, SLOT( slotClearAddressee() ) ); + connect( btnSelectAddressee, SIGNAL( clicked() ), SLOT( slotSelectAddressee() ) ); +} + +void AddressBookLinkWidget::setAddressee( const KABC::Addressee& addr ) +{ + edtAddressee->setText( addr.realName() ); + btnClear->setEnabled( !addr.isEmpty() ); +} + +void AddressBookLinkWidget::setMetaContact( const Kopete::MetaContact * mc ) +{ + mMetaContact = mc; +} + +QString AddressBookLinkWidget::uid() const +{ + return mSelectedUid; +} + +void AddressBookLinkWidget::slotClearAddressee() +{ + edtAddressee->clear(); + btnClear->setEnabled( false ); + KABC::Addressee mrEmpty; + mSelectedUid = QString::null; + emit addresseeChanged( mrEmpty ); +} + +void AddressBookLinkWidget::slotSelectAddressee() +{ + QString message; + if ( mMetaContact ) + message = i18n("Choose the corresponding entry for '%1'" ).arg( mMetaContact->displayName() ); + else + message = i18n("Choose the corresponding entry in the address book" ); + + Kopete::UI::AddressBookSelectorDialog dialog( i18n("Addressbook Association"), message, ( mMetaContact ? mMetaContact->metaContactId() : QString::null ), this ); + int result = dialog.exec(); + + KABC::Addressee addr; + if ( result == QDialog::Accepted ) + { + addr = dialog.addressBookSelectorWidget()->addressee(); + + edtAddressee->setText( addr.realName() ); + btnClear->setEnabled( !addr.isEmpty() ); + mSelectedUid = ( addr.isEmpty() ? QString::null : addr.uid() ); + emit addresseeChanged( addr ); + } +} + +} // end namespace UI +} // end namespace Kopete + +#include "addressbooklinkwidget.moc" -- cgit v1.2.1