From 2cc450a67cd8c5bef3f0b568735e5bb7efde660a Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 12 May 2002 14:46:46 +0200 Subject: [PATCH] Added 'insert' capabilities to cList --- CONTRIBUTORS | 1 + HISTORY | 1 + osd.c | 13 ++++++++++--- osd.h | 5 +++-- tools.c | 42 +++++++++++++++++++++++++++++++++++------- tools.h | 6 ++++-- 6 files changed, 54 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 35ef4090..78d3d184 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -133,6 +133,7 @@ Stefan Huelswitt for suggesting to make the cPlugin::Start() function return a boolean value that indicates if the plugin will not be able to perform its task for suggesting to add the cPlugin::Housekeeping() function + for suggesting to add 'insert' capabilities to cList Ulrich Röder for pointing out that there are channels that have a symbol rate higher than diff --git a/HISTORY b/HISTORY index c73d86b1..a1cf5d66 100644 --- a/HISTORY +++ b/HISTORY @@ -1276,3 +1276,4 @@ Video Disk Recorder Revision History if the plugin will not be able to perform its task (suggested by Stefan Huelswitt). - Added the cPlugin::Housekeeping() function (suggested by Stefan Huelswitt). - Updated channels.conf.cable (thanks to Uwe Scheffler). +- Added 'insert' capabilities to cList (suggested by Stefan Huelswitt). diff --git a/osd.c b/osd.c index b23796a7..6feeaa87 100644 --- a/osd.c +++ b/osd.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osd.c 1.24 2002/05/05 12:00:00 kls Exp $ + * $Id: osd.c 1.25 2002/05/12 11:38:39 kls Exp $ */ #include "osd.h" @@ -161,9 +161,16 @@ void cOsdMenu::Del(int Index) first--; } -void cOsdMenu::Add(cOsdItem *Item, bool Current) +void cOsdMenu::Add(cOsdItem *Item, bool Current, cOsdItem *After) { - cList::Add(Item); + cList::Add(Item, After); + if (Current) + current = Item->Index(); +} + +void cOsdMenu::Ins(cOsdItem *Item, bool Current, cOsdItem *Before) +{ + cList::Ins(Item, Before); if (Current) current = Item->Index(); } diff --git a/osd.h b/osd.h index 9b619ea5..afd44859 100644 --- a/osd.h +++ b/osd.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osd.h 1.28 2002/05/05 12:00:00 kls Exp $ + * $Id: osd.h 1.29 2002/05/12 11:19:22 kls Exp $ */ #ifndef __OSD_H @@ -116,7 +116,8 @@ public: cOsdMenu(const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0); virtual ~cOsdMenu(); int Current(void) { return current; } - void Add(cOsdItem *Item, bool Current = false); + void Add(cOsdItem *Item, bool Current = false, cOsdItem *After = NULL); + void Ins(cOsdItem *Item, bool Current = false, cOsdItem *Before = NULL); void Display(void); virtual eOSState ProcessKey(eKeys Key); }; diff --git a/tools.c b/tools.c index 6f99ef09..ef37dfda 100644 --- a/tools.c +++ b/tools.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.63 2002/05/01 16:20:30 kls Exp $ + * $Id: tools.c 1.64 2002/05/12 11:37:24 kls Exp $ */ #include "tools.h" @@ -724,6 +724,12 @@ void cListObject::Append(cListObject *Object) Object->prev = this; } +void cListObject::Insert(cListObject *Object) +{ + prev = Object; + Object->next = this; +} + void cListObject::Unlink(void) { if (next) @@ -757,13 +763,35 @@ cListBase::~cListBase() Clear(); } -void cListBase::Add(cListObject *Object) +void cListBase::Add(cListObject *Object, cListObject *After) { - if (lastObject) - lastObject->Append(Object); - else - objects = Object; - lastObject = Object; + if (After && After != lastObject) { + After->Next()->Insert(Object); + After->Append(Object); + } + else { + if (lastObject) + lastObject->Append(Object); + else + objects = Object; + lastObject = Object; + } +} + +void cListBase::Ins(cListObject *Object, cListObject *Before) +{ + if (Before && Before != objects) { + Before->Prev()->Append(Object); + Before->Insert(Object); + } + else { + if (objects) + objects->Insert(Object); + else + objects = Object; + if (!lastObject) + lastObject = Object; + } } void cListBase::Del(cListObject *Object) diff --git a/tools.h b/tools.h index bf064ce7..44b96abc 100644 --- a/tools.h +++ b/tools.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.h 1.43 2002/05/11 08:35:47 kls Exp $ + * $Id: tools.h 1.44 2002/05/12 11:14:18 kls Exp $ */ #ifndef __TOOLS_H @@ -120,6 +120,7 @@ public: virtual ~cListObject(); virtual bool operator< (const cListObject &ListObject) { return false; } void Append(cListObject *Object); + void Insert(cListObject *Object); void Unlink(void); int Index(void); cListObject *Prev(void) const { return prev; } @@ -132,7 +133,8 @@ protected: cListBase(void); public: virtual ~cListBase(); - void Add(cListObject *Object); + void Add(cListObject *Object, cListObject *After = NULL); + void Ins(cListObject *Object, cListObject *Before = NULL); void Del(cListObject *Object); virtual void Move(int From, int To); void Move(cListObject *From, cListObject *To);