display always newest recording of folders in recordings list

This commit is contained in:
louis 2014-10-19 07:47:42 +02:00
parent 3ef0db807d
commit 4d0e2e731a
5 changed files with 69 additions and 51 deletions

View File

@ -26,4 +26,4 @@ Version 0.0.2
- added setup option to choose Menu Item display method between "at one go" and "after one another" - added setup option to choose Menu Item display method between "at one go" and "after one another"
- fixed bug that new skin was not properly loaded sometimes when skin was changed in OSD Setup menu - fixed bug that new skin was not properly loaded sometimes when skin was changed in OSD Setup menu
- fixed bug that new font was displayed first after VDR restart when font was changed in OSD Setup menu - fixed bug that new font was displayed first after VDR restart when font was changed in OSD Setup menu
- added date of newest recording in a folder, thanks@ Lars Hanisch for providing the patch - display always newest recording of folders in recordings list, thanks@ Lars Hanisch for providing the patch

View File

@ -11,6 +11,7 @@ private:
cString _name; cString _name;
time_t _latest; time_t _latest;
int _count; int _count;
cString _latestFileName;
void UpdateData(cRecording *Recording); void UpdateData(cRecording *Recording);
cFolderInfoIntern *FindSubFolder(const char *Name) const; cFolderInfoIntern *FindSubFolder(const char *Name) const;
@ -33,12 +34,13 @@ public:
}; };
cRecordingsFolderInfo::cFolderInfo::cFolderInfo(const char *Name, const char *FullName, time_t Latest, int Count) cRecordingsFolderInfo::cFolderInfo::cFolderInfo(const char *Name, const char *FullName, time_t Latest, int Count, const char *LatestFileName)
{ {
this->Name = Name; this->Name = Name;
this->FullName = FullName; this->FullName = FullName;
this->Latest = Latest; this->Latest = Latest;
this->Count = Count; this->Count = Count;
this->LatestFileName= LatestFileName;
} }
@ -65,8 +67,15 @@ void cRecordingsFolderInfo::Rebuild(void)
_recordings.StateChanged(_recState); _recordings.StateChanged(_recState);
cFolderInfoIntern *info; cFolderInfoIntern *info;
for (cRecording *rec = _recordings.First(); rec; rec = _recordings.Next(rec)) { for (cRecording *rec = _recordings.First(); rec; rec = _recordings.Next(rec)) {
info = _root->Find(*rec->Folder(), true); //cRecording::Folder() first available since VDR 2.1.2
cString folder("");
char *folderName = strdup(rec->Name());
if (char *s = strrchr(folderName, FOLDERDELIMCHAR))
folder = cString(folderName, s);
info = _root->Find(*folder, true);
//info = _root->Find(*rec->Folder(), true);
info->Add(rec); info->Add(rec);
free(folderName);
} }
} }
@ -97,6 +106,7 @@ cRecordingsFolderInfo::cFolderInfoIntern::cFolderInfoIntern(cFolderInfoIntern *P
,_name(Name) ,_name(Name)
,_latest(0) ,_latest(0)
,_count(0) ,_count(0)
,_latestFileName("")
{ {
_subFolders = new cList<cFolderInfoIntern>(); _subFolders = new cList<cFolderInfoIntern>();
} }
@ -145,8 +155,10 @@ void cRecordingsFolderInfo::cFolderInfoIntern::UpdateData(cRecording *Recording)
// update date if newer // update date if newer
time_t recdate = Recording->Start(); time_t recdate = Recording->Start();
if (_latest < recdate) if (_latest < recdate) {
_latest = recdate; _latest = recdate;
_latestFileName = Recording->FileName();
}
} }
cRecordingsFolderInfo::cFolderInfoIntern *cRecordingsFolderInfo::cFolderInfoIntern::FindSubFolder(const char *Name) const cRecordingsFolderInfo::cFolderInfoIntern *cRecordingsFolderInfo::cFolderInfoIntern::FindSubFolder(const char *Name) const
@ -170,7 +182,7 @@ void cRecordingsFolderInfo::cFolderInfoIntern::Add(cRecording *Recording)
cRecordingsFolderInfo::cFolderInfo *cRecordingsFolderInfo::cFolderInfoIntern::GetInfo(void) const cRecordingsFolderInfo::cFolderInfo *cRecordingsFolderInfo::cFolderInfoIntern::GetInfo(void) const
{ {
return new cRecordingsFolderInfo::cFolderInfo(*_name, *FullName(), _latest, _count); return new cRecordingsFolderInfo::cFolderInfo(*_name, *FullName(), _latest, _count, *_latestFileName);
} }
cString cRecordingsFolderInfo::cFolderInfoIntern::FullName(void) const cString cRecordingsFolderInfo::cFolderInfoIntern::FullName(void) const

