diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index c588464f0..3f829e2b8 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -2,15 +2,7 @@ Neutrino-GUI - DBoxII-Project Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. - + Copyright (C) 2009,2011,2013,2016 Stefan Seyfried License: GPL @@ -166,7 +158,7 @@ void CBEBouquetWidget::hide() void CBEBouquetWidget::updateSelection(unsigned int newpos) { - if(newpos == selected) + if (newpos == selected || newpos == (unsigned int)-1) return; unsigned int prev_selected = selected; @@ -272,34 +264,11 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey* cancelMoveBouquet(); } } - else if (msg==CRCInput::RC_up || msg==(neutrino_msg_t)g_settings.key_pageup) + else if (msg == CRCInput::RC_up || msg == (neutrino_msg_t)g_settings.key_pageup || + msg == CRCInput::RC_down || msg == (neutrino_msg_t)g_settings.key_pagedown) { - if (!(Bouquets->empty())) { - int step = (msg == (neutrino_msg_t)g_settings.key_pageup) ? listmaxshow : 1; // browse or step 1 - int new_selected = selected - step; - - if (new_selected < 0) { - if (selected != 0 && step != 1) - new_selected = 0; - else - new_selected = Bouquets->size() - 1; - } - updateSelection(new_selected); - } - } - else if (msg==CRCInput::RC_down || msg==(neutrino_msg_t)g_settings.key_pagedown) - { - if (!(Bouquets->empty())) { - int step = ((int) msg == g_settings.key_pagedown) ? listmaxshow : 1; // browse or step 1 - int new_selected = selected + step; - if (new_selected > (int) Bouquets->size() - 1) { - if ((selected != Bouquets->size() - 1)) - new_selected = Bouquets->size() - 1; - else - new_selected = 0; - } - updateSelection(new_selected); - } + int new_selected = UpDownKey(*Bouquets, msg, listmaxshow, selected); + updateSelection(new_selected); } else if (msg == (neutrino_msg_t) g_settings.key_list_start || msg == (neutrino_msg_t) g_settings.key_list_end) { if (!(Bouquets->empty())) { diff --git a/src/gui/bedit/bouqueteditor_bouquets.h b/src/gui/bedit/bouqueteditor_bouquets.h index 1c935b587..256bd25bb 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.h +++ b/src/gui/bedit/bouqueteditor_bouquets.h @@ -39,6 +39,7 @@ #include #include #include +#include #include /* class for handling when bouquets changed. */ @@ -51,7 +52,7 @@ public: virtual void onBouquetsChanged() {}; }; -class CBEBouquetWidget : public CMenuTarget +class CBEBouquetWidget : public CMenuTarget, public CListHelpers { private: diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index 3a6a14ba5..8a9ef7157 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -5,14 +5,7 @@ Homepage: http://dbox.cyberphoria.org/ Copyright (C) 2011 CoolStream International Ltd - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. - + Copyright (C) 2009,2011,2013,2016 Stefan Seyfried License: GPL @@ -283,7 +276,7 @@ void CBEChannelWidget::hide() void CBEChannelWidget::updateSelection(unsigned int newpos) { - if(newpos == selected) + if (newpos == selected || newpos == (unsigned int)-1) return; unsigned int prev_selected = selected; @@ -360,34 +353,11 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey* cancelMoveChannel(); } } - else if (msg==CRCInput::RC_up || msg==(neutrino_msg_t)g_settings.key_pageup) + else if (msg == CRCInput::RC_up || msg == (neutrino_msg_t)g_settings.key_pageup || + msg == CRCInput::RC_down || msg == (neutrino_msg_t)g_settings.key_pagedown) { - if (!(Channels->empty())) { - int step = (msg == (neutrino_msg_t)g_settings.key_pageup) ? listmaxshow : 1; // browse or step 1 - int new_selected = selected - step; - - if (new_selected < 0) { - if (selected != 0 && step != 1) - new_selected = 0; - else - new_selected = Channels->size() - 1; - } - updateSelection(new_selected); - } - } - else if (msg==CRCInput::RC_down || msg==(neutrino_msg_t)g_settings.key_pagedown) - { - if (!(Channels->empty())) { - int step = ((int) msg == g_settings.key_pagedown) ? listmaxshow : 1; // browse or step 1 - int new_selected = selected + step; - if (new_selected > (int) Channels->size() - 1) { - if ((selected != Channels->size() - 1)) - new_selected = Channels->size() - 1; - else - new_selected = 0; - } - updateSelection(new_selected); - } + int new_selected = UpDownKey(*Channels, msg, listmaxshow, selected); + updateSelection(new_selected); } else if (msg == (neutrino_msg_t) g_settings.key_list_start || msg == (neutrino_msg_t) g_settings.key_list_end) { if (!(Channels->empty())) { diff --git a/src/gui/bedit/bouqueteditor_channels.h b/src/gui/bedit/bouqueteditor_channels.h index fd17636fb..d13b9aa74 100644 --- a/src/gui/bedit/bouqueteditor_channels.h +++ b/src/gui/bedit/bouqueteditor_channels.h @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -42,7 +43,7 @@ #include #include -class CBEChannelWidget : public CMenuTarget +class CBEChannelWidget : public CMenuTarget, public CListHelpers { private: diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index 59d357aa9..567438610 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -2,15 +2,7 @@ Neutrino-GUI - DBoxII-Project Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. - + Copyright (C) 2009,2011,2013,2015-2016 Stefan Seyfried License: GPL @@ -391,6 +383,8 @@ const struct button_label CBouquetListButtons[4] = void CBouquetList::updateSelection(int newpos) { + if (newpos < 0) /* to avoid all callers having to check */ + return; if((int) selected != newpos) { int prev_selected = selected; unsigned int oldliststart = liststart; @@ -528,33 +522,11 @@ int CBouquetList::show(bool bShowChannelList) if (!Bouquets.empty()) updateSelection(Bouquets.size()-1); } - else if (msg == CRCInput::RC_up || (int) msg == g_settings.key_pageup) + else if (msg == CRCInput::RC_up || (int) msg == g_settings.key_pageup || + msg == CRCInput::RC_down || (int) msg == g_settings.key_pagedown) { - if (!Bouquets.empty()) { - int step = ((int) msg == g_settings.key_pageup) ? listmaxshow : 1; // browse or step 1 - int new_selected = selected - step; - if (new_selected < 0) { - if (selected != 0 && step != 1) - new_selected = 0; - else - new_selected = Bouquets.size() - 1; - } - updateSelection(new_selected); - } - } - else if (msg == CRCInput::RC_down || (int) msg == g_settings.key_pagedown) - { - if (!Bouquets.empty()) { - int step = ((int) msg == g_settings.key_pagedown) ? listmaxshow : 1; // browse or step 1 - int new_selected = selected + step; - if (new_selected > (int) Bouquets.size() - 1) { - if ((selected != Bouquets.size() - 1)) - new_selected = Bouquets.size() - 1; - else - new_selected = 0; - } - updateSelection(new_selected); - } + 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) { diff --git a/src/gui/bouquetlist.h b/src/gui/bouquetlist.h index e767a6c47..1ba8a199e 100644 --- a/src/gui/bouquetlist.h +++ b/src/gui/bouquetlist.h @@ -34,6 +34,7 @@ #define __bouquetlist__ #include +#include #include #include @@ -77,7 +78,7 @@ class CBouquet }; -class CBouquetList +class CBouquetList : public CListHelpers { private: CFrameBuffer *frameBuffer; diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 1540fced1..ad3aefdc4 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -2,7 +2,7 @@ Neutrino-GUI - DBoxII-Project Copyright (C) 2001 Steffen Hehn 'McClean' - Copyright (C) 2007-2015 Stefan Seyfried + Copyright (C) 2007-2016 Stefan Seyfried Kommentar: @@ -728,31 +728,13 @@ int CChannelList::show() else if (!empty && msg == (neutrino_msg_t) g_settings.key_list_end) { actzap = updateSelection((*chanlist).size()-1); } - else if (!empty && (msg == CRCInput::RC_up || (int) msg == g_settings.key_pageup)) + else if (!empty && (msg == CRCInput::RC_up || (int)msg == g_settings.key_pageup || + msg == CRCInput::RC_down || (int)msg == g_settings.key_pagedown)) { displayList = 1; - int step = ((int) msg == g_settings.key_pageup) ? listmaxshow : 1; // browse or step 1 - int new_selected = selected - step; - if (new_selected < 0) { - if (selected != 0 && step != 1) - new_selected = 0; - else - new_selected = (*chanlist).size() - 1; - } - actzap = updateSelection(new_selected); - } - else if (!empty && (msg == CRCInput::RC_down || (int) msg == g_settings.key_pagedown)) - { - displayList = 1; - int step = ((int) msg == g_settings.key_pagedown) ? listmaxshow : 1; // browse or step 1 - int new_selected = selected + step; - if (new_selected > (int) (*chanlist).size() - 1) { - if ((selected != (*chanlist).size() - 1)) - new_selected = (*chanlist).size() - 1; - else - new_selected = 0; - } - actzap = updateSelection(new_selected); + int new_selected = UpDownKey((*chanlist), msg, listmaxshow, selected); + if (new_selected >= 0) + actzap = updateSelection(new_selected); } else if (!edit_state && (msg == (neutrino_msg_t)g_settings.key_bouquet_up || msg == (neutrino_msg_t)g_settings.key_bouquet_down)) { diff --git a/src/gui/channellist.h b/src/gui/channellist.h index 96014b6b4..21d2babda 100644 --- a/src/gui/channellist.h +++ b/src/gui/channellist.h @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -63,7 +64,7 @@ enum { class CBouquet; -class CChannelList +class CChannelList : public CListHelpers { private: enum state_