From 64901783526b8d9c9370b297bfd1d109a6cc0bbe Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Thu, 26 May 2016 08:33:30 +0200 Subject: Fix setting recent search server when doing a local user search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test-Information: Builds on OS X 10.11.5. Tested that the recent search server field in the 'Start Chat…" dialog is not set, if you search locally. Searching on remote servers still adds the server to the recent search server list. Change-Id: I62e21339b055ec826f450b8bfb2c662d1df5e84b diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp index 6b56811..b9c0cb1 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include @@ -108,7 +107,9 @@ void QtUserSearchWindow::handleCurrentChanged(int page) { bool remote = firstMultiJIDPage_->byRemoteSearch_->isChecked(); setFirstPage(); firstMultiJIDPage_->byRemoteSearch_->setChecked(remote); - firstMultiJIDPage_->service_->setEditText(P2QSTRING(server.toString())); + if (remote) { + firstMultiJIDPage_->service_->setEditText(P2QSTRING(server.toString())); + } } } else if (page == 4) { @@ -142,14 +143,14 @@ void QtUserSearchWindow::handleAccepted() { break; } - foreach(Contact::ref contact, contactVector_) { + for (Contact::ref contact : contactVector_) { jids.push_back(contact->jid); } eventStream_->send(std::make_shared(jids, JID(), Q2PSTRING(firstMultiJIDPage_->reason_->text()))); break; case InviteToChat: - foreach(Contact::ref contact, contactVector_) { + for (Contact::ref contact : contactVector_) { jids.push_back(contact->jid); } eventStream_->send(std::make_shared(roomJID_, jids, Q2PSTRING(firstMultiJIDPage_->reason_->text()))); @@ -272,7 +273,7 @@ JID QtUserSearchWindow::getContactJID() const { Form::FormItem item = dynamic_cast(model_)->getForm()->getItems().at(row); JID fallbackJid; - foreach(FormField::ref field, item) { + for (FormField::ref field : item) { if (field->getType() == FormField::JIDSingleType) { jid = JID(field->getJIDSingleValue()); break; @@ -318,13 +319,13 @@ void QtUserSearchWindow::show() { void QtUserSearchWindow::addSavedServices(const std::vector& services) { if (type_ == AddContact) { firstPage_->service_->clear(); - foreach (JID jid, services) { + for (auto&& jid : services) { firstPage_->service_->addItem(P2QSTRING(jid.toString())); } firstPage_->service_->clearEditText(); } else { firstMultiJIDPage_->service_->clear(); - foreach (JID jid, services) { + for (auto&& jid : services) { firstMultiJIDPage_->service_->addItem(P2QSTRING(jid.toString())); } firstMultiJIDPage_->service_->clearEditText(); @@ -375,7 +376,7 @@ void QtUserSearchWindow::setContactSuggestions(const std::vector& } void QtUserSearchWindow::setJIDs(const std::vector &jids) { - foreach(JID jid, jids) { + for (auto&& jid : jids) { addSearchedJIDToList(std::make_shared("", jid, StatusShow::None, "")); } onJIDUpdateRequested(jids); @@ -391,7 +392,7 @@ std::string QtUserSearchWindow::getReason() const { std::vector QtUserSearchWindow::getJIDs() const { std::vector jids; - foreach (Contact::ref contact, contactVector_) { + for (Contact::ref contact : contactVector_) { jids.push_back(contact->jid); } return jids; @@ -413,9 +414,9 @@ void QtUserSearchWindow::updateContacts(const std::vector& contact void QtUserSearchWindow::addContacts(const std::vector& contacts) { if (type_ != AddContact) { /* prevent duplicate JIDs from appearing in the contact list */ - foreach (Contact::ref newContact, contacts) { + for (Contact::ref newContact : contacts) { bool found = false; - foreach (Contact::ref oldContact, contactVector_) { + for (Contact::ref oldContact : contactVector_) { if (newContact->jid == oldContact->jid) { found = true; break; @@ -557,7 +558,7 @@ void QtUserSearchWindow::clearForm() { fieldsPage_->fetchingThrobber_->movie()->start(); fieldsPage_->fetchingLabel_->show(); QWidget* legacySearchWidgets[8] = {fieldsPage_->nickInputLabel_, fieldsPage_->nickInput_, fieldsPage_->firstInputLabel_, fieldsPage_->firstInput_, fieldsPage_->lastInputLabel_, fieldsPage_->lastInput_, fieldsPage_->emailInputLabel_, fieldsPage_->emailInput_}; - for (auto& legacySearchWidget : legacySearchWidgets) { + for (auto&& legacySearchWidget : legacySearchWidgets) { legacySearchWidget->hide(); if (QLineEdit* edit = qobject_cast(legacySearchWidget)) { edit->clear(); -- cgit v0.10.2-6-g49f6