gui/channellist.cpp: fix quick zap and virtual zap, when

empty bouquets present and zap cycle in current bouquet is disabled


Origin commit data
------------------
Branch: ni/coolstream
Commit: 853baa6f29
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2013-07-30 (Tue, 30 Jul 2013)



------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2013-07-30 10:26:01 +04:00
parent d485a5b86a
commit d75cb5824d
2 changed files with 37 additions and 26 deletions

View File

@@ -576,6 +576,30 @@ bool CChannelList::updateSelection(int newpos)
return actzap;
}
int CChannelList::getPrevNextBouquet(bool next)
{
bool found = true;
int dir = next ? 1 : -1;
int b_size = bouquetList->Bouquets.size(); /* bigger than 0 */
int nNext = (bouquetList->getActiveBouquetNumber() + b_size + dir) % b_size;
if(bouquetList->Bouquets[nNext]->channelList->isEmpty() ) {
found = false;
int n_old = nNext;
nNext = (nNext + b_size + dir) % b_size;
for (int i = nNext; i != n_old; i = (i + b_size + dir) % b_size) {
if( !bouquetList->Bouquets[i]->channelList->isEmpty() ) {
found = true;
nNext = i;
break;
}
}
}
if (found)
return nNext;
return -1;
}
#define CHANNEL_SMSKEY_TIMEOUT 800
/* return: >= 0 to zap, -1 on cancel, -3 on list mode change, -4 list edited, -2 zap but no restore old list/chan ?? */
int CChannelList::show()
@@ -766,23 +790,8 @@ int CChannelList::show()
if (dline)
dline->kill(); //kill details line on change to next page
if (!bouquetList->Bouquets.empty()) {
bool found = true;
int dir = msg == (neutrino_msg_t)g_settings.key_bouquet_up ? 1 : -1;
int b_size = bouquetList->Bouquets.size(); /* bigger than 0 */
int nNext = (bouquetList->getActiveBouquetNumber() + b_size + dir) % b_size;
if(bouquetList->Bouquets[nNext]->channelList->isEmpty() ) {
found = false;
int n_old = nNext;
nNext = (nNext + b_size + dir) % b_size;
for (int i = nNext; i != n_old; i = (i + b_size + dir) % b_size) {
if( !bouquetList->Bouquets[i]->channelList->isEmpty() ) {
found = true;
nNext = i;
break;
}
}
}
if(found) {
int nNext = getPrevNextBouquet(msg == (neutrino_msg_t)g_settings.key_bouquet_up);
if(nNext >= 0) {
bouquetList->activateBouquet(nNext, false);
res = bouquetList->showChannelList();
loop = false;
@@ -1458,21 +1467,22 @@ CZapitChannel* CChannelList::getPrevNextChannel(int key, unsigned int &sl)
printf("CChannelList::getPrevNextChannel: selected %d total %d active bouquet %d total %d\n", (int)cactive, (int)chanlist.size(), bactive, bsize);
if ((key == g_settings.key_quickzap_down) || (key == CRCInput::RC_left)) {
if(cactive == 0) {
if(bactive == 0)
bactive = bsize - 1;
else
bactive--;
bouquetList->activateBouquet(bactive, false);
cactive = bouquetList->Bouquets[bactive]->channelList->getSize() - 1;
bactive = getPrevNextBouquet(false);
if (bactive >= 0) {
bouquetList->activateBouquet(bactive, false);
cactive = bouquetList->Bouquets[bactive]->channelList->getSize() - 1;
}
} else
--cactive;
}
else if ((key == g_settings.key_quickzap_up) || (key == CRCInput::RC_right)) {
cactive++;
if(cactive >= chanlist.size()) {
bactive = (bactive + 1) % bsize;
bouquetList->activateBouquet(bactive, false);
cactive = 0;
bactive = getPrevNextBouquet(true);
if (bactive >= 0) {
bouquetList->activateBouquet(bactive, false);
cactive = 0;
}
}
}
sl = cactive;

View File

@@ -123,6 +123,7 @@ private:
int emptyLineCount;
void addTextToArray( const std::string & text, int screening );
void processTextToArray(std::string text, int screening = 0);
int getPrevNextBouquet(bool next);
public:
CChannelList(const char * const Name, bool historyMode = false, bool _vlist = false);