From 16b1f85c1a7a0310b0a722c853e5fc8dd799570b Mon Sep 17 00:00:00 2001
From: Richard Maudsley <richard.maudsley@isode.com>
Date: Mon, 30 Jun 2014 13:30:28 +0100
Subject: Reset QtSuggestingJIDInput when a contact has been selected.

Test-Information:

Verified that the selected contact is added to the contact list when selecting from the drop-down list or by pressing the 'Add' button and that the JID field is reset after this happens.

Change-Id: I7ef047ec9dbacf1af8635849320371f082bb3d0d

diff --git a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
index a4a4610..9b96627 100644
--- a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
+++ b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
@@ -91,6 +91,11 @@ void QtSuggestingJIDInput::setSuggestions(const std::vector<Contact::ref>& sugge
 	}
 }
 
+void QtSuggestingJIDInput::clear() {
+	setText("");
+	currentContact_.reset();
+}
+
 void QtSuggestingJIDInput::keyPressEvent(QKeyEvent* event) {
 	if (event->key() == Qt::Key_Up) {
 		if (contactListModel_->rowCount() > 0) {
@@ -138,7 +143,6 @@ void QtSuggestingJIDInput::handleSettingsChanged(const std::string& setting) {
 void QtSuggestingJIDInput::handleClicked(const QModelIndex& index) {
 	if (index.isValid()) {
 		currentContact_ = contactListModel_->getContact(index.row());
-		setText("");
 		onUserSelected(currentContact_->jid);
 		hidePopup();
 	}
diff --git a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h
index 25e7d42..71cd87d 100644
--- a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h
+++ b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h
@@ -33,6 +33,8 @@ class QtSuggestingJIDInput : public QLineEdit {
 
 		void setSuggestions(const std::vector<Contact::ref>& suggestions);
 
+		void clear();
+
 		boost::signal<void (const JID&)> onUserSelected;
 
 	signals:
diff --git a/Swift/QtUI/UserSearch/QtUserSearchFirstMultiJIDPage.cpp b/Swift/QtUI/UserSearch/QtUserSearchFirstMultiJIDPage.cpp
index 8ea49c4..2c34aa6 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchFirstMultiJIDPage.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchFirstMultiJIDPage.cpp
@@ -58,6 +58,7 @@ bool QtUserSearchFirstMultiJIDPage::isComplete() const {
 }
 
 void QtUserSearchFirstMultiJIDPage::reset() {
+	jid_->clear();
 	reason_->clear();
 }
 
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index 260ccfe..ca84759 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -158,6 +158,7 @@ void QtUserSearchWindow::handleContactSuggestionRequested(const QString& text) {
 void QtUserSearchWindow::addContact() {
 	if (!!firstMultiJIDPage_->jid_->getContact()) {
 		contactVector_.push_back(firstMultiJIDPage_->jid_->getContact());
+		firstMultiJIDPage_->jid_->clear();
 	}
 	firstMultiJIDPage_->contactList_->setList(contactVector_);
 	firstMultiJIDPage_->emitCompletenessCheck();
@@ -273,6 +274,7 @@ void QtUserSearchWindow::addSearchedJIDToList(const JID& jid) {
 	std::vector<JID> jids;
 	jids.push_back(jid);
 	handleJIDsAdded(jids);
+	firstMultiJIDPage_->jid_->clear();
 }
 
 void QtUserSearchWindow::show() {
-- 
cgit v0.10.2-6-g49f6