Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PVR] Fixes for hidden channels #14329

Merged
merged 2 commits into from Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions xbmc/pvr/channels/PVRChannelGroup.cpp
Expand Up @@ -489,20 +489,28 @@ PVR_CHANNEL_GROUP_SORTED_MEMBERS CPVRChannelGroup::GetMembers(void) const
return m_sortedMembers;
}

int CPVRChannelGroup::GetMembers(CFileItemList &results, bool bGroupMembers /* = true */) const
int CPVRChannelGroup::GetMembers(CFileItemList &results, Include eFilter /* = Include::ONLY_VISIBLE */) const
{
const CPVRChannelGroup* channels = bGroupMembers ? this : CServiceBroker::GetPVRManager().ChannelGroups()->GetGroupAll(m_bRadio).get();
int iOrigSize = results.Size();
CSingleLock lock(m_critSection);

CSingleLock lock(channels->m_critSection);

for (PVR_CHANNEL_GROUP_SORTED_MEMBERS::const_iterator it = channels->m_sortedMembers.begin(); it != channels->m_sortedMembers.end(); ++it)
for (const auto& member : m_sortedMembers)
{
if (bGroupMembers || !IsGroupMember((*it).channel))
switch (eFilter)
{
CFileItemPtr pFileItem(new CFileItem((*it).channel));
results.Add(pFileItem);
case Include::ONLY_HIDDEN:
if (!member.channel->IsHidden())
continue;
break;
case Include::ONLY_VISIBLE:
if (member.channel->IsHidden())
continue;
break;
default:
break;
}

results.Add(std::make_shared<CFileItem>(member.channel));
}

return results.Size() - iOrigSize;
Expand Down
13 changes: 10 additions & 3 deletions xbmc/pvr/channels/PVRChannelGroup.h
Expand Up @@ -314,13 +314,20 @@ namespace PVR
*/
PVR_CHANNEL_GROUP_SORTED_MEMBERS GetMembers(void) const;

enum class Include
{
ALL,
ONLY_HIDDEN,
ONLY_VISIBLE
};

/*!
* @brief Get the list of channels in a group.
* @brief Get a filtered list of channels in this group.
* @param results The file list to store the results in.
* @param bGroupMembers If true, get the channels that are in this group. Get the channels that are not in this group otherwise.
* @param eFilter A filter to apply to the list.
* @return The amount of channels that were added to the list.
*/
virtual int GetMembers(CFileItemList &results, bool bGroupMembers = true) const;
int GetMembers(CFileItemList &results, Include eFilter = Include::ONLY_VISIBLE) const;

/*!
* @brief Get the list of channel numbers in a group.
Expand Down
12 changes: 0 additions & 12 deletions xbmc/pvr/channels/PVRChannelGroupInternal.cpp
Expand Up @@ -202,18 +202,6 @@ bool CPVRChannelGroupInternal::RemoveFromGroup(const CPVRChannelPtr &channel)
Persist();
}

int CPVRChannelGroupInternal::GetMembers(CFileItemList &results, bool bGroupMembers /* = true */) const
{
int iOrigSize = results.Size();
CSingleLock lock(m_critSection);

for (PVR_CHANNEL_GROUP_SORTED_MEMBERS::const_iterator it = m_sortedMembers.begin(); it != m_sortedMembers.end(); ++it)
if (bGroupMembers != (*it).channel->IsHidden())
results.Add(CFileItemPtr(new CFileItem((*it).channel)));

return results.Size() - iOrigSize;
}

