eventlist: use CListHelpers::UpDownKey

This commit is contained in:
Stefan Seyfried
2016-01-16 15:38:04 +01:00
parent c9e72e654f
commit 5550f89853
3 changed files with 7 additions and 24 deletions

View File

@@ -4,7 +4,7 @@
Copyright (C) 2001 Steffen Hehn 'McClean' Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/ Homepage: http://dbox.cyberphoria.org/
Copyright (C) 2009-2014 Stefan Seyfried Copyright (C) 2009-2016 Stefan Seyfried
License: GPL License: GPL
@@ -359,7 +359,6 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna
msg == CRCInput::RC_down || (int) msg == g_settings.key_pagedown) msg == CRCInput::RC_down || (int) msg == g_settings.key_pagedown)
{ {
bool paint_buttonbar = false; //function bar bool paint_buttonbar = false; //function bar
int step = 0;
int prev_selected = selected; int prev_selected = selected;
// TODO: do we need this at all? Search button is always painted IIUC... // TODO: do we need this at all? Search button is always painted IIUC...
if ((g_settings.key_channelList_addremind != (int)CRCInput::RC_nokey) || if ((g_settings.key_channelList_addremind != (int)CRCInput::RC_nokey) ||
@@ -367,27 +366,9 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna
((g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) && ((g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) &&
(g_settings.key_channelList_addrecord != (int)CRCInput::RC_nokey))) (g_settings.key_channelList_addrecord != (int)CRCInput::RC_nokey)))
paint_buttonbar = true; paint_buttonbar = true;
int new_sel = UpDownKey(evtlist, msg, listmaxshow, selected);
if (msg == CRCInput::RC_up || (int) msg == g_settings.key_pageup) if (new_sel >= 0) {
{ selected = new_sel;
step = ((int) msg == g_settings.key_pageup) ? listmaxshow : 1; // browse or step 1
selected -= step;
if((prev_selected-step) < 0) // because of uint
selected = evtlist.size() - 1;
paintDescription(selected);
}
else if (msg == CRCInput::RC_down || (int) msg == g_settings.key_pagedown)
{
step = ((int) msg == g_settings.key_pagedown) ? listmaxshow : 1; // browse or step 1
selected += step;
if(selected >= evtlist.size())
{
if (((evtlist.size() / listmaxshow) + 1) * listmaxshow == evtlist.size() + listmaxshow) // last page has full entries
selected = 0;
else
selected = ((step == (int)listmaxshow) && (selected < (((evtlist.size() / listmaxshow) + 1) * listmaxshow))) ? (evtlist.size() - 1) : 0;
}
paintDescription(selected); paintDescription(selected);
} }
paintItem(prev_selected - liststart, channel_id); paintItem(prev_selected - liststart, channel_id);

View File

@@ -40,11 +40,12 @@
#include "infoviewer.h" #include "infoviewer.h"
#include "widget/menue.h" #include "widget/menue.h"
#include "widget/listhelpers.h"
#include <string> #include <string>
class CEventList class CEventList : public CListHelpers
{ {
// Eventfinder start // Eventfinder start
public: public:

View File

@@ -69,3 +69,4 @@ template <class T> int CListHelpers::UpDownKey(T list, neutrino_msg_t msg, int l
template int CListHelpers::UpDownKey<std::vector<CBouquet*> >(std::vector<CBouquet*>, neutrino_msg_t, int, int); template int CListHelpers::UpDownKey<std::vector<CBouquet*> >(std::vector<CBouquet*>, neutrino_msg_t, int, int);
template int CListHelpers::UpDownKey<std::vector<CZapitBouquet*> >(std::vector<CZapitBouquet*>, neutrino_msg_t, int, int); template int CListHelpers::UpDownKey<std::vector<CZapitBouquet*> >(std::vector<CZapitBouquet*>, neutrino_msg_t, int, int);
template int CListHelpers::UpDownKey<std::vector<CZapitChannel*> >(std::vector<CZapitChannel*>, neutrino_msg_t, int, int); template int CListHelpers::UpDownKey<std::vector<CZapitChannel*> >(std::vector<CZapitChannel*>, neutrino_msg_t, int, int);
template int CListHelpers::UpDownKey<std::vector<CChannelEvent> >(std::vector<CChannelEvent>, neutrino_msg_t, int, int);