WIP V3 wire in QSortFilterProxyModel
This commit is contained in:
parent
25e3be6fae
commit
23a9eff43b
@ -8,6 +8,7 @@ from typing import List, Optional
|
|||||||
from PyQt6.QtCore import (
|
from PyQt6.QtCore import (
|
||||||
QAbstractTableModel,
|
QAbstractTableModel,
|
||||||
QModelIndex,
|
QModelIndex,
|
||||||
|
QSortFilterProxyModel,
|
||||||
Qt,
|
Qt,
|
||||||
QVariant,
|
QVariant,
|
||||||
)
|
)
|
||||||
@ -94,6 +95,23 @@ class StartEndTimes:
|
|||||||
end_time: Optional[datetime] = None
|
end_time: Optional[datetime] = None
|
||||||
|
|
||||||
|
|
||||||
|
class PlaylistProxyModel(QSortFilterProxyModel):
|
||||||
|
"""
|
||||||
|
For searching and filtering
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
playlist_id: int,
|
||||||
|
*args,
|
||||||
|
**kwargs,
|
||||||
|
):
|
||||||
|
self.playlist_id = playlist_id
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
self.setSourceModel(PlaylistModel(playlist_id))
|
||||||
|
|
||||||
|
|
||||||
class PlaylistModel(QAbstractTableModel):
|
class PlaylistModel(QAbstractTableModel):
|
||||||
"""
|
"""
|
||||||
The Playlist Model
|
The Playlist Model
|
||||||
|
|||||||
@ -55,7 +55,7 @@ from models import PlaylistRows, Settings, Tracks, NoteColours
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from musicmuster import Window
|
from musicmuster import Window
|
||||||
from playlistmodel import PlaylistModel
|
from playlistmodel import PlaylistModel, PlaylistProxyModel
|
||||||
|
|
||||||
# HEADER_NOTES_COLUMN = 2
|
# HEADER_NOTES_COLUMN = 2
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ class PlaylistTab(QTableView):
|
|||||||
# self.edit_cell_type: Optional[int]
|
# self.edit_cell_type: Optional[int]
|
||||||
|
|
||||||
# Load playlist rows
|
# Load playlist rows
|
||||||
self.setModel(PlaylistModel(playlist_id))
|
self.setModel(PlaylistProxyModel(playlist_id))
|
||||||
self._set_column_widths()
|
self._set_column_widths()
|
||||||
|
|
||||||
def closeEditor(
|
def closeEditor(
|
||||||
@ -536,7 +536,6 @@ class PlaylistTab(QTableView):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Add track to section header (ie, make this a track row)
|
# Add track to section header (ie, make this a track row)
|
||||||
# TODO
|
|
||||||
if header_row:
|
if header_row:
|
||||||
self._add_context_menu("Add a track", lambda: self._add_track())
|
self._add_context_menu("Add a track", lambda: self._add_track())
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user