示例#1
0
bool CPVRChannelGroupInternal::AddToGroup(CPVRChannel *channel, int iChannelNumber /* = 0 */)
{
  CSingleLock lock(m_critSection);

  /* get the actual channel since this is called from a fileitemlist copy */
  CPVRChannel *realChannel = (CPVRChannel *) GetByChannelID(channel->ChannelID());
  if (!realChannel)
    return false;

  /* switch the hidden flag */
  if (realChannel->IsHidden())
  {
    realChannel->SetHidden(false, true);
    m_iHiddenChannels--;
  }

  /* renumber this list */
  Renumber();

  /* move this channel and persist */
  if (iChannelNumber > 0)
    return MoveChannel(realChannel->ChannelNumber(), iChannelNumber, true);
  else
    return MoveChannel(realChannel->ChannelNumber(), size() - m_iHiddenChannels, true);
}
bool CPVRChannelGroupInternal::RemoveFromGroup(CPVRChannel *channel)
{
  bool bReturn = false;

  if (!channel)
    return bReturn;

  /* check if there are active timers on this channel if we are hiding it */
  if (!channel->IsHidden() && CPVRManager::GetTimers()->ChannelHasTimers(*channel))
  {
    /* delete the timers */
    CPVRManager::GetTimers()->DeleteTimersOnChannel(*channel);
  }

  /* check if this channel is currently playing if we are hiding it */
  if (!channel->IsHidden() &&
      (CPVRManager::Get()->IsPlayingTV() || CPVRManager::Get()->IsPlayingRadio()) &&
      (CPVRManager::Get()->GetCurrentPlayingItem()->GetPVRChannelInfoTag() == channel))
  {
    CGUIDialogOK::ShowAndGetInput(19098,19101,0,19102);
    return bReturn;
  }

  /* switch the hidden flag */
  channel->SetHidden(!channel->IsHidden());

  /* update the hidden channel counter */
  if (channel->IsHidden())
    ++m_iHiddenChannels;
  else
    --m_iHiddenChannels;

  /* update the database entry */
  channel->Persist();

  /* move the channel to the end of the list */
  MoveChannel(channel->ChannelNumber(), size());

  bReturn = true;

  return bReturn;
}