added parameter mode to viewelement <devices>

This commit is contained in:
louis 2015-04-01 13:26:36 +02:00
parent 25505767d3
commit 7c9ad39e95
17 changed files with 61 additions and 14 deletions

View File

@ -256,3 +256,5 @@ Version 0.3.3
- added Token {percentseen} to listelements in menurecordings. For - added Token {percentseen} to listelements in menurecordings. For
VDR Version < 2.1.8 {percentseen} is set to -1. VDR Version < 2.1.8 {percentseen} is set to -1.
- added Token {timers[isremotetimer]} to <timers> in main menu - added Token {timers[isremotetimer]} to <timers> in main menu
- added parameter mode to viewelement <devices>. if mode="light"
no signal information will be fetched to improve performance.

View File

@ -91,6 +91,7 @@
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
mode CDATA #IMPLIED
> >
<!ELEMENT currentweather (area|areascroll)*> <!ELEMENT currentweather (area|areascroll)*>

View File

@ -82,6 +82,7 @@
fadetime CDATA #IMPLIED fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
mode CDATA #IMPLIED
> >
<!ELEMENT systemload (area|areascroll)*> <!ELEMENT systemload (area|areascroll)*>

View File

@ -53,6 +53,8 @@ void cTemplateFunction::SetParameters(vector<pair<string, string> > params) {
p.first = ptCond; p.first = ptCond;
} else if (!name.compare("name")) { } else if (!name.compare("name")) {
p.first = ptName; p.first = ptName;
} else if (!name.compare("mode")) {
p.first = ptMode;
} else if (!name.compare("x")) { } else if (!name.compare("x")) {
p.first = ptX; p.first = ptX;
} else if (!name.compare("y")) { } else if (!name.compare("y")) {
@ -1488,6 +1490,9 @@ string cTemplateFunction::GetParamName(eParamType pt) {
case ptName: case ptName:
name = "Name"; name = "Name";
break; break;
case ptMode:
name = "Mode";
break;
case ptX: case ptX:
name = "X"; name = "X";
break; break;

View File

@ -40,6 +40,7 @@ enum eFuncType {
enum eParamType { enum eParamType {
ptCond, ptCond,
ptName, ptName,
ptMode,
ptX, ptX,
ptY, ptY,
ptWidth, ptWidth,

View File

@ -229,6 +229,14 @@ bool cTemplateView::DetachViewElement(eViewElement ve) {
return viewElement->Detach(); return viewElement->Detach();
} }
string cTemplateView::GetViewElementMode(eViewElement ve) {
map < eViewElement, cTemplateViewElement* >::iterator hit = viewElements.find(ve);
if (hit == viewElements.end())
return "";
cTemplateViewElement *viewElement = hit->second;
return viewElement->GetMode();
}
int cTemplateView::GetNumListViewMenuItems(void) { int cTemplateView::GetNumListViewMenuItems(void) {
int numElements = 0; int numElements = 0;
cTemplateViewList *menuList = GetViewList(vlMenuItem); cTemplateViewList *menuList = GetViewList(vlMenuItem);
@ -626,6 +634,7 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("fadetime"); attributes.insert("fadetime");
attributes.insert("name"); attributes.insert("name");
attributes.insert("condition"); attributes.insert("condition");
attributes.insert("mode");
funcsAllowed.insert(pair< string, set<string> >(name, attributes)); funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "area"; name = "area";

View File

@ -115,6 +115,7 @@ public:
bool HideView(void); bool HideView(void);
bool ExecuteView(eViewElement ve); bool ExecuteView(eViewElement ve);
bool DetachViewElement(eViewElement ve); bool DetachViewElement(eViewElement ve);
string GetViewElementMode(eViewElement ve);
int GetNumListViewMenuItems(void); int GetNumListViewMenuItems(void);
bool GetScalingWindow(cRect &scalingWindow); bool GetScalingWindow(cRect &scalingWindow);
map<string,string> GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); }; map<string,string> GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); };

View File

@ -133,6 +133,12 @@ bool cTemplateViewElement::Detach(void) {
return false; return false;
} }
string cTemplateViewElement::GetMode(void) {
if (!parameters)
return "";
return parameters->GetParameter(ptMode);
}
bool cTemplateViewElement::DebugTokens(void) { bool cTemplateViewElement::DebugTokens(void) {
if (!parameters) if (!parameters)
return false; return false;

View File

@ -111,6 +111,7 @@ public:
cTemplateFunction *GetFunction(string name); cTemplateFunction *GetFunction(string name);
bool Execute(void); bool Execute(void);
bool Detach(void); bool Detach(void);
string GetMode(void);
bool DebugTokens(void); bool DebugTokens(void);
virtual void Debug(void); virtual void Debug(void);
}; };

View File

@ -107,6 +107,7 @@
</signalqualityback> </signalqualityback>
<!-- Available Variables devices: <!-- Available Variables devices:
signalstrength and -quality are only set if not mode="light" is used in <devices>
{numdevices} number of available devices {numdevices} number of available devices
{devices[]} array with available devices {devices[]} array with available devices
{devices[num]} number of current device {devices[num]} number of current device
@ -124,7 +125,7 @@
{devices[channelid]} ID of the currently tuned channel {devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel {devices[source]} source of the currently tuned channel
--> -->
<devices> <devices mode="full|light">
</devices> </devices>
<!-- Available Variables currentweather: <!-- Available Variables currentweather:

View File

@ -47,6 +47,7 @@
</discusage> </discusage>
<!-- Available Variables devices: <!-- Available Variables devices:
signalstrength and -quality are only set if not mode="light" is used in <devices>
{numdevices} number of available devices {numdevices} number of available devices
{devices[]} array with available devices {devices[]} array with available devices
{devices[num]} number of current device {devices[num]} number of current device
@ -64,7 +65,7 @@
{devices[channelid]} ID of the currently tuned channel {devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel {devices[source]} source of the currently tuned channel
--> -->
<devices> <devices mode="full|light">
</devices> </devices>
<!-- Available Variables systemload: <!-- Available Variables systemload:

View File

@ -409,11 +409,15 @@ void cDisplayChannelView::DrawDevices(bool initial) {
if (!ExecuteViewElement(veDevices)) { if (!ExecuteViewElement(veDevices)) {
return; return;
} }
string mode = tmplView->GetViewElementMode(veDevices);
bool light = false;
if (!mode.compare("light")) {
light = true;
}
if (DetachViewElement(veDevices)) { if (DetachViewElement(veDevices)) {
cViewElement *viewElement = GetViewElement(veDevices); cViewElement *viewElement = GetViewElement(veDevices);
if (!viewElement) { if (!viewElement) {
viewElement = new cViewElementDevices(tmplView->GetViewElement(veDevices)); viewElement = new cViewElementDevices(light, tmplView->GetViewElement(veDevices));
AddViewElement(veDevices, viewElement); AddViewElement(veDevices, viewElement);
viewElement->Start(); viewElement->Start();
} else { } else {
@ -426,7 +430,7 @@ void cDisplayChannelView::DrawDevices(bool initial) {
map < string, vector< map< string, string > > > deviceLoopTokens; map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices; vector< map< string, string > > devices;
bool changed = SetDevices(initial, &intTokens, &devices); bool changed = SetDevices(initial, light, &intTokens, &devices);
if (!changed) if (!changed)
return; return;

View File

@ -423,11 +423,16 @@ bool cDisplayMenuMainView::DrawDevices(void) {
if (!ExecuteViewElement(veDevices)) { if (!ExecuteViewElement(veDevices)) {
return false; return false;
} }
string mode = tmplView->GetViewElementMode(veDevices);
bool light = false;
if (!mode.compare("light")) {
light = true;
}
bool changed = false; bool changed = false;
if (DetachViewElement(veDevices)) { if (DetachViewElement(veDevices)) {
cViewElement *viewElement = GetViewElement(veDevices); cViewElement *viewElement = GetViewElement(veDevices);
if (!viewElement) { if (!viewElement) {
viewElement = new cViewElementDevices(tmplView->GetViewElement(veDevices)); viewElement = new cViewElementDevices(light, tmplView->GetViewElement(veDevices));
AddViewElement(veDevices, viewElement); AddViewElement(veDevices, viewElement);
viewElement->Start(); viewElement->Start();
changed = true; changed = true;
@ -441,7 +446,7 @@ bool cDisplayMenuMainView::DrawDevices(void) {
map < string, vector< map< string, string > > > deviceLoopTokens; map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices; vector< map< string, string > > devices;
changed = SetDevices(initial, &intTokens, &devices); changed = SetDevices(initial, light, &intTokens, &devices);
if (!changed) if (!changed)
return false; return false;

View File

@ -1,6 +1,7 @@
#include "displayviewelements.h" #include "displayviewelements.h"
cViewElementDevices::cViewElementDevices(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) { cViewElementDevices::cViewElementDevices(bool light, cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
this->light = light;
init = true; init = true;
} }
@ -11,7 +12,7 @@ bool cViewElementDevices::Render(void) {
if (init) if (init)
InitDevices(); InitDevices();
bool changed = SetDevices(init, &intTokens, &devices); bool changed = SetDevices(init, light, &intTokens, &devices);
init = false; init = false;
if (!changed) if (!changed)

View File

@ -8,8 +8,9 @@
class cViewElementDevices : public cViewElement, public cViewHelpers { class cViewElementDevices : public cViewElement, public cViewHelpers {
private: private:
bool init; bool init;
bool light;
public: public:
cViewElementDevices(cTemplateViewElement *tmplViewElement); cViewElementDevices(bool light, cTemplateViewElement *tmplViewElement);
virtual ~cViewElementDevices() {}; virtual ~cViewElementDevices() {};
bool Render(void); bool Render(void);
}; };

View File

@ -43,8 +43,10 @@ void cViewHelpers::InitDevices(void) {
devicesInit = true; devicesInit = true;
} }
bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices) { bool cViewHelpers::SetDevices(bool initial, bool light, map<string,int> *intTokens, vector<map<string,string> > *devices) {
if (!initial) { if (!initial) {
if (light)
return false;
//check if drawing is necessary //check if drawing is necessary
bool changed = false; bool changed = false;
for (int i = 0; i < numDevices; i++) { for (int i = 0; i < numDevices; i++) {
@ -105,11 +107,16 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m
} else { } else {
deviceVals.insert(pair< string, string >("devices[hascam]", "0")); deviceVals.insert(pair< string, string >("devices[hascam]", "0"));
} }
int signalStrength = device->SignalStrength();
int signalQuality = device->SignalQuality();
stringstream strCamNumber; stringstream strCamNumber;
strCamNumber << camNumber; strCamNumber << camNumber;
deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str())); deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str()));
int signalStrength = 0;
int signalQuality = 0;
if (!light) {
signalStrength = device->SignalStrength();
signalQuality = device->SignalQuality();
}
stringstream strStrength; stringstream strStrength;
strStrength << signalStrength; strStrength << signalStrength;
deviceVals.insert(pair< string, string >("devices[signalstrength]", strStrength.str())); deviceVals.insert(pair< string, string >("devices[signalstrength]", strStrength.str()));

View File

@ -21,7 +21,7 @@ private:
void SetCurrentScheduleFromRecording(const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens); void SetCurrentScheduleFromRecording(const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens);
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, bool light, map<string,int> *intTokens, vector<map<string,string> > *devices);
bool SetSignal(map < string, int > &intTokens); bool SetSignal(map < string, int > &intTokens);
bool CheckNewMails(void); bool CheckNewMails(void);
void SetScraperTokens(const cEvent *event, const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens, map < string, vector< map< string, string > > > &loopTokens); void SetScraperTokens(const cEvent *event, const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens, map < string, vector< map< string, string > > > &loopTokens);