Exemple #1
0
    def editPlaylistAction(self):
        targetRow = self.playlist.currentRow()
        if targetRow == 0:
            return
        
        currentItem = self.playlist.currentItem()
        currentData = currentItem.data(Qt.UserRole).toInt()[0]
        
        playlistName, response = QInputDialog.getText(self, 'Pysawndz', 'New playlist name:')

        if response:
            Db.update("playlists", {"name": playlistName}, {"id": currentData})
            self.loadAllPlaylists()
            self.playlist.setCurrentRow(targetRow)
            self.loadContextMenu()
Exemple #2
0
 def updateSong(self):
     
     param = {}
     query = Db.select("songs", ["title", "duration", "artist_id", "genre_id", "album_id", "path"], {"id": self.__id})
     if query and query.next():
         if self.__title == None:
             self.__title = str(query.value(0).toString())
         else:
             param["title"] = self.__title
         
         if self.__duration == None:
             self.__duration = query.value(1).toInt()[0]
         else:
             param["duration"] = self.__duration
             
         if self.__path == None:
             self.__path = str(query.value(5).toString())
         else:
             param["path"] = self.__path
         
         #only update song's artist and album if they are both present
         if not self.__artist == None and not self.__album == None:
             param["artist_id"] = self.__getSongArtist()
             param["album_id"] = self.__getSongAlbum(param["artist_id"])
         else:
             #else, just load defaults
             self.__artist = query.value(2).toInt()[0]
             self.__album = query.value(4).toInt()[0]
         
         if self.__genre == None:
             self.__genre = query.value(3).toInt()[0]
         else:
             param["genre_id"] = self.__getSongGenre()
     
         Db.update("songs", param, {"id": self.__id})
         
     else:
         self.dirty = True