View File

@ -23,8 +23,9 @@ public:
cString FullName; cString FullName;
time_t Latest; time_t Latest;
int Count; int Count;
cString LatestFileName;
cFolderInfo(const char *Name, const char *FullName, time_t Latest, int Count); cFolderInfo(const char *Name, const char *FullName, time_t Latest, int Count, const char *LatestFileName);
}; };
cRecordingsFolderInfo(cRecordings &Recordings); cRecordingsFolderInfo(cRecordings &Recordings);

View File

@ -531,15 +531,29 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
} catch (...) { } catch (...) {
buffer = name.c_str(); buffer = name.c_str();
} }
const cRecording *usedRecording = recording;
if (isFolder) {
cRecordingsFolderInfo::cFolderInfo *folderInfo = recFolderInfo.Get(folderName.str().c_str());
if (folderInfo) {
cRecording *newestRec = Recordings.GetByName(*folderInfo->LatestFileName);
if (newestRec) {
usedRecording = newestRec;
}
delete folderInfo;
}
}
stringTokens.insert(pair<string,string>("name", buffer.c_str())); stringTokens.insert(pair<string,string>("name", buffer.c_str()));
intTokens.insert(pair<string,int>("new", recording->IsNew())); intTokens.insert(pair<string,int>("new", usedRecording->IsNew()));
intTokens.insert(pair<string,int>("newrecordingsfolder", newRecs)); intTokens.insert(pair<string,int>("newrecordingsfolder", newRecs));
intTokens.insert(pair<string,int>("numrecordingsfolder", total)); intTokens.insert(pair<string,int>("numrecordingsfolder", total));
intTokens.insert(pair<string,int>("cutted", recording->IsEdited())); intTokens.insert(pair<string,int>("cutted", usedRecording->IsEdited()));
SetScraperPoster(NULL, recording); SetScraperPoster(NULL, usedRecording);
const cRecordingInfo *info = recording->Info(); const cRecordingInfo *info = usedRecording->Info();
if (!info) return; if (!info) return;
stringTokens.insert(pair<string,string>("shorttext", info->ShortText() ? info->ShortText() : "")); stringTokens.insert(pair<string,string>("shorttext", info->ShortText() ? info->ShortText() : ""));
@ -548,24 +562,13 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
const cEvent *event = info->GetEvent(); const cEvent *event = info->GetEvent();
if (!event) return; if (!event) return;
string recDate = ""; string recDate = *(event->GetDateString());
string recTime = ""; string recTime = *(event->GetTimeString());
if (isFolder) {
cRecordingsFolderInfo::cFolderInfo *folderInfo = recFolderInfo.Get(folderName.str().c_str());
if (folderInfo) {
recDate = *DateString(folderInfo->Latest);
recTime = *TimeString(folderInfo->Latest);
}
} else {
recDate = *(event->GetDateString());
recTime = *(event->GetTimeString());
if (recDate.find("1970") != string::npos) { if (recDate.find("1970") != string::npos) {
time_t start = recording->Start(); time_t start = usedRecording->Start();
recDate = *DateString(start); recDate = *DateString(start);
recTime = *TimeString(start); recTime = *TimeString(start);
} }
}
time_t startTime = event->StartTime(); time_t startTime = event->StartTime();
struct tm * sStartTime = localtime(&startTime); struct tm * sStartTime = localtime(&startTime);
@ -574,7 +577,7 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1)); intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
int duration = event->Duration() / 60; int duration = event->Duration() / 60;
int recDuration = recording->LengthInSeconds(); int recDuration = usedRecording->LengthInSeconds();
recDuration = (recDuration>0)?(recDuration / 60):0; recDuration = (recDuration>0)?(recDuration / 60):0;
stringTokens.insert(pair<string,string>("date", recDate.c_str())); stringTokens.insert(pair<string,string>("date", recDate.c_str()));
stringTokens.insert(pair<string,string>("time", recTime.c_str())); stringTokens.insert(pair<string,string>("time", recTime.c_str()));

View File

