added viewelement <lastrecordings> with information about 5 newest recordings in main menu

This commit is contained in:
louis 2015-03-29 13:29:59 +02:00
parent 05912add7a
commit e3ce79dd8c
11 changed files with 172 additions and 3 deletions

View File

@ -239,3 +239,6 @@ Version 0.3.2
Version 0.3.3 Version 0.3.3
- added viewelement <lastrecordings> with information about 5 newest
recordings in main menu

View File

@ -123,6 +123,15 @@
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT lastrecordings (area|areascroll)*>
<!ATTLIST lastrecordings
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT customtokens (area|areascroll)*> <!ELEMENT customtokens (area|areascroll)*>
<!ATTLIST customtokens <!ATTLIST customtokens
detached CDATA #IMPLIED detached CDATA #IMPLIED
@ -165,7 +174,7 @@
<!ELEMENT menumain (background | header | datetime | time | colorbuttons | scrollbar | timers | <!ELEMENT menumain (background | header | datetime | time | colorbuttons | scrollbar | timers |
discusage | devices | systemload | systemmemory | temperatures | currentschedule | discusage | devices | systemload | systemmemory | temperatures | currentschedule |
currentweather | customtokens | menuitems)*> currentweather | lastrecordings | customtokens | menuitems)*>
<!ATTLIST menumain <!ATTLIST menumain
x CDATA #REQUIRED x CDATA #REQUIRED
y CDATA #REQUIRED y CDATA #REQUIRED

View File

