예제 #1
0
파일: table.py 프로젝트: zzcandor/FeelUOwn
 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)
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
    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()