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.
9 #include "GUIDialogPVRChannelGuide.h"
12 #include "FileItemList.h"
13 #include "ServiceBroker.h"
14 #include "pvr/PVRManager.h"
15 #include "pvr/PVRPlaybackState.h"
16 #include "pvr/channels/PVRChannel.h"
17 #include "pvr/epg/EpgInfoTag.h"
24 CGUIDialogPVRChannelGuide::CGUIDialogPVRChannelGuide()
25 : CGUIDialogPVRItemsViewBase(WINDOW_DIALOG_PVR_CHANNEL_GUIDE
, "DialogPVRChannelGuide.xml")
29 void CGUIDialogPVRChannelGuide::Open(const std::shared_ptr
<const CPVRChannel
>& channel
)
32 CGUIDialogPVRItemsViewBase::Open();
35 void CGUIDialogPVRChannelGuide::OnInitWindow()
37 // no user-specific channel is set; use current playing channel
39 m_channel
= CServiceBroker::GetPVRManager().PlaybackState()->GetPlayingChannel();
49 const std::vector
<std::shared_ptr
<CPVREpgInfoTag
>> tags
= m_channel
->GetEpgTags();
50 for (const auto& tag
: tags
)
52 m_vecItems
->Add(std::make_shared
<CFileItem
>(tag
));
55 m_viewControl
.SetItems(*m_vecItems
);
57 CGUIDialogPVRItemsViewBase::OnInitWindow();
59 // select the active entry
60 unsigned int iSelectedItem
= 0;
61 for (int iEpgPtr
= 0; iEpgPtr
< m_vecItems
->Size(); ++iEpgPtr
)
63 const CFileItemPtr entry
= m_vecItems
->Get(iEpgPtr
);
64 if (entry
->HasEPGInfoTag() && entry
->GetEPGInfoTag()->IsActive())
66 iSelectedItem
= iEpgPtr
;
70 m_viewControl
.SetSelectedItem(iSelectedItem
);
73 void CGUIDialogPVRChannelGuide::OnDeinitWindow(int nextWindowID
)
75 CGUIDialogPVRItemsViewBase::OnDeinitWindow(nextWindowID
);