[video] fix selection after changing video or extra art
[xbmc.git] / xbmc / pvr / dialogs / GUIDialogPVRTimerSettings.h
blobd3e9e3eadf34451a65620ede95743f35c9382d9a
1 /*
2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "XBDateTime.h"
12 #include "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h" // PVR_CHANNEL_INVALID_UID
13 #include "settings/SettingConditions.h"
14 #include "settings/dialogs/GUIDialogSettingsManualBase.h"
15 #include "settings/lib/SettingDependency.h"
17 #include <map>
18 #include <memory>
19 #include <string>
20 #include <vector>
22 class CSetting;
24 struct IntegerSettingOption;
26 namespace PVR
28 class CPVRTimerInfoTag;
29 class CPVRTimerType;
31 class CGUIDialogPVRTimerSettings : public CGUIDialogSettingsManualBase
33 public:
34 CGUIDialogPVRTimerSettings();
35 ~CGUIDialogPVRTimerSettings() override;
37 bool CanBeActivated() const override;
39 void SetTimer(const std::shared_ptr<CPVRTimerInfoTag>& timer);
41 protected:
42 // implementation of ISettingCallback
43 void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override;
44 void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override;
46 // specialization of CGUIDialogSettingsBase
47 bool AllowResettingSettings() const override { return false; }
48 bool Save() override;
49 void SetupView() override;
51 // specialization of CGUIDialogSettingsManualBase
52 void InitializeSettings() override;
54 private:
55 bool Validate();
56 void InitializeTypesList();
57 void InitializeChannelsList();
58 void SetButtonLabels();
60 static int GetDateAsIndex(const CDateTime& datetime);
61 static void SetDateFromIndex(CDateTime& datetime, int date);
62 static void SetTimeFromSystemTime(CDateTime& datetime, const KODI::TIME::SystemTime& time);
64 static int GetWeekdaysFromSetting(const std::shared_ptr<const CSetting>& setting);
66 static void TypesFiller(const std::shared_ptr<const CSetting>& setting,
67 std::vector<IntegerSettingOption>& list,
68 int& current,
69 void* data);
70 static void ChannelsFiller(const std::shared_ptr<const CSetting>& setting,
71 std::vector<IntegerSettingOption>& list,
72 int& current,
73 void* data);
74 static void DaysFiller(const std::shared_ptr<const CSetting>& setting,
75 std::vector<IntegerSettingOption>& list,
76 int& current,
77 void* data);
78 static void DupEpisodesFiller(const std::shared_ptr<const CSetting>& setting,
79 std::vector<IntegerSettingOption>& list,
80 int& current,
81 void* data);
82 static void WeekdaysFiller(const std::shared_ptr<const CSetting>& setting,
83 std::vector<IntegerSettingOption>& list,
84 int& current,
85 void* data);
86 static void PrioritiesFiller(const std::shared_ptr<const CSetting>& setting,
87 std::vector<IntegerSettingOption>& list,
88 int& current,
89 void* data);
90 static void LifetimesFiller(const std::shared_ptr<const CSetting>& setting,
91 std::vector<IntegerSettingOption>& list,
92 int& current,
93 void* data);
94 static void MaxRecordingsFiller(const std::shared_ptr<const CSetting>& setting,
95 std::vector<IntegerSettingOption>& list,
96 int& current,
97 void* data);
98 static void RecordingGroupFiller(const std::shared_ptr<const CSetting>& setting,
99 std::vector<IntegerSettingOption>& list,
100 int& current,
101 void* data);
102 static void MarginTimeFiller(const std::shared_ptr<const CSetting>& setting,
103 std::vector<IntegerSettingOption>& list,
104 int& current,
105 void* data);
107 static std::string WeekdaysValueFormatter(const std::shared_ptr<const CSetting>& setting);
109 void AddCondition(const std::shared_ptr<CSetting>& setting,
110 const std::string& identifier,
111 SettingConditionCheck condition,
112 SettingDependencyType depType,
113 const std::string& settingId);
115 void AddTypeDependentEnableCondition(const std::shared_ptr<CSetting>& setting,
116 const std::string& identifier);
117 static bool TypeReadOnlyCondition(const std::string& condition,
118 const std::string& value,
119 const std::shared_ptr<const CSetting>& setting,
120 void* data);
122 void AddTypeDependentVisibilityCondition(const std::shared_ptr<CSetting>& setting,
123 const std::string& identifier);
124 static bool TypeSupportsCondition(const std::string& condition,
125 const std::string& value,
126 const std::shared_ptr<const CSetting>& setting,
127 void* data);
129 void AddStartAnytimeDependentVisibilityCondition(const std::shared_ptr<CSetting>& setting,
130 const std::string& identifier);
131 static bool StartAnytimeSetCondition(const std::string& condition,
132 const std::string& value,
133 const std::shared_ptr<const CSetting>& setting,
134 void* data);
135 void AddEndAnytimeDependentVisibilityCondition(const std::shared_ptr<CSetting>& setting,
136 const std::string& identifier);
137 static bool EndAnytimeSetCondition(const std::string& condition,
138 const std::string& value,
139 const std::shared_ptr<const CSetting>& setting,
140 void* data);
142 typedef std::map<int, std::shared_ptr<CPVRTimerType>> TypeEntriesMap;
144 typedef struct ChannelDescriptor
146 int channelUid;
147 int clientId;
148 std::string description;
150 ChannelDescriptor(int _channelUid = PVR_CHANNEL_INVALID_UID,
151 int _clientId = -1,
152 const std::string& _description = "")
153 : channelUid(_channelUid), clientId(_clientId), description(_description)
157 inline bool operator==(const ChannelDescriptor& right) const
159 return (channelUid == right.channelUid && clientId == right.clientId &&
160 description == right.description);
163 } ChannelDescriptor;
165 typedef std::map<int, ChannelDescriptor> ChannelEntriesMap;
167 std::shared_ptr<CPVRTimerInfoTag> m_timerInfoTag;
168 TypeEntriesMap m_typeEntries;
169 ChannelEntriesMap m_channelEntries;
170 std::string m_timerStartTimeStr;
171 std::string m_timerEndTimeStr;
173 std::shared_ptr<CPVRTimerType> m_timerType;
174 bool m_bIsRadio = false;
175 bool m_bIsNewTimer = true;
176 bool m_bTimerActive = false;
177 std::string m_strTitle;
178 std::string m_strEpgSearchString;
179 bool m_bFullTextEpgSearch = true;
180 ChannelDescriptor m_channel;
181 CDateTime m_startLocalTime;
182 CDateTime m_endLocalTime;
183 bool m_bStartAnyTime = false;
184 bool m_bEndAnyTime = false;
185 unsigned int m_iWeekdays;
186 CDateTime m_firstDayLocalTime;
187 unsigned int m_iPreventDupEpisodes = 0;
188 unsigned int m_iMarginStart = 0;
189 unsigned int m_iMarginEnd = 0;
190 int m_iPriority = 0;
191 int m_iLifetime = 0;
192 int m_iMaxRecordings = 0;
193 std::string m_strDirectory;
194 unsigned int m_iRecordingGroup = 0;
196 } // namespace PVR