diff options
author | phunkyfish <phunkyfish@gmail.com> | 2020-02-10 10:24:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-10 10:24:31 +0000 |
commit | b1547ab3c8b192ae8da91d3e13fae9f7af60e680 (patch) | |
tree | b5dbccaecaeadb986bb1e9f682565827c3e599e9 | |
parent | 9b77063d40bd1a3d89e557313e8c24d4891c859b (diff) | |
parent | bc66779fd9ab231b60718ef04194a2f8a17f1572 (diff) |
Merge pull request #17348 from phunkyfish/pvr-group-manager
[pvr] always add new members to group at end in group manager
-rw-r--r-- | xbmc/pvr/channels/PVRChannelGroup.cpp | 14 | ||||
-rw-r--r-- | xbmc/pvr/channels/PVRChannelGroup.h | 9 | ||||
-rw-r--r-- | xbmc/pvr/channels/PVRChannelGroupInternal.cpp | 7 | ||||
-rw-r--r-- | xbmc/pvr/channels/PVRChannelGroupInternal.h | 5 | ||||
-rw-r--r-- | xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp | 3 |
5 files changed, 36 insertions, 2 deletions
diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index cb35cebf8b..8c0c3f36d4 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -714,6 +714,20 @@ bool CPVRChannelGroup::AddToGroup(const std::shared_ptr<CPVRChannel>& channel, c return bReturn; } +bool CPVRChannelGroup::AppendToGroup(const std::shared_ptr<CPVRChannel>& channel) +{ + CSingleLock lock(m_critSection); + + unsigned int channelNumberMax = 0; + for (const auto& member : m_sortedMembers) + { + if (member->channelNumber.GetChannelNumber() > channelNumberMax) + channelNumberMax = member->channelNumber.GetChannelNumber(); + } + + return AddToGroup(channel, CPVRChannelNumber(channelNumberMax + 1, 0), 0, false); +} + bool CPVRChannelGroup::IsGroupMember(const std::shared_ptr<CPVRChannel>& channel) const { CSingleLock lock(m_critSection); diff --git a/xbmc/pvr/channels/PVRChannelGroup.h b/xbmc/pvr/channels/PVRChannelGroup.h index 0dabe871e4..b0c3b7a07b 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.h +++ b/xbmc/pvr/channels/PVRChannelGroup.h @@ -150,7 +150,7 @@ namespace PVR /*! * @brief Add a channel to this container. * @param channel The channel to add. - * @param channelNumber The channel number of the channel to add. Use empty channel number to add it at the end. + * @param channelNumber The channel number of the channel to add. Use empty channel number if it's to be generated. * @param iOrder The value denoting the order of this member in the group, 0 if unknown and needs to be generated * @param bUseBackendChannelNumbers True, if channelNumber contains a backend channel number. * @param clientChannelNumber The client channel number of the channel to add. (optional) @@ -159,6 +159,13 @@ namespace PVR virtual bool AddToGroup(const std::shared_ptr<CPVRChannel>& channel, const CPVRChannelNumber& channelNumber, int iOrder, bool bUseBackendChannelNumbers, const CPVRChannelNumber& clientChannelNumber = {}); /*! + * @brief Append a channel to this container. + * @param channel The channel to append. + * @return True if the channel was appended, false otherwise. + */ + virtual bool AppendToGroup(const std::shared_ptr<CPVRChannel>& channel); + + /*! * @brief Change the name of this group. * @param strGroupName The new group name. */ diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp index 640b63304c..66e30a2c7f 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp @@ -157,6 +157,13 @@ bool CPVRChannelGroupInternal::AddToGroup(const std::shared_ptr<CPVRChannel>& ch return bReturn; } +bool CPVRChannelGroupInternal::AppendToGroup(const std::shared_ptr<CPVRChannel>& channel) +{ + CSingleLock lock(m_critSection); + + return AddToGroup(channel, CPVRChannelNumber(), 0, false); +} + bool CPVRChannelGroupInternal::RemoveFromGroup(const std::shared_ptr<CPVRChannel>& channel) { if (!IsGroupMember(channel)) diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.h b/xbmc/pvr/channels/PVRChannelGroupInternal.h index 4e42017c21..39e7dba7e0 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.h +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.h @@ -58,6 +58,11 @@ namespace PVR bool AddToGroup(const std::shared_ptr<CPVRChannel>& channel, const CPVRChannelNumber& channelNumber, int iOrder, bool bUseBackendChannelNumbers, const CPVRChannelNumber& clientChannelNumber = {}) override; /*! + * @see CPVRChannelGroup::AppendToGroup + */ + bool AppendToGroup(const std::shared_ptr<CPVRChannel>& channel) override; + + /*! * @see CPVRChannelGroup::RemoveFromGroup */ bool RemoveFromGroup(const std::shared_ptr<CPVRChannel>& channel) override; diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp index 6f36f60b69..5aef28e14a 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp @@ -201,7 +201,8 @@ bool CGUIDialogPVRGroupManager::ActionButtonUngroupedChannels(CGUIMessage& messa else if (m_ungroupedChannels->GetFileCount() > 0) { CFileItemPtr pItemChannel = m_ungroupedChannels->Get(m_iSelectedUngroupedChannel); - if (m_selectedGroup->AddToGroup(pItemChannel->GetPVRChannelInfoTag(), CPVRChannelNumber(), 0, false)) + + if (m_selectedGroup->AppendToGroup(pItemChannel->GetPVRChannelInfoTag())) { ClearSelectedGroupsThumbnail(); Update(); |