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

kopete/libkopete

  • sources
  • kde-4.12
  • kdenetwork
  • kopete
  • libkopete
  • ui
addressbooklinkwidget.cpp
Go to the documentation of this file.
1 /*
2  AddressBookLinkWidget
3 
4  A compact widget for showing and changing which address book item a
5  particular Kopete::MetaContact is related to.
6 
7  Comprises a label showing the contact's name, a Clear button, and a Change
8  button that usually invokes the AddressBookSelectorWidget.
9 
10  Copyright (c) 2006 by Will Stephenson <wstephenson@kde.org>
11 
12  Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
13 
14  *************************************************************************
15  * *
16  * This program is free software; you can redistribute it and/or modify *
17  * it under the terms of the GNU General Public License as published by *
18  * the Free Software Foundation; either version 2 of the License, or *
19  * (at your option) any later version. *
20  * *
21  *************************************************************************
22 */
23 
24 #include <qapplication.h>
25 #include <klineedit.h>
26 #include <klocale.h>
27 #include <kpushbutton.h>
28 
29 #include <kiconloader.h>
30 
31 #include <kopetemetacontact.h>
32 
33 #include "addressbooklinkwidget.h"
34 #include "addressbookselectordialog.h"
35 #include "addressbookselectorwidget.h"
36 
37 namespace Kopete {
38 namespace UI {
39 
40 
41 AddressBookLinkWidget::AddressBookLinkWidget( QWidget * parent, const char * name ) : QWidget(parent), Ui::AddressBookLinkWidgetBase(), mMetaContact( 0 )
42 {
43  setObjectName(name);
44  setupUi(this);
45 
46  btnClear->setIcon( KIcon( (QApplication::layoutDirection() == Qt::RightToLeft) ? QString::fromLatin1( "edit-clear-locationbar-ltr" ) : QString::fromLatin1( "edit-clear-locationbar-rtl") ) );
47  connect( btnClear, SIGNAL(clicked()), this, SLOT(slotClearAddressee()) );
48  connect( btnSelectAddressee, SIGNAL(clicked()), SLOT(slotSelectAddressee()) );
49 }
50 
51 void AddressBookLinkWidget::setAddressee( const KABC::Addressee& addr )
52 {
53  edtAddressee->setText( addr.realName() );
54  btnClear->setEnabled( !addr.isEmpty() );
55 }
56 
57 void AddressBookLinkWidget::setMetaContact( const Kopete::MetaContact * mc )
58 {
59  mMetaContact = mc;
60 }
61 
62 QString AddressBookLinkWidget::uid() const
63 {
64  return mSelectedUid;
65 }
66 
67 void AddressBookLinkWidget::slotClearAddressee()
68 {
69  edtAddressee->clear();
70  btnClear->setEnabled( false );
71  KABC::Addressee mrEmpty;
72  mSelectedUid.clear();
73  emit addresseeChanged( mrEmpty );
74 }
75 
76 void AddressBookLinkWidget::slotSelectAddressee()
77 {
78  QString message;
79  if ( mMetaContact )
80  message = i18n("Choose the corresponding entry for '%1'", mMetaContact->displayName() );
81  else
82  message = i18n("Choose the corresponding entry in the address book" );
83 
84  QString assocDisplayText;
85  if ( mMetaContact )
86  {
87  assocDisplayText = mMetaContact->kabcId();
88  }
89  QPointer <Kopete::UI::AddressBookSelectorDialog> dialog = new Kopete::UI::AddressBookSelectorDialog( i18n("Address Book Association"), message,
90  assocDisplayText, this );
91  int result = dialog->exec();
92 
93  KABC::Addressee addr;
94  if ( result == QDialog::Accepted && dialog )
95  {
96  addr = dialog->addressBookSelectorWidget()->addressee();
97 
98  edtAddressee->setText( addr.realName() );
99  btnClear->setEnabled( !addr.isEmpty() );
100  mSelectedUid = ( addr.isEmpty() ? QString() : addr.uid() );
101  emit addresseeChanged( addr );
102  }
103  delete dialog;
104 }
105 
106 } // end namespace UI
107 } // end namespace Kopete
108 
109 #include "addressbooklinkwidget.moc"
kopetemetacontact.h
Kopete::MetaContact::kabcId
QString kabcId() const
Get the KABC id for this metacontact.
Definition: kopetemetacontact.cpp:1161
QWidget
addressbookselectorwidget.h
addressbooklinkwidget.h
Kopete::MetaContact::displayName
QString displayName
Definition: kopetemetacontact.h:58
Kopete::UI::AddressBookSelectorDialog
A dialog that uses AddressBookSelectorWidget to allow the user to select a KDE addressbook contact...
Definition: addressbookselectordialog.h:49
addressbookselectordialog.h
Kopete::UI::AddressBookLinkWidget::slotSelectAddressee
void slotSelectAddressee()
Definition: addressbooklinkwidget.cpp:76
Kopete::UI::AddressBookLinkWidget::uid
QString uid() const
Return the selected addressbook UID.
Definition: addressbooklinkwidget.cpp:62
Kopete::MetaContact
Definition: kopetemetacontact.h:54
Kopete::UI::AddressBookLinkWidget::addresseeChanged
void addresseeChanged(const KABC::Addressee &addr)
Emitted when the selected addressee changed.
Kopete::UI::AddressBookLinkWidget::AddressBookLinkWidget
AddressBookLinkWidget(QWidget *parent=0, const char *name=0)
Definition: addressbooklinkwidget.cpp:41
Kopete::UI::AddressBookLinkWidget::setAddressee
void setAddressee(const KABC::Addressee &addr)
Set the currently selected addressee.
Definition: addressbooklinkwidget.cpp:51
Kopete::UI::AddressBookLinkWidget::slotClearAddressee
void slotClearAddressee()
Definition: addressbooklinkwidget.cpp:67
name
const char * name
Definition: kopeteonlinestatus.cpp:104
Kopete::UI::AddressBookLinkWidget::setMetaContact
void setMetaContact(const Kopete::MetaContact *)
Set the current metacontact so that the selector dialog may be preselected.
Definition: addressbooklinkwidget.cpp:57
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

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

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



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