summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-04-07 09:19:50 (GMT)
committerRichard Maudsley <richard.maudsley@isode.com>2014-04-07 13:07:43 (GMT)
commita7c7602e89d58056940885112f8764a31e9991da (patch)
treee713e2d7eed2c2ba2925ec0a70fe93eb707c077a /Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
parent1a35178bcad7c30e50a19e4017d021fb0485ccf0 (diff)
downloadswift-a7c7602e89d58056940885112f8764a31e9991da.zip
swift-a7c7602e89d58056940885112f8764a31e9991da.tar.bz2
Allow contacts to be dragged from the Chats tab into the search window
Change-Id: Ib1ecd2f95fb26269d8aa19094aac6e1f691cdf35
Diffstat (limited to 'Swift/QtUI/UserSearch/QtUserSearchWindow.cpp')
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchWindow.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index c0c7972..ec5dd39 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2013 Kevin Smith
+ * Copyright (c) 2010-2014 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -377,6 +377,26 @@ void QtUserSearchWindow::updateContacts(const std::vector<Contact>& contacts) {
}
}
+void QtUserSearchWindow::addContacts(const std::vector<Contact>& contacts) {
+ if (type_ != AddContact) {
+ /* prevent duplicate JIDs from appearing in the contact list */
+ foreach (const Contact& newContact, contacts) {
+ bool found = false;
+ foreach (const Contact& oldContact, contactVector_) {
+ if (newContact.jid == oldContact.jid) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ contactVector_.push_back(newContact);
+ }
+ }
+ firstMultiJIDPage_->contactList_->setList(contactVector_);
+ firstMultiJIDPage_->emitCompletenessCheck();
+ }
+}
+
void QtUserSearchWindow::handleAddViaSearch() {
searchNext_ = true;
next();
@@ -390,7 +410,7 @@ void QtUserSearchWindow::handleListChanged(std::vector<Contact> list) {
}
void QtUserSearchWindow::handleJIDsAdded(std::vector<JID> jids) {
- onJIDUpdateRequested(jids);
+ onJIDAddRequested(jids);
}
void QtUserSearchWindow::setResults(const std::vector<UserSearchResult>& results) {
@@ -449,6 +469,7 @@ void QtUserSearchWindow::setFirstPage(QString title) {
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>)));
+ connect(firstMultiJIDPage_, SIGNAL(onJIDsDropped(std::vector<JID>)), this, SLOT(handleJIDsAdded(std::vector<JID>)));
setPage(1, firstMultiJIDPage_);
}
}