def on_delete_click(self): """ Remove a song from the list and database """ if check_item_selected(self.list_view, UiStrings().SelectDelete): items = self.list_view.selectedItems() if QtWidgets.QMessageBox.question( self, UiStrings().ConfirmDelete, translate( 'SongsPlugin.MediaItem', 'Are you sure you want to delete the following songs?') + '\n\n- {songs}'.format( songs='\n- '.join([item.text() for item in items])), defaultButton=QtWidgets.QMessageBox.Yes ) == QtWidgets.QMessageBox.No: return self.application.set_busy_cursor() self.main_window.display_progress_bar(len(items)) for item in items: item_id = item.data(QtCore.Qt.UserRole) delete_song(item_id, self.plugin) self.main_window.increment_progress_bar() self.main_window.finished_progress_bar() self.application.set_normal_cursor() self.on_search_text_button_clicked()
def on_delete_click(self): """ Remove a song from the list and database """ if check_item_selected(self.list_view, UiStrings().SelectDelete): items = self.list_view.selectedIndexes() if QtGui.QMessageBox.question( self, UiStrings().ConfirmDelete, translate( 'SongsPlugin.MediaItem', 'Are you sure you want to delete the %n selected song(s)?', '', QtCore.QCoreApplication.CodecForTr, len(items)), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: return self.application.set_busy_cursor() self.main_window.display_progress_bar(len(items)) for item in items: item_id = item.data(QtCore.Qt.UserRole) delete_song(item_id, self.plugin) self.main_window.increment_progress_bar() self.main_window.finished_progress_bar() self.application.set_normal_cursor() self.on_search_text_button_clicked()
def remove_button_clicked(self, song_review_widget): """ Removes a song from the database, removes the GUI element representing the song on the review page, and disable the remove button if only one duplicate is left. :param song_review_widget: The SongReviewWidget whose song we should delete. """ # Remove song from duplicate song list. self.duplicate_song_list[-1].remove(song_review_widget.song) # Remove song from the database. delete_song(song_review_widget.song.id, self.plugin) # Remove GUI elements for the song. self.review_scroll_area_layout.removeWidget(song_review_widget) song_review_widget.setParent(None) # Check if we only have one duplicate left: # 2 stretches + 1 SongReviewWidget = 3 # The SongReviewWidget is then at position 1. if len(self.duplicate_song_list[-1]) == 1: self.review_scroll_area_layout.itemAt(1).widget().song_remove_button.setEnabled(False)
def on_delete_click(self): """ Remove a song from the list and database """ if check_item_selected(self.list_view, UiStrings().SelectDelete): items = self.list_view.selectedIndexes() if QtGui.QMessageBox.question( self, UiStrings().ConfirmDelete, translate('SongsPlugin.MediaItem', 'Are you sure you want to delete the %n selected song(s)?', '', QtCore.QCoreApplication.CodecForTr, len(items)), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: return self.application.set_busy_cursor() self.main_window.display_progress_bar(len(items)) for item in items: item_id = item.data(QtCore.Qt.UserRole) delete_song(item_id, self.plugin) self.main_window.increment_progress_bar() self.main_window.finished_progress_bar() self.application.set_normal_cursor() self.on_search_text_button_clicked()