Skip to content

Commit

Permalink
Merge pull request #4646 from xhaggi/channel-selection
Browse files Browse the repository at this point in the history
[pvr] numeric input to select a channel within pvr views
  • Loading branch information
xhaggi committed May 7, 2014
2 parents 1a2cf73 + d26a659 commit 619880f
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 6 deletions.
6 changes: 5 additions & 1 deletion language/English/strings.po
Expand Up @@ -7726,7 +7726,11 @@ msgctxt "#19102"
msgid "Please switch to another channel."
msgstr ""

#empty string with id 19103
#. Title of numeric dialog for choosing a channel by entering a number
#: xbmc/pvr/windows/GUIWindowPVRCommon.cpp
msgctxt "#19103"
msgid "Go to channel"
msgstr ""

msgctxt "#19104"
msgid "Enter the name of the folder for the recording"
Expand Down
27 changes: 23 additions & 4 deletions xbmc/epg/GUIEPGGridContainer.cpp
Expand Up @@ -1069,8 +1069,7 @@ void CGUIEPGGridContainer::SetChannel(const CStdString &channel)
}
}

if (iChannelIndex >= 0)
ScrollToChannelOffset(iChannelIndex);
SetSelectedChannel(iChannelIndex);
}

void CGUIEPGGridContainer::SetChannel(const CPVRChannel &channel)
Expand All @@ -1086,8 +1085,7 @@ void CGUIEPGGridContainer::SetChannel(const CPVRChannel &channel)
}
}

if (iChannelIndex >= 0)
ScrollToChannelOffset(iChannelIndex);
SetSelectedChannel(iChannelIndex);
}

void CGUIEPGGridContainer::SetChannel(int channel)
Expand Down Expand Up @@ -1266,6 +1264,27 @@ bool CGUIEPGGridContainer::OnMouseWheel(char wheel, const CPoint &point)
return true;
}

void CGUIEPGGridContainer::SetSelectedChannel(int channelIndex)
{
if (channelIndex < 0)
return;

if (channelIndex - m_channelOffset < m_channelsPerPage && channelIndex - m_channelOffset >= 0)
{
SetChannel(channelIndex - m_channelOffset);
}
else if(channelIndex < m_channels - m_channelsPerPage)
{
ScrollToChannelOffset(channelIndex - m_channelsPerPage + 1);
SetChannel(m_channelsPerPage - 1);
}
else
{
ScrollToChannelOffset(m_channels - m_channelsPerPage);
SetChannel(channelIndex - (m_channels - m_channelsPerPage));
}
}

int CGUIEPGGridContainer::GetSelectedItem() const
{
if (m_gridIndex.empty() ||
Expand Down
1 change: 1 addition & 0 deletions xbmc/epg/GUIEPGGridContainer.h
Expand Up @@ -65,6 +65,7 @@ namespace EPG
const int GetNumChannels() { return m_channels; };
virtual int GetSelectedItem() const;
const int GetSelectedChannel() { return m_channelCursor + m_channelOffset; }
void SetSelectedChannel(int channelIndex);
virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);

virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
Expand Down
20 changes: 20 additions & 0 deletions xbmc/pvr/windows/GUIWindowPVRChannels.cpp
Expand Up @@ -264,6 +264,26 @@ void CGUIWindowPVRChannels::UpdateData(bool bUpdateSelectedFile /* = true */)
m_parent->SetLabel(CONTROL_LABELGROUP, currentGroup->GroupName());
}

bool CGUIWindowPVRChannels::OnAction(const CAction &action)
{
switch (action.GetID())
{
case REMOTE_0:
case REMOTE_1:
case REMOTE_2:
case REMOTE_3:
case REMOTE_4:
case REMOTE_5:
case REMOTE_6:
case REMOTE_7:
case REMOTE_8:
case REMOTE_9:
return ActionInputChannelNumber(action.GetID() - REMOTE_0);
}

return false;
}

bool CGUIWindowPVRChannels::OnClickButton(CGUIMessage &message)
{
bool bReturn = false;
Expand Down
1 change: 1 addition & 0 deletions xbmc/pvr/windows/GUIWindowPVRChannels.h
Expand Up @@ -45,6 +45,7 @@ namespace PVR
void Notify(const Observable &obs, const ObservableMessage msg);
void ResetObservers(void);
void UnregisterObservers(void);
bool OnAction(const CAction &action);

private:
bool OnClickButton(CGUIMessage &message);
Expand Down
32 changes: 31 additions & 1 deletion xbmc/pvr/windows/GUIWindowPVRCommon.cpp
Expand Up @@ -22,6 +22,7 @@

#include "Application.h"
#include "ApplicationMessenger.h"
#include "dialogs/GUIDialogNumeric.h"
#include "dialogs/GUIDialogKaiToast.h"
#include "dialogs/GUIDialogOK.h"
#include "dialogs/GUIDialogYesNo.h"
Expand Down Expand Up @@ -566,6 +567,36 @@ bool CGUIWindowPVRCommon::ActionDeleteChannel(CFileItem *item)
return true;
}

