From 182a14f4b9aec4722f7f94ab44bf57356c6d71aa Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Tue, 21 Dec 2021 08:16:55 +0100 Subject: Added AB controller with some tests, minor refactor to playlist --- playlist.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'playlist.py') diff --git a/playlist.py b/playlist.py index b175a08..6e96534 100644 --- a/playlist.py +++ b/playlist.py @@ -1,24 +1,10 @@ import logging -""" -class PlaylistModel(QAbstractListModel): - def __init__(self, medialist, *args, **kwargs): - super(PlaylistModel, self).__init__(*args, **kwargs) - self.medialist = medialist - - def data(self, index, role): - if role == Qt.DisplayRole: - return self.medialist.item_at_index(index.row()).get_mrl() - - def rowCount(self, index): - return self.medialist.count() -""" - class Playlist: - def __init__(self, setSongCallback): + def __init__(self, callback): self.songList = list() self.currentSong = None - self.callback = setSongCallback + self.setSongCallback = callback def addSong(self, path): self.songList.append(path) @@ -27,8 +13,10 @@ class Playlist: self.setCurrentSong(0) def setCurrentSong(self, index): - if index < len(self.songList): + if index >= 0 and index < len(self.songList): self.currentSong = index - self.callback(self.songList[index]) + self.setSongCallback(self.songList[index]) logging.debug(f"Selected song: {self.currentSong}") - + + def getCurrentSong(self): + return self.currentSong -- cgit v1.2.3