From 97f3d372dc6cdd81f3f298f37c6a542adc6aa959 Mon Sep 17 00:00:00 2001 From: louis Date: Tue, 7 Apr 2015 17:46:39 +0200 Subject: [PATCH] fixed bug that datetime was not drawn correctly in menus --- HISTORY | 2 +- views/displaychannelview.c | 4 ++-- views/displaymenurootview.c | 25 ++++++++++++++++--------- views/displaymenurootview.h | 5 +++-- views/displaymenuview.c | 8 ++++---- views/displaymenuview.h | 4 ++-- views/displayreplayview.c | 4 ++-- views/displayviewelements.c | 8 ++++++-- views/displayviewelements.h | 2 ++ views/viewhelpers.c | 9 +++++---- views/viewhelpers.h | 4 ++-- 11 files changed, 45 insertions(+), 30 deletions(-) diff --git a/HISTORY b/HISTORY index bd2c7d0..a6cdd5b 100644 --- a/HISTORY +++ b/HISTORY @@ -286,5 +286,5 @@ Version 0.4.1 Version 0.4.2 - +- fixed bug that datetime was not drawn correctly in menus diff --git a/views/displaychannelview.c b/views/displaychannelview.c index 425f744..9252c40 100644 --- a/views/displaychannelview.c +++ b/views/displaychannelview.c @@ -76,7 +76,7 @@ void cDisplayChannelView::DrawDate(void) { map < string, string > stringTokens; map < string, int > intTokens; - if (!SetDate(stringTokens, intTokens)) { + if (!SetDate(false, stringTokens, intTokens)) { return; } @@ -104,7 +104,7 @@ void cDisplayChannelView::DrawTime(void) { map < string, string > stringTokens; map < string, int > intTokens; - if (!SetTime(stringTokens, intTokens)) { + if (!SetTime(false, stringTokens, intTokens)) { return; } ClearViewElement(veTime); diff --git a/views/displaymenurootview.c b/views/displaymenurootview.c index c101d38..7b514d7 100644 --- a/views/displaymenurootview.c +++ b/views/displaymenurootview.c @@ -15,6 +15,7 @@ cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(root viewType = svUndefined; subView = NULL; subViewAvailable = false; + subViewInit = true; pluginName = ""; pluginMenu = -1; pluginMenuType = mtUnknown; @@ -102,6 +103,7 @@ bool cDisplayMenuRootView::createOsd(void) { void cDisplayMenuRootView::SetMenu(eMenuCategory menuCat, bool menuInit) { eSubView newViewType = svUndefined; cat = menuCat; + subViewInit = true; bool isListView = true; if (menuCat != mcPlugin) { pluginName = ""; @@ -473,26 +475,31 @@ bool cDisplayMenuRootView::RenderDynamicElements(void) { return false; bool updated = false; bool implemented = false; - if (view->DrawTime(implemented)) { + if (view->DrawTime(subViewInit, implemented)) { defaultTimeDrawn = false; updated = true; - } else if (!implemented && DrawTime()) { + } else if (!implemented && DrawTime(subViewInit)) { defaultTimeDrawn = true; updated = true; } implemented = false; - if (view->DrawDateTime(implemented)) { + if (view->DrawDateTime(subViewInit, implemented)) { defaultDateTimeDrawn = false; } else if (!implemented) { - DrawDateTime(); + DrawDateTime(subViewInit); defaultDateTimeDrawn = true; } - if (view->DrawDynamicViewElements()){ + if (view->DrawDynamicViewElements()) { updated = true; } + if (subViewInit) { + subViewInit = false; + return true; + } + subViewInit = false; return updated; } @@ -517,7 +524,7 @@ void cDisplayMenuRootView::DrawHeader(void) { DrawViewElement(veHeader, &stringTokens, &intTokens); } -void cDisplayMenuRootView::DrawDateTime(void) { +void cDisplayMenuRootView::DrawDateTime(bool forced) { if (!ExecuteViewElement(veDateTime)) { return; } @@ -525,7 +532,7 @@ void cDisplayMenuRootView::DrawDateTime(void) { map < string, string > stringTokens; map < string, int > intTokens; - if (!SetDate(stringTokens, intTokens)) { + if (!SetDate(forced, stringTokens, intTokens)) { return; } @@ -533,7 +540,7 @@ void cDisplayMenuRootView::DrawDateTime(void) { DrawViewElement(veDateTime, &stringTokens, &intTokens); } -bool cDisplayMenuRootView::DrawTime(void) { +bool cDisplayMenuRootView::DrawTime(bool forced) { if (!ExecuteViewElement(veTime)) { return false; } @@ -541,7 +548,7 @@ bool cDisplayMenuRootView::DrawTime(void) { map < string, string > stringTokens; map < string, int > intTokens; - if (!SetTime(stringTokens, intTokens)) { + if (!SetTime(forced, stringTokens, intTokens)) { return false; } diff --git a/views/displaymenurootview.h b/views/displaymenurootview.h index 79b4b56..cec7708 100644 --- a/views/displaymenurootview.h +++ b/views/displaymenurootview.h @@ -21,6 +21,7 @@ private: eSubView viewType; cTemplateView *subView; bool subViewAvailable; + bool subViewInit; string pluginName; int pluginMenu; ePluginMenuType pluginMenuType; @@ -40,8 +41,8 @@ private: bool defaultSortmodeDrawn; void DrawBackground(void); void DrawHeader(void); - void DrawDateTime(void); - bool DrawTime(void); + void DrawDateTime(bool forced); + bool DrawTime(bool forced); void DrawSortMode(void); void DrawColorButtons(void); void DrawMessage(eMessageType type, const char *text); diff --git a/views/displaymenuview.c b/views/displaymenuview.c index f1fb7de..16492b5 100644 --- a/views/displaymenuview.c +++ b/views/displaymenuview.c @@ -46,7 +46,7 @@ bool cDisplayMenuView::DrawHeader(void) { return true; } -bool cDisplayMenuView::DrawDateTime(bool &implemented) { +bool cDisplayMenuView::DrawDateTime(bool forced, bool &implemented) { if (!ExecuteViewElement(veDateTime)) { return false; } @@ -54,7 +54,7 @@ bool cDisplayMenuView::DrawDateTime(bool &implemented) { map < string, string > stringTokens; map < string, int > intTokens; - if (!SetDate(stringTokens, intTokens)) { + if (!SetDate(forced, stringTokens, intTokens)) { return false; } @@ -63,7 +63,7 @@ bool cDisplayMenuView::DrawDateTime(bool &implemented) { return true; } -bool cDisplayMenuView::DrawTime(bool &implemented) { +bool cDisplayMenuView::DrawTime(bool forced, bool &implemented) { if (!ExecuteViewElement(veTime)) { return false; } @@ -71,7 +71,7 @@ bool cDisplayMenuView::DrawTime(bool &implemented) { map < string, string > stringTokens; map < string, int > intTokens; - if (!SetTime(stringTokens, intTokens)) { + if (!SetTime(forced, stringTokens, intTokens)) { return false; } diff --git a/views/displaymenuview.h b/views/displaymenuview.h index 52b3479..acd4512 100644 --- a/views/displaymenuview.h +++ b/views/displaymenuview.h @@ -37,8 +37,8 @@ public: void SetButtonTexts(string *buttonTexts) { this->buttonTexts = buttonTexts; }; bool DrawBackground(void); virtual bool DrawHeader(void); - bool DrawDateTime(bool &implemented); - bool DrawTime(bool &implemented); + bool DrawDateTime(bool forced, bool &implemented); + bool DrawTime(bool forced, bool &implemented); bool DrawColorButtons(void); bool DrawMessage(eMessageType type, const char *text); void DrawScrollbar(int numMax, int numDisplayed, int offset); diff --git a/views/displayreplayview.c b/views/displayreplayview.c index 818ba9e..a8f2fca 100644 --- a/views/displayreplayview.c +++ b/views/displayreplayview.c @@ -52,7 +52,7 @@ void cDisplayReplayView::DrawDate(void) { map < string, string > stringTokens; map < string, int > intTokens; - if (!SetDate(stringTokens, intTokens)) { + if (!SetDate(false, stringTokens, intTokens)) { return; } ClearViewElement(veDateTime); @@ -67,7 +67,7 @@ void cDisplayReplayView::DrawTime(void) { map < string, string > stringTokens; map < string, int > intTokens; - if (!SetTime(stringTokens, intTokens)) { + if (!SetTime(false, stringTokens, intTokens)) { return; } ClearViewElement(veTime); diff --git a/views/displayviewelements.c b/views/displayviewelements.c index 6a1b2b6..7f88990 100644 --- a/views/displayviewelements.c +++ b/views/displayviewelements.c @@ -59,13 +59,15 @@ bool cViewElementWeather::Render(void) { /********************************************************************************************************************/ cViewElementDate::cViewElementDate(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) { + init = true; } bool cViewElementDate::Render(void) { ClearTokens(); - if (!SetDate(stringTokens, intTokens)) { + if (!SetDate(init, stringTokens, intTokens)) { return false; } + init = false; ClearViewElement(veDateTime); DrawViewElement(veDateTime, &stringTokens, &intTokens); return true; @@ -74,13 +76,15 @@ bool cViewElementDate::Render(void) { /********************************************************************************************************************/ cViewElementTime::cViewElementTime(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) { + init = true; } bool cViewElementTime::Render(void) { ClearTokens(); - if (!SetTime(stringTokens, intTokens)) { + if (!SetTime(init, stringTokens, intTokens)) { return false; } + init = false; ClearViewElement(veTime); DrawViewElement(veTime, &stringTokens, &intTokens); return true; diff --git a/views/displayviewelements.h b/views/displayviewelements.h index d47350e..070d205 100644 --- a/views/displayviewelements.h +++ b/views/displayviewelements.h @@ -33,6 +33,7 @@ public: class cViewElementDate : public cViewElement, public cViewHelpers { private: + bool init; public: cViewElementDate(cTemplateViewElement *tmplViewElement); virtual ~cViewElementDate() {}; @@ -41,6 +42,7 @@ public: class cViewElementTime : public cViewElement, public cViewHelpers { private: + bool init; public: cViewElementTime(cTemplateViewElement *tmplViewElement); virtual ~cViewElementTime() {}; diff --git a/views/viewhelpers.c b/views/viewhelpers.c index 4fd50ad..67216ad 100644 --- a/views/viewhelpers.c +++ b/views/viewhelpers.c @@ -465,11 +465,11 @@ void cViewHelpers::SetPosterBanner(const cEvent *event, map < string, string > & } } -bool cViewHelpers::SetTime(map < string, string > &stringTokens, map < string, int > &intTokens) { +bool cViewHelpers::SetTime(bool forced, map < string, string > &stringTokens, map < string, int > &intTokens) { time_t t = time(0); // get time now struct tm * now = localtime(&t); int sec = now->tm_sec; - if (sec == lastSecond) { + if (!forced && sec == lastSecond) { return false; } int min = now->tm_min; @@ -485,12 +485,13 @@ bool cViewHelpers::SetTime(map < string, string > &stringTokens, map < string, i return true; } -bool cViewHelpers::SetDate(map < string, string > &stringTokens, map < string, int > &intTokens) { +bool cViewHelpers::SetDate(bool forced, map < string, string > &stringTokens, map < string, int > &intTokens) { time_t t = time(0); // get time now struct tm * now = localtime(&t); int min = now->tm_min; - if (min == lastMinute) + if (!forced && min == lastMinute) { return false; + } lastMinute = min; intTokens.insert(pair("year", now->tm_year + 1900)); diff --git a/views/viewhelpers.h b/views/viewhelpers.h index e4c0d12..112b3ca 100644 --- a/views/viewhelpers.h +++ b/views/viewhelpers.h @@ -26,8 +26,8 @@ protected: 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 SetPosterBanner(const cEvent *event, map < string, string > &stringTokens, map < string, int > &intTokens); - bool SetTime(map < string, string > &stringTokens, map < string, int > &intTokens); - bool SetDate(map < string, string > &stringTokens, map < string, int > &intTokens); + bool SetTime(bool forced, map < string, string > &stringTokens, map < string, int > &intTokens); + bool SetDate(bool forced, map < string, string > &stringTokens, map < string, int > &intTokens); bool SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens); void SetTimers(map *intTokens, map *stringTokens, vector > *timers); void SetLastRecordings(map *intTokens, map *stringTokens, vector > *lastRecordings);