Exemplo n.º 1
0
    async def render(self):
        artist = self.artist

        # bind signal first
        # we only show album that implements create_albums_g
        if artist.meta.allow_create_albums_g:
            self.toolbar.filter_albums_needed.connect(
                lambda types: self.albums_table.model().filter_by_types(types))
            self.tabbar.show_albums_needed.connect(
                lambda: self.show_albums(self.artist.create_albums_g()))
            self.albums_table.show_album_needed.connect(self.show_model)
        if hasattr(artist, 'contributed_albums') and artist.contributed_albums:
            # show contributed_album list
            self.tabbar.show_contributed_albums_needed.connect(
                lambda: self.show_albums(self.artist.
                                         create_contributed_albums_g()))

        # fetch and render basic metadata
        self.meta_widget.title = artist.name
        self.meta_widget.show()
        self.tabbar.show()
        self.tabbar.artist_mode()

        # fetch and render songs
        songs = songs_g = None
        if artist.meta.allow_create_songs_g:
            songs_g = wrap(artist.create_songs_g())
            self.tabbar.show_songs_needed.connect(
                lambda: self.show_songs(songs_g=wrap(artist.create_songs_g()),
                                        songs=songs,
                                        show_count=True))
        else:
            songs = await async_run(lambda: artist.songs)
            self.tabbar.show_songs_needed.connect(lambda: self.show_songs(
                songs_g=None, songs=songs, show_count=True))
        self.show_songs(songs_g=songs_g, songs=songs, show_count=True)

        # finally, we render cover and description
        cover = await async_run(lambda: artist.cover)
        if cover:

            aio.create_task(
                self.show_cover(cover,
                                reverse(artist, '/cover'),
                                as_background=True))

        self.tabbar.show_desc_needed.connect(
            lambda: aio.create_task(self._show_desc()))
Exemplo n.º 2
0
async def render(req, **kwargs):
    """/search handler

    :type app: feeluown.app.App
    """
    q = req.query.get('q', '')
    if not q:
        return
    type_ = req.query.get('type', None)
    type_ = SearchType.parse(type_) if type_ else SearchType.so
    source_in = req.query.get('source_in', None)
    if source_in is not None:
        source_in = source_in.split(',')
    else:
        source_in = None

    app = req.ctx['app']
    ui = app.ui
    right_panel = ui.right_panel
    table_container = right_panel.table_container

    right_panel.collection_container.hide()
    right_panel.scrollarea.show()

    reader = wrap(await app.library.a_search(q,
                                             type_in=type_,
                                             source_in=source_in))
    renderer = SearchResultRenderer(q, type_, reader, source_in=source_in)
    await table_container.set_renderer(renderer)
Exemplo n.º 3
0
def test_sequential_reader():
    def g_func():
        for i in range(0, 5):
            yield i

    g = g_func()
    reader = wrap(g)
    assert len(list(reader)) == 5
Exemplo n.º 4
0
    def __init__(self, reader, fetch_image, source_name_map=None, parent=None):
        """

        :param reader: objects in reader should have `name` property
        :param fetch_image: func(item, cb, uid)
        :type reader: Iterable
        """
        super().__init__(parent)

        self.source_name_map = source_name_map or {}
        self.reader = wrap(reader)
        self.fetch_image = fetch_image
        # false: no more, true: maybe more
        self._maybe_has_more = True
        self.items = []
        self.colors = []
        self.pixmaps = {}  # {uri: QPixmap}
Exemplo n.º 5
0
 def create_contributed_albums_g(self):
     return wrap(self.contributed_albums)
Exemplo n.º 6
0
 def create_albums_g(self):
     return wrap(self.albums)