コード例 #1
0
 def removeRows(self, position):
     row_count = self.rowCount()
     row_count -= 1
     self.beginRemoveRows(QtCore.QModelIndex(), row_count, row_count)
     row_id = position.row()
     document_id = self.customer_data[row_id]['_id']
     databaseOperations.remove_data(document_id)
     self.customer_data.pop(row_id)
     self.endRemoveRows()
     return True
コード例 #2
0
 def removeRows(self, invoice_number, position):
     row_count = self.rowCount()
     row_count -= 1
     self.beginRemoveRows(QtCore.QModelIndex(), row_count, row_count)
     row_id = position.row()
     document_id = self.user_data[row_id][0]
     # print("To be deleted: {}".format(document_id))
     databaseOperations.remove_data(document_id, self.table_name)
     self.user_data = databaseOperations.get_multiple_data_invoice(
         invoice_number, self.table_name)
     # print(self.user_data)
     self.endRemoveRows()
     return True
コード例 #3
0
    def removeRows(self, position):
        row_count = self.rowCount()
        row_count -= 1
        self.beginRemoveRows(QtCore.QModelIndex(), row_count, row_count)
        if isinstance(position, int):
            document_id = self.user_data[position][0]
            databaseOperations.remove_data(document_id, self.table_name)
        elif isinstance(position, QtCore.QModelIndex):
            row_id = position.row()
            document_id = self.user_data[row_id][0]
            databaseOperations.remove_data(document_id, self.table_name)

        elif isinstance(position, list):
            for data in self.user_data:
                k = 0
                for i in range(len(position)):
                    if data[i + 1] == position[i].data():
                        k += 1

                if (k == len(position)):
                    rowid = data[0]
                    databaseOperations.remove_data(rowid, self.table_name)

        else:
            return False

        self.user_data = databaseOperations.get_multiple_data(self.table_name)
        # print(self.user_data)
        self.endRemoveRows()
        return True