Skip to content
Permalink
Browse files

Make sure filter never hides the channel the user resides in.

- This only fixes the bug and doesn't perform the needed
  refactoring in the implementation of the channel filtering
  logic.
  • Loading branch information...
hacst committed Sep 19, 2013
1 parent 983b6db commit d35468c78d04ccbb5aed056964d00746be7f3646
Showing with 22 additions and 7 deletions.
  1. +22 −7 src/mumble/UserView.cpp
@@ -312,7 +312,7 @@ void UserView::selectSearchResult() {
qpmiSearch = QPersistentModelIndex();
}

bool ChannelHasUsers(const Channel *c)
bool channelHasUsers(const Channel *c)
{
if(c->qlUsers.isEmpty() == false)
return true;
@@ -321,13 +321,13 @@ bool ChannelHasUsers(const Channel *c)

for(i=0;i<c->qlChannels.count();i++)
{
if(ChannelHasUsers(c->qlChannels[i]))
if(channelHasUsers(c->qlChannels[i]))
return true;
}
return false;
}

static bool ChannelHidden(const Channel *c)
static bool channelFiltered(const Channel *c)
{
while(c) {
if(c->bFiltered)
@@ -355,12 +355,27 @@ void UserView::updateChannel(const QModelIndex &idx) {
if(g.s.bFilterActive == false) {
setRowHidden(idx.row(),idx.parent(),false);
} else {

if(ChannelHidden(c)) {
QByteArray ba = c->qsName.toLocal8Bit();
bool isChannelUserIsIn = false;

// Check whether user resides in this channel or a subchannel
if (g.uiSession != 0) {
const ClientUser* user = ClientUser::get(g.uiSession);
if (user != NULL) {
Channel *chan = user->cChannel;
while (chan) {
if (chan == c) {
isChannelUserIsIn = true;
break;
}
chan = chan->cParent;
}
}
}

if(channelFiltered(c) && !isChannelUserIsIn) {
setRowHidden(idx.row(),idx.parent(),true);
} else {
if(g.s.bFilterHidesEmptyChannels && !ChannelHasUsers(c)) {
if(g.s.bFilterHidesEmptyChannels && !channelHasUsers(c)) {
setRowHidden(idx.row(),idx.parent(),true);
} else {
setRowHidden(idx.row(),idx.parent(),false);

0 comments on commit d35468c

Please sign in to comment.
You can’t perform that action at this time.