From 02087213c15a17e290e1d364b9c4823004c402c6 Mon Sep 17 00:00:00 2001 From: Manjeet Dahiya Date: Thu, 9 Sep 2010 11:21:43 +0000 Subject: link the profile dialog --- examples/GuiClient/mainDialog.cpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'examples/GuiClient/mainDialog.cpp') diff --git a/examples/GuiClient/mainDialog.cpp b/examples/GuiClient/mainDialog.cpp index e8c53f73..35705e89 100644 --- a/examples/GuiClient/mainDialog.cpp +++ b/examples/GuiClient/mainDialog.cpp @@ -34,6 +34,8 @@ #include "QXmppLogger.h" #include "QXmppVCardIq.h" +#include "profileDialog.h" + #include mainDialog::mainDialog(QWidget *parent): QDialog(parent, Qt::Window), @@ -74,6 +76,10 @@ mainDialog::mainDialog(QWidget *parent): QDialog(parent, Qt::Window), this, SLOT(showChatDialog(const QString&))); Q_ASSERT(check); + check = connect(ui->listView, SIGNAL(showProfile(const QString&)), + this, SLOT(showProfile(const QString&))); + Q_ASSERT(check); + check = connect(&m_xmppClient, SIGNAL(messageReceived(const QXmppMessage&)), SLOT(messageReceived(const QXmppMessage&))); Q_ASSERT(check); @@ -255,7 +261,8 @@ chatDialog* mainDialog::getChatDialog(const QString& bareJid) void mainDialog::showChatDialog(const QString& bareJid) { - getChatDialog(bareJid)->show(); + if(!bareJid.isEmpty()) + getChatDialog(bareJid)->show(); } void mainDialog::messageReceived(const QXmppMessage& msg) @@ -439,3 +446,32 @@ void mainDialog::updateVCard(const QString& bareJid) m_statusWidget.setAvatar(m_vCardManager.getVCard(bareJid).image); } } + +void mainDialog::showProfile(const QString& bareJid) +{ + if(bareJid.isEmpty()) + return; + + profileDialog dlg(this); + dlg.setBareJid(bareJid); + dlg.setAvatar(m_vCardManager.getVCard(bareJid).imageOriginal); + QStringList resources = m_xmppClient.rosterManager().getResources(bareJid); + + dlg.setFullName(m_vCardManager.getVCard(bareJid).fullName); + + QString statusText; + for(int i = 0; i < resources.count(); ++i) + { + QString resource = resources.at(i); + statusText += ""+ resource+ ""; + statusText += "
"; + QXmppPresence presence = m_xmppClient.rosterManager().getPresence(bareJid, resource); + statusText += presenceToStatusText(presence); + + if(i < resources.count() - 1) // skip for the last item + statusText += "

"; + } + dlg.setStatusText(statusText); + + dlg.exec(); +} -- cgit v1.2.3