diff --git a/mediaportal/Databases/Video/IVideoDatabase.cs b/mediaportal/Databases/Video/IVideoDatabase.cs index 5b34ce33637..7447640a8ee 100644 --- a/mediaportal/Databases/Video/IVideoDatabase.cs +++ b/mediaportal/Databases/Video/IVideoDatabase.cs @@ -143,6 +143,8 @@ public interface IVideoDatabase void MovieWatchedCountIncrease(int idMovie); void SetMovieWatchedCount(int movieId, int watchedCount); bool GetMovieWatchedStatus(int iFileId, out int percent, out int timesWatched); + void ResetWatchedForAllMoviesInFolder(string folderName); + void DeleteMovie(string strFilenameAndPath); // User Rating diff --git a/mediaportal/Databases/Video/SqlLite/VideoDatabaseSqlLite.cs b/mediaportal/Databases/Video/SqlLite/VideoDatabaseSqlLite.cs index b3c60bb60e3..c813285a8bc 100644 --- a/mediaportal/Databases/Video/SqlLite/VideoDatabaseSqlLite.cs +++ b/mediaportal/Databases/Video/SqlLite/VideoDatabaseSqlLite.cs @@ -4045,6 +4045,24 @@ public bool GetMovieWatchedStatus(int idMovie, out int percent, out int timesWat return false; } + public void ResetWatchedForAllMoviesInFolder(string folderName) + { + try + { + string sql = String.Format("UPDATE movie SET watched = 0 WHERE movie.idPath IN (SELECT idPath FROM path WHERE strPath='{0}' OR strPath LIKE '{0}\\%')", folderName); + m_db.Execute(sql); + } + catch (ThreadAbortException) + { + // Will be logged in thread main code + } + catch (Exception ex) + { + Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); + Open(); + } + } + #endregion #region User Rating diff --git a/mediaportal/Databases/Video/VideoDatabase.cs b/mediaportal/Databases/Video/VideoDatabase.cs index 0c2d146ee3b..8a190cec2da 100644 --- a/mediaportal/Databases/Video/VideoDatabase.cs +++ b/mediaportal/Databases/Video/VideoDatabase.cs @@ -573,6 +573,11 @@ public static bool GetmovieWatchedStatus(int iMovieId, out int percent, out int return _database.GetMovieWatchedStatus(iMovieId, out percent, out timesWatched); } + public static void ResetWatchedForAllMoviesInFolder(string folderName) + { + _database.ResetWatchedForAllMoviesInFolder(folderName); + } + #endregion #region User Rating diff --git a/mediaportal/WindowPlugins/GUIVideos/GUIVideoFiles.cs b/mediaportal/WindowPlugins/GUIVideos/GUIVideoFiles.cs index 57ec55e7a47..0a2ab580bca 100644 --- a/mediaportal/WindowPlugins/GUIVideos/GUIVideoFiles.cs +++ b/mediaportal/WindowPlugins/GUIVideos/GUIVideoFiles.cs @@ -1381,7 +1381,8 @@ protected override void OnShowContextMenu() dlg.AddLocalizedString(1204); // Play All in selected folder dlg.AddLocalizedString(926); //Queue dlg.AddLocalizedString(102); //Scan - dlg.AddLocalizedString(1280); // Scan using nfo files + dlg.AddLocalizedString(1280); // Scan using nfo files + dlg.AddLocalizedString(830); //Reset watched status } // DVD folder else if (item.IsBdDvdFolder) @@ -1683,8 +1684,16 @@ protected override void OnShowContextMenu() facadeLayout.SelectedListItemIndex = currentIndex; break; - case 830: // Reset watched status - SetMovieWatchStatus(item.Path, item.IsFolder, false); + case 830: // Reset watched status + if (item.IsFolder && !item.IsBdDvdFolder) + { + //reset all items in this folder + ResetWatchedForAllMoviesInFolder(item.Path); + } + else + { + SetMovieWatchStatus(item.Path, item.IsFolder, false); + } int selectedIndex = facadeLayout.SelectedListItemIndex; LoadDirectory(_currentFolder, false); UpdateButtonStates(); @@ -4829,7 +4838,13 @@ private void SetMovieWatchStatus(string movieFileName, bool isFolder, bool watch } } } - + + private void ResetWatchedForAllMoviesInFolder(string folderName) + { + if (OnResetFolderSettings()) + VideoDatabase.ResetWatchedForAllMoviesInFolder(folderName); + } + private void item_OnItemSelected(GUIListItem item, GUIControl parent) { GUIPropertyManager.SetProperty("#groupmovielist", string.Empty);