Big changes all around. Basic download works.
[mussorgsky] / src / qml / albumItem.py
1 # -*- coding: utf-8 -*-
2 import os
3 import sys
4 from PySide import QtCore
5 from PySide import QtGui
6 from PySide import QtDeclarative
7
8 from albumArt import AlbumArt
9
10 class AlbumItem (QtCore.QObject):
11
12     def __init__ (self, title, artist):
13         QtCore.QObject.__init__(self)
14         self._title = title
15         self._artist = artist
16         self.aa = AlbumArt (self._title, self._artist)
17         self.require_download = False
18         if os.path.exists (self.aa.get_media_art_path ()):
19             self._album_art = self.aa.get_media_art_path ()
20         elif os.path.exists (self.aa.get_generated ()):
21             self._album_art = self.aa.get_generated ()
22             self.require_download = True
23         else:
24             self.require_download = True
25             self._album_art = None
26
27     def _title (self):
28         return self._title
29
30     def _artist (self):
31         return self._artist
32
33     def _albumArt (self):
34         return self._album_art
35
36     def _setAlbumArt (self, path):
37         print "Setting the new album art to", path
38         self.require_download = False
39         self._album_art = path
40         self.album_art_changed.emit ()
41
42     def get_aa (self):
43         return self.aa
44
45     prop_changed = QtCore.Signal ()
46     album_art_changed = QtCore.Signal ()
47
48     title = QtCore.Property (unicode, _title, notify=prop_changed)
49     artist = QtCore.Property (unicode, _artist, notify=prop_changed)
50     album_art = QtCore.Property (unicode,
51                                  _albumArt,
52                                  _setAlbumArt,
53                                  notify=album_art_changed)
54