From 67cc8dff4e80344c2d10e2691c562c2440fd8c1c Mon Sep 17 00:00:00 2001 From: Richard Maudsley Date: Thu, 17 Apr 2014 09:20:32 +0100 Subject: Fix QtTreeWidget compiler warnings. Change-Id: Ib15a950faca1d0fcc9c20809e63b531160995247 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(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(new RequestChatUIEvent(target))); - } - break; + if (!target.isValid()) { + target = JID(Q2PSTRING(index.data(JIDRole).toString())); } + if (target.isValid()) { + eventStream_->send(boost::shared_ptr(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(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 { -- cgit v0.10.2-6-g49f6