Skip to content
Browse files

EPG - improve GoToEnd and GoToBegin functions in CGUIEPGGridContainer

  • Loading branch information...
1 parent 1c5ca99 commit 5f6fec883c33ca2187fb9b70f4c41023bec7a299 @mikrohard committed
Showing with 21 additions and 1 deletion.
  1. +21 −1 xbmc/epg/GUIEPGGridContainer.cpp
View
22 xbmc/epg/GUIEPGGridContainer.cpp
@@ -1627,11 +1627,31 @@ void CGUIEPGGridContainer::Reset()
void CGUIEPGGridContainer::GoToBegin()
{
ScrollToBlockOffset(0);
+ SetBlock(0);
}
void CGUIEPGGridContainer::GoToEnd()
{
- ScrollToBlockOffset(m_blocks - m_blocksPerPage);
+ int blocksEnd = 0; // the end block of the last epg element for the selected channel
+ int blocksStart = 0; // the start block of the last epg element for the selected channel
+ int blockOffset = 0; // the block offset to scroll to
+ for (int blockIndex = m_blocks; blockIndex>=0; blockIndex--)
+ {
+ if (!blocksEnd && m_gridIndex[m_channelCursor + m_channelOffset][blockIndex].item != NULL)
+ blocksEnd = blockIndex;
+ if (blocksEnd && m_gridIndex[m_channelCursor + m_channelOffset][blocksEnd].item !=
+ m_gridIndex[m_channelCursor + m_channelOffset][blockIndex].item)
+ blocksStart = blockIndex + 1;
+ if (blocksEnd && blocksStart)
+ break;
+ }
+ if (blocksEnd - blocksStart > m_blocksPerPage)
+ blockOffset = blocksStart;
+ else if (blocksEnd > m_blocksPerPage)
+ blockOffset = blocksEnd - m_blocksPerPage;
+
+ ScrollToBlockOffset(blockOffset); // scroll to the start point of the last epg element
+ SetBlock(m_blocksPerPage - 1); // select the last epg element
}
void CGUIEPGGridContainer::SetStartEnd(CDateTime start, CDateTime end)

0 comments on commit 5f6fec8

Please sign in to comment.
Something went wrong with that request. Please try again.