From patchwork Mon Jul 18 15:41:46 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lauri Tischler X-Patchwork-Id: 11949 Received: from fep19.inet.fi ([194.251.242.244]) by www.linuxtv.org with esmtp (Exim 4.34) id 1DuXkb-0001qw-G8 for vdr@linuxtv.org; Mon, 18 Jul 2005 17:41:49 +0200 Received: from [127.0.0.1] ([84.248.25.64]) by fep19.inet.fi with ESMTP id <20050718154147.YLJD20441.fep19.inet.fi@[127.0.0.1]> for ; Mon, 18 Jul 2005 18:41:47 +0300 Message-ID: <42DBCDBA.7080307@iki.fi> Date: Mon, 18 Jul 2005 18:41:46 +0300 From: Lauri Tischler User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Klaus Schmidinger's VDR Subject: Re: [vdr] Re: Reducing clutter in channels.conf References: <42DA45F6.1000408@iki.fi> <127oa1v3x9ofo$.17wtsf6j133l.dlg@40tude.net> <1121654466.5009.14.camel@localhost.localdomain> <42DB4BC9.10703@cadsoft.de> <1121698262.4368.9.camel@localhost.localdomain> In-Reply-To: <1121698262.4368.9.camel@localhost.localdomain> X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2005 15:41:49 -0000 Status: O X-Status: X-Keywords: X-UID: 3604 Malcolm Caldwell wrote: > Also, I like the sorting ability now in the channels menu. I would like > one more option: sort by source, where source is the value defined in > sources.conf (eg the satellite names etc). In my setup this would be > quite useful. (Sort by provider is not quite good enough - most c-band > channels seem to have a provider of 'default provider' :) ) There's a patch for that, by Luca Olivetti. --- menu.c.sortbysource 2005-01-09 16:42:26.532491562 +0100 +++ menu.c 2005-01-09 18:37:29.606277755 +0100 @@ -328,14 +328,14 @@ class cMenuChannelItem : public cOsdItem { public: - enum eChannelSortMode { csmNumber, csmName, csmProvider }; + enum eChannelSortMode { csmNumber, csmName, csmProvider, csmSourceNumber, csmSourceName, csmSourceProvider }; 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); } + static void IncSortMode(void) { sortMode = eChannelSortMode((sortMode == csmSourceProvider) ? csmNumber : sortMode + 1); } virtual int Compare(const cListObject &ListObject) const; virtual void Set(void); cChannel *Channel(void) { return channel; } @@ -352,10 +352,42 @@ Set(); } +int snum(int source) +{ + int stype = (source & cSource::st_Mask); + // arbitrary order: sat, cable, terrestrial, none + int r; + switch(stype) { + case cSource::stCable: + r=0x7FF0; + break; + case cSource::stTerr: + r=0x7FF2; + break; + case cSource::stSat: + r=source & cSource::st_Pos; + if (source & cSource::st_Neg) r*=-1; + break; + default: //stNone or unknown + r=0x7FFF; + } + return r; +} + int cMenuChannelItem::Compare(const cListObject &ListObject) const { cMenuChannelItem *p = (cMenuChannelItem *)&ListObject; int r = -1; + if (sortMode >= csmSourceNumber) { + int rsource = snum(channel->Source()) - snum(p->channel->Source()); + if (sortMode == csmSourceProvider && rsource == 0) + r = strcoll(channel->Provider(), p->channel->Provider()); + if ((sortMode == csmSourceName || r == 0) && rsource == 0) + r = strcoll(channel->Name(), p->channel->Name()); + if ((sortMode == csmSourceNumber || r == 0) && rsource == 0) + r = channel->Number() - p->channel->Number(); + return ((rsource == 0) ? r : rsource); + } if (sortMode == csmProvider) r = strcoll(channel->Provider(), p->channel->Provider()); if (sortMode == csmName || r == 0) @@ -369,10 +401,10 @@ { char *buffer = NULL; if (!channel->GroupSep()) { - if (sortMode == csmProvider) - asprintf(&buffer, "%d\t%s - %s", channel->Number(), channel->Provider(), channel->Name()); + if (sortMode == csmProvider || sortMode == csmSourceProvider) + asprintf(&buffer, "%d\t%s %c %s - %s", channel->Number(), *cSource::ToString(channel->Source()), (sortMode >= csmSourceNumber) ? '*' : '-', channel->Provider(), channel->Name()); else - asprintf(&buffer, "%d\t%s", channel->Number(), channel->Name()); + asprintf(&buffer, "%d\t%s %c %s", channel->Number(), *cSource::ToString(channel->Source()), (sortMode >= csmSourceNumber) ? '*' : '-', channel->Name()); } else asprintf(&buffer, "---\t%s ----------------------------------------------------------------", channel->Name());