From 1a35178bcad7c30e50a19e4017d021fb0485ccf0 Mon Sep 17 00:00:00 2001
From: Richard Maudsley <richard.maudsley@isode.com>
Date: Mon, 24 Mar 2014 09:53:37 +0000
Subject: Automatically moving user into the chat list when you select from the
 population drop-down.

Change-Id: I69b44e0e1dda2fa513d2d867ed10e5a8046ff0e9

diff --git a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
index ca65dca..de935d9 100644
--- a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
+++ b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
@@ -131,7 +131,8 @@ void QtSuggestingJIDInput::handleSettingsChanged(const std::string& setting) {
 void QtSuggestingJIDInput::handleClicked(const QModelIndex& index) {
 	if (index.isValid()) {
 		currentContact_ = &contactListModel_->getList()[index.row()];
-		setText(P2QSTRING(currentContact_->jid.toString()));
+		setText("");
+		onUserSelected(currentContact_->jid);
 		hidePopup();
 	}
 }
diff --git a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h
index 673621c..9ec0512 100644
--- a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h
+++ b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h
@@ -8,7 +8,7 @@
 
 #include <QLineEdit>
 #include <QTreeView>
-
+#include <Swiften/Base/boost_bsignals.h>
 #include <Swift/Controllers/Contact.h>
 
 namespace Swift {
@@ -27,6 +27,8 @@ class QtSuggestingJIDInput : public QLineEdit {
 
 		void setSuggestions(const std::vector<Contact>& suggestions);
 
+		boost::signal<void (const JID&)> onUserSelected;
+
 	signals:
 		void editingDone();
 
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index d06fa19..c0c7972 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -10,6 +10,7 @@
 #include <QModelIndex>
 #include <QWizardPage>
 #include <QMovie>
+#include <boost/bind.hpp>
 #include <boost/smart_ptr/make_shared.hpp>
 
 #include <Swiften/Base/foreach.h>
@@ -444,6 +445,7 @@ void QtUserSearchWindow::setFirstPage(QString title) {
 		firstMultiJIDPage_ = new QtUserSearchFirstMultiJIDPage(type_, title.isEmpty() ? firstMultiJIDPage_->title() : title, settings_);
 		connect(firstMultiJIDPage_->addContactButton_, SIGNAL(clicked()), this, SLOT(addContact()));
 		connect(firstMultiJIDPage_->jid_, SIGNAL(textEdited(QString)), this, SLOT(handleContactSuggestionRequested(QString)));
+		firstMultiJIDPage_->jid_->onUserSelected.connect(boost::bind(&QtUserSearchWindow::addSearchedJIDToList, this, _1));
 		connect(firstMultiJIDPage_->addViaSearchButton_, SIGNAL(clicked()), this, SLOT(handleAddViaSearch()));
 		connect(firstMultiJIDPage_->contactList_, SIGNAL(onListChanged(std::vector<Contact>)), this, SLOT(handleListChanged(std::vector<Contact>)));
 		connect(firstMultiJIDPage_->contactList_, SIGNAL(onJIDsAdded(std::vector<JID>)), this, SLOT(handleJIDsAdded(std::vector<JID>)));
-- 
cgit v0.10.2-6-g49f6