fixed sort order in lastrecordings viewelement

This commit is contained in:
louis 2015-04-18 18:11:44 +02:00
parent abbdea4b76
commit eb3f8f074d
2 changed files with 26 additions and 3 deletions

View File

@ -298,4 +298,5 @@ Version 0.4.3
- added strequal, strnotequal, strcontains, strnotcontains functions
to compare strings in conditions
- fixed sort order in lastrecordings viewelement

View File

@ -1,5 +1,6 @@
#include <fstream>
#include <iostream>
#include <list>
#include <vdr/menu.h>
#include <vdr/videodir.h>
#include <sys/sysinfo.h>
@ -624,10 +625,31 @@ void cViewHelpers::SetTimers(map<string,int> *intTokens, map<string,string> *str
}
void cViewHelpers::SetLastRecordings(map<string,int> *intTokens, map<string,string> *stringTokens, vector<map<string,string> > *lastRecordings) {
RecordingsSortMode = rsmTime;
Recordings.Sort();
list<cRecording*> orderedRecs;
for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording)) {
if (orderedRecs.size() == 0) {
orderedRecs.push_back(recording);
continue;
}
bool inserted = false;
for (list<cRecording*>::iterator it = orderedRecs.begin(); it != orderedRecs.end(); it++) {
const cRecording *orderedRec = *it;
if (recording->Start() >= orderedRec->Start()) {
orderedRecs.insert(it, recording);
inserted = true;
break;
}
}
if (!inserted) {
orderedRecs.push_back(recording);
}
}
int found = 0;
for (cRecording *recording = Recordings.Last(); recording; recording = Recordings.Prev(recording)) {
for (list<cRecording*>::iterator it = orderedRecs.begin(); it != orderedRecs.end(); it++) {
const cRecording *recording = *it;
#if APIVERSNUM >= 20101
if (recording->IsInUse()) {
continue;