- bouquetlist: formatting code using astyle; some manual code nicenings

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2021-12-14 11:11:25 +01:00
committed by Thilo Graf
parent 265d7e462c
commit 62253613e1
2 changed files with 290 additions and 206 deletions

View File

@@ -33,7 +33,6 @@
#include <gui/color.h>
#include <gui/eventlist.h>
#include <gui/infoviewer.h>
#include <gui/components/cc.h>
#include <gui/widget/menue.h>
#include <gui/widget/menue_options.h>
@@ -104,10 +103,12 @@ CBouquet* CBouquetList::addBouquet(const char * const pname, int BouquetKey, boo
void CBouquetList::deleteBouquet(CBouquet *bouquet)
{
if (bouquet != NULL) {
if (bouquet != NULL)
{
std::vector<CBouquet *>::iterator it = find(Bouquets.begin(), Bouquets.end(), bouquet);
if (it != Bouquets.end()) {
if (it != Bouquets.end())
{
Bouquets.erase(it);
delete bouquet;
}
@@ -122,9 +123,11 @@ t_bouquet_id CBouquetList::getActiveBouquetNumber()
#if 0
void CBouquetList::adjustToChannel(int nChannelNr)
{
for (uint32_t i=0; i<Bouquets.size(); i++) {
for (uint32_t i = 0; i < Bouquets.size(); i++)
{
int nChannelPos = Bouquets[i]->channelList->hasChannel(nChannelNr);
if (nChannelPos > -1) {
if (nChannelPos > -1)
{
selected = i;
Bouquets[i]->channelList->setSelected(nChannelPos);
return;
@@ -132,9 +135,11 @@ void CBouquetList::adjustToChannel( int nChannelNr)
}
}
#endif
bool CBouquetList::hasChannelID(t_channel_id channel_id)
{
for (uint32_t i = 0; i < Bouquets.size(); i++) {
for (uint32_t i = 0; i < Bouquets.size(); i++)
{
int nChannelPos = Bouquets[i]->channelList->hasChannelID(channel_id);
if (nChannelPos > -1)
return true;
@@ -145,20 +150,24 @@ bool CBouquetList::hasChannelID(t_channel_id channel_id)
bool CBouquetList::adjustToChannelID(t_channel_id channel_id)
{
//printf("CBouquetList::adjustToChannelID [%s] to %llx, selected %d size %d\n", name.c_str(), channel_id, selected, Bouquets.size());
if(selected < Bouquets.size()) {
if (selected < Bouquets.size())
{
int nChannelPos = Bouquets[selected]->channelList->hasChannelID(channel_id);
if(nChannelPos > -1) {
if (nChannelPos > -1)
{
//printf("CBouquetList::adjustToChannelID [%s] to %llx -> not needed\n", name.c_str(), channel_id);
Bouquets[selected]->channelList->setSelected(nChannelPos);
return true;
}
}
//printf("CBouquetList::adjustToChannelID [%s] to %llx\n", name.c_str(), channel_id);
for (uint32_t i=0; i < Bouquets.size(); i++) {
for (uint32_t i = 0; i < Bouquets.size(); i++)
{
if (i == selected)
continue;
int nChannelPos = Bouquets[i]->channelList->hasChannelID(channel_id);
if (nChannelPos > -1) {
if (nChannelPos > -1)
{
selected = i;
Bouquets[i]->channelList->setSelected(nChannelPos);
return true;
@@ -166,20 +175,23 @@ bool CBouquetList::adjustToChannelID(t_channel_id channel_id)
}
return false;
}
/* used in channellist to switch bouquets up/down */
// used in channellist to switch bouquets up/down
int CBouquetList::showChannelList(int nBouquet)
{
if ((nBouquet < 0) || (nBouquet >= (int) Bouquets.size()))
nBouquet = selected;
int nNewChannel = Bouquets[nBouquet]->channelList->exec();
if (nNewChannel > -1) {
if (nNewChannel > -1)
{
selected = nBouquet;
nNewChannel = -2;
}
return nNewChannel;
}
/* bShowChannelList default to false , return seems not checked anywhere */
// bShowChannelList default to false , return seems not checked anywhere
int CBouquetList::activateBouquet(int id, bool bShowChannelList)
{
int res = -1;
@@ -187,7 +199,8 @@ int CBouquetList::activateBouquet( int id, bool bShowChannelList)
if ((id >= 0) && (id < (int) Bouquets.size()))
selected = id;
if (bShowChannelList) {
if (bShowChannelList)
{
res = Bouquets[selected]->channelList->exec();
if (res > -1)
res = -2;
@@ -197,16 +210,15 @@ int CBouquetList::activateBouquet( int id, bool bShowChannelList)
int CBouquetList::exec(bool bShowChannelList)
{
/* select bouquet to show */
int res = show(bShowChannelList);
//printf("Bouquet-exec: res %d bShowChannelList %d\n", res, bShowChannelList); fflush(stdout);
if (!bShowChannelList)
return res;
/* if >= 0, call activateBouquet to show channel list */
if ( res > -1) {
if (res > -1)
return activateBouquet(selected, bShowChannelList);
}
return res;
}
@@ -224,7 +236,8 @@ int CBouquetList::doMenu()
return 0;
zapitBouquet = Bouquets[selected]->zapitBouquet;
/* zapitBouquet not NULL only on real bouquets, satellitePosition is set for providers or SAT */
// zapitBouquet not NULL only on real bouquets, satellitePosition is set for providers or SAT
if (!zapitBouquet && Bouquets[selected]->satellitePosition == INVALID_SAT_POSITION)
return 0;
@@ -236,9 +249,11 @@ int CBouquetList::doMenu()
int old_epg = zapitBouquet ? zapitBouquet->bScanEpg : 0;
int old_ci = zapitBouquet ? zapitBouquet->bUseCI : 0;
sprintf(cnt, "%d", i);
/* FIXME menu centered different than bouquet list ??? */
/* provider bouquet */
if (zapitBouquet && !zapitBouquet->bUser) {
// FIXME menu centered different than bouquet list ???
// provider bouquet
if (zapitBouquet && !zapitBouquet->bUser)
{
menu->addItem(new CMenuForwarder(LOCALE_FAVORITES_COPY, true, NULL, selector, cnt, CRCInput::RC_blue), old_selected == i ++);
if ((!zapitBouquet->bWebtv && !zapitBouquet->bWebradio) && g_settings.epg_scan == CEpgScan::SCAN_SEL)
menu->addItem(new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SCAN, &zapitBouquet->bScanEpg, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true));
@@ -248,12 +263,14 @@ int CBouquetList::doMenu()
delete menu;
delete selector;
printf("CBouquetList::doMenu: %d selected\n", select);
if (old_epg != zapitBouquet->bScanEpg) {
if (old_epg != zapitBouquet->bScanEpg)
{
save_bouquets = true;
CNeutrinoApp::getInstance()->MarkBouquetsChanged();
ret = -1;
}
if (old_ci != zapitBouquet->bUseCI) {
if (old_ci != zapitBouquet->bUseCI)
{
channels = &zapitBouquet->tvChannels;
for (int li = 0; li < (int) channels->size(); li++)
(*channels)[li]->bUseCI = zapitBouquet->bUseCI;
@@ -268,37 +285,47 @@ int CBouquetList::doMenu()
ret = -1;
}
if(select >= 0) {
if (select >= 0)
{
bool added = false;
old_selected = select;
switch(select) {
case 0: // copy to favorites
switch (select)
{
// copy to favorites
case 0:
hide();
bouquet_id = g_bouquetManager->existsUBouquet(Bouquets[selected]->channelList->getName());
if(bouquet_id < 0) {
if (bouquet_id < 0)
{
tmp = g_bouquetManager->addBouquet(Bouquets[selected]->channelList->getName(), true);
bouquet_id = g_bouquetManager->existsUBouquet(Bouquets[selected]->channelList->getName());
} else
}
else
tmp = g_bouquetManager->Bouquets[bouquet_id];
if (bouquet_id < 0)
return 0;
channels = &zapitBouquet->tvChannels;
for(int li = 0; li < (int) channels->size(); li++) {
if (!g_bouquetManager->existsChannelInBouquet(bouquet_id, ((*channels)[li])->getChannelID())) {
for (int li = 0; li < (int) channels->size(); li++)
{
if (!g_bouquetManager->existsChannelInBouquet(bouquet_id, ((*channels)[li])->getChannelID()))
{
added = true;
tmp->addService((*channels)[li]);
}
}
channels = &zapitBouquet->radioChannels;
for(int li = 0; li < (int) channels->size(); li++) {
if (!g_bouquetManager->existsChannelInBouquet(bouquet_id, ((*channels)[li])->getChannelID())) {
for (int li = 0; li < (int) channels->size(); li++)
{
if (!g_bouquetManager->existsChannelInBouquet(bouquet_id, ((*channels)[li])->getChannelID()))
{
added = true;
tmp->addService((*channels)[li]);
}
}
if (added) {
if (added)
{
CNeutrinoApp::getInstance()->MarkFavoritesChanged();
CNeutrinoApp::getInstance()->MarkChannelsInit();
return 1;
@@ -308,8 +335,10 @@ int CBouquetList::doMenu()
break;
}
}
} else {
/* user or satellite bouquet */
}
else
{
// user or satellite bouquet
menu->addItem(new CMenuForwarder(LOCALE_BOUQUETEDITOR_DELETE, true, NULL, selector, cnt, CRCInput::RC_red), old_selected == i ++);
if (zapitBouquet && (!zapitBouquet->bWebtv && !zapitBouquet->bWebradio) && (g_settings.epg_scan == CEpgScan::SCAN_SEL))
menu->addItem(new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SCAN, &zapitBouquet->bScanEpg, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true));
@@ -319,12 +348,14 @@ int CBouquetList::doMenu()
menu->exec(NULL, "");
delete menu;
delete selector;
if (zapitBouquet && (old_epg != zapitBouquet->bScanEpg)) {
if (zapitBouquet && (old_epg != zapitBouquet->bScanEpg))
{
save_bouquets = true;
CNeutrinoApp::getInstance()->MarkFavoritesChanged();
ret = -1;
}
if (zapitBouquet && (old_ci != zapitBouquet->bUseCI)) {
if (zapitBouquet && (old_ci != zapitBouquet->bUseCI))
{
channels = &zapitBouquet->tvChannels;
for (int li = 0; li < (int) channels->size(); li++)
(*channels)[li]->bUseCI = zapitBouquet->bUseCI;
@@ -340,22 +371,27 @@ int CBouquetList::doMenu()
}
printf("CBouquetList::doMenu: %d selected\n", select);
if(select >= 0) {
if (select >= 0)
{
old_selected = select;
int result = ShowMsg(LOCALE_BOUQUETEDITOR_DELETE, Bouquets[selected]->channelList->getName(), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo);
if (result != CMsgBox::mbrYes)
return 0;
if (zapitBouquet) {
if (zapitBouquet)
{
bouquet_id = g_bouquetManager->existsUBouquet(Bouquets[selected]->channelList->getName());
if(bouquet_id >= 0) {
if (bouquet_id >= 0)
{
g_bouquetManager->deleteBouquet(bouquet_id);
CNeutrinoApp::getInstance()->MarkFavoritesChanged();
CNeutrinoApp::getInstance()->MarkChannelsInit();
return 1;
}
} else {
}
else
{
CServiceManager::getInstance()->RemovePosition(Bouquets[selected]->satellitePosition);
g_bouquetManager->loadBouquets();
g_bouquetManager->deletePosition(Bouquets[selected]->satellitePosition);
@@ -379,9 +415,10 @@ const struct button_label CBouquetListButtons[4] =
void CBouquetList::updateSelection(int newpos)
{
if (newpos < 0) /* to avoid all callers having to check */
if (newpos < 0) // to avoid all callers having to check
return;
if((int) selected != newpos) {
if ((int) selected != newpos)
{
int prev_selected = selected;
unsigned int oldliststart = liststart;
@@ -389,14 +426,15 @@ void CBouquetList::updateSelection(int newpos)
liststart = (selected / listmaxshow) * listmaxshow;
if (oldliststart != liststart)
paint();
else {
else
{
paintItem(prev_selected - liststart);
paintItem(selected - liststart);
}
}
}
/* bShowChannelList default to true, returns new bouquet or -1/-2 */
// bShowChannelList default to true, returns new bouquet or -1/-2
int CBouquetList::show(bool bShowChannelList)
{
neutrino_msg_t msg;
@@ -460,75 +498,99 @@ int CBouquetList::show(bool bShowChannelList)
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
bool loop = true;
while (loop) {
while (loop)
{
g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd);
if (msg <= CRCInput::RC_MaxRC)
timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
if((msg == NeutrinoMessages::EVT_TIMER) && (data == fader.GetFadeTimer())) {
if ((msg == NeutrinoMessages::EVT_TIMER) && (data == fader.GetFadeTimer()))
{
if (fader.FadeDone())
loop = false;
}
else if ((msg == CRCInput::RC_timeout ) ||
(msg == (neutrino_msg_t) g_settings.key_channelList_cancel) ||
else if ((msg == CRCInput::RC_timeout) || (msg == (neutrino_msg_t) g_settings.key_channelList_cancel) ||
((msg == (neutrino_msg_t) g_settings.key_favorites) && (CNeutrinoApp::getInstance()->GetChannelMode() == LIST_MODE_FAV)))
{
selected = oldselected;
if(fader.StartFadeOut()) {
if (fader.StartFadeOut())
{
timeoutEnd = CRCInput::calcTimeoutEnd(1);
msg = 0;
} else
}
else
loop = false;
}
else if(msg == CRCInput::RC_red || msg == (neutrino_msg_t) g_settings.key_favorites) {
if (!favonly && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_FAV) {
else if (msg == CRCInput::RC_red || msg == (neutrino_msg_t) g_settings.key_favorites)
{
if (!favonly && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_FAV)
{
CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_FAV);
hide();
return CHANLIST_CHANGE_MODE;
}
} else if(msg == CRCInput::RC_green) {
if (!favonly && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_PROV) {
}
else if (msg == CRCInput::RC_green)
{
if (!favonly && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_PROV)
{
CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_PROV);
hide();
return CHANLIST_CHANGE_MODE;
}
} else if(msg == CRCInput::RC_yellow || msg == CRCInput::RC_sat) {
if(!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_SAT) {
}
else if (msg == CRCInput::RC_yellow || msg == CRCInput::RC_sat)
{
if (!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_SAT)
{
CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_SAT);
hide();
return CHANLIST_CHANGE_MODE;
}
} else if(msg == CRCInput::RC_blue) {
if(!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_ALL) {
}
else if (msg == CRCInput::RC_blue)
{
if (!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_ALL)
{
CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_ALL);
hide();
return CHANLIST_CHANGE_MODE;
}
} else if(msg == CRCInput::RC_www) {
if(!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_WEB) {
}
else if (msg == CRCInput::RC_www)
{
if (!favonly && bShowChannelList && CNeutrinoApp::getInstance()->GetChannelMode() != LIST_MODE_WEB)
{
CNeutrinoApp::getInstance()->SetChannelMode(LIST_MODE_WEB);
hide();
return CHANLIST_CHANGE_MODE;
}
}
else if ( msg == CRCInput::RC_setup) {
if (!favonly && !Bouquets.empty()) {
else if (msg == CRCInput::RC_setup)
{
if (!favonly && !Bouquets.empty())
{
int ret = doMenu();
if(ret > 0) {
if (ret > 0)
{
res = CHANLIST_NO_RESTORE;
loop = false;
} else if(ret < 0) {
}
else if (ret < 0)
{
paintHead();
paint();
}
}
}
else if ( msg == (neutrino_msg_t) g_settings.key_list_start ) {
else if (msg == (neutrino_msg_t) g_settings.key_list_start)
{
if (!Bouquets.empty())
updateSelection(0);
}
else if ( msg == (neutrino_msg_t) g_settings.key_list_end ) {
else if (msg == (neutrino_msg_t) g_settings.key_list_end)
{
if (!Bouquets.empty())
updateSelection(Bouquets.size() - 1);
}
@@ -538,8 +600,10 @@ int CBouquetList::show(bool bShowChannelList)
int new_selected = UpDownKey(Bouquets, msg, listmaxshow, selected);
updateSelection(new_selected);
}
else if(msg == (neutrino_msg_t)g_settings.key_bouquet_up || msg == (neutrino_msg_t)g_settings.key_bouquet_down) {
if(bShowChannelList) {
else if (msg == (neutrino_msg_t)g_settings.key_bouquet_up || msg == (neutrino_msg_t)g_settings.key_bouquet_down)
{
if (bShowChannelList)
{
int mode = CNeutrinoApp::getInstance()->GetChannelMode();
mode += (msg == (neutrino_msg_t)g_settings.key_bouquet_down) ? -1 : 1;
if (mode < 0)
@@ -551,28 +615,39 @@ int CBouquetList::show(bool bShowChannelList)
return CHANLIST_CHANGE_MODE;
}
}
else if ( msg == CRCInput::RC_ok ) {
if(!Bouquets.empty() /* && (!bShowChannelList || !Bouquets[selected]->channelList->isEmpty())*/) {
else if (msg == CRCInput::RC_ok)
{
if (!Bouquets.empty() /*&& (!bShowChannelList || !Bouquets[selected]->channelList->isEmpty())*/)
{
zapOnExit = true;
loop = false;
}
}
else if (CRCInput::isNumeric(msg)) {
if (!Bouquets.empty()) {
if (pos == lmaxpos) {
if (msg == CRCInput::RC_0) {
else if (CRCInput::isNumeric(msg))
{
if (!Bouquets.empty())
{
if (pos == lmaxpos)
{
if (msg == CRCInput::RC_0)
{
chn = firstselected;
pos = lmaxpos;
} else {
}
else
{
chn = CRCInput::getNumericValue(msg);
pos = 1;
}
} else {
}
else
{
chn = chn * 10 + CRCInput::getNumericValue(msg);
pos++;
}
if (chn > Bouquets.size()) {
if (chn > Bouquets.size())
{
chn = firstselected;
pos = lmaxpos;
}
@@ -580,12 +655,17 @@ int CBouquetList::show(bool bShowChannelList)
int new_selected = (chn - 1) % Bouquets.size(); // is % necessary (i.e. can firstselected be > Bouquets.size()) ?
updateSelection(new_selected);
}
} else if (msg == NeutrinoMessages::EVT_SERVICESCHANGED || msg == NeutrinoMessages::EVT_BOUQUETSCHANGED) {
}
else if (msg == NeutrinoMessages::EVT_SERVICESCHANGED || msg == NeutrinoMessages::EVT_BOUQUETSCHANGED)
{
g_RCInput->postMsg(msg, data);
loop = false;
res = CHANLIST_CANCEL_ALL;
} else {
if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) {
}
else
{
if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all)
{
loop = false;
res = CHANLIST_CANCEL_ALL;
}
@@ -604,14 +684,17 @@ int CBouquetList::show(bool bShowChannelList)
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
if (save_bouquets) {
if (save_bouquets)
{
save_bouquets = false;
#if 0
if (CNeutrinoApp::getInstance()->GetChannelMode() == LIST_MODE_FAV)
g_bouquetManager->saveUBouquets();
else
g_bouquetManager->saveBouquets();
#endif
if (g_settings.epg_scan == CEpgScan::SCAN_SEL)
CEpgScan::getInstance()->Start();
}
@@ -679,23 +762,28 @@ void CBouquetList::paintItem(int pos)
}
}
if (npos < (int) Bouquets.size()) {
if (npos < (int) Bouquets.size())
{
char num[12];
snprintf(num, sizeof(num), "%d", npos + 1);
int iw = 0, ih = 0;
if ((g_settings.epg_scan == CEpgScan::SCAN_SEL) &&
Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bScanEpg) {
Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bScanEpg)
{
frameBuffer->getIconSize(NEUTRINO_ICON_MARKER_EPG, &iw, &ih);
if (iw && ih) {
if (iw && ih)
{
int icon_x = x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iw;
frameBuffer->paintIcon(NEUTRINO_ICON_MARKER_EPG, icon_x, ypos, item_height);
iw = iw + OFFSET_INNER_MID;
}
}
if (Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bUseCI) {
if (Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bUseCI)
{
int iw2 = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_MARKER_SCRAMBLED, &iw2, &ih);
if (iw2 && ih) {
if (iw2 && ih)
{
int icon_x = x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iw - iw2;
frameBuffer->paintIcon(NEUTRINO_ICON_MARKER_SCRAMBLED, icon_x, ypos, item_height);
iw = iw + iw2 + OFFSET_INNER_MID;
@@ -728,7 +816,8 @@ void CBouquetList::paint()
numwidth = 0;
int maxDigitWidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getMaxDigitWidth();
int _lastnum = lastnum;
while (_lastnum) {
while (_lastnum)
{
numwidth += maxDigitWidth;
_lastnum /= 10;
}
@@ -745,10 +834,8 @@ void CBouquetList::paint()
if (!Bouquets.empty())
{
for (unsigned int count = 0; count < listmaxshow; count++)
{
paintItem(count);
}
}
int total_pages;
int current_page;

View File

@@ -29,7 +29,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __bouquetlist__
#define __bouquetlist__
@@ -52,7 +51,6 @@ typedef enum bouquetSwitchMode
class CBouquet
{
public:
int unique_key;
bool bLocked;
@@ -125,5 +123,4 @@ class CBouquetList : public CListHelpers
bool hasChannelID(t_channel_id channel_id);
};
#endif