Move the qml/* files to the src folder. Now it is the main version
[mussorgsky] / src / coverItem.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
9 class CoverItem (QtCore.QObject):
10
11     def __init__ (self, image, initialImage=False, deleteAction=False):
12         QtCore.QObject.__init__(self)
13         self.initialImage = initialImage
14         self.deleteAction = deleteAction
15         self._url = image
16         
17     def _url (self):
18         return self._url
19
20     def _setUrl (self, url):
21         self._url = url
22         self.url_changed.emit ()
23
24     def save (self, destination):
25         if self.initialImage:
26             print " -> No changes"
27             return
28
29         if self.deleteAction:
30             print " -> Remove the album art"
31             if os.path.exists (destination):
32                 os.remove (destination)
33             return
34
35         print " -> Saving:", self.url, "to", destination
36         os.rename (self.url, destination)
37
38
39     def remove (self):
40         print "Removing", self.url
41         if os.path.exists (self.url):
42             os.remove (self.url)
43
44
45     url_changed = QtCore.Signal ()
46     url = QtCore.Property (unicode, _url, _setUrl, notify=url_changed)