aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphunkyfish <phunkyfish@gmail.com>2020-02-08 17:43:00 +0000
committerphunkyfish <phunkyfish@gmail.com>2020-02-09 19:58:30 +0000
commitbc66779fd9ab231b60718ef04194a2f8a17f1572 (patch)
tree1b87b4a04f5e0d8ab36bfff4dc00ff42b952499b
parent3c3bb43feac3da359e83d37919aca83a6c2fbc5f (diff)
[pvr] always add new members to group at end in group manager
-rw-r--r--xbmc/pvr/channels/PVRChannelGroup.cpp14
-rw-r--r--xbmc/pvr/channels/PVRChannelGroup.h9
-rw-r--r--xbmc/pvr/channels/PVRChannelGroupInternal.cpp7
-rw-r--r--xbmc/pvr/channels/PVRChannelGroupInternal.h5
-rw-r--r--xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp3
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();