bool CGUIWindowPVRCommon::ActionInputChannelNumber(int input, bool bGuideGrid)
{
CStdString strInput = StringUtils::Format("%i", input);
if (CGUIDialogNumeric::ShowAndGetNumber(strInput, g_localizeStrings.Get(19103)))
{
int iChannelNumber = atoi(strInput.c_str());
if (iChannelNumber > 0)
{
int itemIndex = 0;
VECFILEITEMS items = m_parent->m_vecItems->GetList();
for(VECFILEITEMS::iterator it = items.begin(); it != items.end(); ++it)
{
if(((*it)->HasPVRChannelInfoTag() && (*it)->GetPVRChannelInfoTag()->ChannelNumber() == iChannelNumber) ||
((*it)->HasEPGInfoTag() && (*it)->GetEPGInfoTag()->HasPVRChannel() && (*it)->GetEPGInfoTag()->PVRChannelNumber() == iChannelNumber))
{
// different handling for guide grid
if (bGuideGrid && m_parent->m_guideGrid)
m_parent->m_guideGrid->SetChannel((*(*it)->GetEPGInfoTag()->ChannelTag()));
else
m_parent->m_viewControl.SetSelectedItem(itemIndex);
return true;
}
itemIndex++;
}
}
}

return false;
}

bool CGUIWindowPVRCommon::UpdateEpgForChannel(CFileItem *item)
{
CPVRChannel *channel = item->GetPVRChannelInfoTag();
Expand Down Expand Up @@ -602,7 +633,6 @@ bool CGUIWindowPVRCommon::ShowTimerSettings(CFileItem *item)
return pDlgInfo->GetOK();
}


bool CGUIWindowPVRCommon::PlayRecording(CFileItem *item, bool bPlayMinimized /* = false */)
{
if (!item->HasPVRRecordingInfoTag())
Expand Down
1 change: 1 addition & 0 deletions xbmc/pvr/windows/GUIWindowPVRCommon.h
Expand Up @@ -117,6 +117,7 @@ namespace PVR
virtual bool ActionPlayChannel(CFileItem *item);
virtual bool ActionPlayEpg(CFileItem *item);
virtual bool ActionDeleteChannel(CFileItem *item);
virtual bool ActionInputChannelNumber(int input, bool bGuideGrid = false);

virtual bool PlayRecording(CFileItem *item, bool bPlayMinimized = false);
virtual bool PlayFile(CFileItem *item, bool bPlayMinimized = false);
Expand Down
21 changes: 21 additions & 0 deletions xbmc/pvr/windows/GUIWindowPVRGuide.cpp
Expand Up @@ -120,6 +120,27 @@ void CGUIWindowPVRGuide::GetContextButtons(int itemNumber, CContextButtons &butt
buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */
}

bool CGUIWindowPVRGuide::OnAction(const CAction &action)
{
switch (action.GetID())
{
case REMOTE_0:
case REMOTE_1:
case REMOTE_2:
case REMOTE_3:
case REMOTE_4:
case REMOTE_5:
case REMOTE_6:
case REMOTE_7:
case REMOTE_8:
case REMOTE_9:
if (m_iGuideView != GUIDE_VIEW_CHANNEL)
return ActionInputChannelNumber(action.GetID() - REMOTE_0, (m_iGuideView == GUIDE_VIEW_TIMELINE));
break;
}

return false;
}

bool CGUIWindowPVRGuide::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
{
Expand Down
1 change: 1 addition & 0 deletions xbmc/pvr/windows/GUIWindowPVRGuide.h
Expand Up @@ -48,6 +48,7 @@ namespace PVR
CGUIWindowPVRGuide(CGUIWindowPVR *parent);
virtual ~CGUIWindowPVRGuide(void);

bool OnAction(const CAction &action);
void GetContextButtons(int itemNumber, CContextButtons &buttons) const;
bool OnContextButton(int itemNumber, CONTEXT_BUTTON button);
void UpdateData(bool bUpdateSelectedFile = true);
Expand Down

0 comments on commit 619880f

Please sign in to comment.