@ -1213,6 +1213,7 @@ void cTemplateViewMenu::SetViewElements(void) {
viewElementsAllowed.insert("systemmemory"); viewElementsAllowed.insert("systemmemory");
viewElementsAllowed.insert("temperatures"); viewElementsAllowed.insert("temperatures");
viewElementsAllowed.insert("timers"); viewElementsAllowed.insert("timers");
viewElementsAllowed.insert("lastrecordings");
viewElementsAllowed.insert("devices"); viewElementsAllowed.insert("devices");
viewElementsAllowed.insert("currentweather"); viewElementsAllowed.insert("currentweather");
viewElementsAllowed.insert("currentschedule"); viewElementsAllowed.insert("currentschedule");
@ -1303,13 +1304,16 @@ string cTemplateViewMenu::GetViewElementName(eViewElement ve) {
case veTimers: case veTimers:
name = "Timers"; name = "Timers";
break; break;
case veLastRecordings:
name = "Last Recordings";
break;
case veCurrentSchedule: case veCurrentSchedule:
name = "Current Schedule"; name = "Current Schedule";
break; break;
case veCurrentWeather: case veCurrentWeather:
name = "Current Weather"; name = "Current Weather";
break; break;
case veCustomTokens: case veCustomTokens:
name = "Custom Tokens"; name = "Custom Tokens";
break; break;
case veDevices: case veDevices:
@ -1424,6 +1428,8 @@ void cTemplateViewMenu::AddPixmap(string sViewElement, cTemplatePixmap *pix, vec
ve = veTemperatures; ve = veTemperatures;
} else if (!sViewElement.compare("timers")) { } else if (!sViewElement.compare("timers")) {
ve = veTimers; ve = veTimers;
} else if (!sViewElement.compare("lastrecordings")) {
ve = veLastRecordings;
} else if (!sViewElement.compare("currentschedule")) { } else if (!sViewElement.compare("currentschedule")) {
ve = veCurrentSchedule; ve = veCurrentSchedule;
} else if (!sViewElement.compare("customtokens")) { } else if (!sViewElement.compare("customtokens")) {

View File

@ -48,6 +48,7 @@ enum eViewElement {
veSystemMemory, veSystemMemory,
veTemperatures, veTemperatures,
veTimers, veTimers,
veLastRecordings,
veCurrentSchedule, veCurrentSchedule,
veMenuItem, veMenuItem,
veMenuCurrentItemDetail, veMenuCurrentItemDetail,

View File

@ -19,6 +19,21 @@
<timers> <timers>
</timers> </timers>
<!-- Available Variables lastrecordings: 5 newest recordings
{recordings[]} array with 5 newest recordings
{recordings[name]} name of recording
{recordings[seriesname]} series name if available
{recordings[date]} date of recording in dd.mm.yy
{recordings[time]} time of recording in hh:mm
{recordings[duration]} duration of recording in minutes
{recordings[hasposter]} true if poster available
{recordings[posterpath]} path of poster if available
{recordings[posterwidth]} width of poster
{recordings[posterheight]} height of poster
-->
<lastrecordings>
</lastrecordings>
<!-- Available Variables discusage: <!-- Available Variables discusage:
{freetime} available disc capacity in hh:mm {freetime} available disc capacity in hh:mm
{freepercent} available disc capacity in percent {freepercent} available disc capacity in percent

View File

@ -205,6 +205,7 @@ cDisplayMenuMainView::~cDisplayMenuMainView() {
void cDisplayMenuMainView::DrawStaticViewElements(void) { void cDisplayMenuMainView::DrawStaticViewElements(void) {
DrawTimers(); DrawTimers();
DrawLastRecordings();
DrawDiscUsage(); DrawDiscUsage();
DrawTemperatures(); DrawTemperatures();
DrawCurrentSchedule(); DrawCurrentSchedule();
@ -250,6 +251,35 @@ void cDisplayMenuMainView::DrawTimers(void) {
} }
} }
void cDisplayMenuMainView::DrawLastRecordings(void) {
if (!ExecuteViewElement(veLastRecordings)) {
return;
}
if (DetachViewElement(veLastRecordings)) {
cViewElement *viewElement = GetViewElement(veLastRecordings);
if (!viewElement) {
viewElement = new cViewElementLastRecordings(tmplView->GetViewElement(veLastRecordings));
AddViewElement(veLastRecordings, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > recordingLoopTokens;
vector< map< string, string > > lastRecordings;
SetLastRecordings(&intTokens, &stringTokens, &lastRecordings);
recordingLoopTokens.insert(pair< string, vector< map< string, string > > >("recordings", lastRecordings));
ClearViewElement(veLastRecordings);
DrawViewElement(veLastRecordings, &stringTokens, &intTokens, &recordingLoopTokens);
}
}
void cDisplayMenuMainView::DrawDiscUsage(void) { void cDisplayMenuMainView::DrawDiscUsage(void) {
if (!ExecuteViewElement(veDiscUsage)) { if (!ExecuteViewElement(veDiscUsage)) {
return; return;

View File

@ -38,6 +38,7 @@ class cDisplayMenuMainView : public cDisplayMenuView {
private: private:
bool initial; bool initial;
void DrawTimers(void); void DrawTimers(void);
void DrawLastRecordings(void);
void DrawDiscUsage(void); void DrawDiscUsage(void);
bool DrawLoad(void); bool DrawLoad(void);
bool DrawMemory(void); bool DrawMemory(void);

View File

@ -129,7 +129,6 @@ bool cViewElementTimers::Render(void) {
vector< map< string, string > > timers; vector< map< string, string > > timers;
SetTimers(&intTokens, &stringTokens, &timers); SetTimers(&intTokens, &stringTokens, &timers);
timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers)); timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers));
ClearViewElement(veTimers); ClearViewElement(veTimers);
@ -139,6 +138,24 @@ bool cViewElementTimers::Render(void) {
/********************************************************************************************************************/ /********************************************************************************************************************/
cViewElementLastRecordings::cViewElementLastRecordings(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementLastRecordings::Render(void) {
ClearTokens();
map < string, vector< map< string, string > > > recordingLoopTokens;
vector< map< string, string > > lastRecordings;
SetLastRecordings(&intTokens, &stringTokens, &lastRecordings);
recordingLoopTokens.insert(pair< string, vector< map< string, string > > >("recordings", lastRecordings));
ClearViewElement(veLastRecordings);
DrawViewElement(veLastRecordings, &stringTokens, &intTokens, &recordingLoopTokens);
return true;
}
/********************************************************************************************************************/
cViewElementDiscUsage::cViewElementDiscUsage(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) { cViewElementDiscUsage::cViewElementDiscUsage(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
} }

View File

@ -78,6 +78,14 @@ public:
bool Render(void); bool Render(void);
}; };
class cViewElementLastRecordings : public cViewElement, public cViewHelpers {
private:
public:
cViewElementLastRecordings(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementLastRecordings() {};
bool Render(void);
};
class cViewElementDiscUsage : public cViewElement, public cViewHelpers { class cViewElementDiscUsage : public cViewElement, public cViewHelpers {
private: private:
public: public:

View File

@ -612,6 +612,45 @@ 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();
int found = 0;
for (cRecording *recording = Recordings.Last(); recording; recording = Recordings.Prev(recording)) {
map< string, string > recVals;
string recFullPath = recording->Name() ? recording->Name() : "";
string recName = "";
string recPath = "";
RecName(recFullPath, recName, recPath);
stringstream recDuration;
int dur = recording->LengthInSeconds()/60;
recDuration << dur;
string posterPath = "";
int posterWidth = 0;
int posterHeight = 0;
bool hasPoster = false;
RecPoster(recording, posterWidth, posterHeight, posterPath, hasPoster);
stringstream sPosterWidth;
sPosterWidth << posterWidth;
stringstream sPosterHeight;
sPosterHeight << posterHeight;
string sHasPoster = hasPoster ? "1" : "0";
recVals.insert(pair< string, string >("recordings[name]", recName));
recVals.insert(pair< string, string >("recordings[seriesname]", recPath));
recVals.insert(pair< string, string >("recordings[date]", *ShortDateString(recording->Start())));
recVals.insert(pair< string, string >("recordings[time]", *TimeString(recording->Start())));
recVals.insert(pair< string, string >("recordings[duration]", recDuration.str()));
recVals.insert(pair< string, string >("recordings[hasposter]", sHasPoster));
recVals.insert(pair< string, string >("recordings[posterpath]", posterPath));
recVals.insert(pair< string, string >("recordings[posterwidth]", sPosterWidth.str()));
recVals.insert(pair< string, string >("recordings[posterheight]", sPosterHeight.str()));
lastRecordings->push_back(recVals);
found++;
if (found == 5)
break;
}
}
void cViewHelpers::SetMenuHeader(eMenuCategory cat, string menuTitle, map < string, string > &stringTokens, map < string, int > &intTokens) { void cViewHelpers::SetMenuHeader(eMenuCategory cat, string menuTitle, map < string, string > &stringTokens, map < string, int > &intTokens) {
stringTokens.insert(pair<string,string>("title", menuTitle)); stringTokens.insert(pair<string,string>("title", menuTitle));
stringTokens.insert(pair<string,string>("vdrversion", VDRVERSION)); stringTokens.insert(pair<string,string>("vdrversion", VDRVERSION));
@ -845,3 +884,40 @@ void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map
stringTokens.insert(pair<string,string>("bannerpath", bannerPath)); stringTokens.insert(pair<string,string>("bannerpath", bannerPath));
intTokens.insert(pair<string,int>("hasbanner", hasBanner)); intTokens.insert(pair<string,int>("hasbanner", hasBanner));
} }
void cViewHelpers::RecName(string &path, string &name, string &folder) {
size_t delim = path.find_last_of('~');
if (delim == string::npos) {
name = path;
if (name.find('%') == 0) {
name = name.substr(1);
}
return;
}
name = path.substr(delim+1);
if (name.find('%') == 0) {
name = name.substr(1);
}
folder = path.substr(0, delim);
size_t delim2 = folder.find_last_of('~');
if (delim2 == string::npos) {
return;
}
folder = folder.substr(delim2+1);
}
void cViewHelpers::RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster) {
static cPlugin *pScraper = GetScraperPlugin();
if (!pScraper)
return;
ScraperGetPoster callPoster;
callPoster.event = NULL;
callPoster.recording = rec;
if (pScraper->Service("GetPoster", &callPoster)) {
posterWidth = callPoster.poster.width;
posterHeight = callPoster.poster.height;
path = callPoster.poster.path;
hasPoster = true;
}
}

View File

@ -15,6 +15,8 @@ private:
int lastMinute; int lastMinute;
double lastSystemLoad; double lastSystemLoad;
int lastMemUsage; int lastMemUsage;
void RecName(string &path, string &name, string &folder);
void RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster);
protected: protected:
void InitDevices(void); void InitDevices(void);
bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices); bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices);
@ -26,6 +28,7 @@ protected:
bool SetDate(map < string, string > &stringTokens, map < string, int > &intTokens); bool SetDate(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens); bool SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens);
void SetTimers(map<string,int> *intTokens, map<string,string> *stringTokens, vector<map<string,string> > *timers); void SetTimers(map<string,int> *intTokens, map<string,string> *stringTokens, vector<map<string,string> > *timers);
void SetLastRecordings(map<string,int> *intTokens, map<string,string> *stringTokens, vector<map<string,string> > *lastRecordings);
void SetMenuHeader(eMenuCategory cat, string menuTitle, map < string, string > &stringTokens, map < string, int > &intTokens); void SetMenuHeader(eMenuCategory cat, string menuTitle, map < string, string > &stringTokens, map < string, int > &intTokens);
void SetDiscUsage(map < string, string > &stringTokens, map < string, int > &intTokens); void SetDiscUsage(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetSystemLoad(map < string, string > &stringTokens, map < string, int > &intTokens); bool SetSystemLoad(map < string, string > &stringTokens, map < string, int > &intTokens);