1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Implemented sort modes for the 'Channels' menu

This commit is contained in:
Klaus Schmidinger 2004-11-01 13:59:58 +01:00
parent 0b62aff0e3
commit c054f39620
3 changed files with 64 additions and 10 deletions

View File

@ -3109,3 +3109,7 @@ Video Disk Recorder Revision History
cListObject::operator<() has been replaced with cListObject::Compare().
Plugins that implement derived cListObject classes may need to adjust their
code.
- The "Channels" menu can now be sorted "by number" (default), "by name" and
"by provider". While in the "Channels" menu, pressing the '0' key switches
through these modes.

4
MANUAL
View File

@ -24,7 +24,7 @@ Version 1.2
Green - Language New New Ins/Ovr Rewind Skip -60s
Yellow - Pause live Delete Delete Delete Delete Skip +60s
Blue - Stop/Resume Mark On/Off(1) - Summary Stop
0..9 Ch select - - - Numeric inp. Exec cmd(2) Editing
0..9 Ch select - Sort(3) - Numeric inp. Exec cmd(2) Editing
In a numerical input field (like the response to a CAM enquiry) the keys 0..9
are used to enter the data, and the Left key can be used to delete the last
@ -71,6 +71,8 @@ Version 1.2
has been enabled in the "Setup" menu. Otherwise the Blue button is used
to "mark" a timer for moving.
(2) See "Processing Recordings" below.
(3) In the "Channels" menu the '0' key switches the sort mode through "by number",
"by name" and "by provider".
* Navigating through the On Screen Menus

66
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: menu.c 1.318 2004/11/01 10:40:38 kls Exp $
* $Id: menu.c 1.319 2004/11/01 13:49:40 kls Exp $
*/
#include "menu.h"
@ -327,14 +327,23 @@ eOSState cMenuEditChannel::ProcessKey(eKeys Key)
// --- cMenuChannelItem ------------------------------------------------------
class cMenuChannelItem : public cOsdItem {
public:
enum eChannelSortMode { csmNumber, csmName, csmProvider };
private:
static eChannelSortMode sortMode;
cChannel *channel;
public:
cMenuChannelItem(cChannel *Channel);
static void SetSortMode(eChannelSortMode SortMode) { sortMode = SortMode; }
static void IncSortMode(void) { sortMode = eChannelSortMode((sortMode == csmProvider) ? csmNumber : sortMode + 1); }
virtual int Compare(const cListObject &ListObject) const;
virtual void Set(void);
cChannel *Channel(void) { return channel; }
static eChannelSortMode SortMode(void) { return sortMode; }
};
cMenuChannelItem::eChannelSortMode cMenuChannelItem::sortMode = csmNumber;
cMenuChannelItem::cMenuChannelItem(cChannel *Channel)
{
channel = Channel;
@ -343,11 +352,28 @@ cMenuChannelItem::cMenuChannelItem(cChannel *Channel)
Set();
}
int cMenuChannelItem::Compare(const cListObject &ListObject) const
{
cMenuChannelItem *p = (cMenuChannelItem *)&ListObject;
int r = -1;
if (sortMode == csmProvider)
r = strcoll(channel->Provider(), p->channel->Provider());
if (sortMode == csmName || r == 0)
r = strcoll(channel->Name(), p->channel->Name());
if (sortMode == csmNumber || r == 0)
r = channel->Number() - p->channel->Number();
return r;
}
void cMenuChannelItem::Set(void)
{
char *buffer = NULL;
if (!channel->GroupSep())
asprintf(&buffer, "%d\t%s", channel->Number(), channel->Name());
if (!channel->GroupSep()) {
if (sortMode == csmProvider)
asprintf(&buffer, "%d\t%s - %s", channel->Number(), channel->Provider(), channel->Name());
else
asprintf(&buffer, "%d\t%s", channel->Number(), channel->Name());
}
else
asprintf(&buffer, "---\t%s ----------------------------------------------------------------", channel->Name());
SetText(buffer, false);
@ -357,6 +383,7 @@ void cMenuChannelItem::Set(void)
class cMenuChannels : public cOsdMenu {
private:
void Setup(void);
cChannel *GetChannel(int Index);
void Propagate(void);
protected:
@ -374,11 +401,7 @@ public:
cMenuChannels::cMenuChannels(void)
:cOsdMenu(tr("Channels"), CHNUMWIDTH)
{
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
if (!channel->GroupSep() || *channel->Name())
Add(new cMenuChannelItem(channel), channel->Number() == cDevice::CurrentChannel());
}
SetHelp(tr("Edit"), tr("New"), tr("Delete"), tr("Mark"));
Setup();
Channels.IncBeingEdited();
}
@ -387,6 +410,28 @@ cMenuChannels::~cMenuChannels()
Channels.DecBeingEdited();
}
void cMenuChannels::Setup(void)
{
cChannel *currentChannel = GetChannel(Current());
if (!currentChannel)
currentChannel = Channels.GetByNumber(cDevice::CurrentChannel());
cMenuChannelItem *currentItem = NULL;
Clear();
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
if (!channel->GroupSep() || cMenuChannelItem::SortMode() == cMenuChannelItem::csmNumber && *channel->Name()) {
cMenuChannelItem *item = new cMenuChannelItem(channel);
Add(item);
if (channel == currentChannel)
currentItem = item;
}
}
if (cMenuChannelItem::SortMode() != cMenuChannelItem::csmNumber)
Sort();
SetCurrent(currentItem);
SetHelp(tr("Edit"), tr("New"), tr("Delete"), cMenuChannelItem::SortMode() == cMenuChannelItem::csmNumber ? tr("Mark") : NULL);
Display();
}
cChannel *cMenuChannels::GetChannel(int Index)
{
cMenuChannelItem *p = (cMenuChannelItem *)Get(Index);
@ -486,11 +531,14 @@ eOSState cMenuChannels::ProcessKey(eKeys Key)
default:
if (state == osUnknown) {
switch (Key) {
case k0: cMenuChannelItem::IncSortMode();
Setup();
break;
case kOk: return Switch();
case kRed: return Edit();
case kGreen: return New();
case kYellow: return Delete();
case kBlue: if (!HasSubMenu())
case kBlue: if (!HasSubMenu() && cMenuChannelItem::SortMode() == cMenuChannelItem::csmNumber)
Mark();
break;
default: break;