~mmcg069/totallywired/trunk

« back to all changes in this revision

Viewing changes to totallywired/models/music.py

  • Committer: Matthew McGowan
  • Date: 2013-04-15 22:32:54 UTC
  • Revision ID: matthew.joseph.mcgowan@gmail.com-20130415223254-0cpu3j3jl7ldlbm8
slight refactoring of some code

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    pyqtSlot,
26
26
    pyqtSignal,
27
27
    pyqtProperty,
 
28
    QObject,
28
29
    QModelIndex,
29
30
    TrackListModel)
30
31
 
53
54
    searchChanged = pyqtSignal()
54
55
    currentArtistChanged = pyqtSignal()
55
56
 
56
 
    def __init__(self, app, queue, collection):
57
 
        TrackListModel.__init__(self, app, collection)
 
57
    def __init__(self, app):
 
58
        TrackListModel.__init__(self, app)
58
59
 
59
60
        self._subber = SubMany({
60
61
            'DISLIKED': 'lkd:hate',
73
74
        self._dataset = set()
74
75
        self._artists = ArtistsModel()
75
76
        self._albums = AlbumsModel()
76
 
        self._cdda = CddaModel(app, queue, collection)
 
77
        self._cdda = CddaModel(app)
77
78
        self._currentArtist = 0
78
79
        self._sections = {}
79
 
        self.queue = queue
 
80
        self.queue = app.queue
80
81
        return
81
82
 
82
83
    # internal stuff
200
201
            try:
201
202
                q = self._qparser.parse_query(
202
203
                    qstr,
203
 
                    self.collection.DEFAULT_QUERY_FLAGS)
 
204
                    self._collections.DEFAULT_QUERY_FLAGS)
204
205
            except Exception as e:
205
206
                print('Ignoring malformed query!\n  ', e)
206
207
                return
271
272
 
272
273
        mset = self._enq.get_mset(0, self._db.get_doccount())
273
274
 
274
 
        self._albums.set_spy(self.collection, spy, artist=artist_name)
 
275
        self._albums.set_spy(self._collections, spy, artist=artist_name)
275
276
        if artist_spy:
276
277
            self._artists.set_spy(ar_spy)
277
278
        if highlight_artist:
327
328
        self._data = []
328
329
        self._count = 0
329
330
 
330
 
        self._db = self.collection.db
331
 
        self._enq = self.collection._enq
332
 
        self._qparser = self.collection._parser
 
331
        self._db = self._collections.db
 
332
        self._enq = self._collections._enq
 
333
        self._qparser = self._collections._parser
333
334
        doccount = 0
334
335
        # unset the cached artist param in the album model so that it 
335
336
        # reloads
340
341
            self.player.sync_with_remote_player()
341
342
        else:
342
343
            self.clear()
343
 
        print("Reloaded collection.  Searching %s docs." % doccount)
 
344
        print("Reloaded _collections.  Searching %s docs." % doccount)
344
345
 
345
346
        self._cdda.reload()
346
347
        return
354
355
 
355
356
    def reload_document(self, docid):
356
357
        TrackListModel.reload_document(self, docid)
357
 
        if self.collection.cdda_present:
 
358
        if self._collections.cdda_present:
358
359
            self._cdda.reload_document(docid)
359
360
        return
360
361
 
377
378
        mset = self._enq.get_mset(0, self._db.get_doccount())
378
379
 
379
380
        self._artists.set_spy(ar_spy)
380
 
        self._albums.set_spy(self.collection, al_spy, query=q)
 
381
        self._albums.set_spy(self._collections, al_spy, query=q)
381
382
        self._update_for_new_mset(mset)
382
383
        return
383
384
 
490
491
        for docid in playlist:
491
492
            queue.enqueue_docid(docid)
492
493
        return
 
494
 
 
495
    @pyqtProperty(QObject, notify=_silentSignal)
 
496
    def backend(self):
 
497
        print(self._collections)
 
498
        return self._collections