def add (self, filepaths): # TODO: emit the list self.newSongs_= [] # we get a QStringList; convert to a list so we can python-iterate it for filepath in list (filepaths): # filepath can be a QString because this method # is also connected to a signal and they get converted by ptqt4 if isinstance (filepath, QString): # paths must be bytes, not ascii or utf-8 filepath= utils.qstring2path (filepath) # normalize! this way we avoid this dupes (couldn't find where they're originated) # C.add(): [(4081, '/home/mdione/media/music/Poison/2000 - Crack a smile... and more!//01 - Best thing you ever had.ogg')] # C.add(): [(4082, '/home/mdione/media/music/Poison/2000 - Crack a smile... and more!/01 - Best thing you ever had.ogg')] song= Song (self, os.path.normpath (filepath)) # this works because Song.__cmp__() does not compare tags if one song # has not loaded them and Song does not do it automatically # so only paths are compared. index= bisect.bisect (self.songs, song) s= len (self.songs) # print "C.add(): %d==0, %d==%d, %d" % (s, index, s-1, index) # empty list or # index is the last position or # the new Song is not the same already in the position (to the left) if s==0 or index==s-1 or self.songs[index-1]!=song: self.songs.insert (index, song) self.count+= 1 if self.loadMetadata: song.loadMetadata () self.newSongs_.append ((index, filepath)) logger.debug ("C.add():", self.newSongs_) self.newSongs.emit ()
def newFiles (self, path): path= utils.qstring2path (path) self.scan (path)