From 3108a53a7fefa91600a06b83774594c59a744436 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 15 Sep 2019 20:53:12 +0200 Subject: [PATCH] hide empty groups in FriendList --- .../src/gui/common/NewFriendList.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 600dead7f..99d59766c 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -128,10 +128,25 @@ public: bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override { - if(!m_showOfflineNodes && !sourceModel()->index(source_row,0,source_parent).data(RsFriendListModel::OnlineRole).toBool()) + // do not show empty groups + + QModelIndex index = sourceModel()->index(source_row,0,source_parent); + + if(index.data(RsFriendListModel::TypeRole) == RsFriendListModel::ENTRY_TYPE_GROUP) + { + RsGroupInfo group_info ; + static_cast(sourceModel())->getGroupData(index,group_info); + + if(group_info.peerIds.empty()) + return false; + } + + // Filter offline friends + + if(!m_showOfflineNodes && !index.data(RsFriendListModel::OnlineRole).toBool()) return false; - return sourceModel()->index(source_row,0,source_parent).data(RsFriendListModel::FilterRole).toString() == RsFriendListModel::FilterString ; + return index.data(RsFriendListModel::FilterRole).toString() == RsFriendListModel::FilterString ; } void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override