From c7cd9c8d239c1c5d604de8862625741754138771 Mon Sep 17 00:00:00 2001
From: Richard Maudsley <richard.maudsley@isode.com>
Date: Thu, 24 Jul 2014 09:18:49 +0100
Subject: Fix JID auto-complete item select not working when adding a contact.

Test-Information:

Confirm that clicking a suggested user fills the JID box on the "Add User" dialog. Confirm that JID suggestion functions normally in other places.

Change-Id: Ic1a5c30b95416fd46bc22a612793621e9501d770

diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index e5bd5d0..29ee306 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -281,6 +281,10 @@ void QtUserSearchWindow::addSearchedJIDToList(const Contact::ref& contact) {
 	firstMultiJIDPage_->jid_->clear();
 }
 
+void QtUserSearchWindow::handleOnSearchedJIDSelected(const Contact::ref& contact) {
+	firstPage_->jid_->setText(P2QSTRING(contact->jid.toString()));
+}
+
 void QtUserSearchWindow::show() {
 	clear();
 	QWidget::show();
@@ -468,6 +472,7 @@ void QtUserSearchWindow::setFirstPage(QString title) {
 	if (type_ == AddContact) {
 		firstPage_ = new QtUserSearchFirstPage(type_, title.isEmpty() ? firstPage_->title() : title, settings_);
 		connect(firstPage_->jid_, SIGNAL(textEdited(QString)), this, SLOT(handleContactSuggestionRequested(QString)));
+		firstPage_->jid_->onUserSelected.connect(boost::bind(&QtUserSearchWindow::handleOnSearchedJIDSelected, this, _1));
 		connect(firstPage_->byJID_, SIGNAL(toggled(bool)), this, SLOT(handleFirstPageRadioChange()));
 		connect(firstPage_->byLocalSearch_, SIGNAL(toggled(bool)), this, SLOT(handleFirstPageRadioChange()));
 		connect(firstPage_->byRemoteSearch_, SIGNAL(toggled(bool)), this, SLOT(handleFirstPageRadioChange()));
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.h b/Swift/QtUI/UserSearch/QtUserSearchWindow.h
index 0318b3d..255b8fe 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.h
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.h
@@ -79,6 +79,7 @@ namespace Swift {
 			JID getContactJID() const;
 			Contact::ref getContact() const;
 			void addSearchedJIDToList(const Contact::ref& contact);
+			void handleOnSearchedJIDSelected(const Contact::ref& contact);
 
 		private:
 			UIEventStream* eventStream_;
-- 
cgit v0.10.2-6-g49f6