added weather viewelement to metrix main menu

This commit is contained in:
louis
2015-01-14 14:20:22 +01:00
parent 645f625d79
commit 3de7f8f13d
14 changed files with 138 additions and 40 deletions

View File

@@ -545,7 +545,10 @@ void cDisplayChannelView::DrawCurrentWeather(void) {
}
map < string, string > stringTokens;
map < string, int > intTokens;
SetCurrentWeatherTokens(stringTokens, intTokens);
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather);
return;
}
ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);

View File

@@ -237,6 +237,7 @@ void cDisplayMenuMainView::DrawStaticViewElements(void) {
DrawDiscUsage();
DrawTemperatures();
DrawCurrentSchedule();
DrawCurrentWeather();
DrawCustomTokens();
}
@@ -581,6 +582,21 @@ void cDisplayMenuMainView::DrawCurrentSchedule(void) {
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
}
void cDisplayMenuMainView::DrawCurrentWeather(void) {
if (!ViewElementImplemented(veCurrentWeather)) {
return;
}
map < string, string > stringTokens;
map < string, int > intTokens;
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather);
return;
}
ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
}
void cDisplayMenuMainView::DrawCustomTokens(void) {
if (!ViewElementImplemented(veCustomTokens)) {
return;

View File

@@ -44,6 +44,7 @@ private:
void DrawTemperatures(void);
bool DrawDevices(void);
void DrawCurrentSchedule(void);
void DrawCurrentWeather(void);
void DrawCustomTokens(void);
public:
cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit);

View File

@@ -427,13 +427,13 @@ bool cViewHelpers::SetDate(map < string, string > &stringTokens, map < string, i
return true;
}
void cViewHelpers::SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens) {
bool cViewHelpers::SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens) {
static cPlugin *pWeatherForecast = cPluginManager::GetPlugin("weatherforecast");
if (!pWeatherForecast)
return;
return false;
cServiceCurrentWeather currentWeather;
if (!pWeatherForecast->Service("GetCurrentWeather", &currentWeather)) {
return;
return false;
}
stringTokens.insert(pair<string,string>("timestamp", currentWeather.timeStamp));
stringTokens.insert(pair<string,string>("temperature", currentWeather.temperature));
@@ -453,4 +453,5 @@ void cViewHelpers::SetCurrentWeatherTokens(map < string, string > &stringTokens,
intTokens.insert(pair<string,int>("cloudcover", currentWeather.cloudCover));
stringTokens.insert(pair<string,string>("pressure", currentWeather.pressure));
stringTokens.insert(pair<string,string>("ozone", currentWeather.ozone));
return true;
}

View File

@@ -16,7 +16,7 @@ protected:
void SetScraperTokens(const cEvent *event, const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens, map < string, vector< map< string, string > > > &loopTokens);
bool SetTime(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetDate(map < string, string > &stringTokens, map < string, int > &intTokens);
void SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens);
public:
cViewHelpers(void);
virtual ~cViewHelpers(void);