diff options
author | Richard Maudsley <richard.maudsley@isode.com> | 2014-07-01 12:54:14 (GMT) |
---|---|---|
committer | Richard Maudsley <richard.maudsley@isode.com> | 2014-07-01 12:57:14 (GMT) |
commit | 9179b54ac93ddc88765c3cd984916d7ffd130d20 (patch) | |
tree | ddcbacdd0228d52ba3f0ad4d6e8e5f09e8d12c87 /Swift/QtUI/Roster/QtTreeWidget.cpp | |
parent | f90a0307a16a93376270a84be61451faa9bd9701 (diff) | |
download | swift-contrib-9179b54ac93ddc88765c3cd984916d7ffd130d20.zip swift-contrib-9179b54ac93ddc88765c3cd984916d7ffd130d20.tar.bz2 |
Reset roster filter when hitting enter to start chat.
Test-Information:
Enter search term and use keyboard arrows to move to select a contact and pressing enter will start a chat and clear the filter. Confirm that pressing escape still clears the filter without starting a chat and that the changes do not interfere with starting a chat normally by double clicking on a contact.
Change-Id: I90f5d431da56896eeb10f16c0ba23bdc143c4857
Diffstat (limited to 'Swift/QtUI/Roster/QtTreeWidget.cpp')
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidget.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp index fbe85de..5333260 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.cpp +++ b/Swift/QtUI/Roster/QtTreeWidget.cpp @@ -139,12 +139,5 @@ void QtTreeWidget::currentChanged(const QModelIndex& current, const QModelIndex& void QtTreeWidget::handleItemActivated(const QModelIndex& index) { - JID target; - if (messageTarget_ == MessageDisplayJID) { - target = JID(Q2PSTRING(index.data(DisplayJIDRole).toString())); - target = target.toBare(); - } - if (!target.isValid()) { - target = JID(Q2PSTRING(index.data(JIDRole).toString())); - } + JID target = jidFromIndex(index); if (target.isValid()) { eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(target))); @@ -240,3 +233,23 @@ void QtTreeWidget::setMessageTarget(MessageTarget messageTarget) { } +JID QtTreeWidget::jidFromIndex(const QModelIndex& index) const { + JID target; + if (messageTarget_ == MessageDisplayJID) { + target = JID(Q2PSTRING(index.data(DisplayJIDRole).toString())); + target = target.toBare(); + } + if (!target.isValid()) { + target = JID(Q2PSTRING(index.data(JIDRole).toString())); + } + return target; +} + +JID QtTreeWidget::selectedJID() const { + QModelIndexList list = selectedIndexes(); + if (list.size() != 1) { + return JID(); + } + return jidFromIndex(list[0]); +} + } |