def existingQuantityEdit(self, QModelIndex): row = QModelIndex.row() data = [] for column in range(4): data.append(QModelIndex.sibling(row,column).data()) dialog = SetQuantity(data[0], data[1], data[2], data[3]) dialog.setModal(True) newData = dialog.exec_() if newData == False: # User cancelled the operation pass else: # newData = [id, name, portion, quantity] self.foodLogModel.editFood(newData[0], newData[3], row)
def quantityEdit(self, QModelIndex): """ Adds a food to from the food list to the daily consumption list """ row = QModelIndex.row() data = [] for column in range(9): data.append(QModelIndex.sibling(row,column).data()) dialog = SetQuantity(data[0], data[1], data[2]) dialog.setModal(True) newData = dialog.exec_() if newData == False: # User cancelled the operation pass else: # newData = [id, name, portion, quantity] self.foodLogModel.addFood(newData[0], newData[1], newData[2], newData[3])