diff options
author | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2015-12-10 16:54:09 +0100 |
---|---|---|
committer | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2015-12-16 14:51:04 +0100 |
commit | 142faf9ee7c90341c3007c197ef30f8a82303559 (patch) | |
tree | 5e08639d8301c0758a4c65a8717df4a4b736fe10 | |
parent | c80bcfa018076194b6d6a61a03417ea54757ecf4 (diff) |
[PVR] Split Timer window containing both timers and timer rules into separate "Timer rules" and "Timers" windows
22 files changed, 652 insertions, 450 deletions
diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po index adce230dc2..c4844076b8 100644 --- a/addons/resource.language.en_gb/resources/strings.po +++ b/addons/resource.language.en_gb/resources/strings.po @@ -9045,7 +9045,11 @@ msgctxt "#19137" msgid "No groups defined. Please create a group first" msgstr "" -#empty string with id 19138 +#. Label of timer rules tv/radio home submenu item +#: skin.confluence +msgctxt "#19138" +msgid "Timer rules" +msgstr "" msgctxt "#19139" msgid "Name of the new group" diff --git a/addons/skin.confluence/720p/IncludesHomeMenuItems.xml b/addons/skin.confluence/720p/IncludesHomeMenuItems.xml index 30346dce9f..533635b046 100644 --- a/addons/skin.confluence/720p/IncludesHomeMenuItems.xml +++ b/addons/skin.confluence/720p/IncludesHomeMenuItems.xml @@ -268,15 +268,20 @@ </control> <control type="button" id="90146"> <include>ButtonHomeSubCommonValues</include> + <label>19138</label> + <onclick>ActivateWindow(TVTimerRules)</onclick> + </control> + <control type="button" id="90147"> + <include>ButtonHomeSubCommonValues</include> <label>19040</label> <onclick>ActivateWindow(TVTimers)</onclick> </control> - <control type="button" id="90147"> + <control type="button" id="90148"> <include>ButtonHomeSubCommonValues</include> <label>137</label> <onclick>ActivateWindow(TVSearch)</onclick> </control> - <control type="image" id="90148"> + <control type="image" id="90149"> <width>35</width> <height>35</height> <texture border="0,0,0,3">HomeSubEnd.png</texture> @@ -305,15 +310,20 @@ </control> <control type="button" id="90246"> <include>ButtonHomeSubCommonValues</include> + <label>19138</label> + <onclick>ActivateWindow(RadioTimerRules)</onclick> + </control> + <control type="button" id="90247"> + <include>ButtonHomeSubCommonValues</include> <label>19040</label> <onclick>ActivateWindow(RadioTimers)</onclick> </control> - <control type="button" id="90247"> + <control type="button" id="90248"> <include>ButtonHomeSubCommonValues</include> <label>137</label> <onclick>ActivateWindow(RadioSearch)</onclick> </control> - <control type="image" id="90248"> + <control type="image" id="90249"> <width>35</width> <height>35</height> <texture border="0,0,0,3">HomeSubEnd.png</texture> diff --git a/addons/skin.confluence/720p/IncludesPVR.xml b/addons/skin.confluence/720p/IncludesPVR.xml index 92bb15a85a..a73440eebf 100644 --- a/addons/skin.confluence/720p/IncludesPVR.xml +++ b/addons/skin.confluence/720p/IncludesPVR.xml @@ -47,6 +47,11 @@ </control> <control type="label"> <include>WindowTitleCommons</include> + <label>[COLOR=blue] - [/COLOR]$LOCALIZE[19138]</label> + <visible>Window.IsActive(TVTimerRules) | Window.IsActive(RadioTimerRules)</visible> + </control> + <control type="label"> + <include>WindowTitleCommons</include> <label>[COLOR=blue] - [/COLOR]$LOCALIZE[19040]</label> <visible>Window.IsActive(TVTimers) | Window.IsActive(RadioTimers)</visible> </control> @@ -123,6 +128,14 @@ <onclick condition="IsEmpty(Window.Property(IsRadio))">ActivateWindow(TVRecordings)</onclick> <onclick condition="!IsEmpty(Window.Property(IsRadio))">ActivateWindow(RadioRecordings)</onclick> </control> + <control type="button" id="105"> + <description>Timer Rules</description> + <textwidth>235</textwidth> + <include>ButtonCommonValues</include> + <label>19138</label> + <onclick condition="IsEmpty(Window.Property(IsRadio))">ActivateWindow(TVTimerRules)</onclick> + <onclick condition="!IsEmpty(Window.Property(IsRadio))">ActivateWindow(RadioTimerRules)</onclick> + </control> <control type="button" id="103"> <description>Timers</description> <textwidth>235</textwidth> @@ -228,7 +241,7 @@ <textwidth>235</textwidth> <include>ButtonCommonValues</include> <label>19077</label> - <visible>Window.IsActive(TVTimers) | Window.IsActive(RadioTimers)</visible> + <visible>Window.IsActive(TVTimers) | Window.IsActive(RadioTimers) | Window.IsActive(TVTimerRules) | Window.IsActive(RadioTimerRules)</visible> </control> <!-- Playback controls --> <include>CommonNowPlaying_Controls</include> diff --git a/addons/skin.confluence/720p/MyPVRTimers.xml b/addons/skin.confluence/720p/MyPVRTimers.xml index 87ca26bb81..e6ac977f3f 100644 --- a/addons/skin.confluence/720p/MyPVRTimers.xml +++ b/addons/skin.confluence/720p/MyPVRTimers.xml @@ -132,7 +132,8 @@ <height>330</height> <onup>50</onup> <ondown>50</ondown> - <onleft>103</onleft> + <onleft condition="Window.IsActive(TVTimers) | Window.IsActive(RadioTimers)">103</onleft> + <onleft condition="Window.IsActive(TVTimerRules) | Window.IsActive(RadioTimerRules)">105</onleft> <onright>73</onright> <pagecontrol>73</pagecontrol> <scrolltime>200</scrolltime> @@ -323,7 +324,8 @@ <textureslidernib>ScrollBarNib.png</textureslidernib> <textureslidernibfocus>ScrollBarNib.png</textureslidernibfocus> <onleft>50</onleft> - <onright>103</onright> + <onright condition="Window.IsActive(TVTimers) | Window.IsActive(RadioTimers)">103</onright> + <onright condition="Window.IsActive(TVTimerRules) | Window.IsActive(RadioTimerRules)">105</onright> <showonepage>false</showonepage> <orientation>vertical</orientation> </control> @@ -422,7 +424,24 @@ <control type="label"> <depth>DepthFooter</depth> <animation effect="slide" start="0,0" end="-90,0" time="0" condition="system.getbool(input.enablemouse)">Conditional</animation> - <description>Page Count Label</description> + <description>Page Count Label for Timer Rules</description> + <right>40</right> + <top>53r</top> + <width>500</width> + <height>20</height> + <font>font12</font> + <textcolor>grey</textcolor> + <scroll>false</scroll> + <align>right</align> + <aligny>center</aligny> + <label>([COLOR=blue]$INFO[Container(50).NumItems][/COLOR]) $LOCALIZE[19138] - $LOCALIZE[31024] ([COLOR=blue]$INFO[Container(50).CurrentPage]/$INFO[Container(50).NumPages][/COLOR])</label> + <visible>Window.IsActive(TVTimerRules) | Window.IsActive(RadioTimerRules)</visible> + <include>Window_OpenClose_Animation</include> + </control> + <control type="label"> + <depth>DepthFooter</depth> + <animation effect="slide" start="0,0" end="-90,0" time="0" condition="system.getbool(input.enablemouse)">Conditional</animation> + <description>Page Count Label for Timers</description> <right>40</right> <top>53r</top> <width>500</width> @@ -433,6 +452,7 @@ <align>right</align> <aligny>center</aligny> <label>([COLOR=blue]$INFO[Container(50).NumItems][/COLOR]) $LOCALIZE[19040] - $LOCALIZE[31024] ([COLOR=blue]$INFO[Container(50).CurrentPage]/$INFO[Container(50).NumPages][/COLOR])</label> + <visible>Window.IsActive(TVTimers) | Window.IsActive(RadioTimers)</visible> <include>Window_OpenClose_Animation</include> </control> </control> diff --git a/xbmc/guilib/GUIWindowManager.cpp b/xbmc/guilib/GUIWindowManager.cpp index 455feac391..76ff33fd10 100644 --- a/xbmc/guilib/GUIWindowManager.cpp +++ b/xbmc/guilib/GUIWindowManager.cpp @@ -120,6 +120,7 @@ #include "pvr/windows/GUIWindowPVRRecordings.h" #include "pvr/windows/GUIWindowPVRGuide.h" #include "pvr/windows/GUIWindowPVRTimers.h" +#include "pvr/windows/GUIWindowPVRTimerRules.h" #include "pvr/windows/GUIWindowPVRSearch.h" #include "pvr/dialogs/GUIDialogPVRChannelManager.h" #include "pvr/dialogs/GUIDialogPVRChannelsOSD.h" @@ -250,11 +251,13 @@ void CGUIWindowManager::CreateWindows() Add(new CGUIWindowPVRRecordings(false)); Add(new CGUIWindowPVRGuide(false)); Add(new CGUIWindowPVRTimers(false)); + Add(new CGUIWindowPVRTimerRules(false)); Add(new CGUIWindowPVRSearch(false)); Add(new CGUIWindowPVRChannels(true)); Add(new CGUIWindowPVRRecordings(true)); Add(new CGUIWindowPVRGuide(true)); Add(new CGUIWindowPVRTimers(true)); + Add(new CGUIWindowPVRTimerRules(true)); Add(new CGUIDialogPVRRadioRDSInfo); Add(new CGUIWindowPVRSearch(true)); Add(new CGUIDialogPVRGuideInfo); @@ -342,11 +345,13 @@ bool CGUIWindowManager::DestroyWindows() Delete(WINDOW_TV_RECORDINGS); Delete(WINDOW_TV_GUIDE); Delete(WINDOW_TV_TIMERS); + Delete(WINDOW_TV_TIMER_RULES); Delete(WINDOW_TV_SEARCH); Delete(WINDOW_RADIO_CHANNELS); Delete(WINDOW_RADIO_RECORDINGS); Delete(WINDOW_RADIO_GUIDE); Delete(WINDOW_RADIO_TIMERS); + Delete(WINDOW_RADIO_TIMER_RULES); Delete(WINDOW_RADIO_SEARCH); Delete(WINDOW_DIALOG_PVR_GUIDE_INFO); Delete(WINDOW_DIALOG_PVR_RECORDING_INFO); diff --git a/xbmc/guilib/WindowIDs.h b/xbmc/guilib/WindowIDs.h index 58d6ddb9b5..d50f24d6dc 100644 --- a/xbmc/guilib/WindowIDs.h +++ b/xbmc/guilib/WindowIDs.h @@ -137,6 +137,8 @@ #define WINDOW_RADIO_SEARCH 10624 #define WINDOW_FULLSCREEN_RADIO 10625 // virtual window for PVR radio specific keymaps with fallback to WINDOW_VISUALISATION #define WINDOW_DIALOG_PVR_RADIO_RDS_INFO 10626 +#define WINDOW_TV_TIMER_RULES 10627 +#define WINDOW_RADIO_TIMER_RULES 10628 //#define WINDOW_VIRTUAL_KEYBOARD 11000 // WINDOW_ID's from 11100 to 11199 reserved for Skins diff --git a/xbmc/input/ButtonTranslator.cpp b/xbmc/input/ButtonTranslator.cpp index 0efbddae58..a495d02ab9 100644 --- a/xbmc/input/ButtonTranslator.cpp +++ b/xbmc/input/ButtonTranslator.cpp @@ -393,7 +393,9 @@ static const ActionMapping windows[] = { "extendedprogressdialog" , WINDOW_DIALOG_EXT_PROGRESS }, { "mediafilter" , WINDOW_DIALOG_MEDIA_FILTER }, { "addon" , WINDOW_ADDON_START }, - { "eventlog" , WINDOW_EVENT_LOG} + { "eventlog" , WINDOW_EVENT_LOG}, + { "tvtimerrules" , WINDOW_TV_TIMER_RULES}, + { "radiotimerrules" , WINDOW_RADIO_TIMER_RULES} }; static const ActionMapping mousekeys[] = diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 8ae26e54d6..a53563b25d 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -71,17 +71,19 @@ using namespace KODI::MESSAGING; using KODI::MESSAGING::HELPERS::DialogResponse; -int CPVRManager::m_pvrWindowIds[10] = { +int CPVRManager::m_pvrWindowIds[12] = { WINDOW_TV_CHANNELS, WINDOW_TV_GUIDE, WINDOW_TV_RECORDINGS, WINDOW_TV_SEARCH, WINDOW_TV_TIMERS, + WINDOW_TV_TIMER_RULES, WINDOW_RADIO_CHANNELS, WINDOW_RADIO_GUIDE, WINDOW_RADIO_RECORDINGS, WINDOW_RADIO_SEARCH, - WINDOW_RADIO_TIMERS + WINDOW_RADIO_TIMERS, + WINDOW_RADIO_TIMER_RULES }; CPVRManager::CPVRManager(void) : @@ -237,11 +239,13 @@ bool CPVRManager::IsPVRWindowActive(void) const g_windowManager.IsWindowActive(WINDOW_TV_GUIDE) || g_windowManager.IsWindowActive(WINDOW_TV_RECORDINGS) || g_windowManager.IsWindowActive(WINDOW_TV_TIMERS) || + g_windowManager.IsWindowActive(WINDOW_TV_TIMER_RULES) || g_windowManager.IsWindowActive(WINDOW_TV_SEARCH) || g_windowManager.IsWindowActive(WINDOW_RADIO_CHANNELS) || g_windowManager.IsWindowActive(WINDOW_RADIO_GUIDE) || g_windowManager.IsWindowActive(WINDOW_RADIO_RECORDINGS) || g_windowManager.IsWindowActive(WINDOW_RADIO_TIMERS) || + g_windowManager.IsWindowActive(WINDOW_RADIO_TIMER_RULES) || g_windowManager.IsWindowActive(WINDOW_RADIO_SEARCH) || g_windowManager.IsWindowActive(WINDOW_DIALOG_PVR_CHANNEL_MANAGER) || g_windowManager.IsWindowActive(WINDOW_DIALOG_PVR_OSD_CHANNELS) || @@ -260,11 +264,13 @@ bool CPVRManager::IsPVRWindow(int windowId) windowId == WINDOW_TV_RECORDINGS || windowId == WINDOW_TV_SEARCH || windowId == WINDOW_TV_TIMERS || + windowId == WINDOW_TV_TIMER_RULES || windowId == WINDOW_RADIO_CHANNELS || windowId == WINDOW_RADIO_GUIDE || windowId == WINDOW_RADIO_RECORDINGS || windowId == WINDOW_RADIO_SEARCH || - windowId == WINDOW_RADIO_TIMERS); + windowId == WINDOW_RADIO_TIMERS || + windowId == WINDOW_RADIO_TIMER_RULES); } bool CPVRManager::InstallAddonAllowed(const std::string& strAddonId) const diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 3824a6034e..6f6541f132 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -680,7 +680,7 @@ namespace PVR ManagerState m_managerState; CStopWatch *m_parentalTimer; std::vector<std::string> m_outdatedAddons; - static int m_pvrWindowIds[10]; + static int m_pvrWindowIds[12]; }; class CPVREpgsCreateJob : public CJob diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index e26dda57e8..2b780095c5 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -412,8 +412,8 @@ bool CPVRTimers::GetRootDirectory(const CPVRTimersPath &path, CFileItemList &ite item->SetSpecialSort(SortSpecialOnTop); items.Add(item); - bool bRadio = path.IsRadio(); - bool bGrouped = path.IsGrouped(); + bool bRadio = path.IsRadio(); + bool bRules = path.IsRules(); bool bHideDisabled = CSettings::GetInstance().GetBool(CSettings::SETTING_PVRTIMERS_HIDEDISABLEDTIMERS); @@ -423,7 +423,7 @@ bool CPVRTimers::GetRootDirectory(const CPVRTimersPath &path, CFileItemList &ite for (const auto &timer : *tagsEntry.second) { if ((bRadio == timer->m_bIsRadio) && - (!bGrouped || (timer->m_iParentClientIndex == PVR_TIMER_NO_PARENT)) && + (bRules == timer->IsRepeating()) && (!bHideDisabled || (timer->m_state != PVR_TIMER_STATE_DISABLED))) { item.reset(new CFileItem(timer)); @@ -865,8 +865,8 @@ CPVRTimersPath::CPVRTimersPath(const std::string &strPath, int iClientId, unsign { /* set/replace client and parent id. */ m_path = StringUtils::Format("pvr://timers/%s/%s/%d/%d", - m_bRadio ? "radio" : "tv", - m_bGrouped ? "grouped" : "all", + m_bRadio ? "radio" : "tv", + m_bTimerRules ? "rules" : "timers", iClientId, iParentId); m_iClientId = iClientId; @@ -875,13 +875,13 @@ CPVRTimersPath::CPVRTimersPath(const std::string &strPath, int iClientId, unsign } } -CPVRTimersPath::CPVRTimersPath(bool bRadio, bool bGrouped) : +CPVRTimersPath::CPVRTimersPath(bool bRadio, bool bTimerRules) : m_path(StringUtils::Format( - "pvr://timers/%s/%s", bRadio ? "radio" : "tv", bGrouped ? "grouped" : "all")), + "pvr://timers/%s/%s", bRadio ? "radio" : "tv", bTimerRules ? "rules" : "timers")), m_bValid(true), m_bRoot(true), m_bRadio(bRadio), - m_bGrouped(bGrouped), + m_bTimerRules(bTimerRules), m_iClientId(-1), m_iParentId(0) { @@ -898,10 +898,10 @@ bool CPVRTimersPath::Init(const std::string &strPath) m_bValid = (((segments.size() == 4) || (segments.size() == 6)) && (segments.at(1) == "timers") && ((segments.at(2) == "radio") || (segments.at(2) == "tv"))&& - ((segments.at(3) == "grouped") || (segments.at(3) == "all"))); + ((segments.at(3) == "rules") || (segments.at(3) == "timers"))); m_bRoot = (m_bValid && (segments.size() == 4)); m_bRadio = (m_bValid && (segments.at(2) == "radio")); - m_bGrouped = (m_bValid && (segments.at(3) == "grouped")); + m_bTimerRules = (m_bValid && (segments.at(3) == "rules")); if (!m_bValid || m_bRoot) { diff --git a/xbmc/pvr/timers/PVRTimers.h b/xbmc/pvr/timers/PVRTimers.h index 7ba84183ee..03dd88d647 100644 --- a/xbmc/pvr/timers/PVRTimers.h +++ b/xbmc/pvr/timers/PVRTimers.h @@ -211,7 +211,7 @@ namespace PVR CPVRTimersPath(const std::string &strPath); CPVRTimersPath(const std::string &strPath, int iClientId, unsigned int iParentId); - CPVRTimersPath(bool bRadio, bool bGrouped); + CPVRTimersPath(bool bRadio, bool bTimerRules); bool IsValid() const { return m_bValid; } @@ -219,7 +219,7 @@ namespace PVR bool IsTimersRoot() const { return m_bRoot; } bool IsTimerSchedule() const { return !IsTimersRoot(); } bool IsRadio() const { return m_bRadio; } - bool IsGrouped() const { return m_bGrouped; } + bool IsRules() const { return m_bTimerRules; } int GetClientId() const { return m_iClientId; } unsigned int GetParentId() const { return m_iParentId; } @@ -230,7 +230,7 @@ namespace PVR bool m_bValid; bool m_bRoot; bool m_bRadio; - bool m_bGrouped; + bool m_bTimerRules; int m_iClientId; unsigned int m_iParentId; }; diff --git a/xbmc/pvr/windows/GUIWindowPVRBase.h b/xbmc/pvr/windows/GUIWindowPVRBase.h index eae24e722e..c6226d2388 100644 --- a/xbmc/pvr/windows/GUIWindowPVRBase.h +++ b/xbmc/pvr/windows/GUIWindowPVRBase.h @@ -85,7 +85,7 @@ namespace PVR protected: CGUIWindowPVRBase(bool bRadio, int id, const std::string &xmlFile); - virtual std::string GetDirectoryPath(void) { return ""; }; + virtual std::string GetDirectoryPath(void) = 0; virtual CPVRChannelGroupPtr GetGroup(void); virtual void SetGroup(CPVRChannelGroupPtr group); diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.h b/xbmc/pvr/windows/GUIWindowPVRGuide.h index 311580a144..20d76d9eb0 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.h +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.h @@ -43,6 +43,7 @@ namespace PVR protected: void UpdateSelectedItemPath(); + virtual std::string GetDirectoryPath(void) { return ""; } virtual bool GetDirectory(const std::string &strDirectory, CFileItemList &items); private: diff --git a/xbmc/pvr/windows/GUIWindowPVRSearch.h b/xbmc/pvr/windows/GUIWindowPVRSearch.h index a7bd311c52..d657735da1 100644 --- a/xbmc/pvr/windows/GUIWindowPVRSearch.h +++ b/xbmc/pvr/windows/GUIWindowPVRSearch.h @@ -38,6 +38,7 @@ namespace PVR protected: void OnPrepareFileItems(CFileItemList &items); + virtual std::string GetDirectoryPath(void) { return ""; } private: bool OnContextButtonClear(CFileItem *item, CONTEXT_BUTTON button); diff --git a/xbmc/pvr/windows/GUIWindowPVRTimerRules.cpp b/xbmc/pvr/windows/GUIWindowPVRTimerRules.cpp new file mode 100644 index 0000000000..6f90614fe3 --- /dev/null +++ b/xbmc/pvr/windows/GUIWindowPVRTimerRules.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2012-2013 Team XBMC + * http://xbmc.org + * + * 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 + * <http://www.gnu.org/licenses/>. + * + */ + +#include "utils/StringUtils.h" +#include "pvr/timers/PVRTimers.h" + +#include "GUIWindowPVRTimerRules.h" + +using namespace PVR; + +CGUIWindowPVRTimerRules::CGUIWindowPVRTimerRules(bool bRadio) : + CGUIWindowPVRTimersBase(bRadio, bRadio ? WINDOW_RADIO_TIMER_RULES : WINDOW_TV_TIMER_RULES, "MyPVRTimers.xml") +{ +} + +std::string CGUIWindowPVRTimerRules::GetDirectoryPath(void) +{ + const std::string basePath(CPVRTimersPath(m_bRadio, true).GetPath()); + return StringUtils::StartsWith(m_vecItems->GetPath(), basePath) ? m_vecItems->GetPath() : basePath; +} diff --git a/xbmc/pvr/windows/GUIWindowPVRTimerRules.h b/xbmc/pvr/windows/GUIWindowPVRTimerRules.h new file mode 100644 index 0000000000..650d6c2b24 --- /dev/null +++ b/xbmc/pvr/windows/GUIWindowPVRTimerRules.h @@ -0,0 +1,37 @@ +#pragma once +/* + * Copyright (C) 2012-2013 Team XBMC + * http://xbmc.org + * + * 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 + * <http://www.gnu.org/licenses/>. + * + */ + +#include "GUIWindowPVRTimersBase.h" + +#include <string> + +namespace PVR +{ + class CGUIWindowPVRTimerRules : public CGUIWindowPVRTimersBase + { + public: + CGUIWindowPVRTimerRules(bool bRadio); + virtual ~CGUIWindowPVRTimerRules(void) {}; + + protected: + virtual std::string GetDirectoryPath(void); + }; +} diff --git a/xbmc/pvr/windows/GUIWindowPVRTimers.cpp b/xbmc/pvr/windows/GUIWindowPVRTimers.cpp index c7d050af2b..1765d34de5 100644 --- a/xbmc/pvr/windows/GUIWindowPVRTimers.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRTimers.cpp @@ -18,408 +18,20 @@ * */ -#include "ContextMenuManager.h" -#include "GUIInfoManager.h" -#include "dialogs/GUIDialogOK.h" -#include "dialogs/GUIDialogYesNo.h" -#include "guilib/GUIKeyboardFactory.h" -#include "guilib/GUIWindowManager.h" -#include "input/Key.h" -#include "settings/Settings.h" -#include "threads/SingleLock.h" #include "utils/StringUtils.h" -#include "utils/Variant.h" - -#include "pvr/PVRManager.h" -#include "pvr/dialogs/GUIDialogPVRTimerSettings.h" #include "pvr/timers/PVRTimers.h" -#include "pvr/addons/PVRClients.h" #include "GUIWindowPVRTimers.h" using namespace PVR; CGUIWindowPVRTimers::CGUIWindowPVRTimers(bool bRadio) : - CGUIWindowPVRBase(bRadio, bRadio ? WINDOW_RADIO_TIMERS : WINDOW_TV_TIMERS, "MyPVRTimers.xml") -{ -} - -void CGUIWindowPVRTimers::UnregisterObservers(void) -{ - CSingleLock lock(m_critSection); - if (g_PVRTimers) - g_PVRTimers->UnregisterObserver(this); - g_infoManager.UnregisterObserver(this); -} - -void CGUIWindowPVRTimers::ResetObservers(void) + CGUIWindowPVRTimersBase(bRadio, bRadio ? WINDOW_RADIO_TIMERS : WINDOW_TV_TIMERS, "MyPVRTimers.xml") { - CSingleLock lock(m_critSection); - UnregisterObservers(); - g_PVRTimers->RegisterObserver(this); - g_infoManager.RegisterObserver(this); } std::string CGUIWindowPVRTimers::GetDirectoryPath(void) { - const std::string basePath( - CPVRTimersPath(m_bRadio, CSettings::GetInstance().GetBool(CSettings::SETTING_PVRTIMERS_TIMERTYPEFILTER)).GetPath()); + const std::string basePath(CPVRTimersPath(m_bRadio, false).GetPath()); return StringUtils::StartsWith(m_vecItems->GetPath(), basePath) ? m_vecItems->GetPath() : basePath; } - -void CGUIWindowPVRTimers::GetContextButtons(int itemNumber, CContextButtons &buttons) -{ - if (itemNumber < 0 || itemNumber >= m_vecItems->Size()) - return; - CFileItemPtr pItem = m_vecItems->Get(itemNumber); - - if (!URIUtils::PathEquals(pItem->GetPath(), CPVRTimersPath::PATH_ADDTIMER)) - { - CPVRTimerInfoTagPtr timer(pItem->GetPVRTimerInfoTag()); - if (timer) - { - if (timer->HasEpgInfoTag()) - buttons.Add(CONTEXT_BUTTON_INFO, 19047); /* Programme information */ - - CPVRTimerTypePtr timerType(timer->GetTimerType()); - if (timerType) - { - if (timerType->SupportsEnableDisable()) - { - if (timer->m_state == PVR_TIMER_STATE_DISABLED) - buttons.Add(CONTEXT_BUTTON_ACTIVATE, 843); /* Activate */ - else - buttons.Add(CONTEXT_BUTTON_ACTIVATE, 844); /* Deactivate */ - } - - if (!timerType->IsReadOnly()) - { - buttons.Add(CONTEXT_BUTTON_EDIT, 21450); /* Edit */ - - // As epg-based timers will get it's title from the epg tag, they should not be renamable. - if (timer->IsManual()) - buttons.Add(CONTEXT_BUTTON_RENAME, 118); /* Rename */ - - if (timer->IsRecording()) - buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19059); /* Stop recording */ - else - buttons.Add(CONTEXT_BUTTON_DELETE, 117); /* Delete */ - } - } - - if (g_PVRClients->HasMenuHooks(timer->m_iClientId, PVR_MENUHOOK_TIMER)) - buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ - } - } - - CGUIWindowPVRBase::GetContextButtons(itemNumber, buttons); - CContextMenuManager::GetInstance().AddVisibleItems(pItem, buttons); -} - -bool CGUIWindowPVRTimers::OnAction(const CAction &action) -{ - if (action.GetID() == ACTION_PARENT_DIR || - action.GetID() == ACTION_NAV_BACK) - { - CPVRTimersPath path(m_vecItems->GetPath()); - if (path.IsValid() && path.IsTimerSchedule()) - { - m_currentFileItem.reset(); - GoParentFolder(); - return true; - } - } - return CGUIWindowPVRBase::OnAction(action); -} - -bool CGUIWindowPVRTimers::OnContextButton(int itemNumber, CONTEXT_BUTTON button) -{ - if (itemNumber < 0 || itemNumber >= m_vecItems->Size()) - return false; - CFileItemPtr pItem = m_vecItems->Get(itemNumber); - - return OnContextButtonActivate(pItem.get(), button) || - OnContextButtonAdd(pItem.get(), button) || - OnContextButtonDelete(pItem.get(), button) || - OnContextButtonStopRecord(pItem.get(), button) || - OnContextButtonEdit(pItem.get(), button) || - OnContextButtonRename(pItem.get(), button) || - OnContextButtonInfo(pItem.get(), button) || - CGUIWindowPVRBase::OnContextButton(itemNumber, button); -} - -bool CGUIWindowPVRTimers::Update(const std::string &strDirectory, bool updateFilterPath /* = true */) -{ - return CGUIWindowPVRBase::Update(strDirectory); -} - -void CGUIWindowPVRTimers::UpdateButtons(void) -{ - SET_CONTROL_SELECTED(GetID(), CONTROL_BTNTIMERTYPEFILTER, CSettings::GetInstance().GetBool(CSettings::SETTING_PVRTIMERS_TIMERTYPEFILTER)); - SET_CONTROL_SELECTED(GetID(), CONTROL_BTNHIDEDISABLEDTIMERS, CSettings::GetInstance().GetBool(CSettings::SETTING_PVRTIMERS_HIDEDISABLEDTIMERS)); - - CGUIWindowPVRBase::UpdateButtons(); - - std::string strHeaderTitle; - if (m_currentFileItem && m_currentFileItem->HasPVRTimerInfoTag()) - { - CPVRTimerInfoTagPtr timer = m_currentFileItem->GetPVRTimerInfoTag(); - strHeaderTitle = timer->Title(); - } - - SET_CONTROL_LABEL(CONTROL_LABEL_HEADER1, strHeaderTitle); -} - -bool CGUIWindowPVRTimers::OnMessage(CGUIMessage &message) -{ - if (!IsValidMessage(message)) - return false; - - bool bReturn = false; - switch (message.GetMessage()) - { - case GUI_MSG_CLICKED: - if (message.GetSenderId() == m_viewControl.GetCurrentControl()) - { - int iItem = m_viewControl.GetSelectedItem(); - if (iItem >= 0 && iItem < m_vecItems->Size()) - { - bReturn = true; - switch (message.GetParam1()) - { - case ACTION_SHOW_INFO: - case ACTION_SELECT_ITEM: - case ACTION_MOUSE_LEFT_CLICK: - { - CFileItemPtr item(m_vecItems->Get(iItem)); - if (item->m_bIsFolder && (message.GetParam1() != ACTION_SHOW_INFO)) - { - m_currentFileItem = item; - bReturn = false; // folders are handled by base class - } - else - { - m_currentFileItem.reset(); - ActionShowTimer(item.get()); - } - break; - } - case ACTION_CONTEXT_MENU: - case ACTION_MOUSE_RIGHT_CLICK: - OnPopupMenu(iItem); - break; - case ACTION_DELETE_ITEM: - ActionDeleteTimer(m_vecItems->Get(iItem).get()); - break; - default: - bReturn = false; - break; - } - } - } - else if (message.GetSenderId() == CONTROL_BTNTIMERTYPEFILTER) - { - CSettings::GetInstance().ToggleBool(CSettings::SETTING_PVRTIMERS_TIMERTYPEFILTER); - CSettings::GetInstance().Save(); - Update(GetDirectoryPath()); - bReturn = true; - } - else if (message.GetSenderId() == CONTROL_BTNHIDEDISABLEDTIMERS) - { - CSettings::GetInstance().ToggleBool(CSettings::SETTING_PVRTIMERS_HIDEDISABLEDTIMERS); - CSettings::GetInstance().Save(); - Update(GetDirectoryPath()); - bReturn = true; - } - break; - case GUI_MSG_REFRESH_LIST: - switch(message.GetParam1()) - { - case ObservableMessageTimers: - case ObservableMessageEpg: - case ObservableMessageEpgContainer: - case ObservableMessageEpgActiveItem: - case ObservableMessageCurrentItem: - { - if (IsActive()) - SetInvalid(); - bReturn = true; - break; - } - case ObservableMessageTimersReset: - { - if (IsActive()) - Refresh(true); - bReturn = true; - break; - } - } - } - - return bReturn || CGUIWindowPVRBase::OnMessage(message); -} - -bool CGUIWindowPVRTimers::OnContextButtonActivate(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_ACTIVATE) - { - bReturn = true; - if (!item->HasPVRTimerInfoTag()) - return bReturn; - - CPVRTimerInfoTagPtr timer = item->GetPVRTimerInfoTag(); - if (timer->m_state == PVR_TIMER_STATE_DISABLED) - timer->m_state = PVR_TIMER_STATE_SCHEDULED; - else - timer->m_state = PVR_TIMER_STATE_DISABLED; - - g_PVRTimers->UpdateTimer(*item); - } - - return bReturn; -} - -bool CGUIWindowPVRTimers::OnContextButtonAdd(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_ADD) - bReturn = ShowNewTimerDialog(); - - return bReturn; -} - -bool CGUIWindowPVRTimers::OnContextButtonDelete(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_DELETE) - { - DeleteTimer(item); - bReturn = true; - } - - return bReturn; -} - -bool CGUIWindowPVRTimers::OnContextButtonStopRecord(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_STOP_RECORD) - { - StopRecordFile(item); - bReturn = true; - } - - return bReturn; -} - -bool CGUIWindowPVRTimers::OnContextButtonEdit(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_EDIT) - { - bReturn = true; - if (!item->HasPVRTimerInfoTag()) - return bReturn; - - if (ShowTimerSettings(item) && !item->GetPVRTimerInfoTag()->GetTimerType()->IsReadOnly()) - g_PVRTimers->UpdateTimer(*item); - } - - return bReturn; -} - -bool CGUIWindowPVRTimers::OnContextButtonRename(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_RENAME) - { - bReturn = true; - if (!item->HasPVRTimerInfoTag()) - return bReturn; - CPVRTimerInfoTagPtr timer = item->GetPVRTimerInfoTag(); - - std::string strNewName(timer->m_strTitle); - if (CGUIKeyboardFactory::ShowAndGetInput(strNewName, CVariant{g_localizeStrings.Get(19042)}, false)) - g_PVRTimers->RenameTimer(*item, strNewName); - } - - return bReturn; -} - -bool CGUIWindowPVRTimers::OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button) -{ - bool bReturn = false; - - if (button == CONTEXT_BUTTON_INFO) - { - ShowEPGInfo(item); - bReturn = true; - } - - return bReturn; -} - -bool CGUIWindowPVRTimers::ActionDeleteTimer(CFileItem *item) -{ - bool bReturn = DeleteTimer(item); - - if (bReturn && (m_vecItems->GetObjectCount() == 0)) - { - /* go to the parent folder if we're in a subdirectory and just deleted the last item */ - CPVRTimersPath path(m_vecItems->GetPath()); - if (path.IsValid() && path.IsTimerSchedule()) - { - m_currentFileItem.reset(); - GoParentFolder(); - } - } - return bReturn; -} - -bool CGUIWindowPVRTimers::ActionShowTimer(CFileItem *item) -{ - bool bReturn = false; - - /* Check if "Add timer..." entry is pressed by OK, if yes - create a new timer and open settings dialog, otherwise - open settings for selected timer entry */ - if (URIUtils::PathEquals(item->GetPath(), CPVRTimersPath::PATH_ADDTIMER)) - { - bReturn = ShowNewTimerDialog(); - } - else - { - if (ShowTimerSettings(item) && !item->GetPVRTimerInfoTag()->GetTimerType()->IsReadOnly()) - { - /* Update timer on pvr backend */ - bReturn = g_PVRTimers->UpdateTimer(*item); - } - } - - return bReturn; -} - -bool CGUIWindowPVRTimers::ShowNewTimerDialog(void) -{ - bool bReturn(false); - - CPVRTimerInfoTagPtr newTimer(new CPVRTimerInfoTag(m_bRadio)); - CFileItem *newItem = new CFileItem(newTimer); - - if (ShowTimerSettings(newItem)) - { - /* Add timer to backend */ - bReturn = g_PVRTimers->AddTimer(newItem->GetPVRTimerInfoTag()); - } - - delete newItem; - - return bReturn; -} diff --git a/xbmc/pvr/windows/GUIWindowPVRTimers.h b/xbmc/pvr/windows/GUIWindowPVRTimers.h index e6dbd8a22c..a3072462c2 100644 --- a/xbmc/pvr/windows/GUIWindowPVRTimers.h +++ b/xbmc/pvr/windows/GUIWindowPVRTimers.h @@ -19,46 +19,19 @@ * */ -#include "GUIWindowPVRBase.h" +#include "GUIWindowPVRTimersBase.h" -#include <memory> - -class CFileItem; -typedef std::shared_ptr<CFileItem> CFileItemPtr; +#include <string> namespace PVR { - class CGUIWindowPVRTimers : public CGUIWindowPVRBase + class CGUIWindowPVRTimers : public CGUIWindowPVRTimersBase { public: CGUIWindowPVRTimers(bool bRadio); virtual ~CGUIWindowPVRTimers(void) {}; - bool OnMessage(CGUIMessage& message); - bool OnAction(const CAction &action); - void GetContextButtons(int itemNumber, CContextButtons &buttons); - bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); - bool Update(const std::string &strDirectory, bool updateFilterPath = true); - void UpdateButtons(void); - void UnregisterObservers(void); - void ResetObservers(void); - protected: - std::string GetDirectoryPath(void); - - private: - bool ActionDeleteTimer(CFileItem *item); - bool ActionShowTimer(CFileItem *item); - bool ShowNewTimerDialog(void); - - bool OnContextButtonActivate(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonAdd(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonDelete(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonStopRecord(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonEdit(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonRename(CFileItem *item, CONTEXT_BUTTON button); - bool OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button); - - CFileItemPtr m_currentFileItem; + virtual std::string GetDirectoryPath(void); }; } diff --git a/xbmc/pvr/windows/GUIWindowPVRTimersBase.cpp b/xbmc/pvr/windows/GUIWindowPVRTimersBase.cpp new file mode 100644 index 0000000000..026332b170 --- /dev/null +++ b/xbmc/pvr/windows/GUIWindowPVRTimersBase.cpp @@ -0,0 +1,410 @@ +/* + * Copyright (C) 2012-2013 Team XBMC + * http://xbmc.org + * + * 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 + * <http://www.gnu.org/licenses/>. + * + */ + +#include "ContextMenuManager.h" +#include "GUIInfoManager.h" +#include "dialogs/GUIDialogOK.h" +#include "dialogs/GUIDialogYesNo.h" +#include "guilib/GUIKeyboardFactory.h" +#include "guilib/GUIWindowManager.h" +#include "input/Key.h" +#include "settings/Settings.h" +#include "threads/SingleLock.h" +#include "utils/StringUtils.h" +#include "utils/Variant.h" + +#include "pvr/PVRManager.h" +#include "pvr/dialogs/GUIDialogPVRTimerSettings.h" +#include "pvr/timers/PVRTimers.h" +#include "pvr/addons/PVRClients.h" + +#include "GUIWindowPVRTimers.h" + +using namespace PVR; + +CGUIWindowPVRTimersBase::CGUIWindowPVRTimersBase(bool bRadio, int id, const std::string &xmlFile) : + CGUIWindowPVRBase(bRadio, id, xmlFile) +{ +} + +void CGUIWindowPVRTimersBase::UnregisterObservers(void) +{ + CSingleLock lock(m_critSection); + if (g_PVRTimers) + g_PVRTimers->UnregisterObserver(this); + g_infoManager.UnregisterObserver(this); +} + +void CGUIWindowPVRTimersBase::ResetObservers(void) +{ + CSingleLock lock(m_critSection); + UnregisterObservers(); + g_PVRTimers->RegisterObserver(this); + g_infoManager.RegisterObserver(this); +} + +void CGUIWindowPVRTimersBase::GetContextButtons(int itemNumber, CContextButtons &buttons) +{ + if (itemNumber < 0 || itemNumber >= m_vecItems->Size()) + return; + CFileItemPtr pItem = m_vecItems->Get(itemNumber); + + if (!URIUtils::PathEquals(pItem->GetPath(), CPVRTimersPath::PATH_ADDTIMER)) + { + CPVRTimerInfoTagPtr timer(pItem->GetPVRTimerInfoTag()); + if (timer) + { + if (timer->HasEpgInfoTag()) + buttons.Add(CONTEXT_BUTTON_INFO, 19047); /* Programme information */ + + CPVRTimerTypePtr timerType(timer->GetTimerType()); + if (timerType) + { + if (timerType->SupportsEnableDisable()) + { + if (timer->m_state == PVR_TIMER_STATE_DISABLED) + buttons.Add(CONTEXT_BUTTON_ACTIVATE, 843); /* Activate */ + else + buttons.Add(CONTEXT_BUTTON_ACTIVATE, 844); /* Deactivate */ + } + + if (!timerType->IsReadOnly()) + { + buttons.Add(CONTEXT_BUTTON_EDIT, 21450); /* Edit */ + + // As epg-based timers will get it's title from the epg tag, they should not be renamable. + if (timer->IsManual()) + buttons.Add(CONTEXT_BUTTON_RENAME, 118); /* Rename */ + + if (timer->IsRecording()) + buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19059); /* Stop recording */ + else + buttons.Add(CONTEXT_BUTTON_DELETE, 117); /* Delete */ + } + } + + if (g_PVRClients->HasMenuHooks(timer->m_iClientId, PVR_MENUHOOK_TIMER)) + buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ + } + } + + CGUIWindowPVRBase::GetContextButtons(itemNumber, buttons); + CContextMenuManager::GetInstance().AddVisibleItems(pItem, buttons); +} + +bool CGUIWindowPVRTimersBase::OnAction(const CAction &action) +{ + if (action.GetID() == ACTION_PARENT_DIR || + action.GetID() == ACTION_NAV_BACK) + { + CPVRTimersPath path(m_vecItems->GetPath()); + if (path.IsValid() && path.IsTimerSchedule()) + { + m_currentFileItem.reset(); + GoParentFolder(); + return true; + } + } + return CGUIWindowPVRBase::OnAction(action); +} + +bool CGUIWindowPVRTimersBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) +{ + if (itemNumber < 0 || itemNumber >= m_vecItems->Size()) + return false; + CFileItemPtr pItem = m_vecItems->Get(itemNumber); + + return OnContextButtonActivate(pItem.get(), button) || + OnContextButtonAdd(pItem.get(), button) || + OnContextButtonDelete(pItem.get(), button) || + OnContextButtonStopRecord(pItem.get(), button) || + OnContextButtonEdit(pItem.get(), button) || + OnContextButtonRename(pItem.get(), button) || + OnContextButtonInfo(pItem.get(), button) || + CGUIWindowPVRBase::OnContextButton(itemNumber, button); +} + +bool CGUIWindowPVRTimersBase::Update(const std::string &strDirectory, bool updateFilterPath /* = true */) +{ + return CGUIWindowPVRBase::Update(strDirectory); +} + +void CGUIWindowPVRTimersBase::UpdateButtons(void) +{ + SET_CONTROL_SELECTED(GetID(), CONTROL_BTNHIDEDISABLEDTIMERS, CSettings::GetInstance().GetBool(CSettings::SETTING_PVRTIMERS_HIDEDISABLEDTIMERS)); + + CGUIWindowPVRBase::UpdateButtons(); + + std::string strHeaderTitle; + if (m_currentFileItem && m_currentFileItem->HasPVRTimerInfoTag()) + { + CPVRTimerInfoTagPtr timer = m_currentFileItem->GetPVRTimerInfoTag(); + strHeaderTitle = timer->Title(); + } + + SET_CONTROL_LABEL(CONTROL_LABEL_HEADER1, strHeaderTitle); +} + +bool CGUIWindowPVRTimersBase::OnMessage(CGUIMessage &message) +{ + if (!IsValidMessage(message)) + return false; + + bool bReturn = false; + switch (message.GetMessage()) + { + case GUI_MSG_CLICKED: + if (message.GetSenderId() == m_viewControl.GetCurrentControl()) + { + int iItem = m_viewControl.GetSelectedItem(); + if (iItem >= 0 && iItem < m_vecItems->Size()) + { + bReturn = true; + switch (message.GetParam1()) + { + case ACTION_SHOW_INFO: + case ACTION_SELECT_ITEM: + case ACTION_MOUSE_LEFT_CLICK: + { + CFileItemPtr item(m_vecItems->Get(iItem)); + if (item->m_bIsFolder && (message.GetParam1() != ACTION_SHOW_INFO)) + { + m_currentFileItem = item; + bReturn = false; // folders are handled by base class + } + else + { + m_currentFileItem.reset(); + ActionShowTimer(item.get()); + } + break; + } + case ACTION_CONTEXT_MENU: + case ACTION_MOUSE_RIGHT_CLICK: + OnPopupMenu(iItem); + break; + case ACTION_DELETE_ITEM: + ActionDeleteTimer(m_vecItems->Get(iItem).get()); + break; + default: + bReturn = false; + break; + } + } + } + else if (message.GetSenderId() == CONTROL_BTNHIDEDISABLEDTIMERS) + { + CSettings::GetInstance().ToggleBool(CSettings::SETTING_PVRTIMERS_HIDEDISABLEDTIMERS); + CSettings::GetInstance().Save(); + Update(GetDirectoryPath()); + bReturn = true; + } + break; + case GUI_MSG_REFRESH_LIST: + switch(message.GetParam1()) + { + case ObservableMessageTimers: + case ObservableMessageEpg: + case ObservableMessageEpgContainer: + case ObservableMessageEpgActiveItem: + case ObservableMessageCurrentItem: + { + if (IsActive()) + SetInvalid(); + bReturn = true; + break; + } + case ObservableMessageTimersReset: + { + if (IsActive()) + Refresh(true); + bReturn = true; + break; + } + } + } + + return bReturn || CGUIWindowPVRBase::OnMessage(message); +} + +bool CGUIWindowPVRTimersBase::OnContextButtonActivate(CFileItem *item, CONTEXT_BUTTON button) +{ + bool bReturn = false; + + if (button == CONTEXT_BUTTON_ACTIVATE) + { + bReturn = true; + if (!item->HasPVRTimerInfoTag()) + return bReturn; + + CPVRTimerInfoTagPtr timer = item->GetPVRTimerInfoTag(); + if (timer->m_state == PVR_TIMER_STATE_DISABLED) + timer->m_state = PVR_TIMER_STATE_SCHEDULED; + else + timer->m_state = PVR_TIMER_STATE_DISABLED; + + g_PVRTimers->UpdateTimer(*item); + } + + return bReturn; +} + +bool CGUIWindowPVRTimersBase::OnContextButtonAdd(CFileItem *item, CONTEXT_BUTTON button) +{ + bool bReturn = false; + + if (button == CONTEXT_BUTTON_ADD) + bReturn = ShowNewTimerDialog(); + + return bReturn; +} + +bool CGUIWindowPVRTimersBase::OnContextButtonDelete(CFileItem *item, CONTEXT_BUTTON button) +{ + bool bReturn = false; + + if (button == CONTEXT_BUTTON_DELETE) + { + DeleteTimer(item); + bReturn = true; + } + + return bReturn; +} + +bool CGUIWindowPVRTimersBase::OnContextButtonStopRecord(CFileItem *item, CONTEXT_BUTTON button) +{ + bool bReturn = false; + + if (button == CONTEXT_BUTTON_STOP_RECORD) + { + StopRecordFile(item); + bReturn = true; + } + + return bReturn; +} + +bool CGUIWindowPVRTimersBase::OnContextButtonEdit(CFileItem *item, CONTEXT_BUTTON button) +{ + bool bReturn = false; + + if (button == CONTEXT_BUTTON_EDIT) + { + bReturn = true; + if (!item->HasPVRTimerInfoTag()) + return bReturn; + + if (ShowTimerSettings(item) && !item->GetPVRTimerInfoTag()->GetTimerType()->IsReadOnly()) + g_PVRTimers->UpdateTimer(*item); + } + + return bReturn; +} + +bool CGUIWindowPVRTimersBase::OnContextButtonRename(CFileItem *item, CONTEXT_BUTTON button) +{ + bool bReturn = false; + + if (button == CONTEXT_BUTTON_RENAME) + { + bReturn = true; + if (!item->HasPVRTimerInfoTag()) + return bReturn; + CPVRTimerInfoTagPtr timer = item->GetPVRTimerInfoTag(); + + std::string strNewName(timer->m_strTitle); + if (CGUIKeyboardFactory::ShowAndGetInput(strNewName, CVariant{g_localizeStrings.Get(19042)}, false)) + g_PVRTimers->RenameTimer(*item, strNewName); + } + + return bReturn; +} + +bool CGUIWindowPVRTimersBase::OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button) +{ + bool bReturn = false; + + if (button == CONTEXT_BUTTON_INFO) + { + ShowEPGInfo(item); + bReturn = true; + } + + return bReturn; +} + +bool CGUIWindowPVRTimersBase::ActionDeleteTimer(CFileItem *item) +{ + bool bReturn = DeleteTimer(item); + + if (bReturn && (m_vecItems->GetObjectCount() == 0)) + { + /* go to the parent folder if we're in a subdirectory and just deleted the last item */ + CPVRTimersPath path(m_vecItems->GetPath()); + if (path.IsValid() && path.IsTimerSchedule()) + { + m_currentFileItem.reset(); + GoParentFolder(); + } + } + return bReturn; +} + +bool CGUIWindowPVRTimersBase::ActionShowTimer(CFileItem *item) +{ + bool bReturn = false; + + /* Check if "Add timer..." entry is pressed by OK, if yes + create a new timer and open settings dialog, otherwise + open settings for selected timer entry */ + if (URIUtils::PathEquals(item->GetPath(), CPVRTimersPath::PATH_ADDTIMER)) + { + bReturn = ShowNewTimerDialog(); + } + else + { + if (ShowTimerSettings(item) && !item->GetPVRTimerInfoTag()->GetTimerType()->IsReadOnly()) + { + /* Update timer on pvr backend */ + bReturn = g_PVRTimers->UpdateTimer(*item); + } + } + + return bReturn; +} + +bool CGUIWindowPVRTimersBase::ShowNewTimerDialog(void) +{ + bool bReturn(false); + + CPVRTimerInfoTagPtr newTimer(new CPVRTimerInfoTag(m_bRadio)); + CFileItem *newItem = new CFileItem(newTimer); + + if (ShowTimerSettings(newItem)) + { + /* Add timer to backend */ + bReturn = g_PVRTimers->AddTimer(newItem->GetPVRTimerInfoTag()); + } + + delete newItem; + + return bReturn; +} diff --git a/xbmc/pvr/windows/GUIWindowPVRTimersBase.h b/xbmc/pvr/windows/GUIWindowPVRTimersBase.h new file mode 100644 index 0000000000..25cc70526f --- /dev/null +++ b/xbmc/pvr/windows/GUIWindowPVRTimersBase.h @@ -0,0 +1,61 @@ +#pragma once +/* + * Copyright (C) 2012-2013 Team XBMC + * http://xbmc.org + * + * 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 + * <http://www.gnu.org/licenses/>. + * + */ + +#include "GUIWindowPVRBase.h" + +#include <memory> + +class CFileItem; +typedef std::shared_ptr<CFileItem> CFileItemPtr; + +namespace PVR +{ + class CGUIWindowPVRTimersBase : public CGUIWindowPVRBase + { + public: + CGUIWindowPVRTimersBase(bool bRadio, int id, const std::string &xmlFile); + virtual ~CGUIWindowPVRTimersBase(void) {}; + + bool OnMessage(CGUIMessage& message); + bool OnAction(const CAction &action); + void GetContextButtons(int itemNumber, CContextButtons &buttons); + bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); + bool Update(const std::string &strDirectory, bool updateFilterPath = true); + void UpdateButtons(void); + void UnregisterObservers(void); + void ResetObservers(void); + + private: + bool ActionDeleteTimer(CFileItem *item); + bool ActionShowTimer(CFileItem *item); + bool ShowNewTimerDialog(void); + + bool OnContextButtonActivate(CFileItem *item, CONTEXT_BUTTON button); + bool OnContextButtonAdd(CFileItem *item, CONTEXT_BUTTON button); + bool OnContextButtonDelete(CFileItem *item, CONTEXT_BUTTON button); + bool OnContextButtonStopRecord(CFileItem *item, CONTEXT_BUTTON button); + bool OnContextButtonEdit(CFileItem *item, CONTEXT_BUTTON button); + bool OnContextButtonRename(CFileItem *item, CONTEXT_BUTTON button); + bool OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button); + + CFileItemPtr m_currentFileItem; + }; +} diff --git a/xbmc/pvr/windows/Makefile b/xbmc/pvr/windows/Makefile index 386734ba89..49a3537a77 100644 --- a/xbmc/pvr/windows/Makefile +++ b/xbmc/pvr/windows/Makefile @@ -4,7 +4,9 @@ SRCS=GUIViewStatePVR.cpp \ GUIWindowPVRGuide.cpp \ GUIWindowPVRRecordings.cpp \ GUIWindowPVRSearch.cpp \ - GUIWindowPVRTimers.cpp + GUIWindowPVRTimersBase.cpp \ + GUIWindowPVRTimers.cpp \ + GUIWindowPVRTimerRules.cpp LIB=pvrwindows.a diff --git a/xbmc/view/GUIViewState.cpp b/xbmc/view/GUIViewState.cpp index b3690669b2..220c292ec7 100644 --- a/xbmc/view/GUIViewState.cpp +++ b/xbmc/view/GUIViewState.cpp @@ -145,6 +145,9 @@ CGUIViewState* CGUIViewState::GetViewState(int windowId, const CFileItemList& it if (windowId == WINDOW_TV_TIMERS) return new CGUIViewStateWindowPVRTimers(windowId, items); + if (windowId == WINDOW_TV_TIMER_RULES) + return new CGUIViewStateWindowPVRTimers(windowId, items); + if (windowId == WINDOW_TV_SEARCH) return new CGUIViewStateWindowPVRSearch(windowId, items); @@ -160,6 +163,9 @@ CGUIViewState* CGUIViewState::GetViewState(int windowId, const CFileItemList& it if (windowId == WINDOW_RADIO_TIMERS) return new CGUIViewStateWindowPVRTimers(windowId, items); + if (windowId == WINDOW_RADIO_TIMER_RULES) + return new CGUIViewStateWindowPVRTimers(windowId, items); + if (windowId == WINDOW_RADIO_SEARCH) return new CGUIViewStateWindowPVRSearch(windowId, items); |