diff options
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidget.cpp | 23 | ||||
-rw-r--r-- | Swift/QtUI/Roster/RosterModel.cpp | 6 |
2 files changed, 13 insertions, 16 deletions
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp index 325edef..fbe85de 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.cpp +++ b/Swift/QtUI/Roster/QtTreeWidget.cpp @@ -138,23 +138,16 @@ void QtTreeWidget::currentChanged(const QModelIndex& current, const QModelIndex& } void QtTreeWidget::handleItemActivated(const QModelIndex& index) { - switch (messageTarget_) { - case MessageDisplayJID: { - QString indexJID = index.data(DisplayJIDRole).toString(); - if (!indexJID.isEmpty()) { - JID target = JID(Q2PSTRING(indexJID)).toBare(); - eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(target))); - break; - } + JID target; + if (messageTarget_ == MessageDisplayJID) { + target = JID(Q2PSTRING(index.data(DisplayJIDRole).toString())); + target = target.toBare(); } - case MessageDefaultJID: { - QString indexJID = index.data(JIDRole).toString(); - if (!indexJID.isEmpty()) { - JID target = JID(Q2PSTRING(indexJID)); - eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(target))); - } - break; + if (!target.isValid()) { + target = JID(Q2PSTRING(index.data(JIDRole).toString())); } + if (target.isValid()) { + eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(target))); } } diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp index d8108ba..730ffbb 100644 --- a/Swift/QtUI/Roster/RosterModel.cpp +++ b/Swift/QtUI/Roster/RosterModel.cpp @@ -190,7 +190,11 @@ QString RosterModel::getJID(RosterItem* item) const { QString RosterModel::getDisplayJID(RosterItem* item) const { ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item); - return contact ? P2QSTRING(contact->getDisplayJID().toString()) : QString(); + QString result = contact ? P2QSTRING(contact->getDisplayJID().toString()) : QString(); + if (result.isEmpty()) { + result = getJID(item); + } + return result; } QIcon RosterModel::getPresenceIcon(RosterItem* item) const { |