From 72f2a1ad6b6de4773fd50a7df878c7576bbe8452 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Tue, 13 Mar 2018 20:09:57 +0100 Subject: [PVR] PVRGUIInfo: Cleanup: Use CPVRItem in CPVRGUIInfo::TranslateIntInfo implementation. --- xbmc/GUIInfoManager.cpp | 2 +- xbmc/pvr/PVRGUIInfo.cpp | 22 ++++++++-------------- xbmc/pvr/PVRGUIInfo.h | 2 +- xbmc/pvr/PVRManager.cpp | 2 +- xbmc/pvr/PVRManager.h | 2 +- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 5602f18eb4..137248e5be 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -6871,7 +6871,7 @@ bool CGUIInfoManager::GetInt(int &value, int info, int contextWindow, const CGUI case PVR_ACTUAL_STREAM_SNR_PROGR: case PVR_BACKEND_DISKSPACE_PROGR: case PVR_TIMESHIFT_PROGRESS: - value = CServiceBroker::GetPVRManager().TranslateIntInfo(*m_currentFile, info); + value = CServiceBroker::GetPVRManager().TranslateIntInfo(m_currentFile, info); return true; case SYSTEM_BATTERY_LEVEL: value = CServiceBroker::GetPowerManager().BatteryLevel(); diff --git a/xbmc/pvr/PVRGUIInfo.cpp b/xbmc/pvr/PVRGUIInfo.cpp index fad14fe027..6b4c049dde 100644 --- a/xbmc/pvr/PVRGUIInfo.cpp +++ b/xbmc/pvr/PVRGUIInfo.cpp @@ -571,25 +571,24 @@ bool CPVRGUIInfo::TranslateBoolInfo(DWORD dwInfo) const return bReturn; } -int CPVRGUIInfo::TranslateIntInfo(const CFileItem &item, DWORD dwInfo) const +int CPVRGUIInfo::TranslateIntInfo(const CFileItem *item, DWORD dwInfo) const { int iReturn(0); CSingleLock lock(m_critSection); if (dwInfo == PVR_EPG_EVENT_PROGRESS) { - CPVREpgInfoTagPtr epgTag; - const CPVRChannelPtr channel = item.GetPVRChannelInfoTag(); - if (channel) - epgTag = channel->GetEPGNow(); - if (!epgTag) - epgTag = item.GetEPGInfoTag(); - - if (epgTag && epgTag != GetPlayingTag()) + CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); + if (epgTag && epgTag != m_playingEpgTag) iReturn = std::lrintf(epgTag->ProgressPercentage()); else iReturn = std::lrintf(static_cast(GetElapsedTime()) / m_iDuration * 100); } + else if (dwInfo == PVR_TIMESHIFT_PROGRESS) + { + iReturn = std::lrintf(static_cast(m_iTimeshiftPlayTime - m_iTimeshiftStartTime) / + (m_iTimeshiftEndTime - m_iTimeshiftStartTime) * 100); + } else if (dwInfo == PVR_ACTUAL_STREAM_SIG_PROGR) iReturn = (int) ((float) m_qualityInfo.iSignal / 0xFFFF * 100); else if (dwInfo == PVR_ACTUAL_STREAM_SNR_PROGR) @@ -601,11 +600,6 @@ int CPVRGUIInfo::TranslateIntInfo(const CFileItem &item, DWORD dwInfo) const else iReturn = 0xFF; } - else if (dwInfo == PVR_TIMESHIFT_PROGRESS) - { - iReturn = std::lrintf(static_cast(m_iTimeshiftPlayTime - m_iTimeshiftStartTime) / - (m_iTimeshiftEndTime - m_iTimeshiftStartTime) * 100); - } return iReturn; } diff --git a/xbmc/pvr/PVRGUIInfo.h b/xbmc/pvr/PVRGUIInfo.h index ab8e7ff53d..4d106aa531 100644 --- a/xbmc/pvr/PVRGUIInfo.h +++ b/xbmc/pvr/PVRGUIInfo.h @@ -47,7 +47,7 @@ namespace PVR bool TranslateBoolInfo(DWORD dwInfo) const; bool TranslateCharInfo(DWORD dwInfo, std::string &strValue) const; - int TranslateIntInfo(const CFileItem &item, DWORD dwInfo) const; + int TranslateIntInfo(const CFileItem *item, DWORD dwInfo) const; /*! * @brief Get a GUIInfoManager video label. diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 0125843d30..748342a204 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -819,7 +819,7 @@ bool CPVRManager::TranslateCharInfo(DWORD dwInfo, std::string &strValue) const return IsStarted() && m_guiInfo ? m_guiInfo->TranslateCharInfo(dwInfo, strValue) : false; } -int CPVRManager::TranslateIntInfo(const CFileItem &item, DWORD dwInfo) const +int CPVRManager::TranslateIntInfo(const CFileItem *item, DWORD dwInfo) const { return IsStarted() && m_guiInfo ? m_guiInfo->TranslateIntInfo(item, dwInfo) : 0; } diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 3ff9cf8cea..84c71e3482 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -174,7 +174,7 @@ namespace PVR * @param dwInfo The integer to get. * @return The requested integer or 0 if it wasn't found. */ - int TranslateIntInfo(const CFileItem &item, DWORD dwInfo) const; + int TranslateIntInfo(const CFileItem *item, DWORD dwInfo) const; /*! * @brief Get a GUIInfoManager boolean. -- cgit v1.2.3 From 29164ecebe945079bf7361d4f56f990ba2b9f59b Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Wed, 14 Mar 2018 09:43:16 +0100 Subject: [PVR] PVRGUIInfo: Fixed PVR.EpgEventDuration, PVR.EpgEvent(Elapsed|Remaining|Finish)Time to support channel preview. --- addons/skin.estuary/xml/DialogSeekBar.xml | 3 +- xbmc/GUIInfoManager.cpp | 2 +- xbmc/pvr/PVRGUIInfo.cpp | 60 ++++++++++++++++++++++--------- xbmc/pvr/PVRGUIInfo.h | 10 +++--- xbmc/pvr/PVRManager.cpp | 4 +-- xbmc/pvr/PVRManager.h | 3 +- 6 files changed, 55 insertions(+), 27 deletions(-) diff --git a/addons/skin.estuary/xml/DialogSeekBar.xml b/addons/skin.estuary/xml/DialogSeekBar.xml index 75464e6dc9..d31d09e7a7 100644 --- a/addons/skin.estuary/xml/DialogSeekBar.xml +++ b/addons/skin.estuary/xml/DialogSeekBar.xml @@ -131,8 +131,7 @@ font45 black - !Player.ChannelPreviewActive - Visible + !Player.ChannelPreviewActive | VideoPlayer.HasEpg 50% diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 137248e5be..ea6afdc75d 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -6057,7 +6057,7 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string * case PVR_RADIO_NEXT_RECORDING_CHANNEL: case PVR_RADIO_NEXT_RECORDING_CHAN_ICO: case PVR_RADIO_NEXT_RECORDING_DATETIME: - CServiceBroker::GetPVRManager().TranslateCharInfo(info, strLabel); + CServiceBroker::GetPVRManager().TranslateCharInfo(m_currentFile, info, strLabel); break; case PVR_EPG_EVENT_SEEK_TIME: CServiceBroker::GetPVRManager().GetSeekTimeLabel(g_application.GetAppPlayer().GetSeekHandler().GetSeekSize(), strLabel); diff --git a/xbmc/pvr/PVRGUIInfo.cpp b/xbmc/pvr/PVRGUIInfo.cpp index 6b4c049dde..8cca15d8e7 100644 --- a/xbmc/pvr/PVRGUIInfo.cpp +++ b/xbmc/pvr/PVRGUIInfo.cpp @@ -322,7 +322,7 @@ void CPVRGUIInfo::UpdateTimeshift(void) m_bHasTimeshiftData = true; } -bool CPVRGUIInfo::TranslateCharInfo(DWORD dwInfo, std::string &strValue) const +bool CPVRGUIInfo::TranslateCharInfo(const CFileItem *item, DWORD dwInfo, std::string &strValue) const { bool bReturn(true); CSingleLock lock(m_critSection); @@ -402,16 +402,16 @@ bool CPVRGUIInfo::TranslateCharInfo(DWORD dwInfo, std::string &strValue) const m_radioTimersInfo.CharInfoNextTimerDateTime(strValue); break; case PVR_EPG_EVENT_DURATION: - CharInfoEpgEventDuration(strValue); + CharInfoEpgEventDuration(item, strValue); break; case PVR_EPG_EVENT_ELAPSED_TIME: - CharInfoEpgEventElapsedTime(strValue); + CharInfoEpgEventElapsedTime(item, strValue); break; case PVR_EPG_EVENT_REMAINING_TIME: - CharInfoEpgEventRemainingTime(strValue); + CharInfoEpgEventRemainingTime(item, strValue); break; case PVR_EPG_EVENT_FINISH_TIME: - CharInfoEpgEventFinishTime(strValue); + CharInfoEpgEventFinishTime(item, strValue); break; case PVR_NEXT_TIMER: m_anyTimersInfo.CharInfoNextTimer(strValue); @@ -853,11 +853,6 @@ bool CPVRGUIInfo::GetSeekTimeLabel(int iSeekSize, std::string &strValue) const return true; } -void CPVRGUIInfo::CharInfoEpgEventDuration(std::string &strValue) const -{ - strValue = StringUtils::SecondsToTimeString(m_iDuration, TIME_FORMAT_GUESS).c_str(); -} - void CPVRGUIInfo::CharInfoTimeshiftStartTime(std::string &strValue) const { strValue = m_strTimeshiftStartTime; @@ -878,20 +873,53 @@ void CPVRGUIInfo::CharInfoTimeshiftOffset(std::string &strValue) const strValue = StringUtils::SecondsToTimeString(m_iTimeshiftOffset, TIME_FORMAT_GUESS).c_str(); } -void CPVRGUIInfo::CharInfoEpgEventElapsedTime(std::string &strValue) const +void CPVRGUIInfo::CharInfoEpgEventDuration(const CFileItem *item, std::string &strValue) const +{ + int iDuration = 0; + CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); + if (epgTag && epgTag != m_playingEpgTag) + iDuration = epgTag->GetDuration(); + else + iDuration = m_iDuration; + + strValue = StringUtils::SecondsToTimeString(iDuration, TIME_FORMAT_GUESS).c_str(); +} + +void CPVRGUIInfo::CharInfoEpgEventElapsedTime(const CFileItem *item, std::string &strValue) const { - strValue = StringUtils::SecondsToTimeString(GetElapsedTime(), TIME_FORMAT_GUESS).c_str(); + int iElapsed = 0; + CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); + if (epgTag && epgTag != m_playingEpgTag) + iElapsed = epgTag->Progress(); + else + iElapsed = GetElapsedTime(); + + strValue = StringUtils::SecondsToTimeString(iElapsed, TIME_FORMAT_GUESS).c_str(); } -void CPVRGUIInfo::CharInfoEpgEventRemainingTime(std::string &strValue) const +void CPVRGUIInfo::CharInfoEpgEventRemainingTime(const CFileItem *item, std::string &strValue) const { - strValue = StringUtils::SecondsToTimeString(m_iDuration - GetElapsedTime(), TIME_FORMAT_GUESS).c_str(); + int iRemaining = 0; + CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); + if (epgTag && epgTag != m_playingEpgTag) + iRemaining = epgTag->GetDuration() - epgTag->Progress(); + else + iRemaining = m_iDuration - GetElapsedTime(); + + strValue = StringUtils::SecondsToTimeString(iRemaining, TIME_FORMAT_GUESS).c_str(); } -void CPVRGUIInfo::CharInfoEpgEventFinishTime(std::string &strValue) const +void CPVRGUIInfo::CharInfoEpgEventFinishTime(const CFileItem *item, std::string &strValue) const { + int iFinish = 0; + CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); + if (epgTag && epgTag != m_playingEpgTag) + iFinish = epgTag->GetDuration() - epgTag->Progress(); + else + iFinish = m_iDuration - GetElapsedTime(); + CDateTime finishTime = CDateTime::GetCurrentDateTime(); - finishTime += CDateTimeSpan(0, 0, 0, m_iDuration - GetElapsedTime()); + finishTime += CDateTimeSpan(0, 0, 0, iFinish); strValue = finishTime.GetAsLocalizedTime("", false); } diff --git a/xbmc/pvr/PVRGUIInfo.h b/xbmc/pvr/PVRGUIInfo.h index 4d106aa531..76fe21e99f 100644 --- a/xbmc/pvr/PVRGUIInfo.h +++ b/xbmc/pvr/PVRGUIInfo.h @@ -46,7 +46,7 @@ namespace PVR void Notify(const Observable &obs, const ObservableMessage msg) override; bool TranslateBoolInfo(DWORD dwInfo) const; - bool TranslateCharInfo(DWORD dwInfo, std::string &strValue) const; + bool TranslateCharInfo(const CFileItem *item, DWORD dwInfo, std::string &strValue) const; int TranslateIntInfo(const CFileItem *item, DWORD dwInfo) const; /*! @@ -198,10 +198,10 @@ namespace PVR void UpdateTimersToggle(void); - void CharInfoEpgEventDuration(std::string &strValue) const; - void CharInfoEpgEventElapsedTime(std::string &strValue) const; - void CharInfoEpgEventRemainingTime(std::string &strValue) const; - void CharInfoEpgEventFinishTime(std::string &strValue) const; + void CharInfoEpgEventDuration(const CFileItem *item, std::string &strValue) const; + void CharInfoEpgEventElapsedTime(const CFileItem *item, std::string &strValue) const; + void CharInfoEpgEventRemainingTime(const CFileItem *item, std::string &strValue) const; + void CharInfoEpgEventFinishTime(const CFileItem *item, std::string &strValue) const; void CharInfoBackendNumber(std::string &strValue) const; void CharInfoTotalDiskSpace(std::string &strValue) const; void CharInfoSignal(std::string &strValue) const; diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 748342a204..9a1abd811e 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -814,9 +814,9 @@ bool CPVRManager::TranslateBoolInfo(DWORD dwInfo) const return IsStarted() && m_guiInfo ? m_guiInfo->TranslateBoolInfo(dwInfo) : false; } -bool CPVRManager::TranslateCharInfo(DWORD dwInfo, std::string &strValue) const +bool CPVRManager::TranslateCharInfo(const CFileItem *item, DWORD dwInfo, std::string &strValue) const { - return IsStarted() && m_guiInfo ? m_guiInfo->TranslateCharInfo(dwInfo, strValue) : false; + return IsStarted() && m_guiInfo ? m_guiInfo->TranslateCharInfo(item, dwInfo, strValue) : false; } int CPVRManager::TranslateIntInfo(const CFileItem *item, DWORD dwInfo) const diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 84c71e3482..1344f0cd84 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -163,10 +163,11 @@ namespace PVR /*! * @brief Get a GUIInfoManager character string. + * @param item The item to get the value for. * @param dwInfo The string to get. * @return The requested string or an empty one if it wasn't found. */ - bool TranslateCharInfo(DWORD dwInfo, std::string &strValue) const; + bool TranslateCharInfo(const CFileItem *item, DWORD dwInfo, std::string &strValue) const; /*! * @brief Get a GUIInfoManager integer. -- cgit v1.2.3 From 079baffd886b009f8e5846632f1e84f10f7587d6 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Wed, 14 Mar 2018 09:55:48 +0100 Subject: [guiinfo] GUIInfomanager cleanup: Fix documentation for method SetCurrentItem (param 'blocking' was removed long time ago. --- xbmc/GUIInfoManager.h | 1 - 1 file changed, 1 deletion(-) diff --git a/xbmc/GUIInfoManager.h b/xbmc/GUIInfoManager.h index 010ac3eafd..0656d26742 100644 --- a/xbmc/GUIInfoManager.h +++ b/xbmc/GUIInfoManager.h @@ -138,7 +138,6 @@ public: std::string GetDuration(TIME_FORMAT format = TIME_FORMAT_GUESS) const; /*! \brief Set currently playing file item - \param blocking whether to run in current thread (true) or background thread (false) */ void SetCurrentItem(const CFileItem &item); void ResetCurrentItem(); -- cgit v1.2.3 From 33e75dcf6608b18abc7cbcfc833ce2f1ba8904a6 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Wed, 14 Mar 2018 11:44:48 +0100 Subject: [PVR] PVRGUIChannelNavigator: Optimize to only call CGUIInfoManager::SetCurrentItem if the channel to play/preview actually has changed. --- xbmc/pvr/PVRGUIChannelNavigator.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/xbmc/pvr/PVRGUIChannelNavigator.cpp b/xbmc/pvr/PVRGUIChannelNavigator.cpp index a08eaf966c..fbd8cdd403 100644 --- a/xbmc/pvr/PVRGUIChannelNavigator.cpp +++ b/xbmc/pvr/PVRGUIChannelNavigator.cpp @@ -179,10 +179,12 @@ namespace PVR m_iChannelInfoJobId = -1; } - m_currentChannel = m_playingChannel; - - if (m_currentChannel) - item.reset(new CFileItem(m_playingChannel)); + if (m_currentChannel != m_playingChannel) + { + m_currentChannel = m_playingChannel; + if (m_playingChannel) + item.reset(new CFileItem(m_playingChannel)); + } } if (item) @@ -206,9 +208,12 @@ namespace PVR CSingleLock lock(m_critSection); m_playingChannel = channel; - m_currentChannel = m_playingChannel; - - item.reset(new CFileItem(m_playingChannel)); + if (m_currentChannel != m_playingChannel) + { + m_currentChannel = m_playingChannel; + if (m_playingChannel) + item.reset(new CFileItem(m_playingChannel)); + } } if (item) -- cgit v1.2.3 From b03ddd0f5306c69dc79dce27cbd6e4d82166e6c5 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Wed, 14 Mar 2018 22:40:20 +0100 Subject: [PVR][guiinfo] PVRGUIInfo: PVR.EpgEventDuration, PVREpgEvent(Elapsed|Remaining|Finish|Seek)Time, PVR.Timeshift(Start|Cur|End|Offset) now support time format strings. --- xbmc/GUIInfoManager.cpp | 320 +++++++++++++++++++++++++++----------------- xbmc/GUIInfoManager.h | 28 +--- xbmc/guiinfo/CMakeLists.txt | 3 +- xbmc/guiinfo/GUIInfo.h | 47 +++++++ xbmc/pvr/PVRGUIInfo.cpp | 149 ++++++++++++--------- xbmc/pvr/PVRGUIInfo.h | 35 +++-- xbmc/pvr/PVRManager.cpp | 9 +- xbmc/pvr/PVRManager.h | 13 +- 8 files changed, 375 insertions(+), 229 deletions(-) create mode 100644 xbmc/guiinfo/GUIInfo.h diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index ea6afdc75d..cbd3014c73 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -4252,46 +4252,6 @@ const infomap playlist[] = {{ "length", PLAYLIST_LENGTH }, /// _boolean_, /// Returns true if there are timers present who currently not do recording /// } -/// \table_row3{ `PVR.NowRecordingTitle`, -/// \anchor PVR_NowRecordingTitle -/// _string_, -/// Title of the programme being recorded -/// } -/// \table_row3{ `PVR.NowRecordingDateTime`, -/// \anchor PVR_NowRecordingDateTime -/// _Date/Time string_, -/// Start date and time of the current recording -/// } -/// \table_row3{ `PVR.NowRecordingChannel`, -/// \anchor PVR_NowRecordingChannel -/// _string_, -/// Channel name of the current recording -/// } -/// \table_row3{ `PVR.NowRecordingChannelIcon`, -/// \anchor PVR_NowRecordingChannelIcon -/// _string_, -/// Icon of the current recording channel -/// } -/// \table_row3{ `PVR.NextRecordingTitle`, -/// \anchor PVR_NextRecordingTitle -/// _string_, -/// Title of the next programme that will be recorded -/// } -/// \table_row3{ `PVR.NextRecordingDateTime`, -/// \anchor PVR_NextRecordingDateTime -/// _Date/Time string_, -/// Start date and time of the next recording -/// } -/// \table_row3{ `PVR.NextRecordingChannel`, -/// \anchor PVR_NextRecordingChannel -/// _string_, -/// Channel name of the next recording -/// } -/// \table_row3{ `PVR.NextRecordingChannelIcon`, -/// \anchor PVR_NextRecordingChannelIcon -/// _string_, -/// Icon of the next recording channel -/// } /// \table_row3{ `PVR.BackendName`, /// \anchor PVR_BackendName /// _string_, @@ -4372,31 +4332,6 @@ const infomap playlist[] = {{ "length", PLAYLIST_LENGTH }, /// _boolean_, /// Returns true when an epg tag is being watched. /// } -/// \table_row3{ `PVR.EpgEventDuration`, -/// \anchor PVR_EpgEventDuration -/// _string_, -/// Returns the duration of the currently playing epg event -/// } -/// \table_row3{ `PVR.EpgEventElapsedTime`, -/// \anchor PVR_EpgEventElapsedTime -/// _string_, -/// Returns the time of the current position of the currently playing epg event -/// } -/// \table_row3{ `PVR.EpgEventRemainingTime`, -/// \anchor PVR_EpgEventRemainingTime -/// _string_, -/// Returns the remaining time for currently playing epg event -/// } -/// \table_row3{ `PVR.EpgEventSeekTime`, -/// \anchor PVR_EpgEventSeekTime -/// _string_, -/// Returns the time the user is seeking within the currently playing epg event -/// } -/// \table_row3{ `PVR.EpgEventFinishTime`, -/// \anchor PVR_EpgEventFinishTime -/// _string_, -/// Returns the time the currently playing epg event will end -/// } /// \table_row3{ `PVR.EpgEventProgress`, /// \anchor PVR_EpgEventProgress /// _integer_, @@ -4477,30 +4412,50 @@ const infomap playlist[] = {{ "length", PLAYLIST_LENGTH }, /// _boolean_, /// Returns true when for channel is timeshift available /// } -/// \table_row3{ `PVR.TimeShiftStart`, -/// \anchor PVR_TimeShiftStart -/// _time string_, -/// Start position of the timeshift -/// } -/// \table_row3{ `PVR.TimeShiftEnd`, -/// \anchor PVR_TimeShiftEnd -/// _time string_, -/// End position of the timeshift -/// } -/// \table_row3{ `PVR.TimeShiftCur`, -/// \anchor PVR_TimeShiftCur -/// _time string_, -/// Current position of the timeshift -/// } /// \table_row3{ `PVR.TimeShiftProgress`, /// \anchor PVR_TimeShiftProgress /// _integer_, /// Returns the position of currently timeshifted title on TV as integer /// } -/// \table_row3{ `PVR.TimeShiftOffset`, -/// \anchor PVR_TimeShiftOffset -/// _integer_, -/// Returns the delta of timeshifted time to actual time +/// \table_row3{ `PVR.NowRecordingTitle`, +/// \anchor PVR_NowRecordingTitle +/// _string_, +/// Title of the programme being recorded +/// } +/// \table_row3{ `PVR.NowRecordingDateTime`, +/// \anchor PVR_NowRecordingDateTime +/// _Date/Time string_, +/// Start date and time of the current recording +/// } +/// \table_row3{ `PVR.NowRecordingChannel`, +/// \anchor PVR_NowRecordingChannel +/// _string_, +/// Channel name of the current recording +/// } +/// \table_row3{ `PVR.NowRecordingChannelIcon`, +/// \anchor PVR_NowRecordingChannelIcon +/// _string_, +/// Icon of the current recording channel +/// } +/// \table_row3{ `PVR.NextRecordingTitle`, +/// \anchor PVR_NextRecordingTitle +/// _string_, +/// Title of the next programme that will be recorded +/// } +/// \table_row3{ `PVR.NextRecordingDateTime`, +/// \anchor PVR_NextRecordingDateTime +/// _Date/Time string_, +/// Start date and time of the next recording +/// } +/// \table_row3{ `PVR.NextRecordingChannel`, +/// \anchor PVR_NextRecordingChannel +/// _string_, +/// Channel name of the next recording +/// } +/// \table_row3{ `PVR.NextRecordingChannelIcon`, +/// \anchor PVR_NextRecordingChannelIcon +/// _string_, +/// Icon of the next recording channel /// } /// \table_row3{ `PVR.TVNowRecordingTitle`, /// \anchor PVR_TVNowRecordingTitle @@ -4636,14 +4591,6 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING { "hastvchannels", PVR_HAS_TV_CHANNELS }, { "hasradiochannels", PVR_HAS_RADIO_CHANNELS }, { "hasnonrecordingtimer", PVR_HAS_NONRECORDING_TIMER }, - { "nowrecordingtitle", PVR_NOW_RECORDING_TITLE }, - { "nowrecordingdatetime", PVR_NOW_RECORDING_DATETIME }, - { "nowrecordingchannel", PVR_NOW_RECORDING_CHANNEL }, - { "nowrecordingchannelicon", PVR_NOW_RECORDING_CHAN_ICO }, - { "nextrecordingtitle", PVR_NEXT_RECORDING_TITLE }, - { "nextrecordingdatetime", PVR_NEXT_RECORDING_DATETIME }, - { "nextrecordingchannel", PVR_NEXT_RECORDING_CHANNEL }, - { "nextrecordingchannelicon", PVR_NEXT_RECORDING_CHAN_ICO }, { "backendname", PVR_BACKEND_NAME }, { "backendversion", PVR_BACKEND_VERSION }, { "backendhost", PVR_BACKEND_HOST }, @@ -4660,11 +4607,6 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING { "isplayingradio", PVR_IS_PLAYING_RADIO }, { "isplayingrecording", PVR_IS_PLAYING_RECORDING }, { "isplayingepgtag", PVR_IS_PLAYING_EPGTAG }, - { "epgeventduration", PVR_EPG_EVENT_DURATION }, - { "epgeventelapsedtime", PVR_EPG_EVENT_ELAPSED_TIME }, - { "epgeventremainingtime", PVR_EPG_EVENT_REMAINING_TIME }, - { "epgeventfinishtime", PVR_EPG_EVENT_FINISH_TIME }, - { "epgeventseektime", PVR_EPG_EVENT_SEEK_TIME }, { "epgeventprogress", PVR_EPG_EVENT_PROGRESS }, { "actstreamclient", PVR_ACTUAL_STREAM_CLIENT }, { "actstreamdevice", PVR_ACTUAL_STREAM_DEVICE }, @@ -4681,11 +4623,7 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING { "actstreammux", PVR_ACTUAL_STREAM_MUX }, { "actstreamprovidername", PVR_ACTUAL_STREAM_PROVIDER }, { "istimeshift", PVR_IS_TIMESHIFTING }, - { "timeshiftstart", PVR_TIMESHIFT_START_TIME }, - { "timeshiftend", PVR_TIMESHIFT_END_TIME }, - { "timeshiftcur", PVR_TIMESHIFT_PLAY_TIME }, { "timeshiftprogress", PVR_TIMESHIFT_PROGRESS }, - { "timeshiftoffset", PVR_TIMESHIFT_OFFSET }, { "nowrecordingtitle", PVR_NOW_RECORDING_TITLE }, { "nowrecordingdatetime", PVR_NOW_RECORDING_DATETIME }, { "nowrecordingchannel", PVR_NOW_RECORDING_CHANNEL }, @@ -4720,6 +4658,142 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING { "canrecordplayingchannel", PVR_CAN_RECORD_PLAYING_CHANNEL }, { "isrecordingplayingchannel", PVR_IS_RECORDING_PLAYING_CHANNEL }}; +/// \page modules__General__List_of_gui_access +/// \section modules__General__List_of_gui_access_PvrTimes PvrTimes +/// @{ +/// \table_start +/// \table_h3{ Labels, Type, Description } +/// \table_row3{ `PVR.EpgEventDuration`, +/// \anchor PVR_EpgEventDuration +/// _string_, +/// Returns the duration of the currently playing epg event in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ `PVR.EpgEventDuration(format)`, +/// \anchor PVR_EpgEventDuration_format +/// _string_, +/// Returns the duration of the currently playing epg event in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ `PVR.EpgEventElapsedTime`, +/// \anchor PVR_EpgEventElapsedTime +/// _string_, +/// Returns the time of the current position of the currently playing epg event in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ `PVR.EpgEventElapsedTime(format)`, +/// \anchor PVR_EpgEventElapsedTime_format +/// _string_, +/// Returns the time of the current position of the currently playing epg event in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ `PVR.EpgEventRemainingTime`, +/// \anchor PVR_EpgEventRemainingTime +/// _string_, +/// Returns the remaining time for currently playing epg event in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ `PVR.EpgEventRemainingTime(format)`, +/// \anchor PVR_EpgEventRemainingTime_format +/// _string_, +/// Returns the remaining time for currently playing epg event in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ `PVR.EpgEventSeekTime`, +/// \anchor PVR_EpgEventSeekTime +/// _string_, +/// Returns the time the user is seeking within the currently playing epg event in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ `PVR.EpgEventSeekTime(format)`, +/// \anchor PVR_EpgEventSeekTime_format +/// _string_, +/// Returns the time the user is seeking within the currently playing epg event in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ `PVR.EpgEventFinishTime`, +/// \anchor PVR_EpgEventFinishTime +/// _string_, +/// Returns the time the currently playing epg event will end in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ `PVR.EpgEventFinishTime(format)`, +/// \anchor PVR_EpgEventFinishTime_format +/// _string_, +/// Returns the time the currently playing epg event will end in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ `PVR.TimeShiftStart`, +/// \anchor PVR_TimeShiftStart +/// _string_, +/// Returns the start time of the timeshift buffer in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ `PVR.TimeShiftStart(format)`, +/// \anchor PVR_TimeShiftStart_format +/// _string_, +/// Returns the start time of the timeshift buffer in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ `PVR.TimeShiftEnd`, +/// \anchor PVR_TimeShiftEnd +/// _string_, +/// Returns the end time of the timeshift buffer in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ `PVR.TimeShiftEnd(format)`, +/// \anchor PVR_TimeShiftEnd_format +/// _string_, +/// Returns the end time of the timeshift buffer in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ `PVR.TimeShiftCur`, +/// \anchor PVR_TimeShiftCur +/// _string_, +/// Returns the current playback time within the timeshift buffer in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ `PVR.TimeShiftCur(format)`, +/// \anchor PVR_TimeShiftCur_format +/// _string_, +/// Returns the current playback time within the timeshift buffer in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ `PVR.TimeShiftOffset`, +/// \anchor PVR_TimeShiftOffset +/// _string_, +/// Returns the delta of timeshifted time to actual time in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ `PVR.TimeShiftOffset(format)`, +/// \anchor PVR_TimeShiftOffset_format +/// _string_, +/// Returns the delta of timeshifted time to actual time in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_end +/// +/// ----------------------------------------------------------------------------- +/// @} +const infomap pvr_times[] = {{ "epgeventduration", PVR_EPG_EVENT_DURATION }, + { "epgeventelapsedtime", PVR_EPG_EVENT_ELAPSED_TIME }, + { "epgeventremainingtime", PVR_EPG_EVENT_REMAINING_TIME }, + { "epgeventfinishtime", PVR_EPG_EVENT_FINISH_TIME }, + { "epgeventseektime", PVR_EPG_EVENT_SEEK_TIME }, + { "timeshiftstart", PVR_TIMESHIFT_START_TIME }, + { "timeshiftend", PVR_TIMESHIFT_END_TIME }, + { "timeshiftcur", PVR_TIMESHIFT_PLAY_TIME }, + { "timeshiftoffset", PVR_TIMESHIFT_OFFSET }}; + /// \page modules__General__List_of_gui_access /// \section modules__General__List_of_gui_access_ADSP ADSP /// @{ @@ -5791,6 +5865,11 @@ int CGUIInfoManager::TranslateSingleString(const std::string &strCondition, bool if (prop.name == pvr[i].str) return pvr[i].val; } + for (size_t i = 0; i < sizeof(pvr_times) / sizeof(infomap); i++) + { + if (prop.name == pvr_times[i].str) + return AddMultiInfo(GUIInfo(pvr_times[i].val, TranslateTimeFormat(prop.param()))); + } } else if (cat.name == "adsp") { @@ -6000,14 +6079,6 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string * switch (info) { - case PVR_NEXT_RECORDING_CHANNEL: - case PVR_NEXT_RECORDING_CHAN_ICO: - case PVR_NEXT_RECORDING_DATETIME: - case PVR_NEXT_RECORDING_TITLE: - case PVR_NOW_RECORDING_CHANNEL: - case PVR_NOW_RECORDING_CHAN_ICO: - case PVR_NOW_RECORDING_DATETIME: - case PVR_NOW_RECORDING_TITLE: case PVR_BACKEND_NAME: case PVR_BACKEND_VERSION: case PVR_BACKEND_HOST: @@ -6019,10 +6090,6 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string * case PVR_BACKEND_NUMBER: case PVR_TOTAL_DISKSPACE: case PVR_NEXT_TIMER: - case PVR_EPG_EVENT_DURATION: - case PVR_EPG_EVENT_ELAPSED_TIME: - case PVR_EPG_EVENT_REMAINING_TIME: - case PVR_EPG_EVENT_FINISH_TIME: case PVR_EPG_EVENT_PROGRESS: case PVR_ACTUAL_STREAM_CLIENT: case PVR_ACTUAL_STREAM_DEVICE: @@ -6037,10 +6104,14 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string * case PVR_ACTUAL_STREAM_SERVICE: case PVR_ACTUAL_STREAM_MUX: case PVR_ACTUAL_STREAM_PROVIDER: - case PVR_TIMESHIFT_START_TIME: - case PVR_TIMESHIFT_END_TIME: - case PVR_TIMESHIFT_PLAY_TIME: - case PVR_TIMESHIFT_OFFSET: + case PVR_NOW_RECORDING_TITLE: + case PVR_NOW_RECORDING_CHANNEL: + case PVR_NOW_RECORDING_CHAN_ICO: + case PVR_NOW_RECORDING_DATETIME: + case PVR_NEXT_RECORDING_TITLE: + case PVR_NEXT_RECORDING_CHANNEL: + case PVR_NEXT_RECORDING_CHAN_ICO: + case PVR_NEXT_RECORDING_DATETIME: case PVR_TV_NOW_RECORDING_TITLE: case PVR_TV_NOW_RECORDING_CHANNEL: case PVR_TV_NOW_RECORDING_CHAN_ICO: @@ -6059,9 +6130,6 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string * case PVR_RADIO_NEXT_RECORDING_DATETIME: CServiceBroker::GetPVRManager().TranslateCharInfo(m_currentFile, info, strLabel); break; - case PVR_EPG_EVENT_SEEK_TIME: - CServiceBroker::GetPVRManager().GetSeekTimeLabel(g_application.GetAppPlayer().GetSeekHandler().GetSeekSize(), strLabel); - break; case PVR_CHANNEL_NUMBER_INPUT: strLabel = CServiceBroker::GetPVRManager().GUIActions()->GetChannelNumberInputHandler().GetChannelNumberAsString(); break; @@ -8025,6 +8093,10 @@ CGUIControl* CGUIInfoManager::GetActiveContainer(int containerId, int contextWin /// \brief Examines the multi information sent and returns the string as appropriate std::string CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWindow, std::string *fallback) { + std::string strValue; + if (CServiceBroker::GetPVRManager().GetMultiInfoLabel(m_currentFile, info, strValue)) + return strValue; + if (info.m_info == SKIN_STRING) { return CSkinSettings::GetInstance().GetString(info.GetData1()); @@ -8087,6 +8159,14 @@ std::string CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextW { return GetCurrentSeekTime((TIME_FORMAT)info.GetData1()); } + else if (info.m_info == PVR_EPG_EVENT_SEEK_TIME) + { + std::string strLabel; + CServiceBroker::GetPVRManager().GetSeekTimeLabel(g_application.GetAppPlayer().GetSeekHandler().GetSeekSize(), + static_cast(info.GetData1()), + strLabel); + return strLabel; + } else if (info.m_info == PLAYER_SEEKOFFSET) { std::string seekOffset = StringUtils::SecondsToTimeString(abs(m_seekOffset / 1000), (TIME_FORMAT)info.GetData1()); diff --git a/xbmc/GUIInfoManager.h b/xbmc/GUIInfoManager.h index 0656d26742..444fab331c 100644 --- a/xbmc/GUIInfoManager.h +++ b/xbmc/GUIInfoManager.h @@ -20,6 +20,7 @@ #pragma once #include "threads/CriticalSection.h" +#include "guiinfo/GUIInfo.h" #include "guilib/IMsgTargetCallback.h" #include "guilib/GUIControl.h" #include "messaging/IMessageTarget.h" @@ -54,33 +55,6 @@ namespace INFO // forward class CGUIWindow; -// structure to hold multiple integer data -// for storage referenced from a single integer -class GUIInfo -{ -public: - GUIInfo(int info, uint32_t data1 = 0, int data2 = 0, uint32_t flag = 0) - { - m_info = info; - m_data1 = data1; - m_data2 = data2; - if (flag) - SetInfoFlag(flag); - } - bool operator ==(const GUIInfo &right) const - { - return (m_info == right.m_info && m_data1 == right.m_data1 && m_data2 == right.m_data2); - }; - uint32_t GetInfoFlag() const; - uint32_t GetData1() const; - int GetData2() const; - int m_info; -private: - void SetInfoFlag(uint32_t flag); - uint32_t m_data1; - int m_data2; -}; - /*! \ingroup strings \brief diff --git a/xbmc/guiinfo/CMakeLists.txt b/xbmc/guiinfo/CMakeLists.txt index 4c01446be3..b52dbe9f71 100644 --- a/xbmc/guiinfo/CMakeLists.txt +++ b/xbmc/guiinfo/CMakeLists.txt @@ -1,4 +1,5 @@ -set(HEADERS GUIInfoLabels.h) +set(HEADERS GUIInfo.h + GUIInfoLabels.h) if(NOT ENABLE_STATIC_LIBS) core_add_library(guiinfo) diff --git a/xbmc/guiinfo/GUIInfo.h b/xbmc/guiinfo/GUIInfo.h new file mode 100644 index 0000000000..d7d0ac8a28 --- /dev/null +++ b/xbmc/guiinfo/GUIInfo.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2005-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ +#pragma once + +// structure to hold multiple integer data +// for storage referenced from a single integer +class GUIInfo +{ +public: + GUIInfo(int info, uint32_t data1 = 0, int data2 = 0, uint32_t flag = 0) + { + m_info = info; + m_data1 = data1; + m_data2 = data2; + if (flag) + SetInfoFlag(flag); + } + bool operator ==(const GUIInfo &right) const + { + return (m_info == right.m_info && m_data1 == right.m_data1 && m_data2 == right.m_data2); + }; + uint32_t GetInfoFlag() const; + uint32_t GetData1() const; + int GetData2() const; + int m_info; +private: + void SetInfoFlag(uint32_t flag); + uint32_t m_data1; + int m_data2; +}; diff --git a/xbmc/pvr/PVRGUIInfo.cpp b/xbmc/pvr/PVRGUIInfo.cpp index 8cca15d8e7..eacb089e4f 100644 --- a/xbmc/pvr/PVRGUIInfo.cpp +++ b/xbmc/pvr/PVRGUIInfo.cpp @@ -26,6 +26,7 @@ #include "Application.h" #include "ServiceBroker.h" #include "cores/DataCacheCore.h" +#include "guiinfo/GUIInfo.h" #include "guiinfo/GUIInfoLabels.h" #include "guilib/LocalizeStrings.h" #include "settings/AdvancedSettings.h" @@ -90,9 +91,6 @@ void CPVRGUIInfo::ResetProperties(void) m_iTimeshiftEndTime = time_t(0); m_iTimeshiftPlayTime = time_t(0); m_iTimeshiftOffset = 0; - m_strTimeshiftStartTime.clear(); - m_strTimeshiftEndTime.clear(); - m_strTimeshiftPlayTime.clear(); ResetPlayingTag(); ClearQualityInfo(m_qualityInfo); @@ -264,9 +262,6 @@ void CPVRGUIInfo::UpdateTimeshift(void) m_iTimeshiftPlayTime = 0; m_iLastTimeshiftUpdate = 0; m_iTimeshiftOffset = 0; - m_strTimeshiftStartTime.clear(); - m_strTimeshiftEndTime.clear(); - m_strTimeshiftPlayTime.clear(); } return; } @@ -309,16 +304,6 @@ void CPVRGUIInfo::UpdateTimeshift(void) m_iTimeshiftOffset = now - m_iTimeshiftPlayTime; - CDateTime tmp; - tmp.SetFromUTCDateTime(m_iTimeshiftStartTime); - m_strTimeshiftStartTime = tmp.GetAsLocalizedTime("", false); - - tmp.SetFromUTCDateTime(m_iTimeshiftEndTime); - m_strTimeshiftEndTime = tmp.GetAsLocalizedTime("", false); - - tmp.SetFromUTCDateTime(m_iTimeshiftPlayTime); - m_strTimeshiftPlayTime = tmp.GetAsLocalizedTime("", true); - m_bHasTimeshiftData = true; } @@ -401,18 +386,6 @@ bool CPVRGUIInfo::TranslateCharInfo(const CFileItem *item, DWORD dwInfo, std::st case PVR_RADIO_NEXT_RECORDING_DATETIME: m_radioTimersInfo.CharInfoNextTimerDateTime(strValue); break; - case PVR_EPG_EVENT_DURATION: - CharInfoEpgEventDuration(item, strValue); - break; - case PVR_EPG_EVENT_ELAPSED_TIME: - CharInfoEpgEventElapsedTime(item, strValue); - break; - case PVR_EPG_EVENT_REMAINING_TIME: - CharInfoEpgEventRemainingTime(item, strValue); - break; - case PVR_EPG_EVENT_FINISH_TIME: - CharInfoEpgEventFinishTime(item, strValue); - break; case PVR_NEXT_TIMER: m_anyTimersInfo.CharInfoNextTimer(strValue); break; @@ -479,18 +452,6 @@ bool CPVRGUIInfo::TranslateCharInfo(const CFileItem *item, DWORD dwInfo, std::st case PVR_TOTAL_DISKSPACE: CharInfoTotalDiskSpace(strValue); break; - case PVR_TIMESHIFT_START_TIME: - CharInfoTimeshiftStartTime(strValue); - break; - case PVR_TIMESHIFT_END_TIME: - CharInfoTimeshiftEndTime(strValue); - break; - case PVR_TIMESHIFT_PLAY_TIME: - CharInfoTimeshiftPlayTime(strValue); - break; - case PVR_TIMESHIFT_OFFSET: - CharInfoTimeshiftOffset(strValue); - break; default: strValue.clear(); bReturn = false; @@ -648,6 +609,7 @@ bool CPVRGUIInfo::GetVideoLabel(const CFileItem *item, int iLabel, std::string & } case VIDEOPLAYER_CHANNEL_GROUP: { + CSingleLock lock(m_critSection); strValue = recording->IsRadio() ? m_strPlayingRadioGroup : m_strPlayingTVGroup; return true; } @@ -821,6 +783,7 @@ bool CPVRGUIInfo::GetVideoLabel(const CFileItem *item, int iLabel, std::string & } case VIDEOPLAYER_CHANNEL_GROUP: { + CSingleLock lock(m_critSection); strValue = channel->IsRadio() ? m_strPlayingRadioGroup : m_strPlayingTVGroup; return true; } @@ -847,33 +810,86 @@ bool CPVRGUIInfo::GetVideoLabel(const CFileItem *item, int iLabel, std::string & return false; } -bool CPVRGUIInfo::GetSeekTimeLabel(int iSeekSize, std::string &strValue) const +bool CPVRGUIInfo::GetMultiInfoLabel(const CFileItem *item, const GUIInfo &info, std::string &strValue) const { - strValue = StringUtils::SecondsToTimeString(GetElapsedTime() + iSeekSize, TIME_FORMAT_GUESS).c_str(); + CSingleLock lock(m_critSection); + + switch (info.m_info) + { + case PVR_EPG_EVENT_DURATION: + CharInfoEpgEventDuration(item, static_cast(info.GetData1()), strValue); + break; + case PVR_EPG_EVENT_ELAPSED_TIME: + CharInfoEpgEventElapsedTime(item, static_cast(info.GetData1()), strValue); + break; + case PVR_EPG_EVENT_REMAINING_TIME: + CharInfoEpgEventRemainingTime(item, static_cast(info.GetData1()), strValue); + break; + case PVR_EPG_EVENT_FINISH_TIME: + CharInfoEpgEventFinishTime(item, static_cast(info.GetData1()), strValue); + break; + case PVR_TIMESHIFT_START_TIME: + CharInfoTimeshiftStartTime(static_cast(info.GetData1()), strValue); + break; + case PVR_TIMESHIFT_END_TIME: + CharInfoTimeshiftEndTime(static_cast(info.GetData1()), strValue); + break; + case PVR_TIMESHIFT_PLAY_TIME: + CharInfoTimeshiftPlayTime(static_cast(info.GetData1()), strValue); + break; + case PVR_TIMESHIFT_OFFSET: + CharInfoTimeshiftOffset(static_cast(info.GetData1()), strValue); + break; + default: + return false; + } + return true; +} + +bool CPVRGUIInfo::GetSeekTimeLabel(int iSeekSize, TIME_FORMAT format, std::string &strValue) const +{ + CSingleLock lock(m_critSection); + strValue = StringUtils::SecondsToTimeString(GetElapsedTime() + iSeekSize, format).c_str(); return true; } -void CPVRGUIInfo::CharInfoTimeshiftStartTime(std::string &strValue) const +namespace +{ + int TimeFromDateTime(time_t datetime) + { + CDateTime time; + time.SetFromUTCDateTime(datetime); + return time.GetHour() * 60 * 60 + time.GetMinute() * 60 + time.GetSecond(); + } +} // unnamed namespace + +void CPVRGUIInfo::CharInfoTimeshiftStartTime(TIME_FORMAT format, std::string &strValue) const { - strValue = m_strTimeshiftStartTime; + if (format == TIME_FORMAT_GUESS) + format = TIME_FORMAT_HH_MM; + + strValue = StringUtils::SecondsToTimeString(TimeFromDateTime(m_iTimeshiftStartTime), format).c_str(); } -void CPVRGUIInfo::CharInfoTimeshiftEndTime(std::string &strValue) const +void CPVRGUIInfo::CharInfoTimeshiftEndTime(TIME_FORMAT format, std::string &strValue) const { - strValue = m_strTimeshiftEndTime; + if (format == TIME_FORMAT_GUESS) + format = TIME_FORMAT_HH_MM; + + strValue = StringUtils::SecondsToTimeString(TimeFromDateTime(m_iTimeshiftEndTime), format).c_str(); } -void CPVRGUIInfo::CharInfoTimeshiftPlayTime(std::string &strValue) const +void CPVRGUIInfo::CharInfoTimeshiftPlayTime(TIME_FORMAT format, std::string &strValue) const { - strValue = m_strTimeshiftPlayTime; + strValue = StringUtils::SecondsToTimeString(TimeFromDateTime(m_iTimeshiftPlayTime), format).c_str(); } -void CPVRGUIInfo::CharInfoTimeshiftOffset(std::string &strValue) const +void CPVRGUIInfo::CharInfoTimeshiftOffset(TIME_FORMAT format, std::string &strValue) const { - strValue = StringUtils::SecondsToTimeString(m_iTimeshiftOffset, TIME_FORMAT_GUESS).c_str(); + strValue = StringUtils::SecondsToTimeString(m_iTimeshiftOffset, format).c_str(); } -void CPVRGUIInfo::CharInfoEpgEventDuration(const CFileItem *item, std::string &strValue) const +void CPVRGUIInfo::CharInfoEpgEventDuration(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const { int iDuration = 0; CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); @@ -882,10 +898,10 @@ void CPVRGUIInfo::CharInfoEpgEventDuration(const CFileItem *item, std::string &s else iDuration = m_iDuration; - strValue = StringUtils::SecondsToTimeString(iDuration, TIME_FORMAT_GUESS).c_str(); + strValue = StringUtils::SecondsToTimeString(iDuration, format).c_str(); } -void CPVRGUIInfo::CharInfoEpgEventElapsedTime(const CFileItem *item, std::string &strValue) const +void CPVRGUIInfo::CharInfoEpgEventElapsedTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const { int iElapsed = 0; CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); @@ -894,10 +910,10 @@ void CPVRGUIInfo::CharInfoEpgEventElapsedTime(const CFileItem *item, std::string else iElapsed = GetElapsedTime(); - strValue = StringUtils::SecondsToTimeString(iElapsed, TIME_FORMAT_GUESS).c_str(); + strValue = StringUtils::SecondsToTimeString(iElapsed, format).c_str(); } -void CPVRGUIInfo::CharInfoEpgEventRemainingTime(const CFileItem *item, std::string &strValue) const +int CPVRGUIInfo::GetRemainingTime(const CFileItem *item) const { int iRemaining = 0; CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); @@ -906,21 +922,22 @@ void CPVRGUIInfo::CharInfoEpgEventRemainingTime(const CFileItem *item, std::stri else iRemaining = m_iDuration - GetElapsedTime(); - strValue = StringUtils::SecondsToTimeString(iRemaining, TIME_FORMAT_GUESS).c_str(); + return iRemaining; } -void CPVRGUIInfo::CharInfoEpgEventFinishTime(const CFileItem *item, std::string &strValue) const +void CPVRGUIInfo::CharInfoEpgEventRemainingTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const { - int iFinish = 0; - CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); - if (epgTag && epgTag != m_playingEpgTag) - iFinish = epgTag->GetDuration() - epgTag->Progress(); - else - iFinish = m_iDuration - GetElapsedTime(); + strValue = StringUtils::SecondsToTimeString(GetRemainingTime(item), format).c_str(); +} + +void CPVRGUIInfo::CharInfoEpgEventFinishTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const +{ + if (format == TIME_FORMAT_GUESS) + format = TIME_FORMAT_HH_MM; - CDateTime finishTime = CDateTime::GetCurrentDateTime(); - finishTime += CDateTimeSpan(0, 0, 0, iFinish); - strValue = finishTime.GetAsLocalizedTime("", false); + CDateTime finish = CDateTime::GetCurrentDateTime(); + finish += CDateTimeSpan(0, 0, 0, GetRemainingTime(item)); + strValue = StringUtils::SecondsToTimeString(finish.GetHour() * 60 * 60 + finish.GetMinute() * 60 + finish.GetSecond(), format).c_str(); } void CPVRGUIInfo::CharInfoBackendNumber(std::string &strValue) const diff --git a/xbmc/pvr/PVRGUIInfo.h b/xbmc/pvr/PVRGUIInfo.h index 76fe21e99f..2f6213346c 100644 --- a/xbmc/pvr/PVRGUIInfo.h +++ b/xbmc/pvr/PVRGUIInfo.h @@ -31,6 +31,8 @@ #include "pvr/PVRTypes.h" #include "pvr/addons/PVRClients.h" +class GUIInfo; + namespace PVR { class CPVRGUIInfo : private CThread, @@ -58,13 +60,23 @@ namespace PVR */ bool GetVideoLabel(const CFileItem *item, int iLabel, std::string &strValue) const; + /*! + * @brief Get a GUIInfoManager multi info label. + * @param item The item to get the label for. + * @param info The GUI info (label id + additional data). + * @param strValue Will be filled with the requested label value. + * @return True if the requested label value was set, false otherwise. + */ + bool GetMultiInfoLabel(const CFileItem *item, const GUIInfo &info, std::string &strValue) const; + /*! * @brief Get a GUIInfoManager seek time label for the currently playing epg tag. * @param iSeekSize The seconds to be seeked from the current playback position. + * @param format The time format for the label. * @param strValue Will be filled with the requested label value. * @return True if the label value was set, false otherwise. */ - bool GetSeekTimeLabel(int iSeekSize, std::string &strValue) const; + bool GetSeekTimeLabel(int iSeekSize, TIME_FORMAT format, std::string &strValue) const; /*! * @brief Get the total duration of the currently playing epg event or if no epg is @@ -198,10 +210,10 @@ namespace PVR void UpdateTimersToggle(void); - void CharInfoEpgEventDuration(const CFileItem *item, std::string &strValue) const; - void CharInfoEpgEventElapsedTime(const CFileItem *item, std::string &strValue) const; - void CharInfoEpgEventRemainingTime(const CFileItem *item, std::string &strValue) const; - void CharInfoEpgEventFinishTime(const CFileItem *item, std::string &strValue) const; + void CharInfoEpgEventDuration(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const; + void CharInfoEpgEventElapsedTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const; + void CharInfoEpgEventRemainingTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const; + void CharInfoEpgEventFinishTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const; void CharInfoBackendNumber(std::string &strValue) const; void CharInfoTotalDiskSpace(std::string &strValue) const; void CharInfoSignal(std::string &strValue) const; @@ -223,10 +235,12 @@ namespace PVR void CharInfoService(std::string &strValue) const; void CharInfoMux(std::string &strValue) const; void CharInfoProvider(std::string &strValue) const; - void CharInfoTimeshiftStartTime(std::string &strValue) const; - void CharInfoTimeshiftEndTime(std::string &strValue) const; - void CharInfoTimeshiftPlayTime(std::string &strValue) const; - void CharInfoTimeshiftOffset(std::string &strValue) const; + void CharInfoTimeshiftStartTime(TIME_FORMAT format, std::string &strValue) const; + void CharInfoTimeshiftEndTime(TIME_FORMAT format, std::string &strValue) const; + void CharInfoTimeshiftPlayTime(TIME_FORMAT format, std::string &strValue) const; + void CharInfoTimeshiftOffset(TIME_FORMAT format, std::string &strValue) const; + + int GetRemainingTime(const CFileItem *item) const; /** @name GUIInfoManager data */ //@{ @@ -275,9 +289,6 @@ namespace PVR time_t m_iTimeshiftEndTime; time_t m_iTimeshiftPlayTime; unsigned int m_iTimeshiftOffset; - std::string m_strTimeshiftStartTime; - std::string m_strTimeshiftEndTime; - std::string m_strTimeshiftPlayTime; CCriticalSection m_critSection; diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 9a1abd811e..32f13df9d7 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -829,9 +829,14 @@ bool CPVRManager::GetVideoLabel(const CFileItem *item, int iLabel, std::string & return IsStarted() && m_guiInfo ? m_guiInfo->GetVideoLabel(item, iLabel, strValue) : false; } -bool CPVRManager::GetSeekTimeLabel(int iSeekSize, std::string &strValue) const +bool CPVRManager::GetMultiInfoLabel(const CFileItem *item, const GUIInfo &info, std::string &strValue) const { - return IsStarted() && m_guiInfo ? m_guiInfo->GetSeekTimeLabel(iSeekSize, strValue) : false; + return IsStarted() && m_guiInfo ? m_guiInfo->GetMultiInfoLabel(item, info, strValue) : false; +} + +bool CPVRManager::GetSeekTimeLabel(int iSeekSize, TIME_FORMAT format, std::string &strValue) const +{ + return IsStarted() && m_guiInfo ? m_guiInfo->GetSeekTimeLabel(iSeekSize, format, strValue) : false; } bool CPVRManager::IsRecording(void) const diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 1344f0cd84..3b24923d62 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -42,6 +42,7 @@ class CStopWatch; class CVariant; +class GUIInfo; namespace PVR { @@ -193,13 +194,23 @@ namespace PVR */ bool GetVideoLabel(const CFileItem *item, int iLabel, std::string &strValue) const; + /*! + * @brief Get a GUIInfoManager multi info label. + * @param item The item to get the label for. + * @param info The GUI info (label id + additional data). + * @param strValue Will be filled with the requested label value. + * @return True if the requested label value was set, false otherwise. + */ + bool GetMultiInfoLabel(const CFileItem *item, const GUIInfo &info, std::string &strValue) const; + /*! * @brief Get a GUIInfoManager seek time label for the currently playing epg tag. * @param iSeekSize The seconds to be seeked from the current playback position. + * @param format The time format for the label. * @param strValue Will be filled with the requested label value. * @return True if the label value was set, false otherwise. */ - bool GetSeekTimeLabel(int iSeekSize, std::string &strValue) const; + bool GetSeekTimeLabel(int iSeekSize, TIME_FORMAT format, std::string &strValue) const; /*! * @brief Check if a TV channel, radio channel or recording is playing. -- cgit v1.2.3 From d4a7fe27d4717937663092583ab9eca77b8ef078 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Thu, 15 Mar 2018 13:05:10 +0100 Subject: [guiinfo] All labels using time format strings now support new formats 'secs' 'mins' and 'hours' (Example: Player.Duration for a 145 minutes movie: hh:mm:ss=2:25:00, hh=2, mm=25, ss=0, hours=2, mins=145, secs=8700). --- xbmc/GUIInfoManager.cpp | 110 ++++++++++++++++++++++++++++----------------- xbmc/XBDateTime.h | 5 ++- xbmc/utils/StringUtils.cpp | 47 +++++++++++-------- 3 files changed, 102 insertions(+), 60 deletions(-) diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index cbd3014c73..dad6f0730c 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -540,8 +540,10 @@ const infomap player_param[] = {{ "art", PLAYER_ITEM_ART }}; /// \table_row3{ `Player.SeekOffset(format)`, /// \anchor Player_SeekOffset_format /// _string_, -/// Returns hours (hh)\, minutes (mm) or seconds (ss). Also supported: (hh:mm)\, -/// (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// Returns hours (hh)\, minutes (mm) or seconds (ss). +/// Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `Player.SeekStepSize`, /// \anchor Player_SeekStepSize @@ -556,9 +558,10 @@ const infomap player_param[] = {{ "art", PLAYER_ITEM_ART }}; /// \table_row3{ `Player.TimeRemaining(format)`, /// \anchor Player_TimeRemaining_format /// _string_, -/// Returns hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is -/// used (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, -/// (hh:mm:ss)\, (hh:mm:ss). +/// Returns hours (hh)\, minutes (mm) or seconds (ss). +/// Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `Player.TimeSpeed`, /// \anchor Player_TimeSpeed @@ -573,9 +576,10 @@ const infomap player_param[] = {{ "art", PLAYER_ITEM_ART }}; /// \table_row3{ `Player.Time(format)`, /// \anchor Player_Time_format /// _string_, -/// Returns hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is -/// used (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, -/// (hh:mm:ss)\, (hh:mm:ss). +/// Returns hours (hh)\, minutes (mm) or seconds (ss). +/// Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `Player.Duration`, /// \anchor Player_Duration @@ -585,9 +589,10 @@ const infomap player_param[] = {{ "art", PLAYER_ITEM_ART }}; /// \table_row3{ `Player.Duration(format)`, /// \anchor Player_Duration_format /// _string_, -/// Returns hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used -/// (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, -/// (hh:mm:ss). +/// Returns hours (hh)\, minutes (mm) or seconds (ss). +/// Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `Player.FinishTime`, /// \anchor Player_FinishTime @@ -597,9 +602,10 @@ const infomap player_param[] = {{ "art", PLAYER_ITEM_ART }}; /// \table_row3{ `Player.FinishTime(format)`, /// \anchor Player_FinishTime_format /// _string_, -/// Returns hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is -/// used (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, -/// (hh:mm:ss)\, (hh:mm:ss). +/// Returns hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used +/// (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `Player.StartTime`, /// \anchor Player_StartTime @@ -609,9 +615,10 @@ const infomap player_param[] = {{ "art", PLAYER_ITEM_ART }}; /// \table_row3{ `Player.StartTime(format)`, /// \anchor Player_StartTime_format /// _string_, -/// Returns hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is -/// used (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, -/// (hh:mm:ss)\, (hh:mm:ss). +/// Returns hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used +/// (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `Player.SeekNumeric`, /// \anchor Player_SeekNumeric @@ -622,8 +629,9 @@ const infomap player_param[] = {{ "art", PLAYER_ITEM_ART }}; /// \anchor Player_SeekNumeric_format /// _string_, /// Returns hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used -/// (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, -/// (hh:mm:ss). +/// (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_end /// @@ -899,9 +907,10 @@ const infomap weather[] = {{ "isfetched", WEATHER_IS_FETCHED }, /// \table_row3{ `System.Time(format)`, /// \anchor System_Time_format /// _string_, -/// Returns hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is -/// used (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, -/// (hh:mm:ss)\, (hh:mm:ss). (xx) option added after dharma +/// Returns hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used +/// (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `System.Date`, /// \anchor System_Date @@ -4673,8 +4682,10 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING /// \anchor PVR_EpgEventDuration_format /// _string_, /// Returns the duration of the currently playing epg event in different formats: -/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will -/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// Hours (hh)\, minutes (mm) or seconds (ss). +/// Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `PVR.EpgEventElapsedTime`, /// \anchor PVR_EpgEventElapsedTime @@ -4686,8 +4697,10 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING /// \anchor PVR_EpgEventElapsedTime_format /// _string_, /// Returns the time of the current position of the currently playing epg event in different formats: -/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will -/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// Hours (hh)\, minutes (mm) or seconds (ss). +/// Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `PVR.EpgEventRemainingTime`, /// \anchor PVR_EpgEventRemainingTime @@ -4699,8 +4712,10 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING /// \anchor PVR_EpgEventRemainingTime_format /// _string_, /// Returns the remaining time for currently playing epg event in different formats: -/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will -/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// Hours (hh)\, minutes (mm) or seconds (ss). +/// Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `PVR.EpgEventSeekTime`, /// \anchor PVR_EpgEventSeekTime @@ -4712,8 +4727,10 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING /// \anchor PVR_EpgEventSeekTime_format /// _string_, /// Returns the time the user is seeking within the currently playing epg event in different formats: -/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will -/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used +/// (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `PVR.EpgEventFinishTime`, /// \anchor PVR_EpgEventFinishTime @@ -4725,8 +4742,10 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING /// \anchor PVR_EpgEventFinishTime_format /// _string_, /// Returns the time the currently playing epg event will end in different formats: -/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will -/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used +/// (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `PVR.TimeShiftStart`, /// \anchor PVR_TimeShiftStart @@ -4738,8 +4757,10 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING /// \anchor PVR_TimeShiftStart_format /// _string_, /// Returns the start time of the timeshift buffer in different formats: -/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will -/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used +/// (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `PVR.TimeShiftEnd`, /// \anchor PVR_TimeShiftEnd @@ -4751,8 +4772,10 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING /// \anchor PVR_TimeShiftEnd_format /// _string_, /// Returns the end time of the timeshift buffer in different formats: -/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will -/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used +/// (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `PVR.TimeShiftCur`, /// \anchor PVR_TimeShiftCur @@ -4764,8 +4787,10 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING /// \anchor PVR_TimeShiftCur_format /// _string_, /// Returns the current playback time within the timeshift buffer in different formats: -/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will -/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used +/// (xx) will return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `PVR.TimeShiftOffset`, /// \anchor PVR_TimeShiftOffset @@ -4777,8 +4802,10 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING /// \anchor PVR_TimeShiftOffset_format /// _string_, /// Returns the delta of timeshifted time to actual time in different formats: -/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will -/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// Hours (hh)\, minutes (mm) or seconds (ss). +/// Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_end /// @@ -6023,6 +6050,9 @@ TIME_FORMAT CGUIInfoManager::TranslateTimeFormat(const std::string &format) else if (StringUtils::EqualsNoCase(format, "h:mm:ss")) return TIME_FORMAT_H_MM_SS; else if (StringUtils::EqualsNoCase(format, "h:mm:ss xx")) return TIME_FORMAT_H_MM_SS_XX; else if (StringUtils::EqualsNoCase(format, "xx")) return TIME_FORMAT_XX; + else if (StringUtils::EqualsNoCase(format, "secs")) return TIME_FORMAT_SECS; + else if (StringUtils::EqualsNoCase(format, "mins")) return TIME_FORMAT_MINS; + else if (StringUtils::EqualsNoCase(format, "hours")) return TIME_FORMAT_HOURS; return TIME_FORMAT_GUESS; } diff --git a/xbmc/XBDateTime.h b/xbmc/XBDateTime.h index a7cd5b9c56..4a06fb9db8 100644 --- a/xbmc/XBDateTime.h +++ b/xbmc/XBDateTime.h @@ -42,7 +42,10 @@ enum TIME_FORMAT { TIME_FORMAT_GUESS = 0, TIME_FORMAT_HH_MM_SS_XX = 15, TIME_FORMAT_H = 16, TIME_FORMAT_H_MM_SS = 19, - TIME_FORMAT_H_MM_SS_XX = 27}; + TIME_FORMAT_H_MM_SS_XX = 27, + TIME_FORMAT_SECS = 32, + TIME_FORMAT_MINS = 64, + TIME_FORMAT_HOURS = 128 }; class CDateTime; diff --git a/xbmc/utils/StringUtils.cpp b/xbmc/utils/StringUtils.cpp index fc4752d420..11cfcfcc30 100644 --- a/xbmc/utils/StringUtils.cpp +++ b/xbmc/utils/StringUtils.cpp @@ -865,26 +865,35 @@ long StringUtils::TimeStringToSeconds(const std::string &timeString) std::string StringUtils::SecondsToTimeString(long lSeconds, TIME_FORMAT format) { - bool isNegative = lSeconds < 0; - lSeconds = std::abs(lSeconds); - int hh = lSeconds / 3600; - lSeconds = lSeconds % 3600; - int mm = lSeconds / 60; - int ss = lSeconds % 60; - - if (format == TIME_FORMAT_GUESS) - format = (hh >= 1) ? TIME_FORMAT_HH_MM_SS : TIME_FORMAT_MM_SS; std::string strHMS; - if (format & TIME_FORMAT_HH) - strHMS += StringUtils::Format("%2.2i", hh); - else if (format & TIME_FORMAT_H) - strHMS += StringUtils::Format("%i", hh); - if (format & TIME_FORMAT_MM) - strHMS += StringUtils::Format(strHMS.empty() ? "%2.2i" : ":%2.2i", mm); - if (format & TIME_FORMAT_SS) - strHMS += StringUtils::Format(strHMS.empty() ? "%2.2i" : ":%2.2i", ss); - if (isNegative) - strHMS = "-" + strHMS; + if (format == TIME_FORMAT_SECS) + strHMS = StringUtils::Format("%i", lSeconds); + else if (format == TIME_FORMAT_MINS) + strHMS = StringUtils::Format("%i", lrintf(static_cast(lSeconds) / 60.0f)); + else if (format == TIME_FORMAT_HOURS) + strHMS = StringUtils::Format("%i", lrintf(static_cast(lSeconds) / 3600.0f)); + else + { + bool isNegative = lSeconds < 0; + lSeconds = std::abs(lSeconds); + int hh = lSeconds / 3600; + lSeconds = lSeconds % 3600; + int mm = lSeconds / 60; + int ss = lSeconds % 60; + + if (format == TIME_FORMAT_GUESS) + format = (hh >= 1) ? TIME_FORMAT_HH_MM_SS : TIME_FORMAT_MM_SS; + if (format & TIME_FORMAT_HH) + strHMS += StringUtils::Format("%2.2i", hh); + else if (format & TIME_FORMAT_H) + strHMS += StringUtils::Format("%i", hh); + if (format & TIME_FORMAT_MM) + strHMS += StringUtils::Format(strHMS.empty() ? "%2.2i" : ":%2.2i", mm); + if (format & TIME_FORMAT_SS) + strHMS += StringUtils::Format(strHMS.empty() ? "%2.2i" : ":%2.2i", ss); + if (isNegative) + strHMS = "-" + strHMS; + } return strHMS; } -- cgit v1.2.3 From c009a13ef6a1b2626430c6196c06adeb1800cb60 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Thu, 15 Mar 2018 15:45:31 +0100 Subject: [guiinfo] ListItem.Duration now supports time format strings. --- xbmc/GUIInfoManager.cpp | 77 ++++++++++++++++++++++++++++---------------- xbmc/GUIInfoManager.h | 1 + xbmc/guiinfo/GUIInfoLabels.h | 5 +-- 3 files changed, 54 insertions(+), 29 deletions(-) diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index dad6f0730c..df22cf8bda 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -3332,8 +3332,17 @@ const infomap container_str[] = {{ "property", CONTAINER_PROPERTY }, /// \table_row3{ `ListItem.Duration`, /// \anchor ListItem_Duration /// _string_, -/// Returns the song or movie duration of the currently selected movie in a -/// container +/// Returns the duration of the currently selected item in a container +/// in the format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ `ListItem.Duration(format)`, +/// \anchor ListItem.Duration_format +/// _string_, +/// Returns the duration of the currently selected item in a container in +/// different formats: hours (hh)\, minutes (mm) or seconds (ss). +/// Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (h:mm:ss). +/// Added with Leia: (secs)\, (mins)\, (hours) for total time values. +/// Example: 3661 seconds => hh=1\, mm=1\, ss=1\, hours=1\, mins=61\, secs=3661 /// } /// \table_row3{ `ListItem.DBTYPE`, /// \anchor ListItem_DBTYPE @@ -6016,6 +6025,8 @@ int CGUIInfoManager::TranslateListItem(const Property &info) return AddListItemProp(info.param(), LISTITEM_VOTES_OFFSET); if (info.name == "ratingandvotes") return AddListItemProp(info.param(), LISTITEM_RATING_AND_VOTES_OFFSET); + if (info.name == "duration") + return AddListItemProp(info.param(), LISTITEM_DURATION_OFFSET); } for (size_t i = 0; i < sizeof(listitem_labels) / sizeof(infomap); i++) // these ones don't have or need an id @@ -9590,6 +9601,36 @@ bool CGUIInfoManager::GetItemInt(int &value, const CGUIListItem *item, int info) return false; } +std::string CGUIInfoManager::GetItemDuration(const CFileItem *item, TIME_FORMAT format) const +{ + int iDuration = -1; + if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer()) + { + const CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); + if (epgTag) + iDuration = epgTag->GetDuration(); + } + else if (item->HasVideoInfoTag()) + { + if (item->GetVideoInfoTag()->GetDuration() > 0) + iDuration = item->GetVideoInfoTag()->GetDuration(); + } + else if (item->HasMusicInfoTag()) + { + if (item->GetMusicInfoTag()->GetDuration() > 0) + iDuration = item->GetMusicInfoTag()->GetDuration(); + } + else if (item->HasProperty(FILEITEM_PROPERTY_SAVESTATE_DURATION)) + { + iDuration = static_cast(item->GetProperty(FILEITEM_PROPERTY_SAVESTATE_DURATION).asInteger()); + } + + if (iDuration != -1) + return StringUtils::SecondsToTimeString(iDuration, format); + + return std::string(); +} + std::string CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::string *fallback) { if (!item) return ""; @@ -9629,6 +9670,12 @@ std::string CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std:: return FormatRatingAndVotes(rating.rating, rating.votes); } + if (info >= LISTITEM_PROPERTY_START + LISTITEM_DURATION_OFFSET && + info - (LISTITEM_PROPERTY_START + LISTITEM_DURATION_OFFSET) < static_cast(m_listitemProperties.size())) + { + return GetItemDuration(item, TranslateTimeFormat(m_listitemProperties[info - (LISTITEM_PROPERTY_START + LISTITEM_DURATION_OFFSET)])); + } + if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size()) { std::string property = m_listitemProperties[info - LISTITEM_PROPERTY_START]; @@ -9897,31 +9944,7 @@ std::string CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std:: } case LISTITEM_DURATION: { - std::string duration; - if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer()) - { - const CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); - if (epgTag) - return StringUtils::SecondsToTimeString(epgTag->GetDuration()); - else - return std::string(); - } - else if (item->HasVideoInfoTag()) - { - if (item->GetVideoInfoTag()->GetDuration() > 0) - duration = StringUtils::SecondsToTimeString(item->GetVideoInfoTag()->GetDuration()); - } - else if (item->HasMusicInfoTag()) - { - if (item->GetMusicInfoTag()->GetDuration() > 0) - duration = StringUtils::SecondsToTimeString(item->GetMusicInfoTag()->GetDuration()); - } - else if (item->HasProperty(FILEITEM_PROPERTY_SAVESTATE_DURATION)) - { - long iDuration = static_cast(item->GetProperty(FILEITEM_PROPERTY_SAVESTATE_DURATION).asInteger()); - duration = StringUtils::SecondsToTimeString(iDuration); - } - return duration; + return GetItemDuration(item, TIME_FORMAT_GUESS); } case LISTITEM_PLOT: if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer()) diff --git a/xbmc/GUIInfoManager.h b/xbmc/GUIInfoManager.h index 444fab331c..86ce562604 100644 --- a/xbmc/GUIInfoManager.h +++ b/xbmc/GUIInfoManager.h @@ -311,6 +311,7 @@ private: static std::string GetEpgEventTitle(const PVR::CPVREpgInfoTagPtr& epgTag); static std::string FormatRatingAndVotes(float rating, int votes); bool IsPlayerChannelPreviewActive() const; + std::string GetItemDuration(const CFileItem *item, TIME_FORMAT format) const; }; /*! diff --git a/xbmc/guiinfo/GUIInfoLabels.h b/xbmc/guiinfo/GUIInfoLabels.h index d0ec637a07..24eaea41ea 100644 --- a/xbmc/guiinfo/GUIInfoLabels.h +++ b/xbmc/guiinfo/GUIInfoLabels.h @@ -822,7 +822,7 @@ //! @todo There are issues with the LISTITEM_PROPERTY range, breakage occurs when more than 200 properties are used in skins. #define LISTITEM_PROPERTY_START (LISTITEM_START + 200) -#define LISTITEM_PROPERTY_END (LISTITEM_PROPERTY_START + 2300) +#define LISTITEM_PROPERTY_END (LISTITEM_PROPERTY_START + 2500) #define LISTITEM_END (LISTITEM_PROPERTY_END) #define MUSICPLAYER_PROPERTY_OFFSET 1300 // 200 id's reserved for musicplayer props. @@ -830,8 +830,9 @@ #define LISTITEM_RATING_OFFSET 1700 // 200 id's reserved for listitem ratings. #define LISTITEM_VOTES_OFFSET 1900 // 200 id's reserved for listitem votes. #define LISTITEM_RATING_AND_VOTES_OFFSET 2100 // 200 id's reserved for listitem ratingandvotes. +#define LISTITEM_DURATION_OFFSET 2300 // 200 id's reserved for listitem duration. -#define CONDITIONAL_LABEL_START LISTITEM_END + 1 // 37501 +#define CONDITIONAL_LABEL_START LISTITEM_END + 1 // 37701 #define CONDITIONAL_LABEL_END 38500 // the multiple information vector -- cgit v1.2.3