def removeEntry(self): selectedIndexes = self.ui.ganttView.selectionModel().selectedIndexes() if len(selectedIndexes) > 0: index = selectedIndexes[0] else: index = QModelIndex() if not index.isValid(): return self.model.removeRow(index.row(), index.parent())
def prompt_delete_folder(self, index: qtc.QModelIndex) -> None: """Opens a message box prompt which confirms if the user wants to delete a folder.""" folder: Folder = index.internalPointer() response = qtw.QMessageBox.question( None, "Prompt", "Are you sure you want to delete '" + folder.title + "'?", qtw.QMessageBox.Yes | qtw.QMessageBox.No) if response == qtw.QMessageBox.Yes: self.feed_view_model.beginRemoveRows(index.parent(), index.row(), index.row()) self.feed_manager.delete_folder(folder) self.feed_view_model.endRemoveRows()
def prompt_delete_feed(self, index: qtc.QModelIndex) -> None: """ Opens a message box prompt which confirms if the user wants to delete a feed. Deletes a feed from the view, then tells the feed manager to remove it from the database. """ feed: Feed = index.internalPointer() response = qtw.QMessageBox.question( None, "Prompt", "Are you sure you want to delete '" + (feed.user_title if feed.user_title is not None else feed.title) + "'?", qtw.QMessageBox.Yes | qtw.QMessageBox.No) if response == qtw.QMessageBox.Yes: self.feed_view_model.beginRemoveRows(index.parent(), index.row(), index.row()) self.feed_manager.delete_feed(feed) self.feed_view_model.endRemoveRows()