changeset 16:447b47ab396f

Implemented dequeue the proper way; Cleaned up stupidity in enqueue code
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Sun, 20 Aug 2006 00:05:14 -0400
parents ae3451bedeb6
children 1c769ae67af4
files vixm/control.py vixm/ui.py
diffstat 2 files changed, 24 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/vixm/control.py	Sat Aug 19 23:53:56 2006 -0400
+++ b/vixm/control.py	Sun Aug 20 00:05:14 2006 -0400
@@ -21,10 +21,25 @@
 		print "Invalid song id"
 		return
 
-	ui.enqueue(id)
+	s = ui.lists[playlist.LIST_DEFAULT][id]
+	print "Enqueuing song: %s (%s)" % (s["title"], util.strtime(s["time"]))
+	ui.lists[playlist.LIST_PRIO].enqueue(s)
 
 def cmd_dequeue(ui, start, stop, args):
-	print "not implemented yet"
+	l = ui.lists[playlist.LIST_PRIO]
+
+	max = len(l)
+	if not max:
+		return
+
+	start = util.fixupint(start, max)
+	stop = util.fixupint(stop, max)
+
+	for i in range(start-1, stop):
+		s = l[start-1]
+		print "Dequeuing song: %s (%s)" % (s["title"],
+				util.strtime(s["time"]))
+		l.dequeue(s)
 
 def cmd_help(ui, start, stop, args):
 	for c in args[0]:
--- a/vixm/ui.py	Sat Aug 19 23:53:56 2006 -0400
+++ b/vixm/ui.py	Sun Aug 20 00:05:14 2006 -0400
@@ -90,9 +90,9 @@
 		#		LIST_PRIO. The enqueued song is added to the
 		#		end of LIST_PRIO
 		#
-		#	dequeue	'd songid'
-		#		remove songid from LIST_PRIO. The songid is
-		#		the id in LIST_PRIO, NOT LIST_DEFAULT
+		#	dequeue	'[range]d'
+		#		remove songs in range from LIST_PRIO. The
+		#		range is in LIST_PRIO, NOT LIST_DEFAULT
 		#
 		# range:
 		#	''	first entry; shortcut for '1'
@@ -128,11 +128,11 @@
 				 False,
 				 "a [songid]",
 				 "add songid from default to priority"),
-			"d ([0-9]+)":
+			"d":
 				(control.cmd_dequeue,
-				 False,
-				 "d [songid]",
-				 "remove songid from priority"),
+				 True,
+				 "[range]d",
+				 "remove songs in range from priority"),
 			"h":
 				(control.cmd_help,
 				 False,
@@ -140,12 +140,6 @@
 				 "this help list"),
 		}
 
-	def enqueue(self, id):
-		s = self.lists[playlist.LIST_DEFAULT][id]
-		print "Enqueuing song: %s (%s)" % (s["title"],
-				util.strtime(s["time"]))
-		self.lists[playlist.LIST_PRIO].enqueue(s)
-
 	def __cmd(self, txt):
 		range_str = "(%|\\$|(\\$|[0-9]+){,1}(,(\\$|[0-9]+)){,1}){,1}"