kodi
GUIWindowPVRGuide.h
1 /*
2  * Copyright (C) 2012-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "pvr/PVRChannelNumberInputHandler.h"
12 #include "pvr/windows/GUIWindowPVRBase.h"
13 #include "threads/Event.h"
14 #include "threads/Thread.h"
15 
16 #include <atomic>
17 #include <memory>
18 #include <string>
19 
20 class CFileItemList;
21 class CGUIMessage;
22 
23 namespace PVR
24 {
25 enum class PVREvent;
26 
27 class CPVRChannelGroup;
28 class CGUIEPGGridContainer;
29 class CPVRRefreshTimelineItemsThread;
30 
32 {
33 public:
34  CGUIWindowPVRGuideBase(bool bRadio, int id, const std::string& xmlFile);
35  ~CGUIWindowPVRGuideBase() override;
36 
37  void OnInitWindow() override;
38  void OnDeinitWindow(int nextWindowID) override;
39  bool OnMessage(CGUIMessage& message) override;
40  bool OnAction(const CAction& action) override;
41  void GetContextButtons(int itemNumber, CContextButtons& buttons) override;
42  bool OnContextButton(int itemNumber, CONTEXT_BUTTON button) override;
43  void UpdateButtons() override;
44  void SetInvalid() override;
45  bool Update(const std::string& strDirectory, bool updateFilterPath = true) override;
46 
47  void NotifyEvent(const PVREvent& event) override;
48 
49  bool RefreshTimelineItems();
50 
51  // CPVRChannelNumberInputHandler implementation
52  void GetChannelNumbers(std::vector<std::string>& channelNumbers) override;
53  void OnInputDone() override;
54 
55  bool GotoBegin();
56  bool GotoEnd();
57  bool GotoCurrentProgramme();
58  bool GotoDate(int deltaHours);
59  bool OpenDateSelectionDialog();
60  bool Go12HoursBack();
61  bool Go12HoursForward();
62  bool GotoFirstChannel();
63  bool GotoLastChannel();
64  bool GotoPlayingChannel();
65 
66 protected:
67  void UpdateSelectedItemPath() override;
68  std::string GetDirectoryPath() override { return ""; }
69  bool GetDirectory(const std::string& strDirectory, CFileItemList& items) override;
70  void FormatAndSort(CFileItemList& items) override;
71  CFileItemPtr GetCurrentListItem(int offset = 0) override;
72 
73  void ClearData() override;
74 
75 private:
76  CGUIEPGGridContainer* GetGridControl();
77  void InitEpgGridControl();
78 
79  bool OnContextButtonNavigate(CONTEXT_BUTTON button);
80 
81  bool ShouldNavigateToGridContainer(int iAction);
82 
83  void StartRefreshTimelineItemsThread();
84  void StopRefreshTimelineItemsThread();
85 
86  void RefreshView(CGUIMessage& message, bool bInitGridControl);
87 
88  int GetCurrentListItemIndex(const std::shared_ptr<const CFileItem>& item);
89 
90  std::unique_ptr<CPVRRefreshTimelineItemsThread> m_refreshTimelineItemsThread;
91  std::atomic_bool m_bRefreshTimelineItems{false};
92  std::atomic_bool m_bSyncRefreshTimelineItems{false};
93 
94  std::shared_ptr<CPVRChannelGroup> m_cachedChannelGroup;
95 
96  bool m_bChannelSelectionRestored{false};
97 };
98 
100 {
101 public:
102  CGUIWindowPVRTVGuide() : CGUIWindowPVRGuideBase(false, WINDOW_TV_GUIDE, "MyPVRGuide.xml") {}
103  std::string GetRootPath() const override;
104 };
105 
107 {
108 public:
109  CGUIWindowPVRRadioGuide() : CGUIWindowPVRGuideBase(true, WINDOW_RADIO_GUIDE, "MyPVRGuide.xml") {}
110  std::string GetRootPath() const override;
111 };
112 
114 {
115 public:
117  ~CPVRRefreshTimelineItemsThread() override;
118 
119  void Process() override;
120 
121  void DoRefresh(bool bWait);
122  void Stop();
123 
124 private:
125  CGUIWindowPVRGuideBase* m_pGuideWindow;
126  CEvent m_ready;
127  CEvent m_done;
128 };
129 } // namespace PVR
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
void GetChannelNumbers(std::vector< std::string > &channelNumbers) override
Get the currently available channel numbers.
Definition: GUIWindowPVRGuide.cpp:878
void OnInputDone() override
This method gets called after the channel number input timer has expired.
Definition: GUIWindowPVRGuide.cpp:869
Definition: GUIWindowPVRGuide.h:113
void OnInitWindow() override
Called on window open.
Definition: GUIWindowPVRGuide.cpp:117
Definition: Thread.h:44
Definition: GUIWindowPVRBase.h:54
Definition: ContextMenuManager.h:24
Definition: PVRChannelNumberInputHandler.h:29
void FormatAndSort(CFileItemList &items) override
Format and sort file items.
Definition: GUIWindowPVRGuide.cpp:268
Represents a list of files.
Definition: FileItem.h:702
bool GetDirectory(const std::string &strDirectory, CFileItemList &items) override
Overwrite to fill fileitems from a source.
Definition: GUIWindowPVRGuide.cpp:242
Definition: GUIEPGGridContainer.h:38
Class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:21
bool DoRefresh()
Refresh window content.
Definition: GUIWindowPVRBase.h:81
Definition: GUIWindowPVRGuide.h:31
void UpdateButtons() override
Updates the states.
Definition: GUIWindowPVRGuide.cpp:208
Definition: GUIMessage.h:365
Definition: GUIDialogContextMenu.h:93
bool Update(const std::string &strDirectory, bool updateFilterPath=true) override
Retrieves the items from the given path and updates the list.
Definition: GUIWindowPVRGuide.cpp:218
Definition: GUIWindowPVRGuide.h:106
Definition: GUIWindowPVRGuide.h:99