• 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
contactaddednotifydialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005 Olivier Goffart <ogoffart@kde.org>
3 
4  Kopete (c) 2005-2007 by the Kopete developers <kopete-devel@kde.org>
5 
6  *************************************************************************
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU Lesser General Public *
10  * License as published by the Free Software Foundation; either *
11  * version 2 of the License, or (at your option) any later version. *
12  * *
13  *************************************************************************
14 */
15 
16 #include "contactaddednotifydialog.h"
17 
18 
19 #include <qlabel.h>
20 #include <qcheckbox.h>
21 #include <qapplication.h>
22 
23 #include <klocale.h>
24 #include <kcombobox.h>
25 #include <klineedit.h>
26 #include <kpushbutton.h>
27 #include <kiconloader.h>
28 
29 #include <kabc/addressee.h>
30 
31 #include "kopetegroup.h"
32 #include "kopeteaccount.h"
33 #include "kopeteuiglobal.h"
34 #include "kopeteprotocol.h"
35 #include "kopetecontactlist.h"
36 #include "kopetemetacontact.h"
37 #include "addressbooklinkwidget.h"
38 #include "addressbookselectordialog.h"
39 #include "ui_contactaddednotifywidget.h"
40 
41 namespace Kopete {
42 
43 namespace UI {
44 
45 struct ContactAddedNotifyDialog::Private
46 {
47  Ui::ContactAddedNotifyWidget *widget;
48  Account *account;
49  QString contactId;
50  QString addressbookId;
51 };
52 
53 
54 ContactAddedNotifyDialog::ContactAddedNotifyDialog(const QString& contactId,
55  const QString& contactNick, Kopete::Account *account, const HideWidgetOptions &hide)
56  : KDialog( Global::mainWidget() ), d(new Private())
57 {
58  setCaption( i18n("Someone Has Added You") );
59  setButtons( KDialog::Ok | KDialog::Cancel );
60  setAttribute( Qt::WA_DeleteOnClose );
61 
62  d->widget=new Ui::ContactAddedNotifyWidget;
63  QWidget* w = new QWidget(this);
64  d->widget->setupUi(w);
65  setMainWidget(w);
66 
67  d->account=account;
68  d->contactId=contactId;
69  d->widget->m_label->setText(i18n("<qt><img src=\"kopete-account-icon:%1\" /> The contact <b>%2</b> has added you to his/her contact list. (Account %3)</qt>",
70  QString(QUrl::toPercentEncoding( account->protocol()->pluginId() )) + QString::fromLatin1(":")
71  + QString(QUrl::toPercentEncoding( account->accountId() )) ,
72  contactNick.isEmpty() ? contactId : contactNick + QString::fromLatin1(" < ") + contactId + QString::fromLatin1(" >") ,
73  account->accountLabel() ) );
74  if( hide & InfoButton)
75  d->widget->m_infoButton->hide() ;
76  if( hide & AuthorizeCheckBox )
77  {
78  d->widget->m_authorizeCb->hide();
79  d->widget->m_authorizeCb->setChecked(false);
80  }
81  if( hide & AddCheckBox )
82  {
83  d->widget->m_addCb->hide();
84  d->widget->m_addCb->setChecked(false);
85  }
86  if( hide & AddGroupBox )
87  d->widget->m_contactInfoBox->hide();
88 
89  // Populate the groups list
90  QListIterator<Group *> it(Kopete::ContactList::self()->groups());
91  while ( it.hasNext() )
92  {
93  Group *g = it.next();
94  QString groupname = g->displayName();
95  if ( g->type() == Group::Normal && !groupname.isEmpty() )
96  {
97  d->widget->m_groupList->addItem(groupname);
98  }
99  }
100  d->widget->m_groupList->setEditText(QString()); //default to top-level
101 
102  connect( d->widget->widAddresseeLink, SIGNAL(addresseeChanged(KABC::Addressee)), this, SLOT(slotAddresseeSelected(KABC::Addressee)) );
103  connect( d->widget->m_infoButton, SIGNAL(clicked()), this, SLOT(slotInfoClicked()) );
104 
105  connect( this, SIGNAL(okClicked()) , this , SLOT(slotFinished()));
106 
107 }
108 
109 
110 ContactAddedNotifyDialog::~ContactAddedNotifyDialog()
111 {
112  delete d->widget;
113  delete d;
114 }
115 
116 bool ContactAddedNotifyDialog::added() const
117 {
118  return d->widget->m_addCb->isChecked();
119 }
120 
121 bool ContactAddedNotifyDialog::authorized() const
122 {
123  return d->widget->m_authorizeCb->isChecked();
124 }
125 
126 QString ContactAddedNotifyDialog::displayName() const
127 {
128  return d->widget->m_displayNameEdit->text();
129 }
130 
131 Group *ContactAddedNotifyDialog::group() const
132 {
133  QString grpName=d->widget->m_groupList->currentText();
134  if(grpName.isEmpty())
135  return Group::topLevel();
136 
137  return ContactList::self()->findGroup( grpName );
138 }
139 
140 MetaContact *ContactAddedNotifyDialog::addContact() const
141 {
142  if(!added() || !d->account)
143  return 0L;
144 
145  MetaContact *metacontact=d->account->addContact(d->contactId, displayName(), group());
146  if(!metacontact)
147  return 0L;
148 
149  metacontact->setKabcId(d->addressbookId);
150 
151  return metacontact;
152 }
153 
154 void ContactAddedNotifyDialog::slotAddresseeSelected( const KABC::Addressee & addr )
155 {
156  if ( !addr.isEmpty() )
157  {
158  d->addressbookId = addr.uid();
159  }
160 }
161 
162 void ContactAddedNotifyDialog::slotInfoClicked()
163 {
164  emit infoClicked(d->contactId);
165 }
166 
167 void ContactAddedNotifyDialog::slotFinished()
168 {
169  emit applyClicked(d->contactId);
170 }
171 
172 
173 
174 } // namespace UI
175 } // namespace Kopete
176 #include "contactaddednotifydialog.moc"
Kopete::Account::accountLabel
QString accountLabel() const
The label for this account.
Definition: kopeteaccount.cpp:292
kopetemetacontact.h
Kopete::UI::ContactAddedNotifyDialog::applyClicked
void applyClicked(const QString &contactId)
the dialog has been applied
Kopete::ContactList::self
static ContactList * self()
The contact list is a singleton object.
Definition: kopetecontactlist.cpp:71
Kopete::Account::protocol
Protocol * protocol() const
Definition: kopeteaccount.cpp:216
contactaddednotifydialog.h
Kopete::UI::ContactAddedNotifyDialog::ContactAddedNotifyDialog
ContactAddedNotifyDialog(const QString &contactId, const QString &contactNick=QString::null, Kopete::Account *account=0L, const HideWidgetOptions &hide=DefaultHide)
Constructor.
Definition: contactaddednotifydialog.cpp:54
QWidget
QListIterator::next
const T & next()
Kopete::UI::ContactAddedNotifyDialog::~ContactAddedNotifyDialog
~ContactAddedNotifyDialog()
Destructor.
Definition: contactaddednotifydialog.cpp:110
kopeteaccount.h
Kopete::ContactList::findGroup
Group * findGroup(const QString &displayName, int type=0)
find a group with his displayName If a group already exists with the given name and the given type...
Definition: kopetecontactlist.cpp:196
kopetegroup.h
Kopete::UI::ContactAddedNotifyDialog::infoClicked
void infoClicked(const QString &contactId)
the button "info" has been pressed If you haven't hidden the more info button, you should connect thi...
KDialog
Kopete::UI::ContactAddedNotifyDialog::group
Group * group() const
return the group the user has selected
Definition: contactaddednotifydialog.cpp:131
Kopete::UI::ContactAddedNotifyDialog::AuthorizeCheckBox
the checkbox which ask for authorize the contact
Definition: contactaddednotifydialog.h:80
kopeteuiglobal.h
Kopete::UI::ContactAddedNotifyDialog::added
bool added() const
return if the user has checked the "add" checkbox
Definition: contactaddednotifydialog.cpp:116
Kopete::Account::accountId
QString accountId
Definition: kopeteaccount.h:77
Kopete::Plugin::pluginId
QString pluginId() const
Get the plugin id.
Definition: kopeteplugin.cpp:46
kopeteprotocol.h
addressbooklinkwidget.h
QString::isEmpty
bool isEmpty() const
kopetecontactlist.h
Kopete::UI::ContactAddedNotifyDialog::displayName
QString displayName() const
return the display name the user has entered
Definition: contactaddednotifydialog.cpp:126
QString
Kopete::Group::Normal
Definition: kopetegroup.h:56
Kopete::UI::Global::setMainWidget
KOPETE_EXPORT void setMainWidget(QWidget *widget)
Set the main widget to widget.
Definition: kopeteuiglobal.cpp:32
Kopete::UI::Global::mainWidget
KOPETE_EXPORT QWidget * mainWidget()
Returns the main widget - this is the widget that message boxes and KNotify stuff should use as a par...
Definition: kopeteuiglobal.cpp:37
addressbookselectordialog.h
Kopete::UI::ContactAddedNotifyDialog::InfoButton
the button which ask for more info about the contact
Definition: contactaddednotifydialog.h:79
Kopete::Group::topLevel
static Group * topLevel()
Definition: kopetegroup.cpp:35
Kopete::Group
Class which represents the Group.
Definition: kopetegroup.h:44
QUrl::toPercentEncoding
QByteArray toPercentEncoding(const QString &input, const QByteArray &exclude, const QByteArray &include)
Kopete::MetaContact
Definition: kopetemetacontact.h:54
QString::fromLatin1
QString fromLatin1(const char *str, int size)
QListIterator
Kopete::MetaContact::setKabcId
void setKabcId(const QString &newKabcId)
Set the KABC id for this metacontact Use with care! You could create a one to many relationship...
Definition: kopetemetacontact.cpp:1183
Kopete::UI::ContactAddedNotifyDialog::addContact
MetaContact * addContact() const
create a metacontact.
Definition: contactaddednotifydialog.cpp:140
Kopete::UI::ContactAddedNotifyDialog::AddGroupBox
all the widget about metacontact properties
Definition: contactaddednotifydialog.h:82
Kopete::Group::type
GroupType type() const
Definition: kopetegroup.cpp:127
Kopete::UI::ContactAddedNotifyDialog::authorized
bool authorized() const
return if the user has checked the "authorize" checkbox
Definition: contactaddednotifydialog.cpp:121
Kopete::Account
The Kopete::Account class handles one account.
Definition: kopeteaccount.h:72
Kopete::Group::displayName
QString displayName
Definition: kopetegroup.h:46
Kopete::UI::ContactAddedNotifyDialog::AddCheckBox
the checkbox which ask if the contact should be added
Definition: contactaddednotifydialog.h:81
QListIterator::hasNext
bool hasNext() const
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