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

@@ -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);