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):
        self.songList = list()
        self.currentSong = None
        self.callback = setSongCallback

    def addSong(self, path):
        self.songList.append(path)
        logging.debug(f"Added song: {path}")
        if self.currentSong is None:
            self.setCurrentSong(0)

    def setCurrentSong(self, index):
        if index < len(self.songList):
            self.currentSong = index
            self.callback(self.songList[index])
            logging.debug(f"Selected song: {self.currentSong}")