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
VDR Version < 2.1.8 {percentseen} is set to -1.
- 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
debug CDATA #IMPLIED
condition CDATA #IMPLIED
mode CDATA #IMPLIED
>
<!ELEMENT currentweather (area|areascroll)*>

View File

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

View File

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

View File

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

View File

@ -229,6 +229,14 @@ bool cTemplateView::DetachViewElement(eViewElement ve) {
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 numElements = 0;
cTemplateViewList *menuList = GetViewList(vlMenuItem);
@ -626,6 +634,7 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("fadetime");
attributes.insert("name");
attributes.insert("condition");
attributes.insert("mode");
funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "area";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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