~mmcg069/totallywired/trunk

« back to all changes in this revision

Viewing changes to totallywired/models/cdda.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:
17
17
    releaseUpdated = pyqtSignal()
18
18
    isWorking = pyqtSignal()
19
19
 
20
 
    def __init__(self, app, queue, manager):
21
 
        TrackListModel.__init__(self, app, manager)
22
 
        self.queue = queue
23
 
 
 
20
    def __init__(self, app):
 
21
        TrackListModel.__init__(self, app)
 
22
        self.queue = app.queue
24
23
        self.ignored = app.ignored
25
24
        self._cdda = False
26
25
        self._firstrun = True
27
26
        self._working = False
28
 
 
29
27
        self.reload()
30
28
        return
31
29
 
32
30
    def reload(self):
33
31
        self.clear()
34
32
 
35
 
        c = self._cdda = self.collection.get_cdda_collection()
 
33
        c = self._cdda = self._collections.get_cdda_collection()
36
34
        print "CddaCollection:", c
37
 
        if self.collection.db and c and c.live:
38
 
            mset = self.collection.partial_query("__cdda")
 
35
        if self._collections.db and c and c.live:
 
36
            mset = self._collections.partial_query("__cdda")
39
37
            self._count = len(mset)
40
38
            self.beginInsertRows(QModelIndex(), 0, self._count-1)
41
39
            self._data = list([m.docid for m in mset])
47
45
    # doers
48
46
    def do_get_document(self, index):
49
47
        docid = self._data[index]
50
 
        return self.collection.db.get_document(docid), docid
 
48
        return self._collections.db.get_document(docid), docid
51
49
 
52
50
    def do_unqueue_selection(self):
53
51
        queue = self.queue
99
97
            return self._data.index(docid)
100
98
        return -1
101
99
 
102
 
    def collection_changed(self, i, collection):
103
 
        if collection.is_cdda:
104
 
            self._working = collection.working
 
100
    def collection_changed(self, i, _collections):
 
101
        if _collections.is_cdda:
 
102
            self._working = _collections.working
105
103
            self.isWorking.emit()
106
104
        return
107
105
 
117
115
        self.isWorking.emit()
118
116
 
119
117
        q = '"%s" AND artist:"%s"' % (album_q, artist_q)
120
 
        self.collection.service.rerun_cdda_collector_with_mbquery(
 
118
        self._collections.service.rerun_cdda_collector_with_mbquery(
121
119
            q, self._cdda.disc_num)
122
120
        return
123
121
 
131
129
        self.isWorking.emit()
132
130
 
133
131
        print("Rerun cdda collector.  DIsc number:", n)
134
 
        self.collection.service.rerun_cdda_collector(int(n))
 
132
        self._collections.service.rerun_cdda_collector(int(n))
135
133
        return
136
134
 
137
135
    @pyqtSlot(result=int)