[gnome-subtitles] Allow to remove a range of subtitles.



commit 128993c79e4b815de6d82be21b0a1661e56470fa
Author: Pedro Castro <mail pedrocastro org>
Date:   Sun Jun 12 23:29:56 2011 +0100

    Allow to remove a range of subtitles.

 src/GnomeSubtitles/Ui/View/Subtitles.cs |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/GnomeSubtitles/Ui/View/Subtitles.cs b/src/GnomeSubtitles/Ui/View/Subtitles.cs
index 7ec8879..677b4d5 100644
--- a/src/GnomeSubtitles/Ui/View/Subtitles.cs
+++ b/src/GnomeSubtitles/Ui/View/Subtitles.cs
@@ -148,6 +148,22 @@ public class Subtitles : SubLib.Core.Domain.Subtitles {
 		return true;
 	}
 	
+	public bool RemoveRange (TreePath firstPath, TreePath lastPath) {
+		if ((firstPath == null) || (lastPath == null))
+			return false;
+			
+		int firstSubtitleNumber = Util.PathToInt(firstPath);
+		int lastSubtitleNumber = Util.PathToInt(lastPath);
+		if ((firstSubtitleNumber < 0) || (firstSubtitleNumber > lastSubtitleNumber) || (lastSubtitleNumber >= Collection.Count))
+			return false;
+			
+		for (int index = firstSubtitleNumber ; index <= lastSubtitleNumber ; index++) {
+			if (!Remove(firstSubtitleNumber)) //the index is constant as subtitles are removed
+				return false;
+		}
+		return true;
+	}
+	
 	/// <summary>Loads possible extra subtitles at the end of the model.</summary>
 	/// <remarks>Extra subtitles exist if subtitles were added to the base collection.</remarks>
 	public void AddExtra (int extraCount) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]