int CPVRChannelGroupInternal::LoadFromDb(bool bCompress /* = false */)
{
const CPVRDatabasePtr database(CServiceBroker::GetPVRManager().GetTVDatabase());
Expand Down
5 changes: 0 additions & 5 deletions xbmc/pvr/channels/PVRChannelGroupInternal.h
Expand Up @@ -57,11 +57,6 @@ namespace PVR
*/
bool RemoveFromGroup(const CPVRChannelPtr &channel) override;

/*!
* @see CPVRChannelGroup::GetMembers
*/
int GetMembers(CFileItemList &results, bool bGroupMembers = true) const override;

/*!
* @brief Check whether the group name is still correct after the language setting changed.
*/
Expand Down
10 changes: 6 additions & 4 deletions xbmc/pvr/channels/PVRChannelGroupsContainer.cpp
Expand Up @@ -172,14 +172,15 @@ bool CPVRChannelGroupsContainer::GetDirectory(const std::string& strPath, CFileI
URIUtils::RemoveSlashAtEnd(strGroupName);

CPVRChannelGroupPtr group;
if (strGroupName == "*") // all channels
bool bShowHiddenChannels = StringUtils::EndsWithNoCase(fileName, ".hidden");
if (strGroupName == "*" || bShowHiddenChannels) // all channels
group = GetGroupAllTV();
else
group = GetTV()->GetByName(strGroupName);

if (group)
{
group->GetMembers(results, !StringUtils::EndsWithNoCase(fileName, ".hidden"));
group->GetMembers(results, bShowHiddenChannels ? CPVRChannelGroup::Include::ONLY_HIDDEN : CPVRChannelGroup::Include::ONLY_VISIBLE);
}
else
{
Expand All @@ -196,14 +197,15 @@ bool CPVRChannelGroupsContainer::GetDirectory(const std::string& strPath, CFileI
URIUtils::RemoveSlashAtEnd(strGroupName);

CPVRChannelGroupPtr group;
if (strGroupName == "*") // all channels
bool bShowHiddenChannels = StringUtils::EndsWithNoCase(fileName, ".hidden");
if (strGroupName == "*" || bShowHiddenChannels) // all channels
group = GetGroupAllRadio();
else
group = GetRadio()->GetByName(strGroupName);

if (group)
{
group->GetMembers(results, !StringUtils::EndsWithNoCase(fileName, ".hidden"));
group->GetMembers(results, bShowHiddenChannels ? CPVRChannelGroup::Include::ONLY_HIDDEN : CPVRChannelGroup::Include::ONLY_VISIBLE);
}
else
{
Expand Down
28 changes: 22 additions & 6 deletions xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp
Expand Up @@ -400,15 +400,31 @@ void CGUIDialogPVRGroupManager::Update()
SET_CONTROL_LABEL(CONTROL_IN_GROUP_LABEL, strNewLabel);
}

/* get all channels that are not in this group for the center part */
m_selectedGroup->GetMembers(*m_ungroupedChannels, false);
m_viewUngroupedChannels.SetItems(*m_ungroupedChannels);
m_viewUngroupedChannels.SetSelectedItem(m_iSelectedUngroupedChannel);
// Slightly different handling for "all" group...
if (m_selectedGroup->IsInternalGroup())
{
m_selectedGroup->GetMembers(*m_groupMembers, CPVRChannelGroup::Include::ONLY_VISIBLE);
m_selectedGroup->GetMembers(*m_ungroupedChannels, CPVRChannelGroup::Include::ONLY_HIDDEN);
}
else
{
m_selectedGroup->GetMembers(*m_groupMembers, CPVRChannelGroup::Include::ALL);

/* get all channels in this group for the right side part */
m_selectedGroup->GetMembers(*m_groupMembers, true);
/* for the center part, get all channels of the "all" channels group that are not in this group */
const CPVRChannelGroupPtr allGroup = CServiceBroker::GetPVRManager().ChannelGroups()->GetGroupAll(m_bIsRadio);
CFileItemList allChannels;
allGroup->GetMembers(allChannels, CPVRChannelGroup::Include::ALL);
for (const auto& channelItem : allChannels)
{
if (!m_selectedGroup->IsGroupMember(channelItem->GetPVRChannelInfoTag()))
m_ungroupedChannels->Add(channelItem);
}
}
m_viewGroupMembers.SetItems(*m_groupMembers);
m_viewGroupMembers.SetSelectedItem(m_iSelectedGroupMember);

m_viewUngroupedChannels.SetItems(*m_ungroupedChannels);
m_viewUngroupedChannels.SetSelectedItem(m_iSelectedUngroupedChannel);
}
}

Expand Down