Example #1
0
void CPVRChannelGroups::FillGroupsGUI(int iWindowId, int iControlId) const
{
  int iListGroupPtr(0);
  int iSelectedGroupPtr(0);
  CPVRChannelGroupPtr selectedGroup = g_PVRManager.GetPlayingGroup(false);
  std::vector<CGUIMessage> messages;

  // fetch all groups
  {
    CSingleLock lock(m_critSection);
    for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++)
    {
      // skip empty groups
      if ((*it)->Size() == 0)
        continue;

      if ((*it)->GroupID() == selectedGroup->GroupID())
        iSelectedGroupPtr = iListGroupPtr;

      CGUIMessage msg(GUI_MSG_LABEL_ADD, iWindowId, iControlId, iListGroupPtr++);
      msg.SetLabel((*it)->GroupName());
      messages.push_back(msg);
    }
  }

  // send updates
  for (std::vector<CGUIMessage>::iterator it = messages.begin(); it != messages.end(); it++)
    g_windowManager.SendMessage(*it);

  // selected group
  CGUIMessage msgSel(GUI_MSG_ITEM_SELECT, iWindowId, iControlId, iSelectedGroupPtr);
  g_windowManager.SendMessage(msgSel);
}
void CGUIDialogPVRChannelsOSD::Update()
{
  // lock our display, as this window is rendered from the player thread
  g_graphicsContext.Lock();

  if (!IsObserving(g_infoManager))
    g_infoManager.RegisterObserver(this);
  if (!IsObserving(g_EpgContainer))
    g_EpgContainer.RegisterObserver(this);

  m_viewControl.SetCurrentView(DEFAULT_VIEW_LIST);

  // empty the list ready for population
  Clear();

  CPVRChannelPtr channel(g_PVRManager.GetCurrentChannel());
  if (channel)
  {
    CPVRChannelGroupPtr group = g_PVRManager.GetPlayingGroup(channel->IsRadio());
    if (group)
    {
      group->GetMembers(*m_vecItems);
      m_viewControl.SetItems(*m_vecItems);

      if (!m_group)
      {
        m_group = group;
        m_viewControl.SetSelectedItem(CGUIWindowPVRBase::GetSelectedItemPath(channel->IsRadio()));
        SaveSelectedItemPath(group->GroupID());
      }
    }
  }

  g_graphicsContext.Unlock();
}
Example #3
0
void CGUIDialogPVRChannelsOSD::SaveControlStates()
{
  CGUIDialog::SaveControlStates();

  CPVRChannelGroupPtr group = GetPlayingGroup();
  SaveSelectedItem(group->GroupID());
}
Example #4
0
void CPVRChannelGroups::FillGroupsGUI(int iWindowId, int iControlId) const
{
  int iListGroupPtr(0);
  int iSelectedGroupPtr(0);
  CPVRChannelGroupPtr selectedGroup = g_PVRManager.GetPlayingGroup(false);
  std::vector< std::pair<std::string, int> > labels;

  // fetch all groups
  {
    CSingleLock lock(m_critSection);
    for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++)
    {
      // skip empty groups
      if ((*it)->Size() == 0)
        continue;

      if ((*it)->GroupID() == selectedGroup->GroupID())
        iSelectedGroupPtr = iListGroupPtr;

      labels.push_back(make_pair((*it)->GroupName(), iListGroupPtr++));
    }
  }

  // selected group
  CGUIMessage msgSel(GUI_MSG_SET_LABELS, iWindowId, iControlId, iSelectedGroupPtr);
  msgSel.SetPointer(&labels);
  g_windowManager.SendMessage(msgSel);
}
void CGUIDialogPVRChannelsOSD::Update()
{
  g_infoManager.RegisterObserver(this);
  CServiceBroker::GetPVRManager().EpgContainer().RegisterObserver(this);

  m_viewControl.SetCurrentView(DEFAULT_VIEW_LIST);

  // empty the list ready for population
  Clear();

  CPVRChannelPtr channel(CServiceBroker::GetPVRManager().GetPlayingChannel());
  if (channel)
  {
    CPVRChannelGroupPtr group = CServiceBroker::GetPVRManager().GetPlayingGroup(channel->IsRadio());
    if (group)
    {
      group->GetMembers(*m_vecItems);
      m_viewControl.SetItems(*m_vecItems);

      if (!m_group)
      {
        m_group = group;
        m_viewControl.SetSelectedItem(CServiceBroker::GetPVRManager().GUIActions()->GetSelectedItemPath(channel->IsRadio()));
        SaveSelectedItemPath(group->GroupID());
      }
    }
  }
}
Example #6
0
void CGUIDialogPVRChannelsOSD::RestoreControlStates()
{
  CGUIDialog::RestoreControlStates();

  CPVRChannelGroupPtr group = GetPlayingGroup();
  if(group)
  {
    m_viewControl.SetSelectedItem(GetLastSelectedItem(group->GroupID()));
  }
}
void CGUIDialogPVRChannelsOSD::RestoreControlStates()
{
  CGUIDialog::RestoreControlStates();

  CPVRChannelGroupPtr group = GetPlayingGroup();
  if (group)
  {
    std::string path = GetLastSelectedItemPath(group->GroupID());
    if (!path.empty())
      m_viewControl.SetSelectedItem(path);
    else
      m_viewControl.SetSelectedItem(0);
  }
}
Example #8
0
bool CGUIDialogPVRChannelsOSD::OnAction(const CAction &action)
{
  switch (action.GetID())
  {
  case ACTION_PREVIOUS_CHANNELGROUP:
  case ACTION_NEXT_CHANNELGROUP:
    {
      CPVRChannelGroupPtr group = GetPlayingGroup();
      CPVRChannelGroupPtr nextGroup = action.GetID() == ACTION_NEXT_CHANNELGROUP ? group->GetNextGroup() : group->GetPreviousGroup();
      g_PVRManager.SetPlayingGroup(nextGroup);
      SetLastSelectedItem(group->GroupID());
      Update();
      return true;
    }
  }

  return CGUIDialog::OnAction(action);
}
Example #9
0
void CPVROperations::FillChannelGroupDetails(const CPVRChannelGroupPtr &channelGroup, const CVariant &parameterObject, CVariant &result, bool append /* = false */)
{
  if (channelGroup == NULL)
    return;

  CVariant object(CVariant::VariantTypeObject);
  object["channelgroupid"] = channelGroup->GroupID();
  object["channeltype"] = channelGroup->IsRadio() ? "radio" : "tv";
  object["label"] = channelGroup->GroupName();

  if (append)
    result.append(object);
  else
  {
    CFileItemList channels;
    channelGroup->GetMembers(channels);
    object["channels"] = CVariant(CVariant::VariantTypeArray);
    HandleFileItemList("channelid", false, "channels", channels, parameterObject["channels"], object, false);

    result = object;
  }
}
void CGUIWindowPVRChannels::UpdateData(bool bUpdateSelectedFile /* = true */)
{
  CSingleLock lock(m_critSection);
  CLog::Log(LOGDEBUG, "CGUIWindowPVRChannels - %s - update window '%s'. set view to %d",
      __FUNCTION__, GetName(), m_iControlList);
  m_bUpdateRequired = false;

  /* lock the graphics context while updating */
  CSingleLock graphicsLock(g_graphicsContext);

  CPVRChannelGroupPtr selectedGroup = SelectedGroup();

  if (!bUpdateSelectedFile)
    m_iSelected = m_parent->m_viewControl.GetSelectedItem();
  else
    m_parent->m_viewControl.SetSelectedItem(0);

  m_parent->m_viewControl.SetCurrentView(m_iControlList);
  ShowBusyItem();
  m_parent->m_vecItems->Clear();

  CPVRChannelGroupPtr currentGroup = g_PVRManager.GetPlayingGroup(m_bRadio);
  if (!currentGroup)
    return;

  SetSelectedGroup(currentGroup);

  CStdString strPath;
  strPath.Format("pvr://channels/%s/%s/",
      m_bRadio ? "radio" : "tv",
      m_bShowHiddenChannels ? ".hidden" : currentGroup->GroupName());

  m_parent->m_vecItems->SetPath(strPath);
  m_parent->Update(m_parent->m_vecItems->GetPath());
  m_parent->m_viewControl.SetItems(*m_parent->m_vecItems);

  if (bUpdateSelectedFile)
  {
    if (!SelectPlayingFile())
      m_parent->m_viewControl.SetSelectedItem(m_iSelected);
  }

  /* empty list */
  if (m_parent->m_vecItems->Size() == 0)
  {
    if (m_bShowHiddenChannels)
    {
      /* show the visible channels instead */
      m_bShowHiddenChannels = false;
      graphicsLock.Leave();
      lock.Leave();

      UpdateData(bUpdateSelectedFile);
      return;
    }
    else if (currentGroup->GroupID() > 0)
    {
      if (*currentGroup != *SelectNextGroup())
        return;
    }
  }

  m_parent->SetLabel(CONTROL_LABELHEADER, g_localizeStrings.Get(m_bRadio ? 19024 : 19023));
  if (m_bShowHiddenChannels)
    m_parent->SetLabel(CONTROL_LABELGROUP, g_localizeStrings.Get(19022));
  else
    m_parent->SetLabel(CONTROL_LABELGROUP, currentGroup->GroupName());

  if (!m_bThreadCreated)
  {
    m_bThreadCreated = true;
    Create();
    SetPriority(-1);
  }
}
bool CGUIDialogPVRChannelsOSD::OnMessage(CGUIMessage& message)
{
  switch (message.GetMessage())
  {
  case GUI_MSG_WINDOW_DEINIT:
    {
      if (m_group)
      {
        g_PVRManager.SetPlayingGroup(m_group);
        SetLastSelectedItem(m_group->GroupID());
      }
      Clear();
    }
    break;

  case GUI_MSG_WINDOW_INIT:
    {
      /* Close dialog immediately if now TV or radio channel is playing */
      if (!g_PVRManager.IsPlaying())
      {
        Close();
        return true;
      }

      m_group = GetPlayingGroup();

      CGUIWindow::OnMessage(message);
      Update(true);

      return true;
    }
    break;

  case GUI_MSG_CLICKED:
    {
      int iControl = message.GetSenderId();

      if (m_viewControl.HasControl(iControl))   // list/thumb control
      {
        int iItem = m_viewControl.GetSelectedItem();
        int iAction = message.GetParam1();

        if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK)
        {
          /* Switch to channel */
          GotoChannel(iItem);
          return true;
        }
        else if (iAction == ACTION_SHOW_INFO || iAction == ACTION_MOUSE_RIGHT_CLICK)
        {
          /* Show information Dialog */
          ShowInfo(iItem);
          return true;
        }
      }
    }
    break;

  case GUI_MSG_MOVE:
    {
      int iAction = message.GetParam1();

      if (iAction == ACTION_MOVE_RIGHT || iAction == ACTION_MOVE_LEFT)
      {
        CPVRChannelGroupPtr group = GetPlayingGroup();
        CPVRChannelGroupPtr nextGroup = iAction == ACTION_MOVE_RIGHT ? group->GetNextGroup() : group->GetPreviousGroup();
        g_PVRManager.SetPlayingGroup(nextGroup);
        SetLastSelectedItem(group->GroupID());

        Update();

        return true;
      }
    }
    break;
  }

  return CGUIDialog::OnMessage(message);
}
void CGUIDialogPVRChannelsOSD::Update(bool selectPlayingChannel)
{
  // lock our display, as this window is rendered from the player thread
  g_graphicsContext.Lock();

  if (!IsObserving(g_infoManager))
    g_infoManager.RegisterObserver(this);

  m_viewControl.SetCurrentView(DEFAULT_VIEW_LIST);

  // empty the list ready for population
  Clear();

  CPVRChannelPtr channel;
  g_PVRManager.GetCurrentChannel(channel);
  CPVRChannelGroupPtr group = g_PVRManager.GetPlayingGroup(channel->IsRadio());

  if (group)
  {
    group->GetMembers(*m_vecItems);
    m_viewControl.SetItems(*m_vecItems);
    m_viewControl.SetSelectedItem(selectPlayingChannel ? group->GetIndex(*channel) : GetLastSelectedItem(group->GroupID()));
  }

  g_graphicsContext.Unlock();
}