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/protocols/jabber/ui/dlgjabberbrowse.cpp | 144 +++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 kopete/protocols/jabber/ui/dlgjabberbrowse.cpp (limited to 'kopete/protocols/jabber/ui/dlgjabberbrowse.cpp') diff --git a/kopete/protocols/jabber/ui/dlgjabberbrowse.cpp b/kopete/protocols/jabber/ui/dlgjabberbrowse.cpp new file mode 100644 index 00000000..f8e2b4ce --- /dev/null +++ b/kopete/protocols/jabber/ui/dlgjabberbrowse.cpp @@ -0,0 +1,144 @@ + +/*************************************************************************** + dlgjabberbrowse.cpp - description + ------------------- + begin : Wed Dec 11 2002 + copyright : (C) 2002-2003 by Till Gerken + email : kopete-devel@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "jabberaccount.h" +#include "jabberprotocol.h" +#include "jabberclient.h" +#include "jabberformtranslator.h" +#include "dlgjabberbrowse.h" + +dlgJabberBrowse::dlgJabberBrowse (JabberAccount *account, const XMPP::Jid & jid, QWidget * parent, const char *name):dlgBrowse (parent, name) +{ + m_account = account; + + // disable the left margin + tblResults->setLeftMargin (0); + + // no content for now + tblResults->setNumRows (0); + + // disable user selections + tblResults->setSelectionMode (QTable::NoSelection); + + XMPP::JT_Search * task = new XMPP::JT_Search (m_account->client()->rootTask ()); + + connect (task, SIGNAL (finished ()), this, SLOT (slotGotForm ())); + + task->get (jid); + task->go (true); +} + +void dlgJabberBrowse::slotGotForm () +{ + XMPP::JT_Search * task = (XMPP::JT_Search *) sender (); + + // delete the wait message + delete lblWait; + + if (!task->success ()) + { + KMessageBox::queuedMessageBox(this, KMessageBox::Information, i18n ("Unable to retrieve search form."), i18n ("Jabber Error")); + + return; + } + + + // translate the form and create it inside the display widget + translator = new JabberFormTranslator (task->form (), dynamicForm); + dynamicForm->layout()->add( translator ); + translator->show(); + + // enable the send button + btnSearch->setEnabled (true); + + // adjust table + tblResults->setNumCols (5); + + for (int i = 0; i < 5; i++) + { + // allow autostretching + tblResults->setColumnStretchable (i, true); + } + + connect (btnSearch, SIGNAL (clicked ()), this, SLOT (slotSendForm ())); + +} + +void dlgJabberBrowse::slotSendForm () +{ + + XMPP::JT_Search * task = new XMPP::JT_Search (m_account->client()->rootTask ()); + + connect (task, SIGNAL (finished ()), this, SLOT (slotSentForm ())); + + task->set (translator->resultData ()); + task->go (true); + + btnSearch->setEnabled (false); + btnClose->setEnabled (false); + +} + +void dlgJabberBrowse::slotSentForm () +{ + XMPP::JT_Search * task = (XMPP::JT_Search *) sender (); + + btnSearch->setEnabled (true); + btnClose->setEnabled (true); + + if (!task->success ()) + { + KMessageBox::queuedMessageBox (this, KMessageBox::Error, i18n ("The Jabber server declined the search."), i18n ("Jabber Search")); + + return; + } + + tblResults->setNumRows (task->results ().count ()); + + int row = 0; + + for (QValueList < XMPP::SearchResult >::const_iterator it = task->results ().begin (); it != task->results ().end (); ++it) + { + tblResults->setText (row, 0, (*it).jid ().userHost ()); + tblResults->setText (row, 1, (*it).first ()); + tblResults->setText (row, 2, (*it).last ()); + tblResults->setText (row, 3, (*it).nick ()); + tblResults->setText (row, 4, (*it).email ()); + + row++; + } + for (int i = 0; i < 5; i++) + { + tblResults->setColumnStretchable (i, false); + tblResults->adjustColumn (i); + } +} + +dlgJabberBrowse::~dlgJabberBrowse () +{ +} + +#include "dlgjabberbrowse.moc" -- cgit v1.2.1