summaryrefslogtreecommitdiff
path: root/command/marks.cpp
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2010-05-15 21:37:48 +0200
committerJochen Dolze <vdr@dolze.de>2010-05-15 21:37:48 +0200
commit9aa6949e5f98e580f91320bb7255f985b5bd6103 (patch)
treef27c7c6f06d662f755a2f04066f0c2844199c46d /command/marks.cpp
parent45a400d45adb2314952eb23dd3a7feb6c4b9526c (diff)
downloadvdr-plugin-markad-9aa6949e5f98e580f91320bb7255f985b5bd6103.tar.gz
vdr-plugin-markad-9aa6949e5f98e580f91320bb7255f985b5bd6103.tar.bz2
Fixed various things
Diffstat (limited to 'command/marks.cpp')
-rw-r--r--command/marks.cpp56
1 files changed, 39 insertions, 17 deletions
diff --git a/command/marks.cpp b/command/marks.cpp
index d84fafd..6935175 100644
--- a/command/marks.cpp
+++ b/command/marks.cpp
@@ -64,17 +64,23 @@ void clMarks::Del(int Type)
}
}
-void clMarks::Clear()
+void clMarks::Clear(int Before)
{
clMark *next,*mark=first;
while (mark)
{
next=mark->Next();
- Del(mark);
+ if (mark->position<Before)
+ {
+ Del(mark);
+ }
mark=next;
}
- first=NULL;
- last=NULL;
+ if (Before==0x7FFFFFFF)
+ {
+ first=NULL;
+ last=NULL;
+ }
}
void clMarks::Del(clMark *Mark)
@@ -85,6 +91,14 @@ void clMarks::Del(clMark *Mark)
{
// we are the first mark
first=Mark->Next();
+ if (first)
+ {
+ first->SetPrev(NULL);
+ }
+ else
+ {
+ last=NULL;
+ }
}
else
{
@@ -118,28 +132,35 @@ clMark *clMarks::Get(int Position)
return mark;
}
-clMark *clMarks::GetPrev(int Position, int Type)
+clMark *clMarks::GetPrev(int Position, int Type, int Mask)
{
if (!first) return NULL; // no elements yet
+ // first advance
clMark *mark=first;
while (mark)
{
- if (Type==0xFF)
- {
- if (mark->position>=Position) break;
- }
- else
+ if (mark->position>=Position) break;
+ mark=mark->Next();
+ }
+ if (Type==0xFF)
+ {
+ if (mark) return mark->Prev();
+ return last;
+ }
+ else
+ {
+ if (!mark) mark=last;
+ while (mark)
{
- if ((mark->position>=Position) && (mark->type==Type)) break;
+ if ((mark->type & Mask)==Type) break;
+ mark=mark->Prev();
}
- mark=mark->Next();
+ return mark;
}
- if (mark) return mark->Prev();
- return last;
}
-clMark *clMarks::GetNext(int Position, int Type)
+clMark *clMarks::GetNext(int Position, int Type, int Mask)
{
if (!first) return NULL; // no elements yet
clMark *mark=first;
@@ -151,11 +172,12 @@ clMark *clMarks::GetNext(int Position, int Type)
}
else
{
- if ((mark->position>=Position) && (mark->type==Type)) break;
+ if ((mark->position>=Position) && ((mark->type & Mask)==Type)) break;
}
mark=mark->Next();
}
- return mark->Next();
+ if (mark) return mark->Next();
+ return NULL;
}
clMark *clMarks::Add(int Type, int Position,const char *Comment)