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"
45 #define BUTTON_APPLY 5
46 #define BUTTON_CANCEL 6
47 #define RADIOBUTTON_ACTIVE 7
49 #define BUTTON_CHANNEL_LOGO 9
50 #define IMAGE_CHANNEL_LOGO 10
51 #define RADIOBUTTON_USEEPG 12
52 #define SPIN_EPGSOURCE_SELECTION 13
53 #define RADIOBUTTON_PARENTAL_LOCK 14
54 #define CONTROL_LIST_CHANNELS 20
55 #define BUTTON_GROUP_MANAGER 30
56 #define BUTTON_EDIT_CHANNEL 31
57 #define BUTTON_DELETE_CHANNEL 32
58 #define BUTTON_NEW_CHANNEL 33
59 #define BUTTON_RADIO_TV 34
64 CGUIDialogPVRChannelManager::CGUIDialogPVRChannelManager(void) :
65 CGUIDialog(WINDOW_DIALOG_PVR_CHANNEL_MANAGER, "DialogPVRChannelManager.xml"),
68 m_bContainsChanges(false),
70 m_channelItems(new CFileItemList)
74 CGUIDialogPVRChannelManager::~CGUIDialogPVRChannelManager(void)
76 delete m_channelItems;
79 bool CGUIDialogPVRChannelManager::OnActionMove(const CAction &action)
82 int iActionId = action.GetID();
83 if (GetFocusedControlID() == CONTROL_LIST_CHANNELS &&
84 (iActionId == ACTION_MOVE_DOWN || iActionId == ACTION_MOVE_UP ||
85 iActionId == ACTION_PAGE_DOWN || iActionId == ACTION_PAGE_UP))
90 CGUIDialog::OnAction(action);
91 int iSelected = m_viewControl.GetSelectedItem();
92 if (iSelected != m_iSelected)
94 m_iSelected = iSelected;
100 CStdString strNumber;
101 CGUIDialog::OnAction(action);
103 bool bMoveUp = iActionId == ACTION_PAGE_UP || iActionId == ACTION_MOVE_UP;
104 unsigned int iLines = bMoveUp ? abs(m_iSelected - m_viewControl.GetSelectedItem()) : 1;
105 bool bOutOfBounds = bMoveUp ? m_iSelected <= 0 : m_iSelected >= m_channelItems->Size() - 1;
109 iLines = m_channelItems->Size() - 1;
112 for (unsigned int iLine = 0; iLine < iLines; iLine++)
114 unsigned int iNewSelect = bMoveUp ? m_iSelected - 1 : m_iSelected + 1;
115 if (m_channelItems->Get(iNewSelect)->GetProperty("Number").asString() != "-")
117 strNumber.Format("%i", m_iSelected+1);
118 m_channelItems->Get(iNewSelect)->SetProperty("Number", strNumber);
119 strNumber.Format("%i", iNewSelect+1);
120 m_channelItems->Get(m_iSelected)->SetProperty("Number", strNumber);
122 m_channelItems->Swap(iNewSelect, m_iSelected);
123 m_iSelected = iNewSelect;
126 m_viewControl.SetItems(*m_channelItems);
127 m_viewControl.SetSelectedItem(m_iSelected);
134 bool CGUIDialogPVRChannelManager::OnAction(const CAction& action)
136 return OnActionMove(action) ||
137 CGUIDialog::OnAction(action);
140 void CGUIDialogPVRChannelManager::OnInitWindow()
142 CGUIDialog::OnInitWindow();
146 m_bMovingMode = false;
147 m_bContainsChanges = false;
148 SetProperty("IsRadio", "");
150 SetData(m_iSelected);
153 void CGUIDialogPVRChannelManager::OnDeinitWindow(int nextWindowID)
157 CGUIDialog::OnDeinitWindow(nextWindowID);
160 bool CGUIDialogPVRChannelManager::OnClickListChannels(CGUIMessage &message)
164 int iAction = message.GetParam1();
165 int iItem = m_viewControl.GetSelectedItem();
167 /* Check file item is in list range and get his pointer */
168 if (iItem < 0 || iItem >= (int)m_channelItems->Size()) return true;
170 /* Process actions */
171 if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_RIGHT_CLICK)
173 /* Show Contextmenu */
181 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
184 pItem->SetProperty("Changed", true);
185 pItem->Select(false);
186 m_bMovingMode = false;
187 m_bContainsChanges = true;
195 bool CGUIDialogPVRChannelManager::OnClickButtonOK(CGUIMessage &message)
202 bool CGUIDialogPVRChannelManager::OnClickButtonApply(CGUIMessage &message)
208 bool CGUIDialogPVRChannelManager::OnClickButtonCancel(CGUIMessage &message)
214 bool CGUIDialogPVRChannelManager::OnClickButtonRadioTV(CGUIMessage &message)
216 if (m_bContainsChanges)
218 CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
222 pDialog->SetHeading(20052);
223 pDialog->SetLine(0, "");
224 pDialog->SetLine(1, 19212);
225 pDialog->SetLine(2, 20103);
228 if (pDialog->IsConfirmed())
233 m_bMovingMode = false;
234 m_bContainsChanges = false;
235 m_bIsRadio = !m_bIsRadio;
236 SetProperty("IsRadio", m_bIsRadio ? "true" : "");
238 SetData(m_iSelected);
242 bool CGUIDialogPVRChannelManager::OnClickButtonRadioActive(CGUIMessage &message)
244 CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_ACTIVE);
247 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
250 pItem->SetProperty("Changed", true);
251 pItem->SetProperty("ActiveChannel", pRadioButton->IsSelected());
252 m_bContainsChanges = true;
261 bool CGUIDialogPVRChannelManager::OnClickButtonRadioParentalLocked(CGUIMessage &message)
263 CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_PARENTAL_LOCK);
266 if (!g_PVRManager.CheckParentalPIN(g_localizeStrings.Get(19262).c_str()))
268 pRadioButton->SetSelected(!pRadioButton->IsSelected());
274 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
277 pItem->SetProperty("Changed", true);
278 pItem->SetProperty("ParentalLocked", pRadioButton->IsSelected());
279 m_bContainsChanges = true;
288 bool CGUIDialogPVRChannelManager::OnClickButtonEditName(CGUIMessage &message)
290 CGUIEditControl *pEdit = (CGUIEditControl *)GetControl(EDIT_NAME);
293 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
296 pItem->SetProperty("Changed", true);
297 pItem->SetProperty("Name", pEdit->GetLabel2());
298 m_bContainsChanges = true;
307 bool CGUIDialogPVRChannelManager::OnClickButtonChannelLogo(CGUIMessage &message)
309 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
312 if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked())
314 else if (!g_passwordManager.IsMasterLockUnlocked(true))
317 // setup our thumb list
320 // add the current thumb, if available
321 if (!pItem->GetProperty("Icon").asString().empty())
323 CFileItemPtr current(new CFileItem("thumb://Current", false));
324 current->SetArt("thumb", pItem->GetPVRChannelInfoTag()->IconPath());
325 current->SetLabel(g_localizeStrings.Get(20016));
328 else if (pItem->HasArt("thumb"))
329 { // already have a thumb that the share doesn't know about - must be a local one, so we mayaswell reuse it.
330 CFileItemPtr current(new CFileItem("thumb://Current", false));
331 current->SetArt("thumb", pItem->GetArt("thumb"));
332 current->SetLabel(g_localizeStrings.Get(20016));
336 // and add a "no thumb" entry as well
337 CFileItemPtr nothumb(new CFileItem("thumb://None", false));
338 nothumb->SetIconImage(pItem->GetIconImage());
339 nothumb->SetLabel(g_localizeStrings.Get(20018));
344 if (CSettings::Get().GetString("pvrmenu.iconpath") != "")
347 share1.strPath = CSettings::Get().GetString("pvrmenu.iconpath");
348 share1.strName = g_localizeStrings.Get(19018);
349 shares.push_back(share1);
351 g_mediaManager.GetLocalDrives(shares);
352 if (!CGUIDialogFileBrowser::ShowAndGetImage(items, shares, g_localizeStrings.Get(1030), strThumb))
355 if (strThumb == "thumb://Current")
358 if (strThumb == "thumb://None")
361 pItem->SetProperty("Icon", strThumb);
362 pItem->SetProperty("Changed", true);
363 m_bContainsChanges = true;
367 bool CGUIDialogPVRChannelManager::OnClickButtonUseEPG(CGUIMessage &message)
369 CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_USEEPG);
372 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
375 pItem->SetProperty("Changed", true);
376 pItem->SetProperty("UseEPG", pRadioButton->IsSelected());
377 m_bContainsChanges = true;
386 bool CGUIDialogPVRChannelManager::OnClickEPGSourceSpin(CGUIMessage &message)
388 // TODO: Add EPG scraper support
390 // CGUISpinControlEx *pSpin = (CGUISpinControlEx *)GetControl(SPIN_EPGSOURCE_SELECTION);
393 // CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
396 // pItem->SetProperty("EPGSource", (int)0);
397 // pItem->SetProperty("Changed", true);
398 // m_bContainsChanges = true;
404 bool CGUIDialogPVRChannelManager::OnClickButtonGroupManager(CGUIMessage &message)
406 /* Load group manager dialog */
407 CGUIDialogPVRGroupManager* pDlgInfo = (CGUIDialogPVRGroupManager*)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_GROUP_MANAGER);
411 pDlgInfo->SetRadio(m_bIsRadio);
413 /* Open dialog window */
420 bool CGUIDialogPVRChannelManager::OnClickButtonEditChannel(CGUIMessage &message)
422 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
426 if (pItem->GetProperty("Virtual").asBoolean())
428 CStdString strURL = pItem->GetProperty("StreamURL").asString();
429 if (CGUIKeyboardFactory::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false))
430 pItem->SetProperty("StreamURL", strURL);
434 CGUIDialogOK::ShowAndGetInput(19033,19038,0,0);
438 bool CGUIDialogPVRChannelManager::OnClickButtonDeleteChannel(CGUIMessage &message)
440 CFileItemPtr pItem = m_channelItems->Get(m_iSelected);
444 CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
448 pDialog->SetHeading(19211);
449 pDialog->SetLine(0, "");
450 pDialog->SetLine(1, 750);
451 pDialog->SetLine(2, "");
454 if (pDialog->IsConfirmed())
456 if (pItem->GetProperty("Virtual").asBoolean())
458 pItem->GetPVRChannelInfoTag()->SetVirtual(true);
459 m_channelItems->Remove(m_iSelected);
460 m_viewControl.SetItems(*m_channelItems);
464 CGUIDialogOK::ShowAndGetInput(19033,19038,0,0);
469 bool CGUIDialogPVRChannelManager::OnClickButtonNewChannel(CGUIMessage &message)
471 std::vector<long> clients;
473 CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
477 pDlgSelect->SetHeading(19213); // Select Client
478 pDlgSelect->Add(g_localizeStrings.Get(19209));
479 clients.push_back(PVR_VIRTUAL_CLIENT_ID);
481 PVR_CLIENTMAP clientMap;
482 if (g_PVRClients->GetConnectedClients(clientMap) > 0)
484 PVR_CLIENTMAP_ITR itr;
485 for (itr = clientMap.begin() ; itr != clientMap.end(); itr++)
487 clients.push_back((*itr).first);
488 pDlgSelect->Add((*itr).second->Name());
491 pDlgSelect->DoModal();
493 int selection = pDlgSelect->GetSelectedLabel();
494 if (selection >= 0 && selection <= (int) clients.size())
496 int clientID = clients[selection];
497 if (clientID == PVR_VIRTUAL_CLIENT_ID)
499 CStdString strURL = "";
500 if (CGUIKeyboardFactory::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false))
502 if (!strURL.IsEmpty())
504 CPVRChannel *newchannel = new CPVRChannel(m_bIsRadio);
505 newchannel->SetChannelName(g_localizeStrings.Get(19204));
506 newchannel->SetEPGEnabled(false);
507 newchannel->SetVirtual(true);
508 newchannel->SetStreamURL(strURL);
509 newchannel->SetClientID(PVR_VIRTUAL_CLIENT_ID);
510 if (g_PVRChannelGroups->CreateChannel(*newchannel))
511 g_PVRChannelGroups->GetGroupAll(m_bIsRadio)->Persist();
513 CFileItemPtr channel(new CFileItem(*newchannel));
516 channel->SetProperty("ActiveChannel", true);
517 channel->SetProperty("Name", g_localizeStrings.Get(19204));
518 channel->SetProperty("UseEPG", false);
519 channel->SetProperty("Icon", newchannel->IconPath());
520 channel->SetProperty("EPGSource", (int)0);
521 channel->SetProperty("ClientName", g_localizeStrings.Get(19209));
522 channel->SetProperty("ParentalLocked", false);
524 m_channelItems->AddFront(channel, m_iSelected);
525 m_viewControl.SetItems(*m_channelItems);
533 CGUIDialogOK::ShowAndGetInput(19033,19038,0,0);
539 bool CGUIDialogPVRChannelManager::OnMessageClick(CGUIMessage &message)
541 int iControl = message.GetSenderId();
544 case CONTROL_LIST_CHANNELS:
545 return OnClickListChannels(message);
547 return OnClickButtonOK(message);
549 return OnClickButtonApply(message);
551 return OnClickButtonCancel(message);
552 case BUTTON_RADIO_TV:
553 return OnClickButtonRadioTV(message);
554 case RADIOBUTTON_ACTIVE:
555 return OnClickButtonRadioActive(message);
556 case RADIOBUTTON_PARENTAL_LOCK:
557 return OnClickButtonRadioParentalLocked(message);
559 return OnClickButtonEditName(message);
560 case BUTTON_CHANNEL_LOGO:
561 return OnClickButtonChannelLogo(message);
562 case RADIOBUTTON_USEEPG:
563 return OnClickButtonUseEPG(message);
564 case SPIN_EPGSOURCE_SELECTION:
565 return OnClickEPGSourceSpin(message);
566 case BUTTON_GROUP_MANAGER:
567 return OnClickButtonGroupManager(message);
568 case BUTTON_EDIT_CHANNEL:
569 return OnClickButtonEditChannel(message);
570 case BUTTON_DELETE_CHANNEL:
571 return OnClickButtonDeleteChannel(message);
572 case BUTTON_NEW_CHANNEL:
573 return OnClickButtonNewChannel(message);
579 bool CGUIDialogPVRChannelManager::OnMessage(CGUIMessage& message)
581 unsigned int iMessage = message.GetMessage();
585 case GUI_MSG_CLICKED:
586 return OnMessageClick(message);
589 return CGUIDialog::OnMessage(message);
592 void CGUIDialogPVRChannelManager::OnWindowLoaded(void)
594 CGUIDialog::OnWindowLoaded();
596 m_viewControl.Reset();
597 m_viewControl.SetParentWindow(GetID());
598 m_viewControl.AddView(GetControl(CONTROL_LIST_CHANNELS));
601 void CGUIDialogPVRChannelManager::OnWindowUnload(void)
603 CGUIDialog::OnWindowUnload();
604 m_viewControl.Reset();
607 CFileItemPtr CGUIDialogPVRChannelManager::GetCurrentListItem(int offset)
609 return m_channelItems->Get(m_iSelected);
612 bool CGUIDialogPVRChannelManager::OnPopupMenu(int iItem)
614 // popup the context menu
615 // grab our context menu
616 CContextButtons buttons;
619 if (iItem >= 0 && iItem < m_channelItems->Size())
620 m_channelItems->Get(iItem)->Select(true);
624 CFileItemPtr pItem = m_channelItems->Get(iItem);
628 buttons.Add(CONTEXT_BUTTON_MOVE, 116); /* Move channel up or down */
629 if (pItem->GetProperty("Virtual").asBoolean())
630 buttons.Add(CONTEXT_BUTTON_EDIT_SOURCE, 1027); /* Edit virtual channel URL */
632 int choice = CGUIDialogContextMenu::ShowAndGetChoice(buttons);
635 if (iItem >= 0 && iItem < m_channelItems->Size())
636 m_channelItems->Get(iItem)->Select(false);
641 return OnContextButton(iItem, (CONTEXT_BUTTON)choice);
644 bool CGUIDialogPVRChannelManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
646 /* Check file item is in list range and get his pointer */
647 if (itemNumber < 0 || itemNumber >= (int)m_channelItems->Size()) return false;
649 CFileItemPtr pItem = m_channelItems->Get(itemNumber);
653 if (button == CONTEXT_BUTTON_MOVE)
655 m_bMovingMode = true;
658 else if (button == CONTEXT_BUTTON_EDIT_SOURCE)
660 CStdString strURL = pItem->GetProperty("StreamURL").asString();
661 if (CGUIKeyboardFactory::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false))
662 pItem->SetProperty("StreamURL", strURL);
667 void CGUIDialogPVRChannelManager::SetData(int iItem)
669 CGUIEditControl *pEdit;
670 CGUIRadioButtonControl *pRadioButton;
672 /* Check file item is in list range and get his pointer */
673 if (iItem < 0 || iItem >= (int)m_channelItems->Size()) return;
675 CFileItemPtr pItem = m_channelItems->Get(iItem);
679 pEdit = (CGUIEditControl *)GetControl(EDIT_NAME);
682 pEdit->SetLabel2(pItem->GetProperty("Name").asString());
683 pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_TEXT, 19208);
686 pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_ACTIVE);
687 if (pRadioButton) pRadioButton->SetSelected(pItem->GetProperty("ActiveChannel").asBoolean());
689 pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_USEEPG);
690 if (pRadioButton) pRadioButton->SetSelected(pItem->GetProperty("UseEPG").asBoolean());
692 pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_PARENTAL_LOCK);
693 if (pRadioButton) pRadioButton->SetSelected(pItem->GetProperty("ParentalLocked").asBoolean());
696 void CGUIDialogPVRChannelManager::Update()
698 // lock our display, as this window is rendered from the player thread
699 g_graphicsContext.Lock();
700 m_viewControl.SetCurrentView(CONTROL_LIST_CHANNELS);
702 // empty the lists ready for population
705 CPVRChannelGroupPtr channels = g_PVRChannelGroups->GetGroupAll(m_bIsRadio);
707 // No channels available, nothing to do.
711 for (int iChannelPtr = 0; iChannelPtr < channels->Size(); iChannelPtr++)
713 CFileItemPtr channelFile = channels->GetByIndex(iChannelPtr);
714 if (!channelFile || !channelFile->HasPVRChannelInfoTag())
716 const CPVRChannel *channel = channelFile->GetPVRChannelInfoTag();
718 channelFile->SetProperty("ActiveChannel", !channel->IsHidden());
719 channelFile->SetProperty("Name", channel->ChannelName());
720 channelFile->SetProperty("UseEPG", channel->EPGEnabled());
721 channelFile->SetProperty("Icon", channel->IconPath());
722 channelFile->SetProperty("EPGSource", (int)0);
723 channelFile->SetProperty("ParentalLocked", channel->IsLocked());
724 CStdString number; number.Format("%i", channel->ChannelNumber());
725 channelFile->SetProperty("Number", number);
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.Format("%i", ++iNextChannelNumber);
838 pItem->SetProperty("Number", strNumber);
841 pItem->SetProperty("Number", "-");