mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
timerlist: use CListHelpers
remove duplicated code and use CListHelpers::UpDownKey(). Some variable types had to be changed to avoid typecasts, as a result (int) casts to foo.size() had to be added :-)
This commit is contained in:
committed by
svenhoefer
parent
edf7d48e04
commit
ed7eaafbcb
@@ -458,7 +458,7 @@ void CTimerList::updateEvents(void)
|
||||
height = theight+listmaxshow*fheight*2+footerHeight; // recalc height
|
||||
}
|
||||
|
||||
if (selected==timerlist.size() && !(timerlist.empty()))
|
||||
if (!timerlist.empty() && selected == (int)timerlist.size())
|
||||
{
|
||||
selected=timerlist.size()-1;
|
||||
liststart = (selected/listmaxshow)*listmaxshow;
|
||||
@@ -519,58 +519,22 @@ int CTimerList::show()
|
||||
loop=false;
|
||||
|
||||
}
|
||||
else if ((msg == CRCInput::RC_up || msg == (unsigned int)g_settings.key_pageup) && !(timerlist.empty()))
|
||||
else if (!timerlist.empty() &&
|
||||
(msg == CRCInput::RC_up || (int)msg == g_settings.key_pageup ||
|
||||
msg == CRCInput::RC_down || (int)msg == g_settings.key_pagedown))
|
||||
{
|
||||
int step = 0;
|
||||
int prev_selected = selected;
|
||||
|
||||
step = (msg == (unsigned int)g_settings.key_pageup) ? listmaxshow : 1; // browse or step 1
|
||||
selected -= step;
|
||||
if((prev_selected-step) < 0) // because of uint
|
||||
selected = timerlist.size() - 1;
|
||||
|
||||
paintItem(prev_selected - liststart);
|
||||
unsigned int oldliststart = liststart;
|
||||
int oldliststart = liststart;
|
||||
selected = UpDownKey(timerlist, msg, listmaxshow, selected);
|
||||
if (selected < 0) /* UpDownKey error */
|
||||
selected = prev_selected;
|
||||
liststart = (selected / listmaxshow) * listmaxshow;
|
||||
if (oldliststart != liststart)
|
||||
{
|
||||
paint();
|
||||
}
|
||||
else
|
||||
{
|
||||
paintItem(selected - liststart);
|
||||
}
|
||||
|
||||
paintFoot();
|
||||
}
|
||||
else if ((msg == CRCInput::RC_down || msg == (unsigned int)g_settings.key_pagedown) && !(timerlist.empty()))
|
||||
{
|
||||
unsigned int step = 0;
|
||||
int prev_selected = selected;
|
||||
|
||||
step = (msg == (unsigned int)g_settings.key_pagedown) ? listmaxshow : 1; // browse or step 1
|
||||
selected += step;
|
||||
|
||||
if(selected >= timerlist.size())
|
||||
{
|
||||
if (((timerlist.size() / listmaxshow) + 1) * listmaxshow == timerlist.size() + listmaxshow) // last page has full entries
|
||||
selected = 0;
|
||||
else
|
||||
selected = ((step == listmaxshow) && (selected < (((timerlist.size() / listmaxshow) + 1) * listmaxshow))) ? (timerlist.size() - 1) : 0;
|
||||
}
|
||||
else {
|
||||
paintItem(prev_selected - liststart);
|
||||
|
||||
unsigned int oldliststart = liststart;
|
||||
liststart = (selected/listmaxshow)*listmaxshow;
|
||||
if (oldliststart!=liststart)
|
||||
{
|
||||
paint();
|
||||
}
|
||||
else
|
||||
{
|
||||
paintItem(selected - liststart);
|
||||
}
|
||||
|
||||
paintFoot();
|
||||
}
|
||||
else if ((msg == CRCInput::RC_right || msg == CRCInput::RC_ok || msg==CRCInput::RC_blue) && !(timerlist.empty()))
|
||||
@@ -719,7 +683,7 @@ void CTimerList::paintItem(int pos)
|
||||
//selected item
|
||||
frameBuffer->paintBoxRel(x,ypos, real_width, 2*fheight, bgcolor, RADIUS_MID);
|
||||
|
||||
if (liststart+pos<timerlist.size())
|
||||
if (liststart + pos < (int)timerlist.size())
|
||||
{
|
||||
CTimerd::responseGetTimer & timer = timerlist[liststart+pos];
|
||||
char zAlarmTime[25] = {0};
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include <timerdclient/timerdtypes.h>
|
||||
|
||||
#include <gui/widget/menue.h>
|
||||
#include <gui/widget/listhelpers.h>
|
||||
|
||||
#include <driver/framebuffer.h>
|
||||
|
||||
@@ -43,7 +44,7 @@
|
||||
|
||||
|
||||
class CTimerdClient;
|
||||
class CTimerList : public CMenuTarget
|
||||
class CTimerList : public CMenuTarget, public CListHelpers
|
||||
{
|
||||
private:
|
||||
CFrameBuffer *frameBuffer;
|
||||
@@ -54,8 +55,8 @@ class CTimerList : public CMenuTarget
|
||||
int fheight; // fontheight content
|
||||
int theight; // fontheight titel
|
||||
int footerHeight;
|
||||
unsigned int selected;
|
||||
unsigned int liststart;
|
||||
int selected;
|
||||
int liststart;
|
||||
unsigned int listmaxshow;
|
||||
bool visible;
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <global.h>
|
||||
#include <gui/bouquetlist.h>
|
||||
#include <libupnpclient/upnpclient.h>
|
||||
#include <timerdclient/timerdtypes.h>
|
||||
|
||||
static int upDownKey(int size, neutrino_msg_t msg, int lines, int sel)
|
||||
{
|
||||
@@ -83,3 +84,4 @@ updown_t(std::vector<CZapitBouquet*>);
|
||||
updown_t(std::vector<CZapitChannel*>);
|
||||
updown_t(std::vector<CChannelEvent>);
|
||||
updown_t(std::vector<CUPnPDevice>);
|
||||
updown_t(std::vector<CTimerd::responseGetTimer>);
|
||||
|
Reference in New Issue
Block a user