Skip to content

Commit

Permalink
refine code 1/n
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed Dec 23, 2023
1 parent 2bc3501 commit 95ed687
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 264 deletions.
39 changes: 21 additions & 18 deletions feeluown/gui/page_containers/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
from feeluown.gui.helpers import BgTransparentMixin, \
disconnect_slots_if_has, fetch_cover_wrapper
from feeluown.gui.components import SongMenuInitializer
from feeluown.gui.widgets.imglist import ImgListView
from feeluown.gui.widgets.album import AlbumListModel, AlbumListView, \
AlbumFilterProxyModel
from feeluown.gui.widgets.artist import ArtistListModel, ArtistListView, \
ArtistFilterProxyModel
from feeluown.gui.widgets.video_list import VideoListModel, VideoListView, \
VideoFilterProxyModel
from feeluown.gui.widgets.playlist import PlaylistListModel, PlaylistListView, \
PlaylistFilterProxyModel
from feeluown.gui.widgets.img_card_list import ImgCardListView
from feeluown.gui.widgets.img_card_list import (
AlbumCardListModel, AlbumCardListView, AlbumFilterProxyModel, AlbumCardListDelegate,
ArtistCardListModel, ArtistCardListView, ArtistFilterProxyModel, ArtistCardListDelegate,
VideoCardListModel, VideoCardListView, VideoFilterProxyModel, VideoCardListDelegate,
PlaylistCardListModel, PlaylistCardListView, PlaylistFilterProxyModel, PlaylistCardListDelegate,
)
from feeluown.gui.widgets.songs import ColumnsMode, SongsTableModel, SongsTableView, \
SongFilterProxyModel
from feeluown.gui.widgets.comment_list import CommentListView, CommentListModel
Expand Down Expand Up @@ -93,25 +91,25 @@ async def show_cover(self, cover, cover_uid, as_background=False):
def show_albums(self, reader):
self._show_model_with_cover(reader,
self.albums_table,
AlbumListModel,
AlbumCardListModel,
AlbumFilterProxyModel)

def show_artists(self, reader):
self._show_model_with_cover(reader,
self.artists_table,
ArtistListModel,
ArtistCardListModel,
ArtistFilterProxyModel)

def show_videos(self, reader):
self._show_model_with_cover(reader,
self.videos_table,
VideoListModel,
VideoCardListModel,
VideoFilterProxyModel)

def show_playlists(self, reader):
self._show_model_with_cover(reader,
self.playlists_table,
PlaylistListModel,
PlaylistCardListModel,
PlaylistFilterProxyModel)

def _show_model_with_cover(self, reader, table, model_cls, filter_model_cls):
Expand Down Expand Up @@ -257,10 +255,15 @@ def __init__(self, app, parent=None):
self.tabbar = TableTabBarV2()
self.meta_widget = TableMetaWidget(parent=self)
self.songs_table = SongsTableView(app=self._app, parent=self)
self.albums_table = AlbumListView(parent=self, img_min_width=120)
self.artists_table = ArtistListView(parent=self)
self.videos_table = VideoListView(parent=self)
self.playlists_table = PlaylistListView(parent=self)
self.albums_table = AlbumCardListView(parent=self)
self.albums_table.setItemDelegate(
AlbumCardListDelegate(self.albums_table, img_min_width=120))
self.artists_table = ArtistCardListView(parent=self)
self.artists_table.setItemDelegate(ArtistCardListDelegate(self.artists_table))
self.videos_table = VideoCardListView(parent=self)
self.videos_table.setItemDelegate(VideoCardListDelegate(self.videos_table))
self.playlists_table = PlaylistCardListView(parent=self)
self.playlists_table.setItemDelegate(PlaylistCardListDelegate(self.playlists_table))
self.comments_table = CommentListView(parent=self)
self.desc_widget = DescLabel(parent=self)

Expand Down Expand Up @@ -361,7 +364,7 @@ def current_table(self, table):
self.toolbar.albums_mode()
if table is self.songs_table:
self.toolbar.songs_mode()
if isinstance(self._table, ImgListView):
if isinstance(self._table, ImgCardListView):
self._table.setModel(None)
self._table = table

Expand Down
6 changes: 3 additions & 3 deletions feeluown/gui/pages/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from feeluown.models import SearchType
from feeluown.gui.page_containers.table import TableContainer, Renderer
from feeluown.gui.page_containers.scroll_area import ScrollArea
from feeluown.gui.widgets.imglist import ImgListView
from feeluown.gui.widgets.img_card_list import ImgCardListDelegate
from feeluown.gui.widgets.songs import SongsTableView, ColumnsMode
from feeluown.gui.base_renderer import TabBarRendererMixin
from feeluown.gui.helpers import BgTransparentMixin
Expand Down Expand Up @@ -58,9 +58,9 @@ async def render(req, **kwargs): # pylint: disable=too-many-locals,too-many-bra
# HACK: set fixed row for tables.
# pylint: disable=protected-access
for table in table_container._tables:
if isinstance(table, ImgListView):
if isinstance(table.itemDelegate(), ImgCardListDelegate):
table._fixed_row_count = 2
table.img_min_width = 100
table.itemDelegate().img_min_width = 100
elif isinstance(table, SongsTableView):
table._fixed_row_count = 8
table._row_height = table.verticalHeader().defaultSectionSize()
Expand Down
71 changes: 0 additions & 71 deletions feeluown/gui/widgets/album.py

This file was deleted.

37 changes: 0 additions & 37 deletions feeluown/gui/widgets/artist.py

This file was deleted.

Loading

0 comments on commit 95ed687

Please sign in to comment.