Skip to content

Commit

Permalink
Completed MP1-5231: Add Reset watched status for folders
Browse files Browse the repository at this point in the history
  • Loading branch information
doskabouter committed Jan 10, 2025
1 parent 4d6b455 commit 50d4112
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
2 changes: 2 additions & 0 deletions mediaportal/Databases/Video/IVideoDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions mediaportal/Databases/Video/SqlLite/VideoDatabaseSqlLite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions mediaportal/Databases/Video/VideoDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 19 additions & 4 deletions mediaportal/WindowPlugins/GUIVideos/GUIVideoFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 50d4112

Please sign in to comment.