summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2004-11-01 13:59:58 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2004-11-01 13:59:58 +0100
commitc054f3962002f153ae6a23da86fdbc9094c063f4 (patch)
tree5bcc545f747861c621c562518e3465dcb7f60f44
parent0b62aff0e3385ed0c11fda145c2a5167bbc1c56d (diff)
downloadvdr-c054f3962002f153ae6a23da86fdbc9094c063f4.tar.gz
vdr-c054f3962002f153ae6a23da86fdbc9094c063f4.tar.bz2
Implemented sort modes for the 'Channels' menu
-rw-r--r--HISTORY4
-rw-r--r--MANUAL4
-rw-r--r--menu.c66
3 files changed, 64 insertions, 10 deletions
diff --git a/HISTORY b/HISTORY
index 6ae727c6..f044bff0 100644
--- a/HISTORY
+++ b/HISTORY
@@ -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.
+
diff --git a/MANUAL b/MANUAL
index 9855d0ee..cc89252f 100644
--- a/MANUAL
+++ b/MANUAL
@@ -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
diff --git a/menu.c b/menu.c
index 5ebf5183..f5c3c611 100644
--- a/menu.c
+++ b/menu.c
@@ -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;