• 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.14
  • 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 "addressbooklinkwidget.h"
25 
26 #include <qapplication.h>
27 #include <klineedit.h>
28 #include <klocale.h>
29 #include <kpushbutton.h>
30 
31 #include <kiconloader.h>
32 
33 #include <kopetemetacontact.h>
34 
35 #include "addressbookselectordialog.h"
36 #include "addressbookselectorwidget.h"
37 
38 namespace Kopete {
39 namespace UI {
40 
41 
42 AddressBookLinkWidget::AddressBookLinkWidget( QWidget * parent, const char * name ) : QWidget(parent), Ui::AddressBookLinkWidgetBase(), mMetaContact( 0 )
43 {
44  setObjectName(name);
45  setupUi(this);
46 
47  btnClear->setIcon( KIcon( (QApplication::layoutDirection() == Qt::RightToLeft) ? QString::fromLatin1( "edit-clear-locationbar-ltr" ) : QString::fromLatin1( "edit-clear-locationbar-rtl") ) );
48  connect( btnClear, SIGNAL(clicked()), this, SLOT(slotClearAddressee()) );
49  connect( btnSelectAddressee, SIGNAL(clicked()), SLOT(slotSelectAddressee()) );
50 }
51 
52 void AddressBookLinkWidget::setAddressee( const KABC::Addressee& addr )
53 {
54  edtAddressee->setText( addr.realName() );
55  btnClear->setEnabled( !addr.isEmpty() );
56 }
57 
58 void AddressBookLinkWidget::setMetaContact( const Kopete::MetaContact * mc )
59 {
60  mMetaContact = mc;
61 }
62 
63 QString AddressBookLinkWidget::uid() const
64 {
65  return mSelectedUid;
66 }
67 
68 void AddressBookLinkWidget::slotClearAddressee()
69 {
70  edtAddressee->clear();
71  btnClear->setEnabled( false );
72  KABC::Addressee mrEmpty;
73  mSelectedUid.clear();
74  emit addresseeChanged( mrEmpty );
75 }
76 
77 void AddressBookLinkWidget::slotSelectAddressee()
78 {
79  QString message;
80  if ( mMetaContact )
81  message = i18n("Choose the corresponding entry for '%1'", mMetaContact->displayName() );
82  else
83  message = i18n("Choose the corresponding entry in the address book" );
84 
85  QString assocDisplayText;
86  if ( mMetaContact )
87  {
88  assocDisplayText = mMetaContact->kabcId();
89  }
90  QPointer <Kopete::UI::AddressBookSelectorDialog> dialog = new Kopete::UI::AddressBookSelectorDialog( i18n("Address Book Association"), message,
91  assocDisplayText, this );
92  int result = dialog->exec();
93 
94  KABC::Addressee addr;
95  if ( result == QDialog::Accepted && dialog )
96  {
97  addr = dialog->addressBookSelectorWidget()->addressee();
98 
99  edtAddressee->setText( addr.realName() );
100  btnClear->setEnabled( !addr.isEmpty() );
101  mSelectedUid = ( addr.isEmpty() ? QString() : addr.uid() );
102  emit addresseeChanged( addr );
103  }
104  delete dialog;
105 }
106 
107 } // end namespace UI
108 } // end namespace Kopete
109 
110 #include "addressbooklinkwidget.moc"
kopetemetacontact.h
QWidget
QWidget::setupUi
void setupUi(QWidget *widget)
QApplication::layoutDirection
Qt::LayoutDirection layoutDirection()
Kopete::MetaContact::kabcId
QString kabcId() const
Get the KABC id for this metacontact.
Definition: kopetemetacontact.cpp:1169
QPointer
QString::clear
void clear()
addressbookselectorwidget.h
addressbooklinkwidget.h
QObject::setObjectName
void setObjectName(const QString &name)
Kopete::MetaContact::displayName
QString displayName
Definition: kopetemetacontact.h:58
QString
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:77
Kopete::UI::AddressBookLinkWidget::uid
QString uid() const
Return the selected addressbook UID.
Definition: addressbooklinkwidget.cpp:63
Kopete::MetaContact
Definition: kopetemetacontact.h:54
QString::fromLatin1
QString fromLatin1(const char *str, int size)
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:42
Kopete::UI::AddressBookLinkWidget::setAddressee
void setAddressee(const KABC::Addressee &addr)
Set the currently selected addressee.
Definition: addressbooklinkwidget.cpp:52
Kopete::UI::AddressBookLinkWidget::slotClearAddressee
void slotClearAddressee()
Definition: addressbooklinkwidget.cpp:68
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
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:58
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 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