- basic support for Enigma2 (Dreambox, Vu+,...) channel lists

- dynamic number of favorite lists (still limited to 64 due to bitmask)
This commit is contained in:
Horst Beham
2021-03-07 16:12:21 +01:00
parent bc4b650f20
commit cb1fb9db5d
17 changed files with 608 additions and 23 deletions

View File

@@ -5,8 +5,6 @@ namespace ChanSort.Api
{
public class ChannelInfo
{
public const int MAX_FAV_LISTS = 16;
private string uid;
private string serviceTypeName;
private int newProgramNr;
@@ -106,13 +104,8 @@ namespace ChanSort.Api
{
this.OldProgramNr = -1;
this.NewProgramNr = -1;
this.FavIndex = new List<int>(MAX_FAV_LISTS);
this.OldFavIndex = new List<int>(MAX_FAV_LISTS);
for (int i = 0; i < MAX_FAV_LISTS; i++)
{
this.FavIndex.Add(-1);
this.OldFavIndex.Add(-1);
}
this.FavIndex = new List<int>();
this.OldFavIndex = new List<int>();
this.Name = "";
this.ShortName = "";
}
@@ -315,7 +308,7 @@ namespace ChanSort.Api
/// </summary>
public int GetPosition(int subListIndex)
{
return subListIndex == 0 ? this.NewProgramNr : this.FavIndex[subListIndex - 1];
return subListIndex < 0 ? -1 : subListIndex == 0 ? this.NewProgramNr : subListIndex - 1 < this.FavIndex.Count ? this.FavIndex[subListIndex - 1] : -1;
}
/// <summary>
@@ -323,7 +316,7 @@ namespace ChanSort.Api
/// </summary>
public int GetOldPosition(int subListIndex)
{
return subListIndex == 0 ? this.OldProgramNr : this.OldFavIndex[subListIndex - 1];
return subListIndex < 0 ? -1 : subListIndex == 0 ? this.OldProgramNr : subListIndex - 1 < this.OldFavIndex.Count ? this.OldFavIndex[subListIndex - 1] : -1;
}
/// <summary>
@@ -331,10 +324,14 @@ namespace ChanSort.Api
/// </summary>
public void SetPosition(int subListIndex, int newPos)
{
if (subListIndex < 0)
return;
if (subListIndex == 0)
this.NewProgramNr = newPos;
else
{
for (int i=this.FavIndex.Count; i<=subListIndex;i++)
this.FavIndex.Add(-1);
this.FavIndex[subListIndex - 1] = newPos;
int mask = 1 << (subListIndex - 1);
if (newPos == -1)
@@ -349,10 +346,16 @@ namespace ChanSort.Api
/// </summary>
public void SetOldPosition(int subListIndex, int oldPos)
{
if (subListIndex < 0)
return;
if (subListIndex == 0)
this.OldProgramNr = oldPos;
else
{
for (int i = this.OldFavIndex.Count; i <= subListIndex; i++)
this.OldFavIndex.Add(-1);
this.OldFavIndex[subListIndex - 1] = oldPos;
}
}
/// <summary>
@@ -363,7 +366,11 @@ namespace ChanSort.Api
if (subListIndex == 0)
this.NewProgramNr += delta;
else
this.FavIndex[subListIndex - 1] += delta;
{
for (int i = this.FavIndex.Count; i <= subListIndex; i++)
this.FavIndex.Add(-1);
this.FavIndex[subListIndex - 1] += delta;
}
}
#endregion
}

View File

@@ -12,6 +12,8 @@ namespace ChanSort.Api
private int insertProgramNr = 1;
private int duplicateUidCount;
private int duplicateProgNrCount;
public int FavListCount { get; set; }
public static List<string> DefaultVisibleColumns { get; set; } = new List<string>(); // initialized by MainForm

View File

@@ -17,7 +17,6 @@ namespace ChanSort.Api
public bool IsEmpty => this.channelLists.Count == 0;
public bool NeedsSaving { get; set; }
public Favorites SupportedFavorites => this.loader.Features.SupportedFavorites;
public bool SortedFavorites => this.loader.Features.SortedFavorites;
public bool MixedSourceFavorites => this.loader.Features.MixedSourceFavorites;
@@ -111,6 +110,12 @@ namespace ChanSort.Api
{
foreach (var list in this.ChannelLists)
{
if (list.FavListCount == 0)
{
for (ulong m = (ulong) this.loader.Features.SupportedFavorites; m != 0; m >>= 1)
++list.FavListCount;
}
if (list.IsMixedSourceFavoritesList)
{
loader.Features.SortedFavorites = true; // all mixed source favorite lists must support ordering
@@ -142,7 +147,7 @@ namespace ChanSort.Api
int c = 0;
if (this.MixedSourceFavorites || this.SortedFavorites)
{
for (int m = (int) this.SupportedFavorites; m != 0; m >>= 1)
for (ulong m = (ulong) this.SupportedFavorites; m != 0; m >>= 1)
++c;
}
@@ -265,7 +270,7 @@ namespace ChanSort.Api
var hasCaption = favListCaptions.TryGetValue(favIndex, out var caption);
if (!asTabCaption)
return caption;
var letter = (char)('A' + favIndex);
var letter = favIndex < 26 ? ((char)('A' + favIndex)).ToString() : (favIndex + 1).ToString();
return hasCaption && !string.IsNullOrEmpty(caption) ? letter + ": " + caption : "Fav " + letter;
}
#endregion

View File

@@ -76,7 +76,7 @@ namespace ChanSort.Api
#endregion
[Flags]
public enum Favorites : byte { A = 0x01, B = 0x02, C = 0x04, D = 0x08, E = 0x10, F=0x20, G=0x40, H=0x80 }
public enum Favorites : long { A = 0x01, B = 0x02, C = 0x04, D = 0x08, E = 0x10, F=0x20, G=0x40, H=0x80 }
public enum UnsortedChannelMode
{