async def show_model(self, model): model_type = ModelType(model.meta.model_type) if model_type == ModelType.album: renderer = AlbumRenderer(model) elif model_type == ModelType.artist: renderer = ArtistRenderer(model) elif model_type == ModelType.playlist: renderer = PlaylistRenderer(model) else: renderer = None await self.set_renderer(renderer)
async def show_model(self, model): model_type = ModelType(model.meta.model_type) if model_type == ModelType.album: delegate = AlbumDelegate(model) elif model_type == ModelType.artist: delegate = ArtistDelegate(model) elif model_type == ModelType.playlist: delegate = PlaylistDelegate(model) else: delegate = None await self.set_delegate(delegate)
async def show_model(self, model): model_type = ModelType(model._meta.model_type) if model_type == ModelType.album: func = self.show_album elif model_type == ModelType.artist: func = self.show_artist elif model_type == ModelType.playlist: func = self.show_playlist else: def func(model): pass # seems silly await func(model)
async def show_model(self, model): model_type = ModelType(model._meta.model_type) if model_type == ModelType.album: func = self.show_album elif model_type == ModelType.artist: func = self.show_artist elif model_type == ModelType.playlist: func = self.show_playlist else: def func(model): pass # seems silly with self._app.create_action('show {}'.format(str(model))): await func(model)
def data(self, index, role=Qt.DisplayRole): if not index.isValid(): return QVariant() row = index.row() if row >= len(self._models) or row < 0: return QVariant() # latest first model = self._models[len(self._models) - row - 1] if role == Qt.DisplayRole: model_type = ModelType(model._meta.model_type) if model_type == ModelType.song: return model.title elif model_type in (ModelType.playlist, ModelType.artist, ModelType.album): return model.name else: return str(model) elif role == Qt.UserRole: return model return QVariant()