def show_songs(self, songs=None, songs_g=None, show_count=False): if show_count: if songs is not None: self.meta_widget.songs_count = len(songs) if songs_g is not None: count = songs_g.count self.meta_widget.songs_count = -1 if count is None else count self.albums_table.hide() songs_table = self.songs_table songs = songs or [] logger.debug('Show songs in table, total: %d', len(songs)) source_name_map = { p.identifier: p.name for p in self._app.library.list() } songs_table.setModel( SongsTableModel(source_name_map=source_name_map, songs_g=songs_g, songs=songs, parent=songs_table)) songs_table.scrollToTop() songs_table.show() self.meta_widget.toolbar.songs_mode()
def _show_songs(self, songs=None, songs_g=None): try: self.songs_table.song_deleted.disconnect() except TypeError: # no connections at all pass self.show() self.songs_table.show() songs = songs or [] logger.debug('Show songs in table, total: %d', len(songs)) source_name_map = {p.identifier: p.name for p in self._app.library.list()} if songs_g is not None: # 优先使用生成器 self.songs_table.setModel(SongsTableModel( source_name_map=source_name_map, songs_g=songs_g, parent=self.songs_table)) else: self.songs_table.setModel(SongsTableModel( songs=songs, source_name_map=source_name_map, parent=self.songs_table )) self.songs_table.scrollToTop()