playlist: Create a SortModelsModel
Containing SortPlaylistModel and FilterSortOptionsModel instances Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
8d901afae7
commit
0966950d86
|
@ -176,6 +176,20 @@ class DisabledOptionsModel(Gtk.FilterListModel):
|
|||
self.get_filter().set_playlist(plist)
|
||||
|
||||
|
||||
class SortModelsModel(GObject.GObject, Gio.ListModel):
|
||||
def __init__(self):
|
||||
GObject.GObject.__init__(self)
|
||||
self.models = [ SortPlaylistModel(), DisabledOptionsModel() ]
|
||||
|
||||
def do_get_item_type(self): return Gio.ListModel
|
||||
def do_get_n_items(self): return len(self.models)
|
||||
def do_get_item(self, n): return self.models[n]
|
||||
|
||||
def set_playlist(self, plist):
|
||||
for model in self.models:
|
||||
model.set_playlist(plist)
|
||||
|
||||
|
||||
class TagModel(GObject.GObject, Gio.ListModel):
|
||||
def __init__(self, tag=None):
|
||||
GObject.GObject.__init__(self)
|
||||
|
|
|
@ -310,6 +310,22 @@ class TestDisabledOptionsModel(unittest.TestCase):
|
|||
self.assertTrue( filter.do_match(Gtk.StringObject.new("tracks.lastplayed ASC")))
|
||||
|
||||
|
||||
class TestSortModelsModel(unittest.TestCase):
|
||||
def test_init(self):
|
||||
sort = model.SortModelsModel()
|
||||
self.assertIsInstance(sort, Gio.ListModel)
|
||||
self.assertEqual(sort.get_n_items(), 2)
|
||||
self.assertIsInstance(sort.get_item(0), model.SortPlaylistModel)
|
||||
self.assertIsInstance(sort.get_item(1), model.DisabledOptionsModel)
|
||||
|
||||
def test_set_playlist(self):
|
||||
collection = db.user.Table.find("Collection")
|
||||
sort = model.SortModelsModel()
|
||||
sort.set_playlist(collection)
|
||||
self.assertEqual(sort.get_item(0).playlist, collection)
|
||||
self.assertEqual(sort.get_item(1).get_filter().playlist, collection)
|
||||
|
||||
|
||||
class TestTagModel(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.changed = (None, None, None)
|
||||
|
|
Loading…
Reference in New Issue