@ -635,37 +635,39 @@ void cDisplayMenuItemRecordingView::SetTokens(void) {
buffer = name.c_str(); buffer = name.c_str();
} }
const cRecording *usedRecording = recording;
if (isFolder) {
cRecordingsFolderInfo::cFolderInfo *folderInfo = recFolderInfo.Get(folderName.str().c_str());
if (folderInfo) {
cRecording *newestRec = Recordings.GetByName(*folderInfo->LatestFileName);
if (newestRec) {
usedRecording = newestRec;
}
delete folderInfo;
}
}
stringTokens.insert(pair<string,string>("name", buffer.c_str())); stringTokens.insert(pair<string,string>("name", buffer.c_str()));
intTokens.insert(pair<string,int>("new", recording->IsNew())); intTokens.insert(pair<string,int>("new", usedRecording->IsNew()));
intTokens.insert(pair<string,int>("newrecordingsfolder", newRecs)); intTokens.insert(pair<string,int>("newrecordingsfolder", newRecs));
intTokens.insert(pair<string,int>("numrecordingsfolder", total)); intTokens.insert(pair<string,int>("numrecordingsfolder", total));
intTokens.insert(pair<string,int>("cutted", recording->IsEdited())); intTokens.insert(pair<string,int>("cutted", usedRecording->IsEdited()));
const cEvent *event = NULL; const cEvent *event = NULL;
const cRecordingInfo *info = recording->Info(); const cRecordingInfo *info = usedRecording->Info();
if (!info) return; if (!info) return;
event = info->GetEvent(); event = info->GetEvent();
if (!event) return; if (!event) return;
string recDate = ""; string recDate = *(event->GetDateString());
string recTime = ""; string recTime = *(event->GetTimeString());
if (isFolder) {
cRecordingsFolderInfo::cFolderInfo *folderInfo = recFolderInfo.Get(folderName.str().c_str());
if (folderInfo) {
recDate = *DateString(folderInfo->Latest);
recTime = *TimeString(folderInfo->Latest);
}
} else {
recDate = *(event->GetDateString());
recTime = *(event->GetTimeString());
if (recDate.find("1970") != string::npos) { if (recDate.find("1970") != string::npos) {
time_t start = recording->Start(); time_t start = usedRecording->Start();
recDate = *DateString(start); recDate = *DateString(start);
recTime = *TimeString(start); recTime = *TimeString(start);
} }
}
time_t startTime = event->StartTime(); time_t startTime = event->StartTime();
struct tm * sStartTime = localtime(&startTime); struct tm * sStartTime = localtime(&startTime);
@ -674,7 +676,7 @@ void cDisplayMenuItemRecordingView::SetTokens(void) {
intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1)); intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
int duration = event->Duration() / 60; int duration = event->Duration() / 60;
int recDuration = recording->LengthInSeconds(); int recDuration = usedRecording->LengthInSeconds();
recDuration = (recDuration>0)?(recDuration / 60):0; recDuration = (recDuration>0)?(recDuration / 60):0;
stringTokens.insert(pair<string,string>("date", recDate.c_str())); stringTokens.insert(pair<string,string>("date", recDate.c_str()));
stringTokens.insert(pair<string,string>("time", recTime.c_str())); stringTokens.insert(pair<string,string>("time", recTime.c_str()));
@ -686,7 +688,7 @@ void cDisplayMenuItemRecordingView::SetTokens(void) {
stringTokens.insert(pair<string,string>("durationeventminutes", *cString::sprintf("%.2d", duration%60))); stringTokens.insert(pair<string,string>("durationeventminutes", *cString::sprintf("%.2d", duration%60)));
static cPlugin *pScraper = GetScraperPlugin(); static cPlugin *pScraper = GetScraperPlugin();
if (!pScraper || !recording) { if (!pScraper || !usedRecording) {
intTokens.insert(pair<string,int>("hasposterthumbnail", false)); intTokens.insert(pair<string,int>("hasposterthumbnail", false));
intTokens.insert(pair<string,int>("thumbnailbwidth", -1)); intTokens.insert(pair<string,int>("thumbnailbwidth", -1));
intTokens.insert(pair<string,int>("thumbnailheight", -1)); intTokens.insert(pair<string,int>("thumbnailheight", -1));
@ -696,7 +698,7 @@ void cDisplayMenuItemRecordingView::SetTokens(void) {
ScraperGetPosterThumb call; ScraperGetPosterThumb call;
call.event = NULL; call.event = NULL;
call.recording = recording; call.recording = usedRecording;
if (pScraper->Service("GetPosterThumb", &call)) { if (pScraper->Service("GetPosterThumb", &call)) {
intTokens.insert(pair<string,int>("hasposterthumbnail", true)); intTokens.insert(pair<string,int>("hasposterthumbnail", true));
intTokens.insert(pair<string,int>("thumbnailbwidth", call.poster.width)); intTokens.insert(pair<string,int>("thumbnailbwidth", call.poster.width));