[pvr] go to parent folder after deleting the last item in a subfolder

Currently when the last recording is deleted you're left in an empty ghost directory that is gone once you go back to the parent folder. This changes that so that you can't end up in an empty folder.

I also changed the call to `TriggerRecordingsUpdate` to a simple `Refresh`. If the recording was reported as deleted by the backend there's no need to fetch the recordings again, something which can take time.

@xhaggi @opdenkamp for review
Meh, damn week ends, forgot to take a look at these and got a bunch of notifications in my mailbox now. Will look at these in a few hours


-------- Oorspronkelijk bericht --------
Van: Sascha Woo <notifications@github.com> 
Datum:16-11-2014  12:41  (GMT+01:00) 
Aan: xbmc/xbmc <xbmc@noreply.github.com> 
Cc: Lars Op den Kamp <opdenkamp@gmail.com> 
Onderwerp: Re: [xbmc] [pvr] go to parent folder after deleting the last item in  a subfolder (#5725) 

In xbmc/pvr/windows/GUIWindowPVRRecordings.cpp:

> +
> +  /* delete the recording */
> +  if (g_PVRRecordings->Delete(*item))
> +  {
> +    g_PVRManager.TriggerRecordingsUpdate();
> +    bReturn = true;
> +
> +    /* remove the item from the list immediately, otherwise the 
> +       item count further down may be wrong */
> +    m_vecItems->Remove(item);
> +
> +    /* go to the parent folder if we're in a subdirectory and just deleted the last item */
> +    std::string directory = item->GetPVRRecordingInfoTag()->m_strDirectory;
> +    URIUtils::RemoveSlashAtEnd(directory);
> +
> +    if (!directory.empty() && m_vecItems->GetObjectCount() == 0)
you could use m_vecItems->GetPath() == "pvr://recordings/" to verify if we stay at the root level.

—
Reply to this email directly or view it on GitHub.