mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
display always newest recording of folders in recordings list
This commit is contained in:
parent
3ef0db807d
commit
4d0e2e731a
2
HISTORY
2
HISTORY
@ -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"
|
||||
- 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
|
||||
- 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
|
@ -11,6 +11,7 @@ private:
|
||||
cString _name;
|
||||
time_t _latest;
|
||||
int _count;
|
||||
cString _latestFileName;
|
||||
|
||||
void UpdateData(cRecording *Recording);
|
||||
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->FullName = FullName;
|
||||
this->Latest = Latest;
|
||||
this->Count = Count;
|
||||
this->LatestFileName= LatestFileName;
|
||||
}
|
||||
|
||||
|
||||
@ -65,8 +67,15 @@ void cRecordingsFolderInfo::Rebuild(void)
|
||||
_recordings.StateChanged(_recState);
|
||||
cFolderInfoIntern *info;
|
||||
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);
|
||||
free(folderName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,6 +106,7 @@ cRecordingsFolderInfo::cFolderInfoIntern::cFolderInfoIntern(cFolderInfoIntern *P
|
||||
,_name(Name)
|
||||
,_latest(0)
|
||||
,_count(0)
|
||||
,_latestFileName("")
|
||||
{
|
||||
_subFolders = new cList<cFolderInfoIntern>();
|
||||
}
|
||||
@ -145,8 +155,10 @@ void cRecordingsFolderInfo::cFolderInfoIntern::UpdateData(cRecording *Recording)
|
||||
|
||||
// update date if newer
|
||||
time_t recdate = Recording->Start();
|
||||
if (_latest < recdate)
|
||||
if (_latest < recdate) {
|
||||
_latest = recdate;
|
||||
_latestFileName = Recording->FileName();
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return new cRecordingsFolderInfo::cFolderInfo(*_name, *FullName(), _latest, _count);
|
||||
return new cRecordingsFolderInfo::cFolderInfo(*_name, *FullName(), _latest, _count, *_latestFileName);
|
||||
}
|
||||
|
||||
cString cRecordingsFolderInfo::cFolderInfoIntern::FullName(void) const
|
||||
|
@ -23,8 +23,9 @@ public:
|
||||
cString FullName;
|
||||
time_t Latest;
|
||||
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);
|
||||
|
@ -531,15 +531,29 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
|
||||
} catch (...) {
|
||||
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()));
|
||||
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>("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;
|
||||
|
||||
stringTokens.insert(pair<string,string>("shorttext", info->ShortText() ? info->ShortText() : ""));
|
||||
@ -548,23 +562,12 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
|
||||
const cEvent *event = info->GetEvent();
|
||||
if (!event) return;
|
||||
|
||||
string recDate = "";
|
||||
string recTime = "";
|
||||
|
||||
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) {
|
||||
time_t start = recording->Start();
|
||||
recDate = *DateString(start);
|
||||
recTime = *TimeString(start);
|
||||
}
|
||||
string recDate = *(event->GetDateString());
|
||||
string recTime = *(event->GetTimeString());
|
||||
if (recDate.find("1970") != string::npos) {
|
||||
time_t start = usedRecording->Start();
|
||||
recDate = *DateString(start);
|
||||
recTime = *TimeString(start);
|
||||
}
|
||||
|
||||
time_t startTime = event->StartTime();
|
||||
@ -574,7 +577,7 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
|
||||
intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
|
||||
|
||||
int duration = event->Duration() / 60;
|
||||
int recDuration = recording->LengthInSeconds();
|
||||
int recDuration = usedRecording->LengthInSeconds();
|
||||
recDuration = (recDuration>0)?(recDuration / 60):0;
|
||||
stringTokens.insert(pair<string,string>("date", recDate.c_str()));
|
||||
stringTokens.insert(pair<string,string>("time", recTime.c_str()));
|
||||
|
@ -635,36 +635,38 @@ void cDisplayMenuItemRecordingView::SetTokens(void) {
|
||||
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()));
|
||||
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>("numrecordingsfolder", total));
|
||||
intTokens.insert(pair<string,int>("cutted", recording->IsEdited()));
|
||||
intTokens.insert(pair<string,int>("cutted", usedRecording->IsEdited()));
|
||||
|
||||
const cEvent *event = NULL;
|
||||
const cRecordingInfo *info = recording->Info();
|
||||
const cRecordingInfo *info = usedRecording->Info();
|
||||
if (!info) return;
|
||||
event = info->GetEvent();
|
||||
if (!event) return;
|
||||
|
||||
|
||||
string recDate = "";
|
||||
string recTime = "";
|
||||
|
||||
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) {
|
||||
time_t start = recording->Start();
|
||||
recDate = *DateString(start);
|
||||
recTime = *TimeString(start);
|
||||
}
|
||||
string recDate = *(event->GetDateString());
|
||||
string recTime = *(event->GetTimeString());
|
||||
if (recDate.find("1970") != string::npos) {
|
||||
time_t start = usedRecording->Start();
|
||||
recDate = *DateString(start);
|
||||
recTime = *TimeString(start);
|
||||
}
|
||||
|
||||
time_t startTime = event->StartTime();
|
||||
@ -674,7 +676,7 @@ void cDisplayMenuItemRecordingView::SetTokens(void) {
|
||||
intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
|
||||
|
||||
int duration = event->Duration() / 60;
|
||||
int recDuration = recording->LengthInSeconds();
|
||||
int recDuration = usedRecording->LengthInSeconds();
|
||||
recDuration = (recDuration>0)?(recDuration / 60):0;
|
||||
stringTokens.insert(pair<string,string>("date", recDate.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)));
|
||||
|
||||
static cPlugin *pScraper = GetScraperPlugin();
|
||||
if (!pScraper || !recording) {
|
||||
if (!pScraper || !usedRecording) {
|
||||
intTokens.insert(pair<string,int>("hasposterthumbnail", false));
|
||||
intTokens.insert(pair<string,int>("thumbnailbwidth", -1));
|
||||
intTokens.insert(pair<string,int>("thumbnailheight", -1));
|
||||
@ -696,7 +698,7 @@ void cDisplayMenuItemRecordingView::SetTokens(void) {
|
||||
|
||||
ScraperGetPosterThumb call;
|
||||
call.event = NULL;
|
||||
call.recording = recording;
|
||||
call.recording = usedRecording;
|
||||
if (pScraper->Service("GetPosterThumb", &call)) {
|
||||
intTokens.insert(pair<string,int>("hasposterthumbnail", true));
|
||||
intTokens.insert(pair<string,int>("thumbnailbwidth", call.poster.width));
|
||||
|
Loading…
Reference in New Issue
Block a user