use CListHelpers to remove duplicated code

CListHelpers::UpDownKey() allows to remove duplicated
code from channellist, bouquetlist and bouqueteditor.
This commit is contained in:
Stefan Seyfried
2016-01-16 15:01:29 +01:00
parent 22c09ce84e
commit c9e72e654f
8 changed files with 33 additions and 136 deletions

View File

@@ -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())) {

View File

@@ -39,6 +39,7 @@
#include <zapit/channel.h>
#include <zapit/bouquets.h>
#include <gui/components/cc.h>
#include <gui/widget/listhelpers.h>
#include <string>
/* 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:

View File

@@ -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())) {

View File

@@ -35,6 +35,7 @@
#include <driver/framebuffer.h>
#include <gui/widget/menue.h>
#include <gui/widget/listhelpers.h>
#include <gui/components/cc.h>
#include <zapit/client/zapitclient.h>
@@ -42,7 +43,7 @@
#include <zapit/channel.h>
#include <zapit/bouquets.h>
class CBEChannelWidget : public CMenuTarget
class CBEChannelWidget : public CMenuTarget, public CListHelpers
{
private:

View File

@@ -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) {

View File

@@ -34,6 +34,7 @@
#define __bouquetlist__
#include <gui/channellist.h>
#include <gui/widget/listhelpers.h>
#include <driver/framebuffer.h>
#include <system/lastchannel.h>
@@ -77,7 +78,7 @@ class CBouquet
};
class CBouquetList
class CBouquetList : public CListHelpers
{
private:
CFrameBuffer *frameBuffer;

View File

@@ -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)) {

View File

@@ -35,6 +35,7 @@
#include <driver/framebuffer.h>
#include <gui/widget/menue.h>
#include <gui/widget/listhelpers.h>
#include <gui/components/cc.h>
#include <system/lastchannel.h>
@@ -63,7 +64,7 @@ enum {
class CBouquet;
class CChannelList
class CChannelList : public CListHelpers
{
private:
enum state_