2 * Copyright (C) 2012-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "GUIDialogPVRChannelManager.h"
24 #include "GUIDialogPVRGroupManager.h"
25 #include "dialogs/GUIDialogFileBrowser.h"
26 #include "guilib/GUIKeyboardFactory.h"
27 #include "dialogs/GUIDialogOK.h"
28 #include "dialogs/GUIDialogProgress.h"
29 #include "dialogs/GUIDialogSelect.h"
30 #include "dialogs/GUIDialogYesNo.h"
31 #include "guilib/GUIEditControl.h"
32 #include "guilib/GUIRadioButtonControl.h"
33 #include "guilib/GUISpinControlEx.h"
34 #include "guilib/GUIWindowManager.h"
35 #include "guilib/Key.h"
36 #include "guilib/LocalizeStrings.h"
37 #include "profiles/ProfilesManager.h"
38 #include "pvr/PVRManager.h"
39 #include "pvr/channels/PVRChannelGroupsContainer.h"
40 #include "pvr/addons/PVRClients.h"
41 #include "settings/Settings.h"
42 #include "storage/MediaManager.h"
43 #include "utils/StringUtils.h"
46 #define BUTTON_APPLY 5
47 #define BUTTON_CANCEL 6
48 #define RADIOBUTTON_ACTIVE 7
50 #define BUTTON_CHANNEL_LOGO 9
51 #define IMAGE_CHANNEL_LOGO 10
52 #define RADIOBUTTON_USEEPG 12
53 #define SPIN_EPGSOURCE_SELECTION 13
54 #define RADIOBUTTON_PARENTAL_LOCK 14
55 #define CONTROL_LIST_CHANNELS 20
56 #define BUTTON_GROUP_MANAGER 30
57 #define BUTTON_EDIT_CHANNEL 31
58 #define BUTTON_DELETE_CHANNEL 32
59 #define BUTTON_NEW_CHANNEL 33
60 #define BUTTON_RADIO_TV 34
65 CGUIDialogPVRChannelManager::CGUIDialogPVRChannelManager(void) :
66 CGUIDialog(WINDOW_DIALOG_PVR_CHANNEL_MANAGER, "DialogPVRChannelManager.xml"),
69 m_bContainsChanges(false),
71 m_channelItems(new CFileItemList)
75 CGUIDialogPVRChannelManager::~CGUIDialogPVRChannelManager(void)
77 delete m_channelItems;
80 bool CGUIDialogPVRChannelManager::OnActionMove(const CAction &action)
83 int iActionId = action.GetID();
84 if (GetFocusedControlID() == CONTROL_LIST_CHANNELS &&
85 (iActionId == ACTION_MOVE_DOWN || iActionId == ACTION_MOVE_UP ||
86 iActionId == ACTION_PAGE_DOWN || iActionId == ACTION_PAGE_UP))
91 CGUIDialog::OnAction(action);
92 int iSelected = m_viewControl.GetSelectedItem();
93 if (iSelected != m_iSelected)
95 m_iSelected = iSelected;
101 CStdString strNumber;
102 CGUIDialog::OnAction(action);
104 bool bMoveUp = iActionId == ACTION_PAGE_UP || iActionId == ACTION_MOVE_UP;
105 unsigned int iLines = bMoveUp ? abs(m_iSelected - m_viewControl.GetSelectedItem()) : 1;
106 bool bOutOfBounds = bMoveUp ? m_iSelected <= 0 : m_iSelected >= m_channelItems->Size() - 1;
110 iLines = m_channelItems->Size() - 1;
113 for (unsigned int iLine = 0; iLine < iLines; iLine++)
115 unsigned int iNewSelect = bMoveUp ? m_iSelected - 1 : m_iSelected + 1;
116 if (m_channelItems->Get(iNewSelect)->GetProperty("Number").asString() != "-")
118 strNumber = StringUtils::Format("%i", m_iSelected+1);
119 m_channelItems->Get(iNewSelect)->SetProperty("Number", strNumber);
120 strNumber = StringUtils::Format("%i", iNewSelect+1);
121 m_channelItems->Get(m_iSelected)->SetProperty("Number", strNumber);
123 m_channelItems->Swap(iNewSelect, m_iSelected);
124 m_iSelected = iNewSelect;
127 m_viewControl.SetItems(*m_channelItems);
128 m_viewControl.SetSelectedItem(m_iSelected);
135 bool CGUIDialogPVRChannelManager::OnAction(const CAction& action)
137 return OnActionMove(action) ||
138 CGUIDialog::OnAction(action);
141 void CGUIDialogPVRChannelManager::OnInitWindow()
143 CGUIDialog::OnInitWindow();
147 m_bMovingMode = false;
148 m_bContainsChanges = false;
149 SetProperty("IsRadio", "");
151 SetData(m_iSelected);
154 void CGUIDialogPVRChannelManager::OnDeinitWindow(int nextWindowID)
158 CGUIDialog::OnDeinitWindow(nextWindowID);
161 bool CGUIDialogPVRChannelManager::OnClickListChannels(CGUIMessage &message)
165 int iAction = message.GetParam1();
166 int iItem = m_viewControl.GetSelectedItem();
168 /* Check file item is in list range and get his pointer */
169 if (iItem < 0 || iItem >= (int)m_channelItems->Size()) return true;
171 /* Process actions */
172 if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_RIGHT_CLICK)
174 /* Show Contextmenu */
182 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
185 pItem->SetProperty("Changed", true);
186 pItem->Select(false);
187 m_bMovingMode = false;
188 m_bContainsChanges = true;
196 bool CGUIDialogPVRChannelManager::OnClickButtonOK(CGUIMessage &message)
203 bool CGUIDialogPVRChannelManager::OnClickButtonApply(CGUIMessage &message)
209 bool CGUIDialogPVRChannelManager::OnClickButtonCancel(CGUIMessage &message)
215 bool CGUIDialogPVRChannelManager::OnClickButtonRadioTV(CGUIMessage &message)
217 if (m_bContainsChanges)
219 CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
223 pDialog->SetHeading(20052);
224 pDialog->SetLine(0, "");
225 pDialog->SetLine(1, 19212);
226 pDialog->SetLine(2, 20103);
229 if (pDialog->IsConfirmed())
234 m_bMovingMode = false;
235 m_bContainsChanges = false;
236 m_bIsRadio = !m_bIsRadio;
237 SetProperty("IsRadio", m_bIsRadio ? "true" : "");
239 SetData(m_iSelected);
243 bool CGUIDialogPVRChannelManager::OnClickButtonRadioActive(CGUIMessage &message)
245 CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_ACTIVE);
248 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
251 pItem->SetProperty("Changed", true);
252 pItem->SetProperty("ActiveChannel", pRadioButton->IsSelected());
253 m_bContainsChanges = true;
262 bool CGUIDialogPVRChannelManager::OnClickButtonRadioParentalLocked(CGUIMessage &message)
264 CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_PARENTAL_LOCK);
267 if (!g_PVRManager.CheckParentalPIN(g_localizeStrings.Get(19262).c_str()))
269 pRadioButton->SetSelected(!pRadioButton->IsSelected());
275 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
278 pItem->SetProperty("Changed", true);
279 pItem->SetProperty("ParentalLocked", pRadioButton->IsSelected());
280 m_bContainsChanges = true;
289 bool CGUIDialogPVRChannelManager::OnClickButtonEditName(CGUIMessage &message)
291 CGUIEditControl *pEdit = (CGUIEditControl *)GetControl(EDIT_NAME);
294 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
297 pItem->SetProperty("Changed", true);
298 pItem->SetProperty("Name", pEdit->GetLabel2());
299 m_bContainsChanges = true;
308 bool CGUIDialogPVRChannelManager::OnClickButtonChannelLogo(CGUIMessage &message)
310 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
313 if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
315 else if (!g_passwordManager.IsMasterLockUnlocked(true))
318 // setup our thumb list
321 // add the current thumb, if available
322 if (!pItem->GetProperty("Icon").asString().empty())
324 CFileItemPtr current(new CFileItem("thumb://Current", false));
325 current->SetArt("thumb", pItem->GetPVRChannelInfoTag()->IconPath());
326 current->SetLabel(g_localizeStrings.Get(20016));
329 else if (pItem->HasArt("thumb"))
330 { // already have a thumb that the share doesn't know about - must be a local one, so we mayaswell reuse it.
331 CFileItemPtr current(new CFileItem("thumb://Current", false));
332 current->SetArt("thumb", pItem->GetArt("thumb"));
333 current->SetLabel(g_localizeStrings.Get(20016));
337 // and add a "no thumb" entry as well
338 CFileItemPtr nothumb(new CFileItem("thumb://None", false));
339 nothumb->SetIconImage(pItem->GetIconImage());
340 nothumb->SetLabel(g_localizeStrings.Get(20018));
345 if (CSettings::Get().GetString("pvrmenu.iconpath") != "")
348 share1.strPath = CSettings::Get().GetString("pvrmenu.iconpath");
349 share1.strName = g_localizeStrings.Get(19018);
350 shares.push_back(share1);
352 g_mediaManager.GetLocalDrives(shares);
353 if (!CGUIDialogFileBrowser::ShowAndGetImage(items, shares, g_localizeStrings.Get(1030), strThumb))
356 if (strThumb == "thumb://Current")
359 if (strThumb == "thumb://None")
362 pItem->SetProperty("Icon", strThumb);
363 pItem->SetProperty("Changed", true);
364 m_bContainsChanges = true;
368 bool CGUIDialogPVRChannelManager::OnClickButtonUseEPG(CGUIMessage &message)
370 CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_USEEPG);
373 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
376 pItem->SetProperty("Changed", true);
377 pItem->SetProperty("UseEPG", pRadioButton->IsSelected());
378 m_bContainsChanges = true;
387 bool CGUIDialogPVRChannelManager::OnClickEPGSourceSpin(CGUIMessage &message)
389 // TODO: Add EPG scraper support
391 // CGUISpinControlEx *pSpin = (CGUISpinControlEx *)GetControl(SPIN_EPGSOURCE_SELECTION);
394 // CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
397 // pItem->SetProperty("EPGSource", (int)0);
398 // pItem->SetProperty("Changed", true);
399 // m_bContainsChanges = true;
405 bool CGUIDialogPVRChannelManager::OnClickButtonGroupManager(CGUIMessage &message)
407 /* Load group manager dialog */
408 CGUIDialogPVRGroupManager* pDlgInfo = (CGUIDialogPVRGroupManager*)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_GROUP_MANAGER);
412 pDlgInfo->SetRadio(m_bIsRadio);
414 /* Open dialog window */
421 bool CGUIDialogPVRChannelManager::OnClickButtonEditChannel(CGUIMessage &message)
423 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
427 if (pItem->GetProperty("Virtual").asBoolean())
429 CStdString strURL = pItem->GetProperty("StreamURL").asString();
430 if (CGUIKeyboardFactory::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false))
431 pItem->SetProperty("StreamURL", strURL);
435 CGUIDialogOK::ShowAndGetInput(19033,19038,0,0);
439 bool CGUIDialogPVRChannelManager::OnClickButtonDeleteChannel(CGUIMessage &message)
441 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
445 CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
449 pDialog->SetHeading(19211);
450 pDialog->SetLine(0, "");
451 pDialog->SetLine(1, 750);
452 pDialog->SetLine(2, "");
455 if (pDialog->IsConfirmed())
457 if (pItem->GetProperty("Virtual").asBoolean())
459 pItem->GetPVRChannelInfoTag()->SetVirtual(true);
460 m_channelItems->Remove(m_iSelected);
461 m_viewControl.SetItems(*m_channelItems);
465 CGUIDialogOK::ShowAndGetInput(19033,19038,0,0);
470 bool CGUIDialogPVRChannelManager::OnClickButtonNewChannel(CGUIMessage &message)
472 std::vector<long> clients;
474 CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
478 pDlgSelect->SetHeading(19213); // Select Client
479 pDlgSelect->Add(g_localizeStrings.Get(19209));
480 clients.push_back(PVR_VIRTUAL_CLIENT_ID);
482 PVR_CLIENTMAP clientMap;
483 if (g_PVRClients->GetConnectedClients(clientMap) > 0)
485 PVR_CLIENTMAP_ITR itr;
486 for (itr = clientMap.begin() ; itr != clientMap.end(); itr++)
488 clients.push_back((*itr).first);
489 pDlgSelect->Add((*itr).second->Name());
492 pDlgSelect->DoModal();
494 int selection = pDlgSelect->GetSelectedLabel();
495 if (selection >= 0 && selection <= (int) clients.size())
497 int clientID = clients[selection];
498 if (clientID == PVR_VIRTUAL_CLIENT_ID)
500 CStdString strURL = "";
501 if (CGUIKeyboardFactory::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false))
503 if (!strURL.IsEmpty())
505 CPVRChannel *newchannel = new CPVRChannel(m_bIsRadio);
506 newchannel->SetChannelName(g_localizeStrings.Get(19204));
507 newchannel->SetEPGEnabled(false);
508 newchannel->SetVirtual(true);
509 newchannel->SetStreamURL(strURL);
510 newchannel->SetClientID(PVR_VIRTUAL_CLIENT_ID);
511 if (g_PVRChannelGroups->CreateChannel(*newchannel))
512 g_PVRChannelGroups->GetGroupAll(m_bIsRadio)->Persist();
514 CFileItemPtr channel(new CFileItem(*newchannel));
517 channel->SetProperty("ActiveChannel", true);
518 channel->SetProperty("Name", g_localizeStrings.Get(19204));
519 channel->SetProperty("UseEPG", false);
520 channel->SetProperty("Icon", newchannel->IconPath());
521 channel->SetProperty("EPGSource", (int)0);
522 channel->SetProperty("ClientName", g_localizeStrings.Get(19209));
523 channel->SetProperty("ParentalLocked", false);
525 m_channelItems->AddFront(channel, m_iSelected);
526 m_viewControl.SetItems(*m_channelItems);
534 CGUIDialogOK::ShowAndGetInput(19033,19038,0,0);
540 bool CGUIDialogPVRChannelManager::OnMessageClick(CGUIMessage &message)
542 int iControl = message.GetSenderId();
545 case CONTROL_LIST_CHANNELS:
546 return OnClickListChannels(message);
548 return OnClickButtonOK(message);
550 return OnClickButtonApply(message);
552 return OnClickButtonCancel(message);
553 case BUTTON_RADIO_TV:
554 return OnClickButtonRadioTV(message);
555 case RADIOBUTTON_ACTIVE:
556 return OnClickButtonRadioActive(message);
557 case RADIOBUTTON_PARENTAL_LOCK:
558 return OnClickButtonRadioParentalLocked(message);
560 return OnClickButtonEditName(message);
561 case BUTTON_CHANNEL_LOGO:
562 return OnClickButtonChannelLogo(message);
563 case RADIOBUTTON_USEEPG:
564 return OnClickButtonUseEPG(message);
565 case SPIN_EPGSOURCE_SELECTION:
566 return OnClickEPGSourceSpin(message);
567 case BUTTON_GROUP_MANAGER:
568 return OnClickButtonGroupManager(message);
569 case BUTTON_EDIT_CHANNEL:
570 return OnClickButtonEditChannel(message);
571 case BUTTON_DELETE_CHANNEL:
572 return OnClickButtonDeleteChannel(message);
573 case BUTTON_NEW_CHANNEL:
574 return OnClickButtonNewChannel(message);
580 bool CGUIDialogPVRChannelManager::OnMessage(CGUIMessage& message)
582 unsigned int iMessage = message.GetMessage();
586 case GUI_MSG_CLICKED:
587 return OnMessageClick(message);
590 return CGUIDialog::OnMessage(message);
593 void CGUIDialogPVRChannelManager::OnWindowLoaded(void)
595 CGUIDialog::OnWindowLoaded();
597 m_viewControl.Reset();
598 m_viewControl.SetParentWindow(GetID());
599 m_viewControl.AddView(GetControl(CONTROL_LIST_CHANNELS));
602 void CGUIDialogPVRChannelManager::OnWindowUnload(void)
604 CGUIDialog::OnWindowUnload();
605 m_viewControl.Reset();
608 CFileItemPtr CGUIDialogPVRChannelManager::GetCurrentListItem(int offset)
610 return m_channelItems->Get(m_iSelected);
613 bool CGUIDialogPVRChannelManager::OnPopupMenu(int iItem)
615 // popup the context menu
616 // grab our context menu
617 CContextButtons buttons;
620 if (iItem >= 0 && iItem < m_channelItems->Size())
621 m_channelItems->Get(iItem)->Select(true);
625 CFileItemPtr pItem = m_channelItems->Get(iItem);
629 buttons.Add(CONTEXT_BUTTON_MOVE, 116); /* Move channel up or down */
630 if (pItem->GetProperty("Virtual").asBoolean())
631 buttons.Add(CONTEXT_BUTTON_EDIT_SOURCE, 1027); /* Edit virtual channel URL */
633 int choice = CGUIDialogContextMenu::ShowAndGetChoice(buttons);
636 if (iItem >= 0 && iItem < m_channelItems->Size())
637 m_channelItems->Get(iItem)->Select(false);
642 return OnContextButton(iItem, (CONTEXT_BUTTON)choice);
645 bool CGUIDialogPVRChannelManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
647 /* Check file item is in list range and get his pointer */
648 if (itemNumber < 0 || itemNumber >= (int)m_channelItems->Size()) return false;
650 CFileItemPtr pItem = m_channelItems->Get(itemNumber);
654 if (button == CONTEXT_BUTTON_MOVE)
656 m_bMovingMode = true;
659 else if (button == CONTEXT_BUTTON_EDIT_SOURCE)
661 CStdString strURL = pItem->GetProperty("StreamURL").asString();
662 if (CGUIKeyboardFactory::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false))
663 pItem->SetProperty("StreamURL", strURL);
668 void CGUIDialogPVRChannelManager::SetData(int iItem)
670 CGUIEditControl *pEdit;
671 CGUIRadioButtonControl *pRadioButton;
673 /* Check file item is in list range and get his pointer */
674 if (iItem < 0 || iItem >= (int)m_channelItems->Size()) return;
676 CFileItemPtr pItem = m_channelItems->Get(iItem);
680 pEdit = (CGUIEditControl *)GetControl(EDIT_NAME);
683 pEdit->SetLabel2(pItem->GetProperty("Name").asString());
684 pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_TEXT, 19208);
687 pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_ACTIVE);
688 if (pRadioButton) pRadioButton->SetSelected(pItem->GetProperty("ActiveChannel").asBoolean());
690 pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_USEEPG);
691 if (pRadioButton) pRadioButton->SetSelected(pItem->GetProperty("UseEPG").asBoolean());
693 pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_PARENTAL_LOCK);
694 if (pRadioButton) pRadioButton->SetSelected(pItem->GetProperty("ParentalLocked").asBoolean());
697 void CGUIDialogPVRChannelManager::Update()
699 // lock our display, as this window is rendered from the player thread
700 g_graphicsContext.Lock();
701 m_viewControl.SetCurrentView(CONTROL_LIST_CHANNELS);
703 // empty the lists ready for population
706 CPVRChannelGroupPtr channels = g_PVRChannelGroups->GetGroupAll(m_bIsRadio);
708 // No channels available, nothing to do.
712 for (int iChannelPtr = 0; iChannelPtr < channels->Size(); iChannelPtr++)
714 CFileItemPtr channelFile = channels->GetByIndex(iChannelPtr);
715 if (!channelFile || !channelFile->HasPVRChannelInfoTag())
717 const CPVRChannel *channel = channelFile->GetPVRChannelInfoTag();
719 channelFile->SetProperty("ActiveChannel", !channel->IsHidden());
720 channelFile->SetProperty("Name", channel->ChannelName());
721 channelFile->SetProperty("UseEPG", channel->EPGEnabled());
722 channelFile->SetProperty("Icon", channel->IconPath());
723 channelFile->SetProperty("EPGSource", (int)0);
724 channelFile->SetProperty("ParentalLocked", channel->IsLocked());
725 channelFile->SetProperty("Number", StringUtils::Format("%i", channel->ChannelNumber()));
727 if (channel->IsVirtual())
729 channelFile->SetProperty("Virtual", true);
730 channelFile->SetProperty("StreamURL", channel->StreamURL());
733 CStdString clientName;
734 if (channel->ClientID() == PVR_VIRTUAL_CLIENT_ID) /* XBMC internal */
735 clientName = g_localizeStrings.Get(19209);
737 g_PVRClients->GetClientName(channel->ClientID(), clientName);
738 channelFile->SetProperty("ClientName", clientName);
740 m_channelItems->Add(channelFile);
743 CGUISpinControlEx *pSpin = (CGUISpinControlEx *)GetControl(SPIN_EPGSOURCE_SELECTION);
747 pSpin->AddLabel(g_localizeStrings.Get(19210), 0);
748 /// TODO: Add Labels for EPG scrapers here
752 m_viewControl.SetItems(*m_channelItems);
753 m_viewControl.SetSelectedItem(m_iSelected);
755 g_graphicsContext.Unlock();
758 void CGUIDialogPVRChannelManager::Clear(void)
760 m_viewControl.Clear();
761 m_channelItems->Clear();
764 bool CGUIDialogPVRChannelManager::PersistChannel(CFileItemPtr pItem, CPVRChannelGroupPtr group, unsigned int *iChannelNumber)
766 if (!pItem || !pItem->HasPVRChannelInfoTag() || !group)
769 /* get values from the form */
770 bool bHidden = !pItem->GetProperty("ActiveChannel").asBoolean();
771 bool bVirtual = pItem->GetProperty("Virtual").asBoolean();
772 bool bEPGEnabled = pItem->GetProperty("UseEPG").asBoolean();
773 bool bParentalLocked = pItem->GetProperty("ParentalLocked").asBoolean();
774 int iEPGSource = (int)pItem->GetProperty("EPGSource").asInteger();
775 CStdString strChannelName = pItem->GetProperty("Name").asString();
776 CStdString strIconPath = pItem->GetProperty("Icon").asString();
777 CStdString strStreamURL = pItem->GetProperty("StreamURL").asString();
779 return group->UpdateChannel(*pItem, bHidden, bVirtual, bEPGEnabled, bParentalLocked, iEPGSource, ++(*iChannelNumber), strChannelName, strIconPath, strStreamURL);
782 void CGUIDialogPVRChannelManager::SaveList(void)
784 if (!m_bContainsChanges)
787 /* display the progress dialog */
788 CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
789 pDlgProgress->SetHeading(190);
790 pDlgProgress->SetLine(0, "");
791 pDlgProgress->SetLine(1, 328);
792 pDlgProgress->SetLine(2, "");
793 pDlgProgress->StartModal();
794 pDlgProgress->Progress();
795 pDlgProgress->SetPercentage(0);
797 /* persist all channels */
798 unsigned int iNextChannelNumber(0);
799 CPVRChannelGroupPtr group = g_PVRChannelGroups->GetGroupAll(m_bIsRadio);
802 for (int iListPtr = 0; iListPtr < m_channelItems->Size(); iListPtr++)
804 CFileItemPtr pItem = m_channelItems->Get(iListPtr);
805 PersistChannel(pItem, group, &iNextChannelNumber);
807 pDlgProgress->SetPercentage(iListPtr * 100 / m_channelItems->Size());
810 group->SortAndRenumber();
812 m_bContainsChanges = false;
814 pDlgProgress->Close();
817 void CGUIDialogPVRChannelManager::SetItemsUnchanged(void)
819 for (int iItemPtr = 0; iItemPtr < m_channelItems->Size(); iItemPtr++)
821 CFileItemPtr pItem = m_channelItems->Get(iItemPtr);
823 pItem->SetProperty("Changed", false);
827 void CGUIDialogPVRChannelManager::Renumber(void)
829 int iNextChannelNumber(0);
830 CStdString strNumber;
832 for (int iChannelPtr = 0; iChannelPtr < m_channelItems->Size(); iChannelPtr++)
834 pItem = m_channelItems->Get(iChannelPtr);
835 if (pItem->GetProperty("ActiveChannel").asBoolean())
837 strNumber = StringUtils::Format("%i", ++iNextChannelNumber);
838 pItem->SetProperty("Number", strNumber);
841 pItem->SetProperty("Number", "-");