More logic to edit the song metadata qmlui
authorIvan Frade <ivan.frade@gmail.com>
Mon, 11 Jul 2011 11:41:25 +0000 (14:41 +0300)
committerIvan Frade <ivan.frade@gmail.com>
Mon, 11 Jul 2011 11:41:25 +0000 (14:41 +0300)
src/controller.py
src/songItem.py
ui/SongsPage.qml

index 86cdd5d..ea8ec99 100644 (file)
@@ -148,6 +148,14 @@ class MussorgskyController (QtCore.QObject):
             self.download.quit ()
             self.download = None
 
+    @QtCore.Slot (QtCore.QObject)
+    def save_song (self, songItem):
+        if songItem.dirty:
+            print "The song was modified and we should write the file!"
+            print " **** Implement me! ****"
+        else:
+            print "Nothing to write into the file"
+
     def get_all_albums (self):
         """
         Return a list of AlbumItem objects to build the model
index 3048c89..6c75977 100644 (file)
@@ -9,12 +9,15 @@ class SongItem (QtCore.QObject):
         self.__title = title
         self.__album = album
         self.__artist = artist
+        self.dirty = False
 
     def _title (self):
         return self.__title
     def _setTitle (self, value):
-        self.__title = value
-        self.title_changed.emit ()
+        if value != self.__title:
+            self.dirty = True
+            self.__title = value
+            self.title_changed.emit ()
 
     title_changed = QtCore.Signal ()
     title = QtCore.Property (unicode, _title, _setTitle, notify=title_changed)
@@ -23,8 +26,10 @@ class SongItem (QtCore.QObject):
     def _album (self):
         return self.__album
     def _setAlbum (self, value):
-        self.__album = value
-        self.album_changed.emit ()
+        if value != self.__album:
+            self.dirty = True
+            self.__album = value
+            self.album_changed.emit ()
 
     album_changed = QtCore.Signal ()
     album = QtCore.Property (unicode, _album, _setAlbum, notify=album_changed)
@@ -33,6 +38,7 @@ class SongItem (QtCore.QObject):
     def _artist (self):
         return self.__artist
     def _setArtist (self, value):
+        self.dirty = True
         self.__artist = value
         self.artist_changed.emit ()
 
index 795bd74..4dcb63b 100644 (file)
@@ -5,7 +5,7 @@ import "UIConstantsExtras.js" as UiConstantsExtras
 
 Page {
     id: songsPage
-    tools: commonTools
+    anchors.fill: parent
 
     ListView {
         id: listView
@@ -13,7 +13,7 @@ Page {
         anchors.leftMargin: 6
         anchors.rightMargin: 6
         model: songModel
-        pressDelay: 140
+        //pressDelay: 140
 
         delegate:  Item {
             id: listItem
@@ -24,8 +24,8 @@ Page {
                 id: background
                 anchors.fill: parent
                 // Fill page porders
-                anchors.leftMargin: -songsPage.anchors.leftMargin
-                anchors.rightMargin: -songsPage.anchors.rightMargin
+                //anchors.leftMargin: listItem.leftMargin
+                //anchors.rightMargin: listItem.rightMargin
                 visible: mouseArea.pressed
                 source: "image://theme/meegotouch-list-background-pressed-center"
             }
@@ -65,12 +65,16 @@ Page {
 
             MouseArea {
                 id: mouseArea
-                anchors.fill: background
+                anchors.fill: listItem
                 onClicked: {
                     console.log ("Well, well, well")
+                    editionSheet.song = model.song
+                    editionSheet.open ()
                 }
             }
         }
     }
 
+    SongEditor { id: editionSheet ; visualParent: songsPage }
+
 }