From 69a33a7458326105f5ac20eba256a66ccbf20f77 Mon Sep 17 00:00:00 2001 From: focus Date: Sat, 3 Jul 2010 13:32:04 +0000 Subject: [PATCH] Fix page up/down in page mode git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@648 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- src/gui/epgplus.cpp | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index 4b6f3a584..84c1ba608 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -870,14 +870,23 @@ int EpgPlus::exec (CChannelList * pchannelList, int selectedChannelIndex, CBouqu switch (this->currentSwapMode) { case SwapMode_ByPage: { - int selectedChannelEntryIndex = this->selectedChannelEntry->index; - selectedChannelEntryIndex += this->maxNumberOfDisplayableEntries; - if (selectedChannelEntryIndex > this->channelList->getSize () - 1) - selectedChannelEntryIndex = 0; + int selected = this->selectedChannelEntry->index; + int prev_selected = selected; + int step = this->maxNumberOfDisplayableEntries; + int listSize = this->channelList->getSize(); - this->createChannelEntries (selectedChannelEntryIndex); + selected += step; + if(selected >= listSize) { + if((listSize - step -1 < prev_selected) && (prev_selected != (listSize - 1))) + selected = listSize - 1; + else if (((listSize / step) + 1) * step == listSize + step) // last page has full entries + selected = 0; + else + selected = ((selected < (((listSize / step)+1) * step))) ? (listSize - 1) : 0; + } + this->createChannelEntries (selected); this->paint (); } break; @@ -911,14 +920,19 @@ int EpgPlus::exec (CChannelList * pchannelList, int selectedChannelIndex, CBouqu switch (this->currentSwapMode) { case SwapMode_ByPage: { - int selectedChannelEntryIndex = this->selectedChannelEntry->index; - selectedChannelEntryIndex -= this->maxNumberOfDisplayableEntries; + int selected = this->selectedChannelEntry->index; + int prev_selected = selected; + int step = this->maxNumberOfDisplayableEntries; - if (selectedChannelEntryIndex < 0) - selectedChannelEntryIndex = this->channelList->getSize () - 1; - - this->createChannelEntries (selectedChannelEntryIndex); + selected -= step; + if((prev_selected-step) < 0) { + if(prev_selected != 0 && step != 1) + selected = 0; + else + selected = this->channelList->getSize() - 1; + } + this->createChannelEntries (selected); this->paint (); } break;