summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2015-03-29 13:29:59 +0200
committerlouis <louis.braun@gmx.de>2015-03-29 13:29:59 +0200
commite3ce79dd8c01222cb65ba1d2190fa463703b9b96 (patch)
treec3928c9aa6ec58e0fab0995483480237b23fb256 /views
parent05912add7a19b78413eb1030669963284ca24dec (diff)
downloadvdr-plugin-skindesigner-e3ce79dd8c01222cb65ba1d2190fa463703b9b96.tar.gz
vdr-plugin-skindesigner-e3ce79dd8c01222cb65ba1d2190fa463703b9b96.tar.bz2
added viewelement <lastrecordings> with information about 5 newest recordings in main menu
Diffstat (limited to 'views')
-rw-r--r--views/displaymenuview.c30
-rw-r--r--views/displaymenuview.h1
-rw-r--r--views/displayviewelements.c19
-rw-r--r--views/displayviewelements.h8
-rw-r--r--views/viewhelpers.c76
-rw-r--r--views/viewhelpers.h3
6 files changed, 136 insertions, 1 deletions
diff --git a/views/displaymenuview.c b/views/displaymenuview.c
index 4e7b0d5..408c088 100644
--- a/views/displaymenuview.c
+++ b/views/displaymenuview.c
@@ -205,6 +205,7 @@ cDisplayMenuMainView::~cDisplayMenuMainView() {
void cDisplayMenuMainView::DrawStaticViewElements(void) {
DrawTimers();
+ DrawLastRecordings();
DrawDiscUsage();
DrawTemperatures();
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) {
if (!ExecuteViewElement(veDiscUsage)) {
return;
diff --git a/views/displaymenuview.h b/views/displaymenuview.h
index dbf8acf..ecea005 100644
--- a/views/displaymenuview.h
+++ b/views/displaymenuview.h
@@ -38,6 +38,7 @@ class cDisplayMenuMainView : public cDisplayMenuView {
private:
bool initial;
void DrawTimers(void);
+ void DrawLastRecordings(void);
void DrawDiscUsage(void);
bool DrawLoad(void);
bool DrawMemory(void);
diff --git a/views/displayviewelements.c b/views/displayviewelements.c
index 61760df..8f2b476 100644
--- a/views/displayviewelements.c
+++ b/views/displayviewelements.c
@@ -129,7 +129,6 @@ bool cViewElementTimers::Render(void) {
vector< map< string, string > > timers;
SetTimers(&intTokens, &stringTokens, &timers);
-
timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers));
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) {
}
diff --git a/views/displayviewelements.h b/views/displayviewelements.h
index 46492f4..5ccf2d9 100644
--- a/views/displayviewelements.h
+++ b/views/displayviewelements.h
@@ -78,6 +78,14 @@ public:
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 {
private:
public:
diff --git a/views/viewhelpers.c b/views/viewhelpers.c
index f5bb1ef..3e50434 100644
--- a/views/viewhelpers.c
+++ b/views/viewhelpers.c
@@ -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) {
stringTokens.insert(pair<string,string>("title", menuTitle));
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));
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;
+ }
+}
+
diff --git a/views/viewhelpers.h b/views/viewhelpers.h
index 4d54677..1223a78 100644
--- a/views/viewhelpers.h
+++ b/views/viewhelpers.h
@@ -15,6 +15,8 @@ private:
int lastMinute;
double lastSystemLoad;
int lastMemUsage;
+ void RecName(string &path, string &name, string &folder);
+ void RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster);
protected:
void InitDevices(void);
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 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 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 SetDiscUsage(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetSystemLoad(map < string, string > &stringTokens, map < string, int > &intTokens);