summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-04-08 07:58:54 (GMT)
committerRichard Maudsley <richard.maudsley@isode.com>2014-04-23 08:10:49 (GMT)
commit09e9713028b728fad9050c4e20180cc96c4572ce (patch)
tree4924a3d4985ec7d89ca69f6f35853e139b74a7de /Swift
parenta7fb55381ab4a5c470bf891b31ac6e201611a2c1 (diff)
downloadswift-09e9713028b728fad9050c4e20180cc96c4572ce.zip
swift-09e9713028b728fad9050c4e20180cc96c4572ce.tar.bz2
Don't suggest people who are already in the Start Chat list.
Change-Id: Ia458634d6bf5f678a34466ac4421c54c65385a3c
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/Chat/UserSearchController.cpp19
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp2
2 files changed, 19 insertions, 2 deletions
diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp
index 8503609..12c6777 100644
--- a/Swift/Controllers/Chat/UserSearchController.cpp
+++ b/Swift/Controllers/Chat/UserSearchController.cpp
@@ -194,7 +194,24 @@ void UserSearchController::handleNameSuggestionRequest(const JID &jid) {
}
void UserSearchController::handleContactSuggestionsRequested(std::string text) {
- window_->setContactSuggestions(contactSuggester_->getSuggestions(text));
+ const std::vector<JID> existingJIDs = window_->getJIDs();
+ std::vector<Contact::ref> suggestions = contactSuggester_->getSuggestions(text);
+ std::vector<Contact::ref>::iterator i = suggestions.begin();
+ while (i != suggestions.end()) {
+ bool found = false;
+ foreach (const JID& jid, existingJIDs) {
+ if ((*i)->jid == jid) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ i = suggestions.erase(i);
+ } else {
+ i++;
+ }
+ }
+ window_->setContactSuggestions(suggestions);
}
void UserSearchController::handleVCardChanged(const JID& jid, VCard::ref vcard) {
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp
index ed76a6f..325edef 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidget.cpp
@@ -31,7 +31,7 @@
namespace Swift {
-QtTreeWidget::QtTreeWidget(UIEventStream* eventStream, SettingsProvider* settings, MessageTarget messageTarget, QWidget* parent) : QTreeView(parent), messageTarget_(messageTarget), tooltipShown_(false) {
+QtTreeWidget::QtTreeWidget(UIEventStream* eventStream, SettingsProvider* settings, MessageTarget messageTarget, QWidget* parent) : QTreeView(parent), tooltipShown_(false), messageTarget_(messageTarget) {
eventStream_ = eventStream;
settings_ = settings;
model_ = new RosterModel(this, settings_->getSetting(QtUISettingConstants::USE_SCREENREADER));